From e109c2440cbd87b3111abcd0aeb0d1f8f4626445 Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sat, 17 Jan 2026 17:44:02 +0800 Subject: [PATCH 1/6] support bulk delete action for all delete api. --- .../NavBar/Dto/DeleteNavBarInputDto.cs | 4 +- .../Asset/Dto/Asset/DeleteAssetInputDto.cs | 4 +- .../Dto/CustoType/DeleteCustoTypeInputDto.cs | 3 +- .../Dto/Customer/DeleteCustomerInputDto.cs | 4 +- .../DeletePassportTypeInputDto.cs | 3 +- .../Dto/DeleteEnergyManagementInputDto.cs | 4 +- .../Business/News/Dto/DeleteNewsInputDto.cs | 4 +- .../Dto/DeletePromotionContentInputDto.cs | 4 +- .../Business/Reser/Dto/DeleteReserInputDto.cs | 4 +- .../Room/Dto/Room/DeleteRoomInputDto.cs | 3 +- .../Dto/RoomState/DeleteRoomStateInputDto.cs | 3 +- .../Dto/RoomType/DeleteRoomTypeInputDto.cs | 3 +- .../Sellthing/Dto/DeleteSellThingInputDto.cs | 14 +- .../Spend/Dto/Spend/DeleteSpendInputDto.cs | 7 +- .../{BaseDto => Common/Dto}/BaseAuditDto.cs | 0 .../{BaseDto => Common/Dto}/BaseDto.cs | 0 .../{BaseDto => Common/Dto}/BaseInputDto.cs | 0 .../{BaseDto => Common/Dto}/BaseOutputDto.cs | 0 .../{BaseDto => Common/Dto}/BaseResponse.cs | 0 .../Dto}/BusinessStatusCode.cs | 0 .../{BaseDto => Common/Dto}/CsrfTokenDto.cs | 0 .../Dto/DeleteDto.cs} | 11 +- .../{BaseDto => Common/Dto}/ListInputDto.cs | 0 .../{BaseDto => Common/Dto}/ListOutputDto.cs | 0 .../{BaseDto => Common/Dto}/MenuDto.cs | 0 .../{BaseDto => Common/Dto}/PagedData.cs | 0 .../Dto}/SingleOutputDto.cs | 0 .../EOM.TSHotelManagement.Contract.csproj | 5 +- .../Dto/Employee/DeleteEmployeeInputDto.cs | 5 +- .../DeleteEmployeeCheckInputDto.cs | 4 +- .../DeleteEmployeeHistoryInputDto.cs | 4 +- .../DeleteEmployeePhotoInputDto.cs | 10 +- .../DeleteEmployeeRewardPunishmentInputDto.cs | 4 +- .../DeleteRewardPunishmentTypeInputDto.cs | 5 +- .../DeleteAdministratorInputDto.cs | 5 +- .../DeleteAdministratorTypeInputDto.cs | 5 +- .../DeleteAppointmentNoticeInputDto.cs | 5 +- .../DeleteAppointmentNoticeTypeInputDto.cs | 5 +- .../Department/DeleteDepartmentInputDto.cs | 27 +- .../Dto/Menu/DeleteMenuInputDto.cs | 13 +- .../Dto/Nation/DeleteNationInputDto.cs | 7 +- .../Dto/Position/DeletePositionInputDto.cs | 5 +- .../Qualification/DeleteEducationInputDto.cs | 5 +- .../Dto/Role/DeleteRoleInputDto.cs | 5 +- .../DeleteSupervisionStatisticsInputDto.cs | 20 +- .../DeleteSystemInformationInputDto.cs | 3 +- .../DeleteVipLevelRuleInputDto.cs | 14 +- .../CreateApplicationVersionInputDto.cs | 12 - .../ReadApplicationVersionInputDto.cs | 9 - .../ReadApplicationVersionOutputDto.cs | 12 - .../UpdateApplicationVersionInputDto.cs | 13 - .../Dto/CardCode/DeleteCardCodeInputDto.cs | 11 +- .../DeleteOperationLogInputDto.cs | 4 +- .../Repository/GenericRepository.cs | 27 + .../Util/ApplicationVersion.cs | 23 - .../EntityBuilder.cs | 1 - .../Application/NavBar/NavBarService.cs | 33 +- .../Business/Asset/AssetService.cs | 47 +- .../Business/Customer/CustomerService.cs | 77 ++- .../EnergyManagementService.cs | 44 +- .../Business/News/NewsService.cs | 49 +- .../PromotionContentService.cs | 71 ++- .../Business/Reser/ReserService.cs | 113 ++-- .../Business/Room/RoomService.cs | 75 ++- .../Business/Room/RoomTypeService.cs | 44 +- .../Business/Sellthing/SellService.cs | 53 +- .../Business/Spend/SpendService.cs | 17 +- .../Employee/EmployeeService.cs | 11 +- .../Employee/Photo/EmployeePhotoService.cs | 13 +- .../Administrator/AdminService.cs | 112 ++-- .../SystemManagement/Base/BaseService.cs | 521 +++++++++++++++--- .../SystemManagement/Menu/MenuService.cs | 56 +- .../SystemManagement/Notice/NoticeService.cs | 65 ++- .../SystemManagement/Role/RoleAppService.cs | 43 +- .../SupervisionStatisticsService.cs | 52 +- .../VipRule/VipRuleAppService.cs | 47 +- .../Util/UtilService.cs | 51 +- 77 files changed, 1252 insertions(+), 685 deletions(-) rename EOM.TSHotelManagement.Contract/{BaseDto => Common/Dto}/BaseAuditDto.cs (100%) rename EOM.TSHotelManagement.Contract/{BaseDto => Common/Dto}/BaseDto.cs (100%) rename EOM.TSHotelManagement.Contract/{BaseDto => Common/Dto}/BaseInputDto.cs (100%) rename EOM.TSHotelManagement.Contract/{BaseDto => Common/Dto}/BaseOutputDto.cs (100%) rename EOM.TSHotelManagement.Contract/{BaseDto => Common/Dto}/BaseResponse.cs (100%) rename EOM.TSHotelManagement.Contract/{BaseDto => Common/Dto}/BusinessStatusCode.cs (100%) rename EOM.TSHotelManagement.Contract/{BaseDto => Common/Dto}/CsrfTokenDto.cs (100%) rename EOM.TSHotelManagement.Contract/{Util/Dto/ApplicationVersion/DeleteApplicationVersionInputDto.cs => Common/Dto/DeleteDto.cs} (32%) rename EOM.TSHotelManagement.Contract/{BaseDto => Common/Dto}/ListInputDto.cs (100%) rename EOM.TSHotelManagement.Contract/{BaseDto => Common/Dto}/ListOutputDto.cs (100%) rename EOM.TSHotelManagement.Contract/{BaseDto => Common/Dto}/MenuDto.cs (100%) rename EOM.TSHotelManagement.Contract/{BaseDto => Common/Dto}/PagedData.cs (100%) rename EOM.TSHotelManagement.Contract/{BaseDto => Common/Dto}/SingleOutputDto.cs (100%) delete mode 100644 EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/CreateApplicationVersionInputDto.cs delete mode 100644 EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/ReadApplicationVersionInputDto.cs delete mode 100644 EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/ReadApplicationVersionOutputDto.cs delete mode 100644 EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/UpdateApplicationVersionInputDto.cs delete mode 100644 EOM.TSHotelManagement.Domain/Util/ApplicationVersion.cs diff --git a/EOM.TSHotelManagement.Contract/Application/NavBar/Dto/DeleteNavBarInputDto.cs b/EOM.TSHotelManagement.Contract/Application/NavBar/Dto/DeleteNavBarInputDto.cs index 1fd2711..0391260 100644 --- a/EOM.TSHotelManagement.Contract/Application/NavBar/Dto/DeleteNavBarInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Application/NavBar/Dto/DeleteNavBarInputDto.cs @@ -2,10 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteNavBarInputDto : BaseInputDto + public class DeleteNavBarInputDto : DeleteDto { - [Required(ErrorMessage = "导航栏ID为必填字段")] - public int NavigationBarId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Business/Asset/Dto/Asset/DeleteAssetInputDto.cs b/EOM.TSHotelManagement.Contract/Business/Asset/Dto/Asset/DeleteAssetInputDto.cs index 4db70db..72912f7 100644 --- a/EOM.TSHotelManagement.Contract/Business/Asset/Dto/Asset/DeleteAssetInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/Asset/Dto/Asset/DeleteAssetInputDto.cs @@ -2,10 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteAssetInputDto : BaseInputDto + public class DeleteAssetInputDto : DeleteDto { - [Required(ErrorMessage = "资产编号为必填字段"), MaxLength(128, ErrorMessage = "资产编号长度不超过128字符")] - public string AssetNumber { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Business/Customer/Dto/CustoType/DeleteCustoTypeInputDto.cs b/EOM.TSHotelManagement.Contract/Business/Customer/Dto/CustoType/DeleteCustoTypeInputDto.cs index 094a42a..1973abe 100644 --- a/EOM.TSHotelManagement.Contract/Business/Customer/Dto/CustoType/DeleteCustoTypeInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/Customer/Dto/CustoType/DeleteCustoTypeInputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Contract { - public class DeleteCustoTypeInputDto : BaseInputDto + public class DeleteCustoTypeInputDto : DeleteDto { - public int CustomerType { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Business/Customer/Dto/Customer/DeleteCustomerInputDto.cs b/EOM.TSHotelManagement.Contract/Business/Customer/Dto/Customer/DeleteCustomerInputDto.cs index 05a7391..f819f20 100644 --- a/EOM.TSHotelManagement.Contract/Business/Customer/Dto/Customer/DeleteCustomerInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/Customer/Dto/Customer/DeleteCustomerInputDto.cs @@ -2,10 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteCustomerInputDto : BaseInputDto + public class DeleteCustomerInputDto : DeleteDto { - [Required(ErrorMessage = "客户编号为必填字段"), MaxLength(128, ErrorMessage = "客户编号长度不超过128字符")] - public string CustomerNumber { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Business/Customer/Dto/PassportType/DeletePassportTypeInputDto.cs b/EOM.TSHotelManagement.Contract/Business/Customer/Dto/PassportType/DeletePassportTypeInputDto.cs index ff51593..705f87d 100644 --- a/EOM.TSHotelManagement.Contract/Business/Customer/Dto/PassportType/DeletePassportTypeInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/Customer/Dto/PassportType/DeletePassportTypeInputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Contract { - public class DeletePassportTypeInputDto : BaseInputDto + public class DeletePassportTypeInputDto : DeleteDto { - public int PassportId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Business/EnergyManagement/Dto/DeleteEnergyManagementInputDto.cs b/EOM.TSHotelManagement.Contract/Business/EnergyManagement/Dto/DeleteEnergyManagementInputDto.cs index 3ba6b9c..5f4f79c 100644 --- a/EOM.TSHotelManagement.Contract/Business/EnergyManagement/Dto/DeleteEnergyManagementInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/EnergyManagement/Dto/DeleteEnergyManagementInputDto.cs @@ -2,10 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteEnergyManagementInputDto : BaseInputDto + public class DeleteEnergyManagementInputDto : DeleteDto { - [Required(ErrorMessage = "信息编号为必填字段")] - public int InformationId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Business/News/Dto/DeleteNewsInputDto.cs b/EOM.TSHotelManagement.Contract/Business/News/Dto/DeleteNewsInputDto.cs index d476ebb..88e761a 100644 --- a/EOM.TSHotelManagement.Contract/Business/News/Dto/DeleteNewsInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/News/Dto/DeleteNewsInputDto.cs @@ -2,9 +2,7 @@ namespace EOM.TSHotelManagement.Contract { - public class DeleteNewsInputDto : BaseInputDto + public class DeleteNewsInputDto : DeleteDto { - [Required(ErrorMessage = "新闻编号为必填字段"), MaxLength(128, ErrorMessage = "新闻编号长度不超过128字符")] - public string NewId { get; set; } } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Contract/Business/PromotionContent/Dto/DeletePromotionContentInputDto.cs b/EOM.TSHotelManagement.Contract/Business/PromotionContent/Dto/DeletePromotionContentInputDto.cs index 0ee8b0a..1dbf039 100644 --- a/EOM.TSHotelManagement.Contract/Business/PromotionContent/Dto/DeletePromotionContentInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/PromotionContent/Dto/DeletePromotionContentInputDto.cs @@ -2,10 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeletePromotionContentInputDto : BaseInputDto + public class DeletePromotionContentInputDto : DeleteDto { - [Required(ErrorMessage = "宣传ID为必填字段"), MaxLength(128, ErrorMessage = "宣传ID长度不超过128字符")] - public string PromotionContentNumber { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Business/Reser/Dto/DeleteReserInputDto.cs b/EOM.TSHotelManagement.Contract/Business/Reser/Dto/DeleteReserInputDto.cs index 041e104..27d4f54 100644 --- a/EOM.TSHotelManagement.Contract/Business/Reser/Dto/DeleteReserInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/Reser/Dto/DeleteReserInputDto.cs @@ -2,10 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteReserInputDto : BaseInputDto + public class DeleteReserInputDto : DeleteDto { - [Required(ErrorMessage = "预约编号为必填字段"), MaxLength(128, ErrorMessage = "预约编号长度不超过128字符")] - public string ReservationId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Business/Room/Dto/Room/DeleteRoomInputDto.cs b/EOM.TSHotelManagement.Contract/Business/Room/Dto/Room/DeleteRoomInputDto.cs index 6d6ec1f..1dc0dcd 100644 --- a/EOM.TSHotelManagement.Contract/Business/Room/Dto/Room/DeleteRoomInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/Room/Dto/Room/DeleteRoomInputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Contract { - public class DeleteRoomInputDto : BaseInputDto + public class DeleteRoomInputDto : DeleteDto { - public string RoomNumber { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Business/Room/Dto/RoomState/DeleteRoomStateInputDto.cs b/EOM.TSHotelManagement.Contract/Business/Room/Dto/RoomState/DeleteRoomStateInputDto.cs index ea68d4a..93f323b 100644 --- a/EOM.TSHotelManagement.Contract/Business/Room/Dto/RoomState/DeleteRoomStateInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/Room/Dto/RoomState/DeleteRoomStateInputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Contract { - public class DeleteRoomStateInputDto : BaseInputDto + public class DeleteRoomStateInputDto : DeleteDto { - public int RoomStateId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Business/Room/Dto/RoomType/DeleteRoomTypeInputDto.cs b/EOM.TSHotelManagement.Contract/Business/Room/Dto/RoomType/DeleteRoomTypeInputDto.cs index 651b08c..7d94d97 100644 --- a/EOM.TSHotelManagement.Contract/Business/Room/Dto/RoomType/DeleteRoomTypeInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/Room/Dto/RoomType/DeleteRoomTypeInputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Contract { - public class DeleteRoomTypeInputDto : BaseInputDto + public class DeleteRoomTypeInputDto : DeleteDto { - public int RoomTypeId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Business/Sellthing/Dto/DeleteSellThingInputDto.cs b/EOM.TSHotelManagement.Contract/Business/Sellthing/Dto/DeleteSellThingInputDto.cs index d4cf117..75876de 100644 --- a/EOM.TSHotelManagement.Contract/Business/Sellthing/Dto/DeleteSellThingInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/Sellthing/Dto/DeleteSellThingInputDto.cs @@ -2,20 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteSellThingInputDto : BaseInputDto + public class DeleteSellThingInputDto : DeleteDto { - [Required(ErrorMessage = "商品编号为必填字段"), MaxLength(128, ErrorMessage = "商品编号长度不超过128字符")] - public string ProductNumber { get; set; } - - [MaxLength(500, ErrorMessage = "商品名称长度不超过500字符")] - public string ProductName { get; set; } - - public decimal ProductPrice { get; set; } - - [MaxLength(1000, ErrorMessage = "规格型号长度不超过1000字符")] - public string Specification { get; set; } - - public decimal Stock { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Business/Spend/Dto/Spend/DeleteSpendInputDto.cs b/EOM.TSHotelManagement.Contract/Business/Spend/Dto/Spend/DeleteSpendInputDto.cs index ec24295..20b822b 100644 --- a/EOM.TSHotelManagement.Contract/Business/Spend/Dto/Spend/DeleteSpendInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Business/Spend/Dto/Spend/DeleteSpendInputDto.cs @@ -2,13 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteSpendInputDto : BaseInputDto + public class DeleteSpendInputDto : DeleteDto { - [Required(ErrorMessage = "房间编号为必填字段")] - public string RoomNumber { get; set; } - - [Required(ErrorMessage = "客户编号为必填字段")] - public string CustomerNumber { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/BaseDto/BaseAuditDto.cs b/EOM.TSHotelManagement.Contract/Common/Dto/BaseAuditDto.cs similarity index 100% rename from EOM.TSHotelManagement.Contract/BaseDto/BaseAuditDto.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/BaseAuditDto.cs diff --git a/EOM.TSHotelManagement.Contract/BaseDto/BaseDto.cs b/EOM.TSHotelManagement.Contract/Common/Dto/BaseDto.cs similarity index 100% rename from EOM.TSHotelManagement.Contract/BaseDto/BaseDto.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/BaseDto.cs diff --git a/EOM.TSHotelManagement.Contract/BaseDto/BaseInputDto.cs b/EOM.TSHotelManagement.Contract/Common/Dto/BaseInputDto.cs similarity index 100% rename from EOM.TSHotelManagement.Contract/BaseDto/BaseInputDto.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/BaseInputDto.cs diff --git a/EOM.TSHotelManagement.Contract/BaseDto/BaseOutputDto.cs b/EOM.TSHotelManagement.Contract/Common/Dto/BaseOutputDto.cs similarity index 100% rename from EOM.TSHotelManagement.Contract/BaseDto/BaseOutputDto.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/BaseOutputDto.cs diff --git a/EOM.TSHotelManagement.Contract/BaseDto/BaseResponse.cs b/EOM.TSHotelManagement.Contract/Common/Dto/BaseResponse.cs similarity index 100% rename from EOM.TSHotelManagement.Contract/BaseDto/BaseResponse.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/BaseResponse.cs diff --git a/EOM.TSHotelManagement.Contract/BaseDto/BusinessStatusCode.cs b/EOM.TSHotelManagement.Contract/Common/Dto/BusinessStatusCode.cs similarity index 100% rename from EOM.TSHotelManagement.Contract/BaseDto/BusinessStatusCode.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/BusinessStatusCode.cs diff --git a/EOM.TSHotelManagement.Contract/BaseDto/CsrfTokenDto.cs b/EOM.TSHotelManagement.Contract/Common/Dto/CsrfTokenDto.cs similarity index 100% rename from EOM.TSHotelManagement.Contract/BaseDto/CsrfTokenDto.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/CsrfTokenDto.cs diff --git a/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/DeleteApplicationVersionInputDto.cs b/EOM.TSHotelManagement.Contract/Common/Dto/DeleteDto.cs similarity index 32% rename from EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/DeleteApplicationVersionInputDto.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/DeleteDto.cs index fc6dad2..021f809 100644 --- a/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/DeleteApplicationVersionInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Common/Dto/DeleteDto.cs @@ -1,10 +1,9 @@ +using System.Collections.Generic; + namespace EOM.TSHotelManagement.Contract { - public class DeleteApplicationVersionInputDto : BaseInputDto + public abstract class DeleteDto { - public int VersionId { get; set; } + public List DelIds { get; set; } } -} - - - +} \ No newline at end of file diff --git a/EOM.TSHotelManagement.Contract/BaseDto/ListInputDto.cs b/EOM.TSHotelManagement.Contract/Common/Dto/ListInputDto.cs similarity index 100% rename from EOM.TSHotelManagement.Contract/BaseDto/ListInputDto.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/ListInputDto.cs diff --git a/EOM.TSHotelManagement.Contract/BaseDto/ListOutputDto.cs b/EOM.TSHotelManagement.Contract/Common/Dto/ListOutputDto.cs similarity index 100% rename from EOM.TSHotelManagement.Contract/BaseDto/ListOutputDto.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/ListOutputDto.cs diff --git a/EOM.TSHotelManagement.Contract/BaseDto/MenuDto.cs b/EOM.TSHotelManagement.Contract/Common/Dto/MenuDto.cs similarity index 100% rename from EOM.TSHotelManagement.Contract/BaseDto/MenuDto.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/MenuDto.cs diff --git a/EOM.TSHotelManagement.Contract/BaseDto/PagedData.cs b/EOM.TSHotelManagement.Contract/Common/Dto/PagedData.cs similarity index 100% rename from EOM.TSHotelManagement.Contract/BaseDto/PagedData.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/PagedData.cs diff --git a/EOM.TSHotelManagement.Contract/BaseDto/SingleOutputDto.cs b/EOM.TSHotelManagement.Contract/Common/Dto/SingleOutputDto.cs similarity index 100% rename from EOM.TSHotelManagement.Contract/BaseDto/SingleOutputDto.cs rename to EOM.TSHotelManagement.Contract/Common/Dto/SingleOutputDto.cs diff --git a/EOM.TSHotelManagement.Contract/EOM.TSHotelManagement.Contract.csproj b/EOM.TSHotelManagement.Contract/EOM.TSHotelManagement.Contract.csproj index 908b840..e32ba9f 100644 --- a/EOM.TSHotelManagement.Contract/EOM.TSHotelManagement.Contract.csproj +++ b/EOM.TSHotelManagement.Contract/EOM.TSHotelManagement.Contract.csproj @@ -43,10 +43,7 @@ - + $(MajorVersion).$(MinorVersion).$(NewBuildNumber) diff --git a/EOM.TSHotelManagement.Contract/Employee/Dto/Employee/DeleteEmployeeInputDto.cs b/EOM.TSHotelManagement.Contract/Employee/Dto/Employee/DeleteEmployeeInputDto.cs index ce3db53..9b51845 100644 --- a/EOM.TSHotelManagement.Contract/Employee/Dto/Employee/DeleteEmployeeInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Employee/Dto/Employee/DeleteEmployeeInputDto.cs @@ -2,11 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteEmployeeInputDto : BaseInputDto + public class DeleteEmployeeInputDto : DeleteDto { - [Required(ErrorMessage = "员工账号为必填字段")] - [MaxLength(128, ErrorMessage = "员工账号长度不超过128字符")] - public string EmployeeId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeeCheck/DeleteEmployeeCheckInputDto.cs b/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeeCheck/DeleteEmployeeCheckInputDto.cs index e9eb67e..d1e0edf 100644 --- a/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeeCheck/DeleteEmployeeCheckInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeeCheck/DeleteEmployeeCheckInputDto.cs @@ -2,10 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteEmployeeCheckInputDto : BaseInputDto + public class DeleteEmployeeCheckInputDto : DeleteDto { - [Required(ErrorMessage = "打卡ID为必填字段")] - public int CheckId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeeHistory/DeleteEmployeeHistoryInputDto.cs b/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeeHistory/DeleteEmployeeHistoryInputDto.cs index 39d731e..6fb9689 100644 --- a/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeeHistory/DeleteEmployeeHistoryInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeeHistory/DeleteEmployeeHistoryInputDto.cs @@ -2,10 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteEmployeeHistoryInputDto : BaseInputDto + public class DeleteEmployeeHistoryInputDto : DeleteDto { - [Required(ErrorMessage = "履历ID为必填字段")] - public int HistoryId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeePhoto/DeleteEmployeePhotoInputDto.cs b/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeePhoto/DeleteEmployeePhotoInputDto.cs index 46d79e7..dc2c627 100644 --- a/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeePhoto/DeleteEmployeePhotoInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeePhoto/DeleteEmployeePhotoInputDto.cs @@ -2,14 +2,10 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteEmployeePhotoInputDto : ListInputDto + public class DeleteEmployeePhotoInputDto { - [Required(ErrorMessage = "照片ID为必填字段")] - public int PhotoId { get; set; } - - [Required(ErrorMessage = "员工工号为必填字段")] - [MaxLength(128, ErrorMessage = "员工工号长度不超过128字符")] - public string EmployeeId { get; set; } + [Required(ErrorMessage = "Employee Id is required")] + public int EmployeeId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeeRewardPunishment/DeleteEmployeeRewardPunishmentInputDto.cs b/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeeRewardPunishment/DeleteEmployeeRewardPunishmentInputDto.cs index fbc0841..f60047b 100644 --- a/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeeRewardPunishment/DeleteEmployeeRewardPunishmentInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Employee/Dto/EmployeeRewardPunishment/DeleteEmployeeRewardPunishmentInputDto.cs @@ -2,10 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteEmployeeRewardPunishmentInputDto : BaseInputDto + public class DeleteEmployeeRewardPunishmentInputDto : DeleteDto { - [Required(ErrorMessage = "奖惩ID为必填字段")] - public int RewardPunishmentId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Employee/Dto/RewardPunishmentType/DeleteRewardPunishmentTypeInputDto.cs b/EOM.TSHotelManagement.Contract/Employee/Dto/RewardPunishmentType/DeleteRewardPunishmentTypeInputDto.cs index a56f016..54a362c 100644 --- a/EOM.TSHotelManagement.Contract/Employee/Dto/RewardPunishmentType/DeleteRewardPunishmentTypeInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Employee/Dto/RewardPunishmentType/DeleteRewardPunishmentTypeInputDto.cs @@ -2,11 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteRewardPunishmentTypeInputDto : BaseInputDto + public class DeleteRewardPunishmentTypeInputDto : DeleteDto { - [Required(ErrorMessage = "奖惩类型编号为必填字段")] - [MaxLength(128, ErrorMessage = "奖惩类型编号长度不超过128字符")] - public string RewardPunishmentTypeId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Administrator/DeleteAdministratorInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Administrator/DeleteAdministratorInputDto.cs index 1d9ff71..911073c 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Administrator/DeleteAdministratorInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Administrator/DeleteAdministratorInputDto.cs @@ -2,11 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteAdministratorInputDto : BaseInputDto + public class DeleteAdministratorInputDto : DeleteDto { - [Required(ErrorMessage = "管理员账号为必填字段")] - [MaxLength(128, ErrorMessage = "管理员账号长度不超过128字符")] - public string Number { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/AdministratorType/DeleteAdministratorTypeInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/AdministratorType/DeleteAdministratorTypeInputDto.cs index 3b29450..580866d 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/AdministratorType/DeleteAdministratorTypeInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/AdministratorType/DeleteAdministratorTypeInputDto.cs @@ -2,11 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteAdministratorTypeInputDto : BaseInputDto + public class DeleteAdministratorTypeInputDto : DeleteDto { - [Required(ErrorMessage = "类型编号为必填字段")] - [MaxLength(128, ErrorMessage = "类型编号长度不超过128字符")] - public string TypeId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/AppointmentNotice/DeleteAppointmentNoticeInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/AppointmentNotice/DeleteAppointmentNoticeInputDto.cs index e1464ab..0ad87bc 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/AppointmentNotice/DeleteAppointmentNoticeInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/AppointmentNotice/DeleteAppointmentNoticeInputDto.cs @@ -2,11 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteAppointmentNoticeInputDto : BaseInputDto + public class DeleteAppointmentNoticeInputDto : DeleteDto { - [Required(ErrorMessage = "公告编号为必填字段")] - [MaxLength(128, ErrorMessage = "公告编号长度不超过128字符")] - public string NoticeId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/AppointmentNoticeType/DeleteAppointmentNoticeTypeInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/AppointmentNoticeType/DeleteAppointmentNoticeTypeInputDto.cs index bb5b3d1..38a74bb 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/AppointmentNoticeType/DeleteAppointmentNoticeTypeInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/AppointmentNoticeType/DeleteAppointmentNoticeTypeInputDto.cs @@ -2,10 +2,7 @@ namespace EOM.TSHotelManagement.Contract { - public class DeleteAppointmentNoticeTypeInputDto : BaseInputDto + public class DeleteAppointmentNoticeTypeInputDto : DeleteDto { - [Required(ErrorMessage = "公告类型编号为必填字段")] - [MaxLength(128, ErrorMessage = "公告类型编号长度不超过128字符")] - public string NoticeTypeNumber { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Department/DeleteDepartmentInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Department/DeleteDepartmentInputDto.cs index f1ffe94..0eb82f4 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Department/DeleteDepartmentInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Department/DeleteDepartmentInputDto.cs @@ -2,33 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteDepartmentInputDto : BaseInputDto + public class DeleteDepartmentInputDto : DeleteDto { - public int? Id { get; set; } - - [Required(ErrorMessage = "部门编号为必填字段")] - [MaxLength(128, ErrorMessage = "部门编号长度不超过128字符")] - public string DepartmentNumber { get; set; } - - [MaxLength(256, ErrorMessage = "部门名称长度不超过256字符")] - public string DepartmentName { get; set; } - - [MaxLength(500, ErrorMessage = "部门描述长度不超过500字符")] - public string DepartmentDescription { get; set; } - - public DateTime DepartmentCreationDate { get; set; } - - [MaxLength(128, ErrorMessage = "部门主管长度不超过128字符")] - public string DepartmentLeader { get; set; } - - [MaxLength(200, ErrorMessage = "部门主管姓名长度不超过200字符")] - public string LeaderName { get; set; } - - [MaxLength(128, ErrorMessage = "上级部门编号长度不超过128字符")] - public string ParentDepartmentNumber { get; set; } - - [MaxLength(256, ErrorMessage = "上级部门名称长度不超过256字符")] - public string ParentDepartmentName { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Menu/DeleteMenuInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Menu/DeleteMenuInputDto.cs index 4373368..ff102a9 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Menu/DeleteMenuInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Menu/DeleteMenuInputDto.cs @@ -2,19 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteMenuInputDto : BaseInputDto + public class DeleteMenuInputDto : DeleteDto { - [MaxLength(256, ErrorMessage = "菜单键长度不超过256字符")] - public string Key { get; set; } - - [MaxLength(256, ErrorMessage = "菜单标题长度不超过256字符")] - public string Title { get; set; } - - public string Path { get; set; } - public int? Parent { get; set; } - - [MaxLength(256, ErrorMessage = "菜单图标长度不超过256字符")] - public string Icon { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Nation/DeleteNationInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Nation/DeleteNationInputDto.cs index f6e5c94..d9f9f5f 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Nation/DeleteNationInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Nation/DeleteNationInputDto.cs @@ -2,13 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteNationInputDto : BaseInputDto + public class DeleteNationInputDto : DeleteDto { - public int NationId { get; set; } - - [Required(ErrorMessage = "民族编号为必填字段")] - [MaxLength(128, ErrorMessage = "民族编号长度不超过128字符")] - public string NationNumber { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Position/DeletePositionInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Position/DeletePositionInputDto.cs index 41e705f..94c45d1 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Position/DeletePositionInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Position/DeletePositionInputDto.cs @@ -2,11 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeletePositionInputDto : BaseInputDto + public class DeletePositionInputDto : DeleteDto { - [Required(ErrorMessage = "职位编号为必填字段")] - [MaxLength(128, ErrorMessage = "职位编号长度不超过128字符")] - public string PositionNumber { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Qualification/DeleteEducationInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Qualification/DeleteEducationInputDto.cs index d017157..a9112f2 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Qualification/DeleteEducationInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Qualification/DeleteEducationInputDto.cs @@ -2,11 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteEducationInputDto : BaseInputDto + public class DeleteEducationInputDto : DeleteDto { - [Required(ErrorMessage = "学历编号为必填字段")] - [MaxLength(128, ErrorMessage = "学历编号长度不超过128字符")] - public string EducationNumber { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Role/DeleteRoleInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Role/DeleteRoleInputDto.cs index 274ecf8..1888fba 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Role/DeleteRoleInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Role/DeleteRoleInputDto.cs @@ -2,11 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteRoleInputDto : BaseInputDto + public class DeleteRoleInputDto : DeleteDto { - [Required(ErrorMessage = "角色编码为必填字段")] - [MaxLength(128, ErrorMessage = "角色编码长度不超过128字符")] - public string RoleNumber { get; set; } = null!; } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/SupervisionStatistics/DeleteSupervisionStatisticsInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/SupervisionStatistics/DeleteSupervisionStatisticsInputDto.cs index 5c71f79..bf83fdb 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/SupervisionStatistics/DeleteSupervisionStatisticsInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/SupervisionStatistics/DeleteSupervisionStatisticsInputDto.cs @@ -2,26 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteSupervisionStatisticsInputDto : BaseInputDto + public class DeleteSupervisionStatisticsInputDto : DeleteDto { - [Required(ErrorMessage = "统计编号为必填字段")] - [MaxLength(128, ErrorMessage = "统计编号长度不超过128字符")] - public string StatisticsNumber { get; set; } - - [MaxLength(128, ErrorMessage = "监督部门长度不超过128字符")] - public string SupervisingDepartment { get; set; } - - [MaxLength(200, ErrorMessage = "监督部门名称长度不超过200字符")] - public string SupervisingDepartmentName { get; set; } - - public string SupervisionProgress { get; set; } - public string SupervisionLoss { get; set; } - public int SupervisionScore { get; set; } - - [MaxLength(128, ErrorMessage = "监督统计事长度不超过128字符")] - public string SupervisionStatistician { get; set; } - - public string SupervisionAdvice { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/SystemInformation/DeleteSystemInformationInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/SystemInformation/DeleteSystemInformationInputDto.cs index fd240c9..dd7eb02 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/SystemInformation/DeleteSystemInformationInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/SystemInformation/DeleteSystemInformationInputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Contract { - public class DeleteSystemInformationInputDto : BaseInputDto + public class DeleteSystemInformationInputDto : DeleteDto { - public int InformationId { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/VipLevelRule/DeleteVipLevelRuleInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/VipLevelRule/DeleteVipLevelRuleInputDto.cs index 7e1f3e0..7805fe7 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/VipLevelRule/DeleteVipLevelRuleInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/VipLevelRule/DeleteVipLevelRuleInputDto.cs @@ -2,20 +2,8 @@ using System.ComponentModel.DataAnnotations; namespace EOM.TSHotelManagement.Contract { - public class DeleteVipLevelRuleInputDto : BaseInputDto + public class DeleteVipLevelRuleInputDto : DeleteDto { - public int? Id { get; set; } - - [Required(ErrorMessage = "会员规则流水号为必填字段")] - [MaxLength(128, ErrorMessage = "会员规则流水号长度不超过128字符")] - public string RuleSerialNumber { get; set; } - - [MaxLength(200, ErrorMessage = "会员规则名称长度不超过200字符")] - public string RuleName { get; set; } - - public decimal RuleValue { get; set; } - public int VipLevelId { get; set; } - public string VipLevelName { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/CreateApplicationVersionInputDto.cs b/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/CreateApplicationVersionInputDto.cs deleted file mode 100644 index 3d056bb..0000000 --- a/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/CreateApplicationVersionInputDto.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace EOM.TSHotelManagement.Contract -{ - public class CreateApplicationVersionInputDto : BaseInputDto - { - public string VersionNumber { get; set; } - public string VersionDescription { get; set; } - public DateTime ReleaseDate { get; set; } - } -} - - - diff --git a/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/ReadApplicationVersionInputDto.cs b/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/ReadApplicationVersionInputDto.cs deleted file mode 100644 index 29d03c4..0000000 --- a/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/ReadApplicationVersionInputDto.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace EOM.TSHotelManagement.Contract -{ - public class ReadApplicationVersionInputDto : ListInputDto - { - public int? VersionId { get; set; } - } -} - - diff --git a/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/ReadApplicationVersionOutputDto.cs b/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/ReadApplicationVersionOutputDto.cs deleted file mode 100644 index b254f71..0000000 --- a/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/ReadApplicationVersionOutputDto.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace EOM.TSHotelManagement.Contract -{ - public class ReadApplicationVersionOutputDto : BaseOutputDto - { - public int ApplicationVersionId { get; set; } - public string VersionNumber { get; set; } - public string VersionDescription { get; set; } - public DateTime ReleaseDate { get; set; } - } -} - - diff --git a/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/UpdateApplicationVersionInputDto.cs b/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/UpdateApplicationVersionInputDto.cs deleted file mode 100644 index 4fb8268..0000000 --- a/EOM.TSHotelManagement.Contract/Util/Dto/ApplicationVersion/UpdateApplicationVersionInputDto.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace EOM.TSHotelManagement.Contract -{ - public class UpdateApplicationVersionInputDto : BaseInputDto - { - public int VersionId { get; set; } - public string VersionNumber { get; set; } - public string VersionDescription { get; set; } - public DateTime ReleaseDate { get; set; } - } -} - - - diff --git a/EOM.TSHotelManagement.Contract/Util/Dto/CardCode/DeleteCardCodeInputDto.cs b/EOM.TSHotelManagement.Contract/Util/Dto/CardCode/DeleteCardCodeInputDto.cs index 854df82..a5164bd 100644 --- a/EOM.TSHotelManagement.Contract/Util/Dto/CardCode/DeleteCardCodeInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Util/Dto/CardCode/DeleteCardCodeInputDto.cs @@ -1,16 +1,7 @@ namespace EOM.TSHotelManagement.Contract { - public class DeleteCardCodeInputDto : BaseInputDto + public class DeleteCardCodeInputDto : DeleteDto { - public long Id { get; set; } - - public string Province { get; set; } - - public string City { get; set; } - - public string District { get; set; } - - public string AreaCode { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/Util/Dto/OperationLog/DeleteOperationLogInputDto.cs b/EOM.TSHotelManagement.Contract/Util/Dto/OperationLog/DeleteOperationLogInputDto.cs index a783b97..4195e3c 100644 --- a/EOM.TSHotelManagement.Contract/Util/Dto/OperationLog/DeleteOperationLogInputDto.cs +++ b/EOM.TSHotelManagement.Contract/Util/Dto/OperationLog/DeleteOperationLogInputDto.cs @@ -1,8 +1,8 @@ + namespace EOM.TSHotelManagement.Contract { - public class DeleteOperationLogInputDto : BaseInputDto + public class DeleteOperationLogInputDto : DeleteDto { - public string OperationId { get; set; } } } diff --git a/EOM.TSHotelManagement.Data/Repository/GenericRepository.cs b/EOM.TSHotelManagement.Data/Repository/GenericRepository.cs index d5b26cd..9a17c9d 100644 --- a/EOM.TSHotelManagement.Data/Repository/GenericRepository.cs +++ b/EOM.TSHotelManagement.Data/Repository/GenericRepository.cs @@ -198,5 +198,32 @@ namespace EOM.TSHotelManagement.Data .IgnoreColumns(ignoreAllNullColumns: true) .ExecuteCommand() > 0; } + + public bool SoftDeleteRange(List entities) + { + if (entities == null || !entities.Any()) + { + return false; + } + + var baseEntities = entities.OfType().ToList(); + if (baseEntities.Any()) + { + var currentUser = GetCurrentUser(); + var now = DateTime.Now; + + foreach (var baseEntity in baseEntities) + { + if (!baseEntity.DataChgDate.HasValue) + baseEntity.DataChgDate = now; + if (string.IsNullOrEmpty(baseEntity.DataChgUsr)) + baseEntity.DataChgUsr = currentUser; + } + } + + return base.Context.Updateable(entities) + .IgnoreColumns(ignoreAllNullColumns: true, false, true) + .ExecuteCommand() > 0; + } } } diff --git a/EOM.TSHotelManagement.Domain/Util/ApplicationVersion.cs b/EOM.TSHotelManagement.Domain/Util/ApplicationVersion.cs deleted file mode 100644 index 614c0e5..0000000 --- a/EOM.TSHotelManagement.Domain/Util/ApplicationVersion.cs +++ /dev/null @@ -1,23 +0,0 @@ -using SqlSugar; - -namespace EOM.TSHotelManagement.Domain -{ - /// - /// 应用版本 (Application Version) - /// - [SugarTable("app_version", "应用版本 (Application Version)")] - public class ApplicationVersion - { - /// - /// 流水号 (Sequence Number) - /// - [SugarColumn(ColumnName = "base_versionId", IsIdentity = true, IsPrimaryKey = true, ColumnDescription = "流水号 (Sequence Number)")] - public int Id { get; set; } - - /// - /// 版本号 (Version Number) - /// - [SugarColumn(ColumnName = "base_version", Length = 100, ColumnDescription = "版本号 (Version Number)")] - public string VersionNumber { get; set; } - } -} diff --git a/EOM.TSHotelManagement.Migration/EntityBuilder.cs b/EOM.TSHotelManagement.Migration/EntityBuilder.cs index 4dc2ac9..842e7d8 100644 --- a/EOM.TSHotelManagement.Migration/EntityBuilder.cs +++ b/EOM.TSHotelManagement.Migration/EntityBuilder.cs @@ -6,7 +6,6 @@ namespace EOM.TSHotelManagement.Migration { private readonly Type[] entityTypes = { - typeof(ApplicationVersion), typeof(Administrator), typeof(AdministratorType), typeof(AppointmentNotice), diff --git a/EOM.TSHotelManagement.Service/Application/NavBar/NavBarService.cs b/EOM.TSHotelManagement.Service/Application/NavBar/NavBarService.cs index b206c04..fc6990a 100644 --- a/EOM.TSHotelManagement.Service/Application/NavBar/NavBarService.cs +++ b/EOM.TSHotelManagement.Service/Application/NavBar/NavBarService.cs @@ -120,29 +120,48 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse DeleteNavBar(DeleteNavBarInputDto input) { - var navBar = navBarRepository.GetById(input.NavigationBarId); - if (navBar == null) + if (input?.DelIds == null || !input.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var navBars = navBarRepository.GetList(a => input.DelIds.Contains(a.Id)); + + if (!navBars.Any()) { return new BaseResponse { Code = BusinessStatusCode.NotFound, - Message = "导航控件未找到" + Message = LocalizationHelper.GetLocalizedString("Navigation Control Not Found", "导航控件未找到") }; } - navBar.IsDelete = 1; - var result = navBarRepository.SoftDelete(navBar); + + navBars = navBars.Select(nb => + { + nb.IsDelete = 1; + return nb; + }).ToList(); + + // 批量软删除 + var result = navBarRepository.SoftDeleteRange(navBars); + if (!result) { return new BaseResponse { Code = BusinessStatusCode.InternalServerError, - Message = "删除失败" + Message = LocalizationHelper.GetLocalizedString("Delete failure", "删除失败") }; } + return new BaseResponse { Code = BusinessStatusCode.Success, - Message = "删除成功" + Message = LocalizationHelper.GetLocalizedString("Delete successful", "删除成功") }; } } diff --git a/EOM.TSHotelManagement.Service/Business/Asset/AssetService.cs b/EOM.TSHotelManagement.Service/Business/Asset/AssetService.cs index 47c3164..f2f0390 100644 --- a/EOM.TSHotelManagement.Service/Business/Asset/AssetService.cs +++ b/EOM.TSHotelManagement.Service/Business/Asset/AssetService.cs @@ -175,19 +175,54 @@ namespace EOM.TSHotelManagement.Service { try { - var dbAsset = assetRepository.GetFirst(a => a.AssetNumber == asset.AssetNumber); - if (dbAsset.IsNullOrEmpty()) + if (asset?.DelIds == null || !asset.DelIds.Any()) { - return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("asset number does not exist.", "资产编号不存在"), Code = BusinessStatusCode.InternalServerError }; + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var assets = assetRepository.GetList(a => asset.DelIds.Contains(a.Id)); + + if (!assets.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Asset Information Not Found", "资产信息未找到") + }; } - dbAsset.IsDelete = asset.IsDelete; - assetRepository.SoftDelete(dbAsset); + + assets = assets.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + var result = assetRepository.SoftDeleteRange(assets); + + if (!result) + { + return new BaseResponse + { + Code = BusinessStatusCode.InternalServerError, + Message = LocalizationHelper.GetLocalizedString("Delete failure", "删除失败") + }; + } + + return new BaseResponse + { + Code = BusinessStatusCode.Success, + Message = LocalizationHelper.GetLocalizedString("Delete successful", "删除成功") + }; } catch (Exception ex) { return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseResponse(); } } } diff --git a/EOM.TSHotelManagement.Service/Business/Customer/CustomerService.cs b/EOM.TSHotelManagement.Service/Business/Customer/CustomerService.cs index f81b67c..8a07cf4 100644 --- a/EOM.TSHotelManagement.Service/Business/Customer/CustomerService.cs +++ b/EOM.TSHotelManagement.Service/Business/Customer/CustomerService.cs @@ -26,6 +26,7 @@ using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.EntityLib; +using Microsoft.Extensions.Logging; using SqlSugar; namespace EOM.TSHotelManagement.Service @@ -70,6 +71,8 @@ namespace EOM.TSHotelManagement.Service /// private readonly DataProtectionHelper dataProtector; + private readonly ILogger logger; + /// /// /// @@ -78,7 +81,7 @@ namespace EOM.TSHotelManagement.Service /// /// /// - public CustomerService(GenericRepository custoRepository, GenericRepository spendRepository, GenericRepository passPortTypeRepository, GenericRepository custoTypeRepository, GenericRepository roleRepository, GenericRepository userRoleRepository, DataProtectionHelper dataProtectionHelper) + public CustomerService(GenericRepository custoRepository, GenericRepository spendRepository, GenericRepository passPortTypeRepository, GenericRepository custoTypeRepository, GenericRepository roleRepository, GenericRepository userRoleRepository, DataProtectionHelper dataProtectionHelper, ILogger logger) { this.custoRepository = custoRepository; this.spendRepository = spendRepository; @@ -87,6 +90,7 @@ namespace EOM.TSHotelManagement.Service this.roleRepository = roleRepository; this.userRoleRepository = userRoleRepository; this.dataProtector = dataProtectionHelper; + this.logger = logger; } /// @@ -145,7 +149,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Insert Customer Failed", "客户信息添加失败"), ex); + logger.LogError(ex, "Error inserting customer information for customer number {CustomerNumber}", custo.CustomerNumber); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Customer Failed", "客户信息添加失败")); } @@ -178,6 +182,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error updating customer information for customer number {CustomerNumber}", custo.CustomerNumber); return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -190,31 +195,57 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse DelCustomerInfo(DeleteCustomerInputDto custo) { - if (!custoRepository.IsAny(a => a.CustomerNumber == custo.CustomerNumber)) - { - return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("customer number does not exist.", "客户编号不存在"), Code = BusinessStatusCode.InternalServerError }; - } - var occupied = Convert.ToInt32(RoomState.Occupied); - var isOccupied = custoRepository.Change().IsAny(a => a.CustomerNumber == custo.CustomerNumber && a.RoomStateId == occupied); - var haveUnSettle = custoRepository.Change().IsAny(a => a.CustomerNumber == custo.CustomerNumber && a.SettlementStatus == ConsumptionConstant.UnSettle.Code); - if (isOccupied) - return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Customer is currently occupying a room", "客户当前正在占用房间")); - if (haveUnSettle) - return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Customer has unsettled bills", "客户有未结算的账单")); - - var result = custoRepository.Update(a => new Customer() + try { - IsDelete = custo.IsDelete, - DataChgUsr = custo.DataChgUsr, - DataChgDate = custo.DataChgDate - }, a => a.CustomerNumber == custo.CustomerNumber); + if (custo?.DelIds == null || !custo.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var customers = custoRepository.GetList(a => custo.DelIds.Contains(a.Id)); + + if (!customers.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Customer Information Not Found", "客户信息未找到") + }; + } + + var occupied = Convert.ToInt32(RoomState.Occupied); + foreach (var customer in customers) + { + var isOccupied = custoRepository.Change().IsAny(a => a.CustomerNumber == customer.CustomerNumber && a.RoomStateId == occupied); + var haveUnSettle = custoRepository.Change().IsAny(a => a.CustomerNumber == customer.CustomerNumber && a.SettlementStatus == ConsumptionConstant.UnSettle.Code); + + if (isOccupied) + return new BaseResponse(BusinessStatusCode.InternalServerError, + string.Format(LocalizationHelper.GetLocalizedString("Customer {0} is currently occupying a room", "客户{0}当前正在占用房间"), customer.CustomerNumber)); + + if (haveUnSettle) + return new BaseResponse(BusinessStatusCode.InternalServerError, + string.Format(LocalizationHelper.GetLocalizedString("Customer {0} has unsettled bills", "客户{0}有未结算的账单"), customer.CustomerNumber)); + } + + customers = customers.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + custoRepository.SoftDeleteRange(customers); - if (result) - { return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Customer Success", "客户信息删除成功")); } - else + catch (Exception) { + logger.LogError("Error deleting customer information for customer IDs {CustomerIds}", string.Join(", ", custo.DelIds)); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Customer Failed", "客户信息删除失败")); } } @@ -245,7 +276,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Customer Type Failed", "客户类型更新失败"), ex); + logger.LogError(ex, "Error updating customer type for customer number {CustomerNumber}", updateCustomerInputDto.CustomerNumber); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Type Failed", "客户类型更新失败")); } } diff --git a/EOM.TSHotelManagement.Service/Business/EnergyManagement/EnergyManagementService.cs b/EOM.TSHotelManagement.Service/Business/EnergyManagement/EnergyManagementService.cs index 5962ecc..c51bdd8 100644 --- a/EOM.TSHotelManagement.Service/Business/EnergyManagement/EnergyManagementService.cs +++ b/EOM.TSHotelManagement.Service/Business/EnergyManagement/EnergyManagementService.cs @@ -25,6 +25,7 @@ using EOM.TSHotelManagement.Common; using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; +using Microsoft.Extensions.Logging; namespace EOM.TSHotelManagement.Service { @@ -37,14 +38,12 @@ namespace EOM.TSHotelManagement.Service /// 水电信息 /// private readonly GenericRepository wtiRepository; + private readonly ILogger _logger; - /// - /// - /// - /// - public EnergyManagementService(GenericRepository wtiRepository) + public EnergyManagementService(GenericRepository wtiRepository, ILogger logger) { this.wtiRepository = wtiRepository; + _logger = logger; } /// @@ -100,7 +99,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Insert Energy Management Failed", "水电信息添加失败"), ex); + _logger.LogError(ex, LocalizationHelper.GetLocalizedString("Insert Energy Management Failed", "水电信息添加失败")); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Energy Management Failed", "水电信息添加失败")); } @@ -133,7 +132,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Energy Management Failed", "水电费信息更新失败"), ex); + _logger.LogError(ex, LocalizationHelper.GetLocalizedString("Update Energy Management Failed", "水电费信息更新失败")); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Energy Management Failed", "水电费信息更新失败")); } } @@ -146,7 +145,34 @@ namespace EOM.TSHotelManagement.Service { try { - var result = wtiRepository.SoftDelete(EntityMapper.Map(hydroelectricity)); + if (hydroelectricity?.DelIds == null || !hydroelectricity.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var energyManagements = wtiRepository.GetList(a => hydroelectricity.DelIds.Contains(a.Id)); + + if (!energyManagements.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Energy Management Information Not Found", "水电费信息未找到") + }; + } + + energyManagements = energyManagements.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + var result = wtiRepository.SoftDeleteRange(energyManagements); if (result) { @@ -159,7 +185,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Delete Energy Management Failed", "水电费信息删除失败"), ex); + _logger.LogError(ex, LocalizationHelper.GetLocalizedString("Delete Energy Management Failed", "水电费信息删除失败")); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Energy Management Failed", "水电费信息删除失败")); } } diff --git a/EOM.TSHotelManagement.Service/Business/News/NewsService.cs b/EOM.TSHotelManagement.Service/Business/News/NewsService.cs index f72219c..a55b4bd 100644 --- a/EOM.TSHotelManagement.Service/Business/News/NewsService.cs +++ b/EOM.TSHotelManagement.Service/Business/News/NewsService.cs @@ -3,16 +3,19 @@ using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.EntityLib; +using Microsoft.Extensions.Logging; namespace EOM.TSHotelManagement.Service { public class NewsService : INewsService { private readonly GenericRepository _newsRepository; + private readonly ILogger _logger; - public NewsService(GenericRepository newsRepository) + public NewsService(GenericRepository newsRepository, ILogger logger) { _newsRepository = newsRepository; + _logger = logger; } /// @@ -156,6 +159,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + _logger.LogError(ex, "添加新闻时发生异常"); return new BaseResponse { Code = BusinessStatusCode.InternalServerError, @@ -206,6 +210,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + _logger.LogError(ex, "更新新闻时发生异常"); return new BaseResponse { Code = BusinessStatusCode.InternalServerError, @@ -226,33 +231,55 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse DeleteNews(DeleteNewsInputDto deleteNewsInputDto) { - var news = _newsRepository.AsQueryable().Where(a => a.NewId == deleteNewsInputDto.NewId).Single(); - if (news.IsNullOrEmpty()) + if (deleteNewsInputDto?.DelIds == null || !deleteNewsInputDto.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var news = _newsRepository.GetList(a => deleteNewsInputDto.DelIds.Contains(a.Id)); + + if (!news.Any()) { return new BaseResponse { Code = BusinessStatusCode.NotFound, - Message = "新闻未找到" + Message = LocalizationHelper.GetLocalizedString("News Information Not Found", "新闻信息未找到") }; } + try { - news.IsDelete = 1; - _newsRepository.SoftDelete(news); + news = news.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + var result = _newsRepository.SoftDeleteRange(news); + + if (result) + { + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete News Success", "新闻信息删除成功")); + } + else + { + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete News Failed", "新闻信息删除失败")); + } } catch (Exception ex) { + _logger.LogError(ex, "删除新闻时发生异常"); return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = $"新闻删除失败: {ex.Message}" }; } - return new BaseResponse - { - Code = BusinessStatusCode.Success, - Message = "新闻删除成功" - }; } } } diff --git a/EOM.TSHotelManagement.Service/Business/PromotionContent/PromotionContentService.cs b/EOM.TSHotelManagement.Service/Business/PromotionContent/PromotionContentService.cs index 95821da..15a82d3 100644 --- a/EOM.TSHotelManagement.Service/Business/PromotionContent/PromotionContentService.cs +++ b/EOM.TSHotelManagement.Service/Business/PromotionContent/PromotionContentService.cs @@ -25,6 +25,7 @@ using EOM.TSHotelManagement.Common; using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; +using Microsoft.Extensions.Logging; namespace EOM.TSHotelManagement.Service { @@ -37,14 +38,12 @@ namespace EOM.TSHotelManagement.Service /// 跑马灯 /// private readonly GenericRepository fontsRepository; + private readonly ILogger logger; - /// - /// - /// - /// - public PromotionContentService(GenericRepository fontsRepository) + public PromotionContentService(GenericRepository fontsRepository, ILogger logger) { this.fontsRepository = fontsRepository; + this.logger = logger; } /// @@ -106,16 +105,11 @@ namespace EOM.TSHotelManagement.Service try { var entity = EntityMapper.Map(createPromotionContentInputDto); - var result = fontsRepository.Insert(entity); - if (!result) - { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Insert Promotion Content Failed", "宣传联动内容添加失败"), null); - return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Promotion Content Failed", "宣传联动内容添加失败")); - } + fontsRepository.Insert(entity); } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Insert Promotion Content Failed", "宣传联动内容添加失败"), ex); + logger.LogError(ex, LocalizationHelper.GetLocalizedString("Insert Promotion Content Failed", "宣传联动内容添加失败")); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Promotion Content Failed", "宣传联动内容添加失败")); } @@ -131,17 +125,49 @@ namespace EOM.TSHotelManagement.Service { try { - var font = fontsRepository.GetFirst(a => a.PromotionContentNumber == deletePromotionContentInputDto.PromotionContentNumber && a.IsDelete != 1); - font.IsDelete = deletePromotionContentInputDto.IsDelete; - fontsRepository.SoftDelete(font); + if (deletePromotionContentInputDto?.DelIds == null || !deletePromotionContentInputDto.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var promotionContents = fontsRepository.GetList(a => deletePromotionContentInputDto.DelIds.Contains(a.Id)); + + if (!promotionContents.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Promotion Content Not Found", "宣传联动内容未找到") + }; + } + + promotionContents = promotionContents.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + var result = fontsRepository.SoftDeleteRange(promotionContents); + + if (result) + { + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Promotion Content Success", "宣传联动内容删除成功")); + } + else + { + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Promotion Content Failed", "宣传联动内容删除失败")); + } } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Delete Promotion Content Failed", "宣传联动内容删除失败"), ex); + logger.LogError(ex, LocalizationHelper.GetLocalizedString("Delete Promotion Content Failed", "宣传联动内容删除失败")); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Promotion Content Failed", "宣传联动内容删除失败")); } - - return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Promotion Content Success", "宣传联动内容删除成功")); } /// @@ -154,16 +180,11 @@ namespace EOM.TSHotelManagement.Service try { var entity = EntityMapper.Map(updatePromotionContentInputDto); - var result = fontsRepository.Update(entity); - if (!result) - { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Promotion Content Failed", "宣传联动内容更新失败"), null); - return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Promotion Content Failed", "宣传联动内容更新失败")); - } + fontsRepository.Update(entity); } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Promotion Content Failed", "宣传联动内容更新失败"), ex); + logger.LogError(ex, LocalizationHelper.GetLocalizedString("Update Promotion Content Failed", "宣传联动内容更新失败")); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Promotion Content Failed", "宣传联动内容更新失败")); } diff --git a/EOM.TSHotelManagement.Service/Business/Reser/ReserService.cs b/EOM.TSHotelManagement.Service/Business/Reser/ReserService.cs index 4253ebb..87f00cb 100644 --- a/EOM.TSHotelManagement.Service/Business/Reser/ReserService.cs +++ b/EOM.TSHotelManagement.Service/Business/Reser/ReserService.cs @@ -25,6 +25,7 @@ using EOM.TSHotelManagement.Common; using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; +using Microsoft.Extensions.Logging; using SqlSugar; using System.Transactions; @@ -50,17 +51,14 @@ namespace EOM.TSHotelManagement.Service /// private readonly DataProtectionHelper dataProtector; - /// - /// - /// - /// - /// - /// - public ReserService(GenericRepository reserRepository, GenericRepository roomRepository, DataProtectionHelper dataProtectionProvider) + private readonly ILogger logger; + + public ReserService(GenericRepository reserRepository, GenericRepository roomRepository, DataProtectionHelper dataProtector, ILogger logger) { this.reserRepository = reserRepository; this.roomRepository = roomRepository; - this.dataProtector = dataProtectionProvider; + this.dataProtector = dataProtector; + this.logger = logger; } /// @@ -158,26 +156,64 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse DeleteReserInfo(DeleteReserInputDto reser) { - var reserInfo = reserRepository.GetFirst(a => a.ReservationId == reser.ReservationId); - using (TransactionScope scope = new TransactionScope()) + if (reser?.DelIds == null || !reser.DelIds.Any()) { - reserInfo.IsDelete = reser.IsDelete; - var result = reserRepository.SoftDelete(reserInfo); + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var resers = reserRepository.GetList(a => reser.DelIds.Contains(a.Id)); - if (result) + if (!resers.Any()) + { + return new BaseResponse { - var roomInfo = roomRepository.GetFirst(a => a.RoomNumber == reserInfo.ReservationRoomNumber); - roomInfo.RoomStateId = (int)RoomState.Vacant; - roomRepository.Update(roomInfo); - scope.Complete(); - return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Reser Success", "预约信息删除成功")); - } - else + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Reservation Information Not Found", "预约信息未找到") + }; + } + + try + { + using (TransactionScope scope = new TransactionScope()) { - return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Reser Failed", "预约信息删除失败")); + var roomNumbers = resers.Select(a => a.ReservationRoomNumber).ToList(); + resers = resers.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + var result = reserRepository.SoftDeleteRange(resers); + + if (result) + { + var rooms = roomRepository.AsQueryable().Where(a => roomNumbers.Contains(a.RoomNumber)).ToList(); + rooms = rooms.Select(a => + { + a.RoomStateId = (int)RoomState.Vacant; + return a; + }).ToList(); + roomRepository.UpdateRange(rooms); + scope.Complete(); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Reser Success", "预约信息删除成功")); + } + else + { + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Reser Failed", "预约信息删除失败")); + } } } + catch (Exception ex) + { + logger.LogError(ex, LocalizationHelper.GetLocalizedString("Delete Reser Failed", "预约信息删除失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Reser Failed", "预约信息删除失败")); + } } /// @@ -192,19 +228,12 @@ namespace EOM.TSHotelManagement.Service try { var entity = EntityMapper.Map(reser); - var result = reserRepository.Update(entity); - if (result) - { - return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Update Customer Success", "预约信息更新成功")); - } - else - { - return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息更新失败")); - } + reserRepository.Update(entity); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Update Customer Success", "预约信息更新成功")); } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息添加失败"), ex); + logger.LogError(ex, LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息更新失败")); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息更新失败")); } } @@ -221,27 +250,21 @@ namespace EOM.TSHotelManagement.Service try { var entity = EntityMapper.Map(r); - var result = reserRepository.Insert(entity); - if (result) - { - var room = roomRepository.GetFirst(a => a.RoomNumber == r.ReservationRoomNumber); - room.RoomStateId = new EnumHelper().GetEnumValue(RoomState.Reserved); - var updateResult = roomRepository.Update(room); + reserRepository.Insert(entity); - if (!updateResult) - { - return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败")); - } - return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Add Customer Success", "预约信息添加成功")); - } - else + var room = roomRepository.GetFirst(a => a.RoomNumber == r.ReservationRoomNumber); + room.RoomStateId = new EnumHelper().GetEnumValue(RoomState.Reserved); + var updateResult = roomRepository.Update(room); + + if (!updateResult) { return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败")); } + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Add Customer Success", "预约信息添加成功")); } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败"), ex); + logger.LogError(ex, LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败")); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败")); } } diff --git a/EOM.TSHotelManagement.Service/Business/Room/RoomService.cs b/EOM.TSHotelManagement.Service/Business/Room/RoomService.cs index eb25092..db32dec 100644 --- a/EOM.TSHotelManagement.Service/Business/Room/RoomService.cs +++ b/EOM.TSHotelManagement.Service/Business/Room/RoomService.cs @@ -27,6 +27,7 @@ using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.CodeLib; using jvncorelib.EntityLib; +using Microsoft.Extensions.Logging; using SqlSugar; using System.Transactions; @@ -82,19 +83,9 @@ namespace EOM.TSHotelManagement.Service /// private readonly UniqueCode uniqueCode; - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public RoomService(GenericRepository roomRepository, GenericRepository spendRepository, GenericRepository roomTypeRepository, GenericRepository energyRepository, GenericRepository custoRepository, GenericRepository custoTypeRepository, GenericRepository vipLevelRuleRepository, GenericRepository reserRepository, UniqueCode uniqueCode) + private readonly ILogger logger; + + public RoomService(GenericRepository roomRepository, GenericRepository spendRepository, GenericRepository roomTypeRepository, GenericRepository energyRepository, GenericRepository custoRepository, GenericRepository custoTypeRepository, GenericRepository vipLevelRuleRepository, GenericRepository reserRepository, UniqueCode uniqueCode, ILogger logger) { this.roomRepository = roomRepository; this.spendRepository = spendRepository; @@ -105,6 +96,7 @@ namespace EOM.TSHotelManagement.Service this.vipLevelRuleRepository = vipLevelRuleRepository; this.reserRepository = reserRepository; this.uniqueCode = uniqueCode; + this.logger = logger; } /// @@ -354,6 +346,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error updating room info for room number {RoomNumber}", r.RoomNumber); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -376,6 +369,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error updating room info with reservation for room number {RoomNumber}", r.RoomNumber); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -546,14 +540,11 @@ namespace EOM.TSHotelManagement.Service var entity = EntityMapper.Map(rn); entity.LastCheckInTime = DateOnly.MinValue; entity.LastCheckOutTime = DateOnly.MinValue; - var result = roomRepository.Insert(entity); - if (!result) - { - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Failed to add room.", "添加房间失败。"), Code = BusinessStatusCode.InternalServerError }; - } + roomRepository.Insert(entity); } catch (Exception ex) { + logger.LogError(ex, "Error inserting room with room number {RoomNumber}", rn.RoomNumber); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } @@ -574,15 +565,12 @@ namespace EOM.TSHotelManagement.Service return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("This room does not exist.", "房间不存在。"), Code = BusinessStatusCode.InternalServerError }; var entity = EntityMapper.Map(rn); - var result = roomRepository.Update(entity); - if (!result) - { - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Failed to update room.", "更新房间失败。"), Code = BusinessStatusCode.InternalServerError }; - } + roomRepository.Update(entity); } catch (Exception ex) { - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; + logger.LogError(ex, "Error updating room with room number {RoomNumber}", rn.RoomNumber); + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Failed to update room.", "更新房间失败。"), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -597,17 +585,41 @@ namespace EOM.TSHotelManagement.Service { try { - var isExist = roomRepository.IsAny(a => a.RoomNumber == rn.RoomNumber); - if (!isExist) - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("This room does not exist.", "房间不存在。"), Code = BusinessStatusCode.InternalServerError }; - roomRepository.Update(EntityMapper.Map(rn)); + if (rn?.DelIds == null || !rn.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var rooms = roomRepository.GetList(a => rn.DelIds.Contains(a.Id)); + + if (!rooms.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Room Information Not Found", "房间信息未找到") + }; + } + + rooms = rooms.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + roomRepository.SoftDeleteRange(rooms); + + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Room Success", "房间信息删除成功")); } catch (Exception ex) { return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - - return new BaseResponse(); } /// @@ -725,6 +737,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error transferring room from {OriginalRoomNumber} to {TargetRoomNumber} for customer {CustomerNumber}", transferRoomDto.OriginalRoomNumber, transferRoomDto.TargetRoomNumber, transferRoomDto.CustomerNumber); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -788,6 +801,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error checking out room number {RoomNumber} for customer {CustomerNumber}", checkoutRoomDto.RoomNumber, checkoutRoomDto.CustomerNumber); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -850,6 +864,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error checking in room number {RoomNumber} by reservation ID {ReservationId}", checkinRoomByReservationDto.RoomNumber, checkinRoomByReservationDto.ReservationId); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); diff --git a/EOM.TSHotelManagement.Service/Business/Room/RoomTypeService.cs b/EOM.TSHotelManagement.Service/Business/Room/RoomTypeService.cs index 2911e5a..7dffc1e 100644 --- a/EOM.TSHotelManagement.Service/Business/Room/RoomTypeService.cs +++ b/EOM.TSHotelManagement.Service/Business/Room/RoomTypeService.cs @@ -25,6 +25,7 @@ using EOM.TSHotelManagement.Common; using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; +using Microsoft.Extensions.Logging; namespace EOM.TSHotelManagement.Service { @@ -42,16 +43,13 @@ namespace EOM.TSHotelManagement.Service /// 客房信息 /// private readonly GenericRepository roomRepository; + private readonly ILogger logger; - /// - /// - /// - /// - /// - public RoomTypeService(GenericRepository roomTypeRepository, GenericRepository roomRepository) + public RoomTypeService(GenericRepository roomTypeRepository, GenericRepository roomRepository, ILogger logger) { this.roomTypeRepository = roomTypeRepository; this.roomRepository = roomRepository; + this.logger = logger; } #region 获取所有房间类型 @@ -130,6 +128,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error inserting room type"); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -158,6 +157,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error updating room type"); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -172,12 +172,38 @@ namespace EOM.TSHotelManagement.Service { try { - var existRoomType = roomTypeRepository.GetFirst(a => a.RoomTypeId == roomType.RoomTypeId && a.IsDelete != 1); - existRoomType.IsDelete = roomType.IsDelete; - roomTypeRepository.SoftDelete(existRoomType); + if (roomType?.DelIds == null || !roomType.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var roomTypes = roomTypeRepository.GetList(a => roomType.DelIds.Contains(a.Id)); + + if (!roomTypes.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Room Type Information Not Found", "房间类型信息未找到") + }; + } + + roomTypes = roomTypes.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + roomTypeRepository.SoftDeleteRange(roomTypes); } catch (Exception ex) { + logger.LogError(ex, "Error deleting room type"); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); diff --git a/EOM.TSHotelManagement.Service/Business/Sellthing/SellService.cs b/EOM.TSHotelManagement.Service/Business/Sellthing/SellService.cs index f8c00bb..fe1bf79 100644 --- a/EOM.TSHotelManagement.Service/Business/Sellthing/SellService.cs +++ b/EOM.TSHotelManagement.Service/Business/Sellthing/SellService.cs @@ -26,6 +26,7 @@ using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.EntityLib; +using Microsoft.Extensions.Logging; using SqlSugar; namespace EOM.TSHotelManagement.Service @@ -44,16 +45,13 @@ namespace EOM.TSHotelManagement.Service /// 消费情况 /// private readonly GenericRepository spendRepository; + private readonly ILogger logger; - /// - /// - /// - /// - /// - public SellService(GenericRepository sellThingRepository, GenericRepository spendRepository) + public SellService(GenericRepository sellThingRepository, GenericRepository spendRepository, ILogger logger) { this.sellThingRepository = sellThingRepository; this.spendRepository = spendRepository; + this.logger = logger; } /// @@ -132,6 +130,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error updating sell thing: {Message}", ex.Message); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -155,6 +154,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error updating sell thing: {Message}", ex.Message); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -169,12 +169,38 @@ namespace EOM.TSHotelManagement.Service { try { - var product = sellThingRepository.GetFirst(a => a.ProductNumber == deleteSellThingInputDto.ProductNumber); - product.IsDelete = deleteSellThingInputDto.IsDelete; - sellThingRepository.SoftDelete(product); + if (deleteSellThingInputDto?.DelIds == null || !deleteSellThingInputDto.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var sellThings = sellThingRepository.GetList(a => deleteSellThingInputDto.DelIds.Contains(a.Id)); + + if (!sellThings.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Goods Information Not Found", "商品信息未找到") + }; + } + + sellThings = sellThings.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + sellThingRepository.SoftDeleteRange(sellThings); } catch (Exception ex) { + logger.LogError(ex, "Error deleting sell thing: {Message}", ex.Message); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -196,7 +222,6 @@ namespace EOM.TSHotelManagement.Service return new SingleOutputDto() { Data = source }; } - #region 添加商品 /// /// 添加商品 /// @@ -207,18 +232,14 @@ namespace EOM.TSHotelManagement.Service try { var entity = EntityMapper.Map(st); - var result = sellThingRepository.Insert(entity); - if (!result) - { - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("insert sellthing failed.", "商品添加失败"), Code = BusinessStatusCode.InternalServerError }; - } + sellThingRepository.Insert(entity); } catch (Exception ex) { + logger.LogError(ex, "Error inserting sell thing: {Message}", ex.Message); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); } - #endregion } } diff --git a/EOM.TSHotelManagement.Service/Business/Spend/SpendService.cs b/EOM.TSHotelManagement.Service/Business/Spend/SpendService.cs index ec10fb4..0971c75 100644 --- a/EOM.TSHotelManagement.Service/Business/Spend/SpendService.cs +++ b/EOM.TSHotelManagement.Service/Business/Spend/SpendService.cs @@ -28,6 +28,7 @@ using EOM.TSHotelManagement.Domain; using jvncorelib.CodeLib; using jvncorelib.EntityLib; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; using SqlSugar; using System.Transactions; @@ -74,7 +75,9 @@ namespace EOM.TSHotelManagement.Service private readonly IHttpContextAccessor _httpContextAccessor; - public SpendService(GenericRepository spendRepository, GenericRepository sellThingRepository, GenericRepository roomRepository, GenericRepository customerRepository, GenericRepository custoTypeRepository, GenericRepository operationLogRepository, IHttpContextAccessor httpContextAccessor) + private readonly ILogger logger; + + public SpendService(GenericRepository spendRepository, GenericRepository sellThingRepository, GenericRepository roomRepository, GenericRepository customerRepository, GenericRepository custoTypeRepository, GenericRepository operationLogRepository, IHttpContextAccessor httpContextAccessor, ILogger logger) { this.spendRepository = spendRepository; this.sellThingRepository = sellThingRepository; @@ -83,6 +86,7 @@ namespace EOM.TSHotelManagement.Service this.custoTypeRepository = custoTypeRepository; this.operationLogRepository = operationLogRepository; _httpContextAccessor = httpContextAccessor; + this.logger = logger; } #region 根据客户编号查询历史消费信息 @@ -257,6 +261,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "撤回客户消费信息失败"); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -362,17 +367,13 @@ namespace EOM.TSHotelManagement.Service LogContent = logContent, LoginIpAddress = context.Connection.RemoteIpAddress?.ToString() ?? string.Empty, OperationAccount = addCustomerSpendInputDto.WorkerNo, - LogLevel = (int)LogLevel.Warning, + LogLevel = (int)Common.LogLevel.Warning, SoftwareVersion = addCustomerSpendInputDto.SoftwareVersion, IsDelete = 0, DataInsUsr = addCustomerSpendInputDto.WorkerNo, DataInsDate = Convert.ToDateTime(DateTime.Now) }; - var logResult = operationLogRepository.Insert(log); - if (!logResult) - { - return new BaseResponse() { Message = "操作日志添加失败", Code = BusinessStatusCode.InternalServerError }; - } + operationLogRepository.Insert(log); scope.Complete(); @@ -380,6 +381,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "添加客户消费信息失败"); return new BaseResponse() { Message = $"添加消费记录失败,请稍后重试。{ex.Message}", Code = BusinessStatusCode.InternalServerError }; } } @@ -404,6 +406,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "更新消费信息失败"); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); diff --git a/EOM.TSHotelManagement.Service/Employee/EmployeeService.cs b/EOM.TSHotelManagement.Service/Employee/EmployeeService.cs index 3794b80..73ed12a 100644 --- a/EOM.TSHotelManagement.Service/Employee/EmployeeService.cs +++ b/EOM.TSHotelManagement.Service/Employee/EmployeeService.cs @@ -26,6 +26,7 @@ using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.EntityLib; +using Microsoft.Extensions.Logging; using SqlSugar; using System.Security.Claims; @@ -46,7 +47,8 @@ namespace EOM.TSHotelManagement.Service /// /// /// - public class EmployeeService(GenericRepository workerRepository, GenericRepository photoRepository, GenericRepository educationRepository, GenericRepository nationRepository, GenericRepository deptRepository, GenericRepository positionRepository, GenericRepository passportTypeRepository, JWTHelper jWTHelper, MailHelper mailHelper, DataProtectionHelper dataProtectionHelper) : IEmployeeService + /// + public class EmployeeService(GenericRepository workerRepository, GenericRepository photoRepository, GenericRepository educationRepository, GenericRepository nationRepository, GenericRepository deptRepository, GenericRepository positionRepository, GenericRepository passportTypeRepository, JWTHelper jWTHelper, MailHelper mailHelper, DataProtectionHelper dataProtectionHelper, ILogger logger) : IEmployeeService { /// /// 员工信息 @@ -98,6 +100,8 @@ namespace EOM.TSHotelManagement.Service /// private readonly MailHelper mailHelper = mailHelper; + private readonly ILogger logger = logger; + /// /// 修改员工信息 /// @@ -129,6 +133,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error updating employee information for EmployeeId: {EmployeeId}", updateEmployeeInputDto.EmployeeId); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -151,6 +156,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error managing employee account for EmployeeId: {EmployeeId}", updateEmployeeInputDto.EmployeeId); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -198,6 +204,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error adding employee: {Message}", ex.Message); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -470,6 +477,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error updating employee password for EmployeeId: {EmployeeId}", updateEmployeeInputDto.EmployeeId); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } @@ -518,6 +526,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error resetting employee password for EmployeeId: {EmployeeId}", updateEmployeeInputDto.EmployeeId); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } diff --git a/EOM.TSHotelManagement.Service/Employee/Photo/EmployeePhotoService.cs b/EOM.TSHotelManagement.Service/Employee/Photo/EmployeePhotoService.cs index 4edd6b4..6eb1df1 100644 --- a/EOM.TSHotelManagement.Service/Employee/Photo/EmployeePhotoService.cs +++ b/EOM.TSHotelManagement.Service/Employee/Photo/EmployeePhotoService.cs @@ -4,6 +4,7 @@ using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.EntityLib; using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; namespace EOM.TSHotelManagement.Service { @@ -22,15 +23,13 @@ namespace EOM.TSHotelManagement.Service /// private readonly LskyHelper lskyHelper; - /// - /// - /// - /// - /// - public EmployeePhotoService(GenericRepository workerPicRepository, LskyHelper lskyHelper) + private readonly ILogger logger; + + public EmployeePhotoService(GenericRepository workerPicRepository, LskyHelper lskyHelper, ILogger logger) { this.workerPicRepository = workerPicRepository; this.lskyHelper = lskyHelper; + this.logger = logger; } /// @@ -146,6 +145,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error inserting employee photo: {Message}", ex.Message); return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } } @@ -183,6 +183,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error updating employee photo: {Message}", ex.Message); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); diff --git a/EOM.TSHotelManagement.Service/SystemManagement/Administrator/AdminService.cs b/EOM.TSHotelManagement.Service/SystemManagement/Administrator/AdminService.cs index a87ae27..2b3cf5a 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/Administrator/AdminService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/Administrator/AdminService.cs @@ -27,6 +27,7 @@ using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.EncryptorLib; using jvncorelib.EntityLib; +using Microsoft.Extensions.Logging; using SqlSugar; using System.Security.Claims; @@ -82,24 +83,9 @@ namespace EOM.TSHotelManagement.Service /// private readonly JWTHelper jWTHelper; - /// - /// - /// - /// - /// - /// - /// - /// - public AdminService( - GenericRepository adminRepository, - GenericRepository adminTypeRepository, - GenericRepository userRoleRepository, - GenericRepository rolePermissionRepository, - GenericRepository permissionRepository, - GenericRepository roleRepository, - DataProtectionHelper dataProtectionProvider, - EncryptLib encrypt, - JWTHelper jWTHelper) + private readonly ILogger logger; + + public AdminService(GenericRepository adminRepository, GenericRepository adminTypeRepository, GenericRepository userRoleRepository, GenericRepository rolePermissionRepository, GenericRepository permissionRepository, GenericRepository roleRepository, DataProtectionHelper dataProtector, EncryptLib encrypt, JWTHelper jWTHelper, ILogger logger) { this.adminRepository = adminRepository; this.adminTypeRepository = adminTypeRepository; @@ -107,9 +93,10 @@ namespace EOM.TSHotelManagement.Service this.rolePermissionRepository = rolePermissionRepository; this.permissionRepository = permissionRepository; this.roleRepository = roleRepository; - this.dataProtector = dataProtectionProvider; + this.dataProtector = dataProtector; this.encrypt = encrypt; this.jWTHelper = jWTHelper; + this.logger = logger; } /// @@ -244,14 +231,11 @@ namespace EOM.TSHotelManagement.Service createAdministratorInputDto.Password = dataProtector.EncryptAdministratorData(createAdministratorInputDto.Password); var admin = EntityMapper.Map(createAdministratorInputDto); - var result = adminRepository.Insert(admin); - if (!result) - { - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Add Administrator Failed", "添加管理员失败"), Code = BusinessStatusCode.InternalServerError }; - } + adminRepository.Insert(admin); } catch (Exception ex) { + logger.LogError(ex, "AddAdmin failed for Account: {Account}", createAdministratorInputDto?.Account); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -276,6 +260,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "UpdAdmin failed for Id: {Id}", updateAdministratorInputDto?.Id); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -290,15 +275,49 @@ namespace EOM.TSHotelManagement.Service { try { - var isSuperAdmin = adminRepository.IsAny(a => a.Number == deleteAdministratorInputDto.Number && a.IsSuperAdmin == 1); - if (isSuperAdmin) + if (deleteAdministratorInputDto?.DelIds == null || !deleteAdministratorInputDto.DelIds.Any()) { - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Super Administrator cannot be deleted", "超级管理员无法删除"), Code = BusinessStatusCode.InternalServerError }; + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var administrators = adminRepository.GetList(a => deleteAdministratorInputDto.DelIds.Contains(a.Id)); + + if (!administrators.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Administrator Not Found", "管理员未找到") + }; + } + + // cannot be delete if is super admin + var admin = administrators.Any(a => a.IsSuperAdmin == 1); + if (admin) + { + return new BaseResponse + { + Code = BusinessStatusCode.InternalServerError, + Message = LocalizationHelper.GetLocalizedString("Cannot delete super administrator", "无法删除超级管理员") + }; } - adminRepository.SoftDelete(EntityMapper.Map(deleteAdministratorInputDto)); + + administrators = administrators.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + adminRepository.SoftDeleteRange(administrators); } catch (Exception ex) { + logger.LogError(ex, "DelAdmin failed for Ids: {DelIds}", deleteAdministratorInputDto?.DelIds); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -350,6 +369,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "AddAdminType failed for TypeId: {TypeId}", createAdministratorTypeInputDto?.TypeId); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -368,6 +388,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "UpdAdminType failed for Id: {Id}", updateAdministratorTypeInputDto?.Id); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -382,12 +403,38 @@ namespace EOM.TSHotelManagement.Service { try { - var adminType = adminTypeRepository.GetFirst(a => a.TypeId == deleteAdministratorTypeInputDto.TypeId); - adminType.IsDelete = deleteAdministratorTypeInputDto.IsDelete; - adminTypeRepository.SoftDelete(adminType); + if (deleteAdministratorTypeInputDto?.DelIds == null || !deleteAdministratorTypeInputDto.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var administratorTypes = adminTypeRepository.GetList(a => deleteAdministratorTypeInputDto.DelIds.Contains(a.Id)); + + if (!administratorTypes.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Administrator Type Not Found", "管理员类型未找到") + }; + } + + administratorTypes = administratorTypes.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + adminTypeRepository.SoftDeleteRange(administratorTypes); } catch (Exception ex) { + logger.LogError(ex, "DelAdminType failed for Ids: {DelIds}", deleteAdministratorTypeInputDto?.DelIds); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -448,6 +495,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "AssignUserRoles failed for UserNumber: {UserNumber}", input?.UserNumber); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString($"Assign roles failed: {ex.Message}", $"分配角色失败:{ex.Message}")); } } @@ -601,6 +649,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "ReadUserRolePermissions failed for UserNumber: {UserNumber}", userNumber); return new ListOutputDto { Code = BusinessStatusCode.InternalServerError, @@ -703,6 +752,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "AssignUserPermissions failed for UserNumber: {UserNumber}", input?.UserNumber); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString($"Assign direct permissions failed: {ex.Message}", $"分配直接权限失败:{ex.Message}")); } } diff --git a/EOM.TSHotelManagement.Service/SystemManagement/Base/BaseService.cs b/EOM.TSHotelManagement.Service/SystemManagement/Base/BaseService.cs index 787989f..551c689 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/Base/BaseService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/Base/BaseService.cs @@ -26,6 +26,7 @@ using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.EntityLib; +using Microsoft.Extensions.Logging; using SqlSugar; namespace EOM.TSHotelManagement.Service @@ -85,20 +86,9 @@ namespace EOM.TSHotelManagement.Service /// private readonly GenericRepository appointmentNoticeTypeRepository; - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public BaseService(GenericRepository workerRepository, GenericRepository educationRepository, GenericRepository nationRepository, GenericRepository deptRepository, GenericRepository positionRepository, GenericRepository passPortTypeRepository, GenericRepository custoTypeRepository, GenericRepository goodbadTypeRepository, GenericRepository baseRepository, GenericRepository appointmentNoticeTypeRepository) + private readonly ILogger logger; + + public BaseService(GenericRepository workerRepository, GenericRepository educationRepository, GenericRepository nationRepository, GenericRepository deptRepository, GenericRepository positionRepository, GenericRepository passPortTypeRepository, GenericRepository custoTypeRepository, GenericRepository goodbadTypeRepository, GenericRepository baseRepository, GenericRepository appointmentNoticeTypeRepository, ILogger logger) { this.workerRepository = workerRepository; this.educationRepository = educationRepository; @@ -110,6 +100,7 @@ namespace EOM.TSHotelManagement.Service this.goodbadTypeRepository = goodbadTypeRepository; this.baseRepository = baseRepository; this.appointmentNoticeTypeRepository = appointmentNoticeTypeRepository; + this.logger = logger; } #region 预约类型模块 @@ -285,9 +276,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse AddPosition(CreatePositionInputDto createPositionInputDto) { - var position = EntityMapper.Map(createPositionInputDto); - var result = positionRepository.Insert(position); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var position = EntityMapper.Map(createPositionInputDto); + var result = positionRepository.Insert(position); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error adding position"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Add Position Failure","添加职位类型失败") }; + } } /// @@ -297,8 +296,43 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse DelPosition(DeletePositionInputDto deletePositionInputDto) { - var result = positionRepository.SoftDelete(EntityMapper.Map(deletePositionInputDto)); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + if (deletePositionInputDto?.DelIds == null || !deletePositionInputDto.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var positions = positionRepository.GetList(a => deletePositionInputDto.DelIds.Contains(a.Id)); + + if (!positions.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Position Not Found", "职位未找到") + }; + } + + positions = positions.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + positionRepository.SoftDeleteRange(positions); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error deleting positions"); + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Delete Position Failure", "删除职位类型失败"), Code = BusinessStatusCode.InternalServerError }; + } } /// @@ -308,9 +342,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse UpdPosition(UpdatePositionInputDto updatePositionInputDto) { - var position = EntityMapper.Map(updatePositionInputDto); - var result = positionRepository.Update(position); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var position = EntityMapper.Map(updatePositionInputDto); + positionRepository.Update(position); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex,"Error updating position with ID {PositionId}", updatePositionInputDto.PositionId); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Update Position Failure", "删除职位类型失败") }; + } } #endregion @@ -367,9 +409,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse AddNation(CreateNationInputDto createNationInputDto) { - var nation = EntityMapper.Map(createNationInputDto); - var result = nationRepository.Insert(nation); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var nation = EntityMapper.Map(createNationInputDto); + nationRepository.Insert(nation); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error adding nation"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Add Nation Type Failure","添加民族类型失败") }; + } } /// @@ -379,8 +429,43 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse DelNation(DeleteNationInputDto deleteNationInputDto) { - var result = nationRepository.SoftDelete(EntityMapper.Map(deleteNationInputDto)); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + if (deleteNationInputDto?.DelIds == null || !deleteNationInputDto.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var nations = nationRepository.GetList(a => deleteNationInputDto.DelIds.Contains(a.Id)); + + if (!nations.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Nation Not Found", "民族类型未找到") + }; + } + + nations = nations.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + nationRepository.SoftDeleteRange(nations); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error deleting nations"); + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Delete Nation Type Failure", "删除民族类型失败"), Code = BusinessStatusCode.InternalServerError }; + } } /// @@ -390,9 +475,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse UpdNation(UpdateNationInputDto updateNationInputDto) { - var nation = EntityMapper.Map(updateNationInputDto); - var result = nationRepository.Update(nation); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var nation = EntityMapper.Map(updateNationInputDto); + nationRepository.Update(nation); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error updating nation"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Update Nation Type Failure", "更新民族类型失败") }; + } } #endregion @@ -448,9 +541,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse AddEducation(CreateEducationInputDto createEducationInputDto) { - var education = EntityMapper.Map(createEducationInputDto); - var result = educationRepository.Insert(education); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var education = EntityMapper.Map(createEducationInputDto); + educationRepository.Insert(education); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error adding education"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Add Education Type Failure","添加学历类型失败") }; + } } /// @@ -460,8 +561,39 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse DelEducation(DeleteEducationInputDto deleteEducationInputDto) { - var result = educationRepository.SoftDelete(EntityMapper.Map(deleteEducationInputDto)); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + if (deleteEducationInputDto?.DelIds == null || !deleteEducationInputDto.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + var educations = educationRepository.GetList(a => deleteEducationInputDto.DelIds.Contains(a.Id)); + if (!educations.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Education Not Found", "学历类型未找到") + }; + } + educations = educations.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + // 批量软删除 + educationRepository.SoftDeleteRange(educations); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error deleting educations"); + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Delete Education Type Failure", "删除学历类型失败"), Code = BusinessStatusCode.InternalServerError }; + } } /// @@ -471,9 +603,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse UpdEducation(UpdateEducationInputDto education) { - var entity = EntityMapper.Map(education); - var result = educationRepository.Update(entity); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var entity = EntityMapper.Map(education); + educationRepository.Update(entity); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error updating education"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Update Education Type Failure", "更新学历类型失败") }; + } } #endregion @@ -561,9 +701,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse AddDept(CreateDepartmentInputDto dept) { - var department = EntityMapper.Map(dept); - var result = deptRepository.Insert(department); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var department = EntityMapper.Map(dept); + deptRepository.Insert(department); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error adding department"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Add Department Failure","添加部门类型失败") }; + } } /// @@ -573,8 +721,39 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse DelDept(DeleteDepartmentInputDto dept) { - var result = deptRepository.SoftDelete(EntityMapper.Map(dept)); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + if (dept?.DelIds == null || !dept.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + var departments = deptRepository.GetList(a => dept.DelIds.Contains(a.Id)); + if (!departments.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Department Not Found", "部门类型未找到") + }; + } + departments = departments.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + // 批量软删除 + deptRepository.SoftDeleteRange(departments); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error deleting departments"); + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Delete Department Failure", "删除部门类型失败"), Code = BusinessStatusCode.InternalServerError }; + } } /// @@ -584,9 +763,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse UpdDept(UpdateDepartmentInputDto dept) { - var department = EntityMapper.Map(dept); - var result = deptRepository.Update(department); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var department = EntityMapper.Map(dept); + var result = deptRepository.Update(department); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error updating department"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Update Department Failure", "更新部门类型失败") }; + } } #endregion @@ -661,9 +848,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse InsertCustoType(CreateCustoTypeInputDto custoType) { - var custoTypeEntity = EntityMapper.Map(custoType); - var result = custoTypeRepository.Insert(custoTypeEntity); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var custoTypeEntity = EntityMapper.Map(custoType); + custoTypeRepository.Insert(custoTypeEntity); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error adding customer type"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Add Customer Type Failure", "添加客户类型失败") }; + } } /// @@ -673,8 +868,39 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse DeleteCustoType(DeleteCustoTypeInputDto custoType) { - var result = custoTypeRepository.SoftDelete(EntityMapper.Map(custoType)); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + if (custoType?.DelIds == null || !custoType.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + var custoTypes = custoTypeRepository.GetList(a => custoType.DelIds.Contains(a.Id)); + if (!custoTypes.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Customer Type Not Found", "客户类型未找到") + }; + } + custoTypes = custoTypes.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + // 批量软删除 + custoTypeRepository.SoftDeleteRange(custoTypes); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error deleting departments"); + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Delete Customer Type Failure", "删除客户类型失败"), Code = BusinessStatusCode.InternalServerError }; + } } /// @@ -684,9 +910,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse UpdateCustoType(UpdateCustoTypeInputDto custoType) { - var entity = EntityMapper.Map(custoType); - var result = custoTypeRepository.Update(entity); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var entity = EntityMapper.Map(custoType); + custoTypeRepository.Update(entity); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error updating customer type"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Update Customer Type Failure", "更新客户类型失败") }; + } } #endregion @@ -761,9 +995,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse InsertPassPortType(CreatePassportTypeInputDto passPortType) { - var passPortTypeEntity = EntityMapper.Map(passPortType); - var result = passPortTypeRepository.Insert(passPortTypeEntity); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var passPortTypeEntity = EntityMapper.Map(passPortType); + passPortTypeRepository.Insert(passPortTypeEntity); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error adding passport type"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Add Passport Type Failure", "添加证件类型失败") }; + } } /// @@ -773,8 +1015,39 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse DeletePassPortType(DeletePassportTypeInputDto portType) { - var result = passPortTypeRepository.SoftDelete(EntityMapper.Map(portType)); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + if (portType?.DelIds == null || !portType.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + var passPortTypes = passPortTypeRepository.GetList(a => portType.DelIds.Contains(a.Id)); + if (!passPortTypes.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Passport Type Not Found", "证件类型未找到") + }; + } + passPortTypes = passPortTypes.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + // 批量软删除 + passPortTypeRepository.SoftDeleteRange(passPortTypes); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error deleting passport types"); + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Delete Passport Type Failure", "删除证件类型失败"), Code = BusinessStatusCode.InternalServerError }; + } } /// @@ -784,9 +1057,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse UpdatePassPortType(UpdatePassportTypeInputDto portType) { - var entity = EntityMapper.Map(portType); - var result = passPortTypeRepository.Update(entity); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var entity = EntityMapper.Map(portType); + var result = passPortTypeRepository.Update(entity); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error updating passport type"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Update Passport Type Failure", "更新证件类型失败") }; + } } #endregion @@ -859,22 +1140,61 @@ namespace EOM.TSHotelManagement.Service /// /// /// - public BaseResponse InsertRewardPunishmentType(CreateRewardPunishmentTypeInputDto gBType) + public BaseResponse InsertRewardPunishmentType(CreateRewardPunishmentTypeInputDto request) { - var gBTypeEntity = EntityMapper.Map(gBType); - var result = goodbadTypeRepository.Insert(gBTypeEntity); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var rewardPunishmentType = EntityMapper.Map(request); + var result = goodbadTypeRepository.Insert(rewardPunishmentType); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error adding Reward & Punishment type"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Add Reward & Punishment Type Failure", "添加奖惩类型失败") }; + } } /// /// 删除奖惩类型 /// - /// + /// /// - public BaseResponse DeleteRewardPunishmentType(DeleteRewardPunishmentTypeInputDto gBType) + public BaseResponse DeleteRewardPunishmentType(DeleteRewardPunishmentTypeInputDto request) { - var result = goodbadTypeRepository.SoftDelete(EntityMapper.Map(gBType)); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + if (request?.DelIds == null || !request.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + var rewardPunishmentTypes = goodbadTypeRepository.GetList(a => request.DelIds.Contains(a.Id)); + if (!rewardPunishmentTypes.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Reward & Punishment Type Not Found", "奖惩类型未找到") + }; + } + rewardPunishmentTypes = rewardPunishmentTypes.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + // 批量软删除 + goodbadTypeRepository.SoftDeleteRange(rewardPunishmentTypes); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error deleting Reward & Punishment types"); + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Delete Reward & Punishment Type Failure", "删除奖惩类型失败"), Code = BusinessStatusCode.InternalServerError }; + } } /// @@ -884,9 +1204,17 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse UpdateRewardPunishmentType(UpdateRewardPunishmentTypeInputDto gBType) { - var entity = EntityMapper.Map(gBType); - var result = goodbadTypeRepository.Update(entity); - return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; + try + { + var entity = EntityMapper.Map(gBType); + var result = goodbadTypeRepository.Update(entity); + return new BaseResponse(); + } + catch (Exception ex) + { + logger.LogError(ex, "Error updating Reward & Punishment type"); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Update Reward & Punishment Type Failure", "更新奖惩类型失败") }; + } } #endregion @@ -950,7 +1278,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("insert appointment notice failed.", "公告类型添加失败"), ex); + logger.LogError(ex, "Error inserting appointment notice type"); return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("insert appointment notice failed.", "公告类型添加失败") }; } @@ -966,19 +1294,37 @@ namespace EOM.TSHotelManagement.Service { try { - if (!appointmentNoticeTypeRepository.IsAny(a => a.NoticeTypeNumber == deleteAppointmentNoticeTypeInputDto.NoticeTypeNumber)) + if (deleteAppointmentNoticeTypeInputDto?.DelIds == null || !deleteAppointmentNoticeTypeInputDto.DelIds.Any()) { - return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("appointment notice number does not already.", "公告类型编号不存在") }; + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + var appointmentNoticeTypes = appointmentNoticeTypeRepository.GetList(a => deleteAppointmentNoticeTypeInputDto.DelIds.Contains(a.Id)); + if (!appointmentNoticeTypes.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Appointment Notice Type Not Found", "公告类型未找到") + }; } - appointmentNoticeTypeRepository.SoftDelete(EntityMapper.Map(deleteAppointmentNoticeTypeInputDto)); + appointmentNoticeTypes = appointmentNoticeTypes.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + // 批量软删除 + appointmentNoticeTypeRepository.SoftDeleteRange(appointmentNoticeTypes); + return new BaseResponse(); } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("delete appointment notice failed.", "公告类型删除失败"), ex); - return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("delete appointment notice failed.", "公告类型删除失败") }; + logger.LogError(ex, "Error deleting appointment notice types"); + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Delete Appointment Notice Type Failure", "删除公告类型失败"), Code = BusinessStatusCode.InternalServerError }; } - - return new BaseResponse { Code = BusinessStatusCode.Success, Message = LocalizationHelper.GetLocalizedString("delete appointment notice successful.", "公告类型删除成功") }; } /// @@ -995,20 +1341,15 @@ namespace EOM.TSHotelManagement.Service return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("appointment notice number does not already.", "公告类型编号不存在") }; } var entity = EntityMapper.Map(updateAppointmentNoticeTypeInputDto); - var result = appointmentNoticeTypeRepository.Update(entity); - if (!result) - { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("update appointment notice failed.", "公告类型更新失败"), null); - return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("update appointment notice failed.", "公告类型更新失败") }; - } + appointmentNoticeTypeRepository.Update(entity); + + return new BaseResponse { Code = BusinessStatusCode.Success, Message = LocalizationHelper.GetLocalizedString("update appointment notice successful.", "公告类型更新成功") }; } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("update appointment notice failed.", "公告类型更新失败"), ex); + logger.LogError(ex, "Error updating appointment notice type"); return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("update appointment notice failed.", "公告类型更新失败") }; } - - return new BaseResponse { Code = BusinessStatusCode.Success, Message = LocalizationHelper.GetLocalizedString("update appointment notice successful.", "公告类型更新成功") }; } #endregion diff --git a/EOM.TSHotelManagement.Service/SystemManagement/Menu/MenuService.cs b/EOM.TSHotelManagement.Service/SystemManagement/Menu/MenuService.cs index 6984fbc..5a84cae 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/Menu/MenuService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/Menu/MenuService.cs @@ -26,6 +26,7 @@ using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.EntityLib; +using Microsoft.Extensions.Logging; using SqlSugar; namespace EOM.TSHotelManagement.Service @@ -48,19 +49,9 @@ namespace EOM.TSHotelManagement.Service private readonly GenericRepository rolePermissionRepository; private readonly GenericRepository userRoleRepository; private readonly GenericRepository administratorRepository; + private readonly ILogger logger; - /// - /// - /// - /// - /// - public MenuService( - GenericRepository menuRepository, - JWTHelper jWTHelper, - GenericRepository permissionRepository, - GenericRepository rolePermissionRepository, - GenericRepository userRoleRepository, - GenericRepository administratorRepository) + public MenuService(GenericRepository menuRepository, JWTHelper jWTHelper, GenericRepository permissionRepository, GenericRepository rolePermissionRepository, GenericRepository userRoleRepository, GenericRepository administratorRepository, ILogger logger) { this.menuRepository = menuRepository; this.jWTHelper = jWTHelper; @@ -68,6 +59,7 @@ namespace EOM.TSHotelManagement.Service this.rolePermissionRepository = rolePermissionRepository; this.userRoleRepository = userRoleRepository; this.administratorRepository = administratorRepository; + this.logger = logger; } /// @@ -263,12 +255,13 @@ namespace EOM.TSHotelManagement.Service } menuRepository.Insert(EntityMapper.Map(menu)); + return new BaseResponse(); } catch (Exception ex) { + logger.LogError(ex, "插入菜单失败"); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseResponse(); } /// @@ -281,12 +274,13 @@ namespace EOM.TSHotelManagement.Service try { menuRepository.Update(EntityMapper.Map(menu)); + return new BaseResponse(); } catch (Exception ex) { + logger.LogError(ex, "更新菜单失败"); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseResponse(); } /// @@ -294,17 +288,45 @@ namespace EOM.TSHotelManagement.Service /// /// /// - public BaseResponse DeleteMenu(DeleteMenuInputDto menu) + public BaseResponse DeleteMenu(DeleteMenuInputDto input) { try { - menuRepository.SoftDelete(EntityMapper.Map(menu)); + if (input?.DelIds == null || !input.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var menus = menuRepository.GetList(a => input.DelIds.Contains(a.Id)); + + if (!menus.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Menu Information Not Found", "菜单信息未找到") + }; + } + + menus = menus.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + menuRepository.SoftDeleteRange(menus); + return new BaseResponse(); } catch (Exception ex) { + logger.LogError(ex, "删除菜单失败"); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseResponse(); } /// diff --git a/EOM.TSHotelManagement.Service/SystemManagement/Notice/NoticeService.cs b/EOM.TSHotelManagement.Service/SystemManagement/Notice/NoticeService.cs index 05903c8..cee54cf 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/Notice/NoticeService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/Notice/NoticeService.cs @@ -25,6 +25,7 @@ using EOM.TSHotelManagement.Common; using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; +using Microsoft.Extensions.Logging; namespace EOM.TSHotelManagement.Service { @@ -38,13 +39,12 @@ namespace EOM.TSHotelManagement.Service /// private readonly GenericRepository noticeRepository; - /// - /// - /// - /// - public NoticeService(GenericRepository noticeRepository) + private readonly ILogger logger; + + public NoticeService(GenericRepository noticeRepository, ILogger logger) { this.noticeRepository = noticeRepository; + this.logger = logger; } /// @@ -114,41 +114,59 @@ namespace EOM.TSHotelManagement.Service { var entity = EntityMapper.Map(notice); var result = noticeRepository.Insert(entity); - if (!result) - { - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("insert appointment notice failed", "公告添加失败"), Code = BusinessStatusCode.InternalServerError }; - } + return new BaseResponse(); } catch (Exception ex) { + logger.LogError(ex, LocalizationHelper.GetLocalizedString("insert appointment notice failed", "公告添加失败")); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseResponse(); } /// /// 删除公告信息 /// - /// + /// /// - public BaseResponse DeleteNotice(DeleteAppointmentNoticeInputDto deleteAppointmentNoticeInputDto) + public BaseResponse DeleteNotice(DeleteAppointmentNoticeInputDto input) { try { - var entity = EntityMapper.Map(deleteAppointmentNoticeInputDto); - var result = noticeRepository.SoftDelete(entity); - if (!result) + if (input?.DelIds == null || !input.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var appointmentNotices = noticeRepository.GetList(a => input.DelIds.Contains(a.Id)); + + if (!appointmentNotices.Any()) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("delete appointment notice failed", "删除公告失败"), null); - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("delete appointment notice failed", "删除公告失败"), Code = BusinessStatusCode.InternalServerError }; + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Appointment Notice Not Found", "公告未找到") + }; } + + appointmentNotices = appointmentNotices.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + noticeRepository.SoftDeleteRange(appointmentNotices); + return new BaseResponse(); } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("delete appointment notice failed", "删除公告失败"), ex); + logger.LogError(ex, LocalizationHelper.GetLocalizedString("delete appointment notice failed", "删除公告失败")); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("delete appointment notice failed", "删除公告失败"), Code = BusinessStatusCode.InternalServerError }; } - return new BaseResponse(); } /// @@ -162,18 +180,13 @@ namespace EOM.TSHotelManagement.Service { var entity = EntityMapper.Map(updateAppointmentNoticeInputDto); var result = noticeRepository.Update(entity); - if (!result) - { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("update appointment notice failed", "更新公告失败"), null); - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("update appointment notice failed", "更新公告失败"), Code = BusinessStatusCode.InternalServerError }; - } + return new BaseResponse(); } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("update appointment notice failed", "更新公告失败"), ex); + logger.LogError(ex, LocalizationHelper.GetLocalizedString("update appointment notice failed", "更新公告失败")); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("update appointment notice failed", "更新公告失败"), Code = BusinessStatusCode.InternalServerError }; } - return new BaseResponse(); } } diff --git a/EOM.TSHotelManagement.Service/SystemManagement/Role/RoleAppService.cs b/EOM.TSHotelManagement.Service/SystemManagement/Role/RoleAppService.cs index 0ae8359..29dc733 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/Role/RoleAppService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/Role/RoleAppService.cs @@ -5,6 +5,7 @@ using EOM.TSHotelManagement.Contract.SystemManagement.Dto.Role; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.EntityLib; +using Microsoft.Extensions.Logging; using SqlSugar; namespace EOM.TSHotelManagement.Service @@ -29,17 +30,14 @@ namespace EOM.TSHotelManagement.Service /// private readonly GenericRepository userRoleRepository; - /// - /// - /// - /// - /// - /// - public RoleAppService(GenericRepository roleRepository, GenericRepository rolePermissionRepository, GenericRepository userRoleRepository) + private readonly ILogger logger; + + public RoleAppService(GenericRepository roleRepository, GenericRepository rolePermissionRepository, GenericRepository userRoleRepository, ILogger logger) { this.roleRepository = roleRepository; this.rolePermissionRepository = rolePermissionRepository; this.userRoleRepository = userRoleRepository; + this.logger = logger; } /// @@ -53,12 +51,13 @@ namespace EOM.TSHotelManagement.Service try { roleRepository.SoftDelete(EntityMapper.Map(deleteRoleInputDto)); + return new BaseResponse(); } - catch (Exception) + catch (Exception ex) { + logger.LogError(ex, "Error deleting role: {RoleNumber}", string.Join(",", deleteRoleInputDto.DelIds)); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Role Error", "删除角色失败")); } - return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Role Success", "删除角色成功")); } /// @@ -108,17 +107,14 @@ namespace EOM.TSHotelManagement.Service try { var entity = EntityMapper.Map(createRoleInputDto); - var result = roleRepository.Insert(entity); - if (!result) - { - return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Create Role Error", "创建角色失败")); - } + roleRepository.Insert(entity); + return new BaseResponse(); } - catch (Exception) + catch (Exception ex) { + logger.LogError(ex, "Error creating role: {Message}", ex.Message); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Create Role Error", "创建角色失败")); } - return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Create Role Success", "创建角色成功")); } /// @@ -132,17 +128,14 @@ namespace EOM.TSHotelManagement.Service try { var entity = EntityMapper.Map(updateRoleInputDto); - var result = roleRepository.Update(entity); - if (!result) - { - return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Role Error", "更新角色失败")); - } + roleRepository.Update(entity); + return new BaseResponse(); } - catch (Exception) + catch (Exception ex) { + logger.LogError(ex, "Error updating role: {Message}", ex.Message); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Role Error", "更新角色失败")); } - return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Update Role Success", "更新角色成功")); } /// @@ -200,6 +193,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error granting permissions to role {RoleNumber}: {Message}", input.RoleNumber, ex.Message); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString($"Grant permissions failed: {ex.Message}", $"授予权限失败:{ex.Message}")); } } @@ -239,6 +233,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error reading permissions for role {RoleNumber}: {Message}", roleNumber, ex.Message); return new ListOutputDto { Code = BusinessStatusCode.InternalServerError, @@ -283,6 +278,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error reading users for role {RoleNumber}: {Message}", roleNumber, ex.Message); return new ListOutputDto { Code = BusinessStatusCode.InternalServerError, @@ -345,6 +341,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error assigning users to role {RoleNumber}: {Message}", input.RoleNumber, ex.Message); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString($"Assign users failed: {ex.Message}", $"分配用户失败:{ex.Message}")); } } diff --git a/EOM.TSHotelManagement.Service/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs b/EOM.TSHotelManagement.Service/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs index 70c4084..b99f26d 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs @@ -26,6 +26,7 @@ using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.EntityLib; +using Microsoft.Extensions.Logging; using SqlSugar; namespace EOM.TSHotelManagement.Service @@ -40,13 +41,16 @@ namespace EOM.TSHotelManagement.Service /// private readonly GenericRepository checkInfoRepository; + private readonly ILogger logger; + /// /// /// /// - public SupervisionStatisticsService(GenericRepository checkInfoRepository) + public SupervisionStatisticsService(GenericRepository checkInfoRepository, ILogger logger) { this.checkInfoRepository = checkInfoRepository; + this.logger = logger; } /// @@ -94,6 +98,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error occurred while inserting Supervision Statistics."); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -120,6 +125,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "Error occurred while updating Supervision Statistics."); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -130,19 +136,53 @@ namespace EOM.TSHotelManagement.Service /// /// /// - public BaseResponse DeleteSupervisionStatistics(DeleteSupervisionStatisticsInputDto checkInfo) + public BaseResponse DeleteSupervisionStatistics(DeleteSupervisionStatisticsInputDto input) { try { - var existing = checkInfoRepository.GetFirst(a => a.StatisticsNumber == checkInfo.StatisticsNumber && a.IsDelete == 0); - existing.IsDelete = 1; - checkInfoRepository.SoftDelete(existing); + if (input?.DelIds == null || !input.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var supervisionStatistics = checkInfoRepository.GetList(a => input.DelIds.Contains(a.Id)); + + if (!supervisionStatistics.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Supervision Statistics Information Not Found", "监管统计信息未找到") + }; + } + + supervisionStatistics = supervisionStatistics.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + var result = checkInfoRepository.SoftDeleteRange(supervisionStatistics); + + if (result) + { + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Supervision Statistics Success", "监管统计信息删除成功")); + } + else + { + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Supervision Statistics Failed", "监管统计信息删除失败")); + } } catch (Exception ex) { + logger.LogError(ex, "Error occurred while deleting Supervision Statistics."); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseResponse(); } } } diff --git a/EOM.TSHotelManagement.Service/SystemManagement/VipRule/VipRuleAppService.cs b/EOM.TSHotelManagement.Service/SystemManagement/VipRule/VipRuleAppService.cs index 932d705..0fa04e0 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/VipRule/VipRuleAppService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/VipRule/VipRuleAppService.cs @@ -26,6 +26,7 @@ using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.EntityLib; +using Microsoft.Extensions.Logging; using SqlSugar; namespace EOM.TSHotelManagement.Service @@ -45,15 +46,13 @@ namespace EOM.TSHotelManagement.Service /// private readonly GenericRepository custoTypeRepository; - /// - /// - /// - /// - /// - public VipRuleAppService(GenericRepository vipRuleRepository, GenericRepository custoTypeRepository) + private readonly ILogger logger; + + public VipRuleAppService(GenericRepository vipRuleRepository, GenericRepository custoTypeRepository, ILogger logger) { this.vipRuleRepository = vipRuleRepository; this.custoTypeRepository = custoTypeRepository; + this.logger = logger; } /// @@ -131,6 +130,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "添加会员等级规则失败"); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); @@ -145,15 +145,41 @@ namespace EOM.TSHotelManagement.Service { try { - var dbVipRule = vipRuleRepository.GetFirst(a => a.RuleSerialNumber == vipRule.RuleSerialNumber && a.IsDelete != 1); - dbVipRule.IsDelete = vipRule.IsDelete; - vipRuleRepository.SoftDelete(dbVipRule); + if (vipRule?.DelIds == null || !vipRule.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var vipLevelRules = vipRuleRepository.GetList(a => vipRule.DelIds.Contains(a.Id)); + + if (!vipLevelRules.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Vip Rule Not Found", "会员规则未找到") + }; + } + + vipLevelRules = vipLevelRules.Select(a => + { + a.IsDelete = 1; + return a; + }).ToList(); + + // 批量软删除 + vipRuleRepository.SoftDeleteRange(vipLevelRules); + return new BaseResponse(); } catch (Exception ex) { + logger.LogError(ex, "删除会员等级规则失败"); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseResponse(); } /// @@ -173,6 +199,7 @@ namespace EOM.TSHotelManagement.Service } catch (Exception ex) { + logger.LogError(ex, "更新会员等级规则失败"); return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } return new BaseResponse(); diff --git a/EOM.TSHotelManagement.Service/Util/UtilService.cs b/EOM.TSHotelManagement.Service/Util/UtilService.cs index b3a3517..f5a9d84 100644 --- a/EOM.TSHotelManagement.Service/Util/UtilService.cs +++ b/EOM.TSHotelManagement.Service/Util/UtilService.cs @@ -3,6 +3,7 @@ using EOM.TSHotelManagement.Contract; using EOM.TSHotelManagement.Data; using EOM.TSHotelManagement.Domain; using jvncorelib.EntityLib; +using Microsoft.Extensions.Logging; using SqlSugar; namespace EOM.TSHotelManagement.Service @@ -27,11 +28,14 @@ namespace EOM.TSHotelManagement.Service /// private readonly GenericRepository requestLogRepository; - public UtilService(GenericRepository cardCodesRepository, GenericRepository operationLogRepository, GenericRepository requestLogRepository) + private readonly ILogger logger; + + public UtilService(GenericRepository cardCodesRepository, GenericRepository operationLogRepository, GenericRepository requestLogRepository, ILogger logger) { this.cardCodesRepository = cardCodesRepository; this.operationLogRepository = operationLogRepository; this.requestLogRepository = requestLogRepository; + this.logger = logger; } /// @@ -62,16 +66,13 @@ namespace EOM.TSHotelManagement.Service { var log = EntityMapper.Map(opr); var result = operationLogRepository.Insert(log); - if (!result) - { - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Add Log Failed", "添加日志失败"), Code = BusinessStatusCode.InternalServerError }; - } + return new BaseResponse(); } catch (Exception ex) { - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; + logger.LogError(ex, "添加操作日志失败"); + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Add Operation Log Failure", "添加操作日志失败"), Code = BusinessStatusCode.InternalServerError }; } - return new BaseResponse(); } /// @@ -97,7 +98,7 @@ namespace EOM.TSHotelManagement.Service operationLogs.ForEach(source => { - source.LogLevelName = source.LogLevel == (int)LogLevel.Normal ? LocalizationHelper.GetLocalizedString("INFO", "常规操作") : source.LogLevel == (int)LogLevel.Warning ? LocalizationHelper.GetLocalizedString("WARNING", "敏感操作") : LocalizationHelper.GetLocalizedString("ERROR", "严重操作"); + source.LogLevelName = source.LogLevel == (int)Common.LogLevel.Normal ? LocalizationHelper.GetLocalizedString("INFO", "常规操作") : source.LogLevel == (int)Common.LogLevel.Warning ? LocalizationHelper.GetLocalizedString("WARNING", "敏感操作") : LocalizationHelper.GetLocalizedString("ERROR", "严重操作"); }); var result = EntityMapper.MapList(operationLogs); @@ -162,12 +163,12 @@ namespace EOM.TSHotelManagement.Service { operationLogRepository.Delete(logsToDelete); } + return new BaseResponse(); } catch (Exception ex) { return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseResponse { Message = "操作日志删除成功", Code = BusinessStatusCode.Success }; } /// @@ -176,15 +177,35 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse DeleteOperationlog(DeleteOperationLogInputDto deleteOperationLogInputDto) { - var result = operationLogRepository.Delete(a => a.OperationId == deleteOperationLogInputDto.OperationId); - - if (result) + try { - return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Operation Log Success", "操作日志删除成功")); + if (deleteOperationLogInputDto?.DelIds == null || !deleteOperationLogInputDto.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var operationLogs = operationLogRepository.GetList(a => deleteOperationLogInputDto.DelIds.Contains(a.Id)); + + if (!operationLogs.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Operation Log Not Found", "操作日志未找到") + }; + } + + operationLogRepository.Delete(operationLogs); + return new BaseResponse(); } - else + catch (Exception ex) { - return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Operation Log Failed", "操作日志删除失败")); + logger.LogError(ex, "Error deleting room type"); + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Delete Operation Log Failure", "删除操作日志失败"), Code = BusinessStatusCode.InternalServerError }; } } } -- Gitee From 66d8ae8dafcb533c886327bf92a088c57c55e046 Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sat, 31 Jan 2026 15:59:50 +0800 Subject: [PATCH 2/6] fix update logic for VipRuleService. --- .../SystemManagement/VipRule/VipRuleAppService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EOM.TSHotelManagement.Service/SystemManagement/VipRule/VipRuleAppService.cs b/EOM.TSHotelManagement.Service/SystemManagement/VipRule/VipRuleAppService.cs index 0fa04e0..d932697 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/VipRule/VipRuleAppService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/VipRule/VipRuleAppService.cs @@ -191,10 +191,11 @@ namespace EOM.TSHotelManagement.Service { try { - var dbVipRule = vipRuleRepository.GetFirst(a => a.RuleSerialNumber == vipRule.RuleSerialNumber && a.IsDelete != 1); + var dbVipRule = vipRuleRepository.GetFirst(a => a.Id == vipRule.Id); dbVipRule.RuleName = vipRule.RuleName; dbVipRule.RuleValue = vipRule.RuleValue; dbVipRule.VipLevelId = vipRule.VipLevelId; + dbVipRule.IsDelete = vipRule.IsDelete; vipRuleRepository.Update(dbVipRule); } catch (Exception ex) -- Gitee From a5b0475f5d140337f2ed9ad106b2a24f2338f536 Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sun, 1 Feb 2026 18:02:12 +0800 Subject: [PATCH 3/6] fix bugs. --- .../Business/Sellthing/SellthingController.cs | 14 +-------- .../Properties/launchSettings.json | 20 ++---------- .../Business/Sellthing/ISellService.cs | 7 ----- .../Business/Sellthing/SellService.cs | 31 +++---------------- 4 files changed, 7 insertions(+), 65 deletions(-) diff --git a/EOM.TSHotelManagement.API/Controllers/Business/Sellthing/SellthingController.cs b/EOM.TSHotelManagement.API/Controllers/Business/Sellthing/SellthingController.cs index 27ed22b..6ece820 100644 --- a/EOM.TSHotelManagement.API/Controllers/Business/Sellthing/SellthingController.cs +++ b/EOM.TSHotelManagement.API/Controllers/Business/Sellthing/SellthingController.cs @@ -38,19 +38,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers [HttpPost] public BaseResponse UpdateSellThing([FromBody] UpdateSellThingInputDto updateSellThingInputDto) { - return sellService.UpdateSellThing(updateSellThingInputDto); - } - - /// - /// 修改商品信息 - /// - /// - /// - [RequirePermission("goodsmanagement.update")] - [HttpPost] - public BaseResponse UpdateSellthing([FromBody] UpdateSellThingInputDto sellThing) - { - return sellService.UpdateSellthing(sellThing); + return sellService.UpdateSellthing(updateSellThingInputDto); } /// diff --git a/EOM.TSHotelManagement.API/Properties/launchSettings.json b/EOM.TSHotelManagement.API/Properties/launchSettings.json index d725b8c..16697cb 100644 --- a/EOM.TSHotelManagement.API/Properties/launchSettings.json +++ b/EOM.TSHotelManagement.API/Properties/launchSettings.json @@ -1,14 +1,6 @@ { "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger/index.html", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "EOM.TSHotelManagement.WebApi": { + "Topsy": { "commandName": "Project", "launchBrowser": true, "launchUrl": "swagger/index.html", @@ -28,13 +20,5 @@ "publishAllPorts": true } }, - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:63001", - "sslPort": 0 - } - } + "$schema": "http://json.schemastore.org/launchsettings.json" } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Service/Business/Sellthing/ISellService.cs b/EOM.TSHotelManagement.Service/Business/Sellthing/ISellService.cs index 35d1f78..7922687 100644 --- a/EOM.TSHotelManagement.Service/Business/Sellthing/ISellService.cs +++ b/EOM.TSHotelManagement.Service/Business/Sellthing/ISellService.cs @@ -36,13 +36,6 @@ namespace EOM.TSHotelManagement.Service /// ListOutputDto SelectSellThingAll(ReadSellThingInputDto sellThing); - /// - /// 修改商品 - /// - /// - /// - BaseResponse UpdateSellThing(UpdateSellThingInputDto updateSellThingInputDto); - /// /// 修改商品信息 /// diff --git a/EOM.TSHotelManagement.Service/Business/Sellthing/SellService.cs b/EOM.TSHotelManagement.Service/Business/Sellthing/SellService.cs index fe1bf79..18cc93a 100644 --- a/EOM.TSHotelManagement.Service/Business/Sellthing/SellService.cs +++ b/EOM.TSHotelManagement.Service/Business/Sellthing/SellService.cs @@ -112,30 +112,6 @@ namespace EOM.TSHotelManagement.Service }; } - /// - /// 更新商品数量 - /// - /// - /// - public BaseResponse UpdateSellThing(UpdateSellThingInputDto updateSellThingInputDto) - { - try - { - var product = sellThingRepository.GetFirst(a => a.ProductNumber == updateSellThingInputDto.ProductNumber); - product.Stock = updateSellThingInputDto.Stock; - product.Specification = updateSellThingInputDto.Specification; - product.ProductPrice = updateSellThingInputDto.ProductPrice; - product.ProductName = updateSellThingInputDto.ProductName; - sellThingRepository.Update(product); - } - catch (Exception ex) - { - logger.LogError(ex, "Error updating sell thing: {Message}", ex.Message); - return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; - } - return new BaseResponse(); - } - /// /// 修改商品信息 /// @@ -145,11 +121,12 @@ namespace EOM.TSHotelManagement.Service { try { - var product = sellThingRepository.GetFirst(a => a.ProductNumber == sellThing.ProductNumber); - product.ProductName = product.ProductName; - product.ProductPrice = product.ProductPrice; + var product = sellThingRepository.GetFirst(a => a.Id == sellThing.Id); + product.ProductName = sellThing.ProductName; + product.ProductPrice = sellThing.ProductPrice; product.Stock = sellThing.Stock; product.Specification = sellThing.Specification; + product.IsDelete = sellThing.IsDelete; sellThingRepository.Update(product); } catch (Exception ex) -- Gitee From 15672ea2694f0d0163b7acd42d6416c9fe488dd2 Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sat, 7 Feb 2026 17:17:55 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=A2=84=E7=BA=A6=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E5=8A=9F=E8=83=BD=E3=80=82=20=E6=89=A9?= =?UTF-8?q?=E5=B1=95appsettings.json=E8=BF=9B=E8=A1=8C=E7=BB=86=E5=88=86?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Util/UtilityController.cs | 11 +++ EOM.TSHotelManagement.API/Program.cs | 14 +++- .../appsettings.Application.json | 22 ++++++ .../appsettings.Database.json | 11 +++ .../appsettings.Services.json | 23 ++++++ .../Business/Reser/ReserService.cs | 79 +++++++++++++++++-- .../Util/IUtilService.cs | 6 ++ .../Util/UtilService.cs | 22 ++++++ 8 files changed, 179 insertions(+), 9 deletions(-) create mode 100644 EOM.TSHotelManagement.API/appsettings.Application.json create mode 100644 EOM.TSHotelManagement.API/appsettings.Database.json create mode 100644 EOM.TSHotelManagement.API/appsettings.Services.json diff --git a/EOM.TSHotelManagement.API/Controllers/Util/UtilityController.cs b/EOM.TSHotelManagement.API/Controllers/Util/UtilityController.cs index b7d37ca..ad71e1c 100644 --- a/EOM.TSHotelManagement.API/Controllers/Util/UtilityController.cs +++ b/EOM.TSHotelManagement.API/Controllers/Util/UtilityController.cs @@ -59,6 +59,17 @@ namespace EOM.TSHotelManagement.WebApi.Controllers return utilService.SelectRequestlogAll(readRequestLogInputDto); } + /// + /// 删除时间范围的请求日志 + /// + /// + /// + [HttpPost] + public BaseResponse DeleteRequestlogByRange([FromBody] ReadRequestLogInputDto readRequestLogInputDto) + { + return utilService.DeleteRequestlogByRange(readRequestLogInputDto); + } + /// /// 删除时间范围的操作日志 /// diff --git a/EOM.TSHotelManagement.API/Program.cs b/EOM.TSHotelManagement.API/Program.cs index edb1c85..fb4f25e 100644 --- a/EOM.TSHotelManagement.API/Program.cs +++ b/EOM.TSHotelManagement.API/Program.cs @@ -12,13 +12,19 @@ namespace EOM.TSHotelManagement.WebApi public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); + // 加载多个配置文件 + builder.Configuration + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile("appsettings.Application.json", optional: true, reloadOnChange: true) + .AddJsonFile("appsettings.Database.json", optional: true, reloadOnChange: true) + .AddJsonFile("appsettings.Services.json", optional: true, reloadOnChange: true); var configuration = builder.Configuration; - // Autofac + // Autofac 容器配置 builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()); builder.Host.ConfigureContainer(AutofacConfigExtensions.ConfigureAutofacContainer); - // + // 服务配置 builder.Services.ConfigureDataProtection(configuration); builder.Services.ConfigureQuartz(configuration); builder.Services.ConfigureAuthentication(configuration); @@ -29,10 +35,10 @@ namespace EOM.TSHotelManagement.WebApi builder.Services.AddHttpContextAccessor(); builder.Services.ConfigureXForward(); - // Ӧ + // 构建应用 var app = builder.Build(); - // Ӧ + // 应用配置 app.ConfigureEnvironment(); app.ConfigureMiddlewares(); diff --git a/EOM.TSHotelManagement.API/appsettings.Application.json b/EOM.TSHotelManagement.API/appsettings.Application.json new file mode 100644 index 0000000..1f0c6fa --- /dev/null +++ b/EOM.TSHotelManagement.API/appsettings.Application.json @@ -0,0 +1,22 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedOrigins": [ + "http://localhost:8080", + "https://tshotel.oscode.top" + ], + "AllowedHosts": "*", + "JobKeys": [ + "ReservationExpirationCheckJob" + ], + "ExpirationSettings": { + "NotifyDaysBefore": 3, + "CheckIntervalMinutes": 5 + }, + "SoftwareVersion": "1.0.0" +} \ No newline at end of file diff --git a/EOM.TSHotelManagement.API/appsettings.Database.json b/EOM.TSHotelManagement.API/appsettings.Database.json new file mode 100644 index 0000000..265b373 --- /dev/null +++ b/EOM.TSHotelManagement.API/appsettings.Database.json @@ -0,0 +1,11 @@ +{ + "DefaultDatabase": "MariaDB", + "ConnectionStrings": { + "PgSqlConnectStr": "Host=my_pgsql_host;Port=5432;Username=my_pgsql_user;Password=my_pgsql_password;Database=tshoteldb;", + "MySqlConnectStr": "Server=my_mysql_host;Database=tshoteldb;User=my_mysql_user;Password=my_mysql_password;", + "MariaDBConnectStr": "Server=localhost;Database=tshoteldb;User=my_mariadb_user;Password=my_mariadb_password;", + "SqlServerConnectStr": "Server=my_sqlserver_host;Database=tshoteldb;User Id=my_sqlserver_user;Password=my_sqlserver_password;", + "OracleConnectStr": "User Id=my_oracle_user;Password=my_oracle_password;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=my_oracle_host)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=my_oracle_service_name)));" + }, + "InitializeDatabase": true +} \ No newline at end of file diff --git a/EOM.TSHotelManagement.API/appsettings.Services.json b/EOM.TSHotelManagement.API/appsettings.Services.json new file mode 100644 index 0000000..7c2ba5c --- /dev/null +++ b/EOM.TSHotelManagement.API/appsettings.Services.json @@ -0,0 +1,23 @@ +{ + "Jwt": { + "Key": "", + "ExpiryMinutes": 20 + }, + "Mail": { + "Enabled": false, + "Host": "...", + "Port": 465, + "UserName": "", + "Password": "", + "EnableSsl": true, + "DisplayName": "" + }, + "Lsky": { + "Enabled": false, + "BaseAddress": "", + "Email": "", + "Password": "", + "UploadApi": "", + "GetTokenApi": "" + } +} \ No newline at end of file diff --git a/EOM.TSHotelManagement.Service/Business/Reser/ReserService.cs b/EOM.TSHotelManagement.Service/Business/Reser/ReserService.cs index 87f00cb..5bea6b3 100644 --- a/EOM.TSHotelManagement.Service/Business/Reser/ReserService.cs +++ b/EOM.TSHotelManagement.Service/Business/Reser/ReserService.cs @@ -217,7 +217,7 @@ namespace EOM.TSHotelManagement.Service } /// - /// 更新预约信息 + /// 更新预约信息(支持恢复功能) /// /// /// @@ -225,16 +225,85 @@ namespace EOM.TSHotelManagement.Service { string NewTel = dataProtector.EncryptReserData(reser.ReservationPhoneNumber); reser.ReservationPhoneNumber = NewTel; + try { - var entity = EntityMapper.Map(reser); - reserRepository.Update(entity); - return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Update Customer Success", "预约信息更新成功")); + using (TransactionScope scope = new TransactionScope()) + { + // 获取原预约(包括软删除的记录) + var originalReser = reserRepository.GetFirst(a => a.Id == reser.Id); + + if (originalReser == null) + { + return new BaseResponse(BusinessStatusCode.NotFound, + LocalizationHelper.GetLocalizedString("Reservation not found", "预约信息不存在")); + } + + bool isRestoring = originalReser.IsDelete == 1 && reser.IsDelete == 0; + + // 如果是恢复操作 + if (isRestoring) + { + // 检查原房间的当前状态 + var room = roomRepository.GetFirst(a => a.RoomNumber == originalReser.ReservationRoomNumber); + + if (room == null) + { + return new BaseResponse(BusinessStatusCode.Conflict, + LocalizationHelper.GetLocalizedString("Room does not exist, cannot restore reservation", + "关联的房间不存在,无法恢复预约")); + } + + // 检查房间是否可用 + if (room.RoomStateId != (int)RoomState.Vacant) + { + return new BaseResponse(BusinessStatusCode.Conflict, + string.Format(LocalizationHelper.GetLocalizedString( + "Room {0} is currently occupied, cannot restore reservation", + "房间{0}当前已被占用,无法恢复预约"), + room.RoomNumber)); + } + + // 检查时间段冲突(如果有时间字段) + var conflictingReservation = reserRepository.GetFirst(r => + r.Id != originalReser.Id && + r.IsDelete == 0 && + r.ReservationRoomNumber == originalReser.ReservationRoomNumber && + r.ReservationStartDate < originalReser.ReservationEndDate && + r.ReservationEndDate > originalReser.ReservationStartDate); + + if (conflictingReservation != null) + { + return new BaseResponse(BusinessStatusCode.Conflict, + LocalizationHelper.GetLocalizedString( + "Room is already reserved during this period, cannot restore reservation", + "该时间段内房间已被预订,无法恢复预约")); + } + + // 恢复预约并更新房间状态 + var entity = EntityMapper.Map(reser); + reserRepository.Update(entity); + + room.RoomStateId = (int)RoomState.Reserved; + roomRepository.Update(room); + } + else + { + // 普通更新逻辑 + var entity = EntityMapper.Map(reser); + reserRepository.Update(entity); + } + + scope.Complete(); + return new BaseResponse(BusinessStatusCode.Success, + LocalizationHelper.GetLocalizedString("Update Reservation Success", "预约信息更新成功")); + } } catch (Exception ex) { logger.LogError(ex, LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息更新失败")); - return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息更新失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, + LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息更新失败")); } } diff --git a/EOM.TSHotelManagement.Service/Util/IUtilService.cs b/EOM.TSHotelManagement.Service/Util/IUtilService.cs index b6e1b89..5dc0f5b 100644 --- a/EOM.TSHotelManagement.Service/Util/IUtilService.cs +++ b/EOM.TSHotelManagement.Service/Util/IUtilService.cs @@ -34,6 +34,12 @@ namespace EOM.TSHotelManagement.Service /// ListOutputDto SelectRequestlogAll(ReadRequestLogInputDto readRequestLogInputDto); + /// + /// 删除指定时间范围的请求日志 + /// + /// + BaseResponse DeleteRequestlogByRange(ReadRequestLogInputDto readRequestLogInputDto); + /// /// 删除指定时间范围的操作日志 /// diff --git a/EOM.TSHotelManagement.Service/Util/UtilService.cs b/EOM.TSHotelManagement.Service/Util/UtilService.cs index f5a9d84..57e29a1 100644 --- a/EOM.TSHotelManagement.Service/Util/UtilService.cs +++ b/EOM.TSHotelManagement.Service/Util/UtilService.cs @@ -147,6 +147,28 @@ namespace EOM.TSHotelManagement.Service }; } + /// + /// 删除指定时间范围的请求日志 + /// + /// + public BaseResponse DeleteRequestlogByRange(ReadRequestLogInputDto readRequestLogInputDto) + { + try + { + var where = SqlFilterBuilder.BuildExpression(readRequestLogInputDto ?? new ReadRequestLogInputDto()); + var logsToDelete = requestLogRepository.AsQueryable().Where(where.ToExpression()).ToList(); + if (logsToDelete.Any()) + { + requestLogRepository.Delete(logsToDelete); + } + return new BaseResponse(); + } + catch (Exception ex) + { + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; + } + } + /// /// 删除指定时间范围的操作日志 /// -- Gitee From a79f705aff03a80a4783f0d52380ff5410ee4d5c Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sun, 8 Feb 2026 02:17:47 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E6=95=B0=E6=8D=AE=E5=BA=93=E9=80=BB=E8=BE=91.=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4Nuget=E5=8C=85=E7=94=9F=E6=88=90.=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=9C=AC=E5=9C=B0Log=EF=BC=8C=E6=94=B9=E4=B8=BAILogge?= =?UTF-8?q?r.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Directory.Build.props | 15 ++++ Directory.Build.targets | 29 ++++++++ .../EOM.TSHotelManagement.API.csproj | 2 +- .../Extensions/ApplicationExtensions.cs | 17 +++++ .../EOM.TSHotelManagement.Common.csproj | 73 +++++-------------- .../Helper/LogHelper.cs | 44 ----------- .../EOM.TSHotelManagement.Contract.csproj | 40 ---------- .../ReadAdministratorOutputDto.cs | 6 -- .../Dto/Menu/ReadMenuInputDto.cs | 2 +- .../Connector/SqlSugarClientConnector.cs | 11 +-- .../DatabaseInitializer.cs | 26 +------ .../EOM.TSHotelManagement.Domain.csproj | 47 +----------- ...OM.TSHotelManagement.Infrastructure.csproj | 51 +------------ .../Business/Customer/CustomerService.cs | 2 +- .../EOM.TSHotelManagement.Service.csproj | 65 +++-------------- .../SystemManagement/Base/BaseService.cs | 2 +- 16 files changed, 101 insertions(+), 331 deletions(-) create mode 100644 Directory.Build.props create mode 100644 Directory.Build.targets delete mode 100644 EOM.TSHotelManagement.Common/Helper/LogHelper.cs diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..30aaeab --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,15 @@ + + + 1 + 10 + 0 + $(MajorVersion).$(MinorVersion).$(PatchVersion) + $(Version) + $(MSBuildThisFileDirectory).buildnumber + 易开元(Easy Open Meta) + Service to TS Hotel Management System Project, Development By Easy Open Meta + MIT + https://gitee.com/java-and-net/topsky-hotel-management-system-web-api + https://gitee.com/java-and-net/topsky-hotel-management-system-web-api + + \ No newline at end of file diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000..8cf90cc --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,29 @@ + + + + + + + + @(BuildNumberLines) + 0 + + $([System.Int32]::Parse($(CurrentBuildNumber))) + $([MSBuild]::Add($(CurrentBuildNumberInt), 1)) + $(NewBuildNumberInt) + + + + + + + + + $(MajorVersion).$(MinorVersion).$(NewBuildNumber) + $(Version) + + + \ No newline at end of file diff --git a/EOM.TSHotelManagement.API/EOM.TSHotelManagement.API.csproj b/EOM.TSHotelManagement.API/EOM.TSHotelManagement.API.csproj index abf8fcd..4e8ca9d 100644 --- a/EOM.TSHotelManagement.API/EOM.TSHotelManagement.API.csproj +++ b/EOM.TSHotelManagement.API/EOM.TSHotelManagement.API.csproj @@ -33,7 +33,7 @@ - Always + PreserveNewest diff --git a/EOM.TSHotelManagement.API/Extensions/ApplicationExtensions.cs b/EOM.TSHotelManagement.API/Extensions/ApplicationExtensions.cs index de7cd59..590b5a5 100644 --- a/EOM.TSHotelManagement.API/Extensions/ApplicationExtensions.cs +++ b/EOM.TSHotelManagement.API/Extensions/ApplicationExtensions.cs @@ -2,6 +2,7 @@ using EOM.TSHotelManagement.Data; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.HttpOverrides; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using System; @@ -43,6 +44,22 @@ namespace EOM.TSHotelManagement.WebApi { try { + var enableInitializeDatabase = false; + if (Environment.GetEnvironmentVariable(SystemConstant.Env.Code) == SystemConstant.Docker.Code) + { + enableInitializeDatabase = Environment.GetEnvironmentVariable(SystemConstant.InitializeDatabase.Code).ToLower() == "true"; + } + else + { + enableInitializeDatabase = app.Configuration.GetSection(SystemConstant.InitializeDatabase.Code).Get(); + } + + if (!enableInitializeDatabase) + { + Console.WriteLine("已跳过初始化数据库"); + return; + } + using var scope = app.Services.CreateScope(); var initializer = scope.ServiceProvider.GetService(); initializer?.InitializeDatabase(); diff --git a/EOM.TSHotelManagement.Common/EOM.TSHotelManagement.Common.csproj b/EOM.TSHotelManagement.Common/EOM.TSHotelManagement.Common.csproj index ae99230..af3b4bc 100644 --- a/EOM.TSHotelManagement.Common/EOM.TSHotelManagement.Common.csproj +++ b/EOM.TSHotelManagement.Common/EOM.TSHotelManagement.Common.csproj @@ -4,71 +4,32 @@ net10.0 enable enable - True + False x64 True EOM.TSHotelManagement.Common - 易开元(Easy Open Meta) - Service to TS Hotel Management System Project, Development By Easy Open Meta EOM.TSHOTEL.COMMON - - 1 - 10 - 0 - - $(MSBuildProjectDirectory)\.buildnumber - - $(MajorVersion).$(MinorVersion).$(PatchVersion) - $(Version) - - MIT - https://gitee.com/java-and-net/topsky-hotel-management-system-web-api - https://gitee.com/java-and-net/topsky-hotel-management-system-web-api - - - - - - - @(BuildNumberLines) - 0 - - $([System.Int32]::Parse($(CurrentBuildNumber))) - $([MSBuild]::Add($(CurrentBuildNumberInt), 1)) - $(NewBuildNumberInt) - - - - - - + + portable + - - $(MajorVersion).$(MinorVersion).$(NewBuildNumber) - $(Version) - - + + portable + - - - - - - - - - - - - - - + + + + + + + + + + diff --git a/EOM.TSHotelManagement.Common/Helper/LogHelper.cs b/EOM.TSHotelManagement.Common/Helper/LogHelper.cs deleted file mode 100644 index a0fac51..0000000 --- a/EOM.TSHotelManagement.Common/Helper/LogHelper.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.IO; - -namespace EOM.TSHotelManagement.Common -{ - public static class LogHelper - { - private static readonly string logFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs", "ErrorLog.txt"); - - static LogHelper() - { - var logDirectory = Path.GetDirectoryName(logFilePath); - if (!Directory.Exists(logDirectory)) - { - Directory.CreateDirectory(logDirectory); - } - } - - /// - /// ¼CRUD־ - /// - /// Ϣ - /// 쳣 - public static void LogError(string message, Exception exception) - { - try - { - using (StreamWriter writer = new StreamWriter(logFilePath, true)) - { - writer.WriteLine("--------------------------------------------------"); - writer.WriteLine($"ʱ: {DateTime.Now}"); - writer.WriteLine($"Ϣ: {message}"); - writer.WriteLine($"쳣: {exception}"); - writer.WriteLine("--------------------------------------------------"); - writer.WriteLine(); - } - } - catch (Exception ex) - { - Console.WriteLine($"¼־ʱ쳣: {ex}"); - } - } - } -} diff --git a/EOM.TSHotelManagement.Contract/EOM.TSHotelManagement.Contract.csproj b/EOM.TSHotelManagement.Contract/EOM.TSHotelManagement.Contract.csproj index e32ba9f..09c4b2a 100644 --- a/EOM.TSHotelManagement.Contract/EOM.TSHotelManagement.Contract.csproj +++ b/EOM.TSHotelManagement.Contract/EOM.TSHotelManagement.Contract.csproj @@ -8,49 +8,9 @@ x64 True EOM.TSHotelManagement.Contract - 易开元(Easy Open Meta) - Service to TS Hotel Management System Project, Development By Easy Open Meta EOM.TSHOTEL.CONTRACT - - 1 - 10 - 0 - - $(MSBuildProjectDirectory)\.buildnumber - - $(MajorVersion).$(MinorVersion).$(PatchVersion) - $(Version) - - MIT - https://gitee.com/java-and-net/topsky-hotel-management-system-web-api - https://gitee.com/java-and-net/topsky-hotel-management-system-web-api - - - - - - - @(BuildNumberLines) - 0 - - $([System.Int32]::Parse($(CurrentBuildNumber))) - $([MSBuild]::Add($(CurrentBuildNumberInt), 1)) - $(NewBuildNumberInt) - - - - - - - - - $(MajorVersion).$(MinorVersion).$(NewBuildNumber) - $(Version) - - - diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Administrator/ReadAdministratorOutputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Administrator/ReadAdministratorOutputDto.cs index c65919c..3bbfad6 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Administrator/ReadAdministratorOutputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Administrator/ReadAdministratorOutputDto.cs @@ -10,14 +10,8 @@ public int IsSuperAdmin { get; set; } - /// - /// 锟角凤拷为锟斤拷锟斤拷锟斤拷锟斤拷员锟斤拷锟斤拷 (Is Super Administrator Description) - /// public string IsSuperAdminDescription { get; set; } - /// - /// 锟斤拷锟斤拷员锟斤拷锟斤拷锟斤拷锟斤拷 (Administrator Type Name) - /// public string TypeName { get; set; } } } diff --git a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Menu/ReadMenuInputDto.cs b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Menu/ReadMenuInputDto.cs index 9b18f63..7b25c1e 100644 --- a/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Menu/ReadMenuInputDto.cs +++ b/EOM.TSHotelManagement.Contract/SystemManagement/Dto/Menu/ReadMenuInputDto.cs @@ -3,7 +3,7 @@ public class ReadMenuInputDto : ListInputDto { public int? Id { get; set; } - + public string? Title { get; set; } public bool SearchParent { get; set; } = false; } } diff --git a/EOM.TSHotelManagement.Data/Connector/SqlSugarClientConnector.cs b/EOM.TSHotelManagement.Data/Connector/SqlSugarClientConnector.cs index 6502185..b8e3af9 100644 --- a/EOM.TSHotelManagement.Data/Connector/SqlSugarClientConnector.cs +++ b/EOM.TSHotelManagement.Data/Connector/SqlSugarClientConnector.cs @@ -60,12 +60,10 @@ namespace EOM.TSHotelManagement.Data // 优先从环境变量获取 var envValue = Environment.GetEnvironmentVariable(SystemConstant.Env.Code); - Console.WriteLine($"ASPNETCORE_ENVIRONMENT: {envValue}"); - + if (!string.IsNullOrEmpty(envValue) && envValue.ToLower() == SystemConstant.Docker.Code) { var envDbName = Environment.GetEnvironmentVariable(SystemConstant.DefaultDatabase.Code); - Console.WriteLine($"环境变量 DefaultDatabase: {envDbName}"); if (!string.IsNullOrEmpty(envDbName)) { @@ -75,7 +73,6 @@ namespace EOM.TSHotelManagement.Data // 从配置文件获取 var configDbName = _configuration[SystemConstant.DefaultDatabase.Code]; - Console.WriteLine($"配置文件 DefaultDatabase: {configDbName}"); return configDbName ?? SystemConstant.MariaDB.Code; } @@ -83,15 +80,11 @@ namespace EOM.TSHotelManagement.Data private string GetConnectionString(string dbName) { var envValue = Environment.GetEnvironmentVariable(SystemConstant.Env.Code); - Console.WriteLine($"连接字符串 - 环境: {envValue}, 数据库: {dbName}"); if (!string.IsNullOrEmpty(envValue) && envValue.ToLower() == "docker") { - Console.WriteLine("从环境变量获取连接字符串"); - var envVarName = $"{dbName}ConnectStr"; var envConnectionString = Environment.GetEnvironmentVariable(envVarName); - Console.WriteLine($"环境变量 {envVarName}: {envConnectionString ?? "null"}"); if (!string.IsNullOrEmpty(envConnectionString)) { @@ -101,9 +94,7 @@ namespace EOM.TSHotelManagement.Data throw new ArgumentException($"Docker环境下未找到环境变量: {envVarName}"); } - Console.WriteLine("从配置文件获取连接字符串"); var configConnectionString = _configuration.GetConnectionString($"{dbName}ConnectStr"); - Console.WriteLine($"配置文件连接字符串: {configConnectionString ?? "null"}"); return configConnectionString; } diff --git a/EOM.TSHotelManagement.Data/DatabaseInitializer/DatabaseInitializer.cs b/EOM.TSHotelManagement.Data/DatabaseInitializer/DatabaseInitializer.cs index e842efb..653933d 100644 --- a/EOM.TSHotelManagement.Data/DatabaseInitializer/DatabaseInitializer.cs +++ b/EOM.TSHotelManagement.Data/DatabaseInitializer/DatabaseInitializer.cs @@ -121,47 +121,33 @@ namespace EOM.TSHotelManagement.Data public string GetDatabaseName(IConfiguration config) { - Console.WriteLine("=== 开始获取数据库名称 ==="); - var envCode = Environment.GetEnvironmentVariable(SystemConstant.Env.Code); - Console.WriteLine($"ASPNETCORE_ENVIRONMENT: {envCode ?? "null"}"); - var isDocker = !string.IsNullOrEmpty(envCode) && envCode.ToLower() == SystemConstant.Docker.Code; - Console.WriteLine($"是否为 Docker 环境: {isDocker}"); - string dbName; if (isDocker) { dbName = Environment.GetEnvironmentVariable(SystemConstant.DefaultDatabase.Code); - Console.WriteLine($"环境变量 DefaultDatabase: {dbName ?? "null"}"); - if (string.IsNullOrEmpty(dbName)) { dbName = config[SystemConstant.DefaultDatabase.Code]; - Console.WriteLine($"配置文件 DefaultDatabase: {dbName ?? "null"}"); - if (string.IsNullOrEmpty(dbName)) { dbName = SystemConstant.MariaDB.Code; - Console.WriteLine($"使用默认数据库: {dbName}"); } } } else { dbName = config[SystemConstant.DefaultDatabase.Code] ?? SystemConstant.MariaDB.Code; - Console.WriteLine($"非Docker环境,使用数据库: {dbName}"); } var supportedDbs = new[] { SystemConstant.MariaDB.Code, SystemConstant.MySql.Code, SystemConstant.PgSql.Code, SystemConstant.SqlServer.Code, SystemConstant.Oracle.Code, SystemConstant.Sqlite.Code }; if (!supportedDbs.Contains(dbName)) { - Console.WriteLine($"警告:不支持的数据库类型 '{dbName}',默认使用 MariaDB"); - dbName = "MariaDB"; + dbName = SystemConstant.MariaDB.Code; } - Console.WriteLine($"最终确定的数据库类型: {dbName}"); return dbName; } @@ -224,34 +210,24 @@ namespace EOM.TSHotelManagement.Data private string GetConnectionString(IConfiguration config, string dbName) { - Console.WriteLine("=== 开始获取连接字符串 ==="); - Console.WriteLine($"参数 dbName: {dbName}"); - var env = Environment.GetEnvironmentVariable(SystemConstant.Env.Code); Console.WriteLine($"ASPNETCORE_ENVIRONMENT: {env}"); if (!string.IsNullOrEmpty(env) && env.ToLower() == "docker") { - Console.WriteLine("检测到 Docker 环境,从环境变量获取连接字符串"); - var envVarName = $"{dbName}ConnectStr"; var connectionString = Environment.GetEnvironmentVariable(envVarName); - Console.WriteLine($"环境变量 {envVarName}: {connectionString ?? "null"}"); - if (!string.IsNullOrEmpty(connectionString)) { var cleanString = connectionString.Trim('"'); - Console.WriteLine($"使用环境变量连接字符串: {cleanString}"); return cleanString; } throw new ArgumentException($"Docker 环境变量 {envVarName} 未找到或为空"); } - Console.WriteLine("从配置文件获取连接字符串"); var configString = config.GetConnectionString($"{dbName}ConnectStr"); - Console.WriteLine($"配置文件连接字符串: {configString ?? "null"}"); if (string.IsNullOrEmpty(configString)) { diff --git a/EOM.TSHotelManagement.Domain/EOM.TSHotelManagement.Domain.csproj b/EOM.TSHotelManagement.Domain/EOM.TSHotelManagement.Domain.csproj index 2fd7c6b..befa5d9 100644 --- a/EOM.TSHotelManagement.Domain/EOM.TSHotelManagement.Domain.csproj +++ b/EOM.TSHotelManagement.Domain/EOM.TSHotelManagement.Domain.csproj @@ -8,54 +8,11 @@ x64 True EOM.TSHotelManagement.Domain - 易开元(Easy Open Meta) - Service to TS Hotel Management System Project, Development By Easy Open Meta EOM.TSHOTEL.DOMAIN - - 1 - 10 - 0 - - $(MSBuildProjectDirectory)\.buildnumber - - $(MajorVersion).$(MinorVersion).$(PatchVersion) - $(Version) - - MIT - https://gitee.com/java-and-net/topsky-hotel-management-system-web-api - https://gitee.com/java-and-net/topsky-hotel-management-system-web-api - - - - - - - @(BuildNumberLines) - 0 - - $([System.Int32]::Parse($(CurrentBuildNumber))) - $([MSBuild]::Add($(CurrentBuildNumberInt), 1)) - $(NewBuildNumberInt) - - - - - - - - - $(MajorVersion).$(MinorVersion).$(NewBuildNumber) - $(Version) - - - - - + + diff --git a/EOM.TSHotelManagement.Infrastructure/EOM.TSHotelManagement.Infrastructure.csproj b/EOM.TSHotelManagement.Infrastructure/EOM.TSHotelManagement.Infrastructure.csproj index 5aa8ab3..d6e07bf 100644 --- a/EOM.TSHotelManagement.Infrastructure/EOM.TSHotelManagement.Infrastructure.csproj +++ b/EOM.TSHotelManagement.Infrastructure/EOM.TSHotelManagement.Infrastructure.csproj @@ -4,59 +4,16 @@ net10.0 enable enable - True + False x64 True EOM.TSHotelManagement.Infrastructure - 易开元(Easy Open Meta) - Service to TS Hotel Management System Project, Development By Easy Open Meta EOM.TSHOTEL.INFRASTRUCTURE - - 1 - 10 - 0 - - $(MSBuildProjectDirectory)\.buildnumber - - $(MajorVersion).$(MinorVersion).$(PatchVersion) - $(Version) - - MIT - https://gitee.com/java-and-net/topsky-hotel-management-system-web-api - https://gitee.com/java-and-net/topsky-hotel-management-system-web-api - - - - - - - @(BuildNumberLines) - 0 - - $([System.Int32]::Parse($(CurrentBuildNumber))) - $([MSBuild]::Add($(CurrentBuildNumberInt), 1)) - $(NewBuildNumberInt) - - - - - - - - - $(MajorVersion).$(MinorVersion).$(NewBuildNumber) - $(Version) - - - - - - + + + diff --git a/EOM.TSHotelManagement.Service/Business/Customer/CustomerService.cs b/EOM.TSHotelManagement.Service/Business/Customer/CustomerService.cs index 8a07cf4..0526a1b 100644 --- a/EOM.TSHotelManagement.Service/Business/Customer/CustomerService.cs +++ b/EOM.TSHotelManagement.Service/Business/Customer/CustomerService.cs @@ -113,7 +113,7 @@ namespace EOM.TSHotelManagement.Service var result = custoRepository.Insert(customer); if (!result) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Insert Customer Failed", "客户信息添加失败"), null); + logger.LogError(LocalizationHelper.GetLocalizedString("Insert Customer Failed", "客户信息添加失败")); return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Customer Failed", "客户信息添加失败")); } diff --git a/EOM.TSHotelManagement.Service/EOM.TSHotelManagement.Service.csproj b/EOM.TSHotelManagement.Service/EOM.TSHotelManagement.Service.csproj index 0bb129a..be64ba7 100644 --- a/EOM.TSHotelManagement.Service/EOM.TSHotelManagement.Service.csproj +++ b/EOM.TSHotelManagement.Service/EOM.TSHotelManagement.Service.csproj @@ -8,67 +8,24 @@ x64 True EOM.TSHotelManagement.Service - 易开元(Easy Open Meta) - Service to TS Hotel Management System Project, Development By Easy Open Meta EOM.TSHOTEL.SERVICE - - 1 - 10 - 0 - - $(MSBuildProjectDirectory)\.buildnumber - - $(MajorVersion).$(MinorVersion).$(PatchVersion) - $(Version) - - MIT - https://gitee.com/java-and-net/topsky-hotel-management-system-web-api - https://gitee.com/java-and-net/topsky-hotel-management-system-web-api - - - - - - - @(BuildNumberLines) - 0 - - $([System.Int32]::Parse($(CurrentBuildNumber))) - $([MSBuild]::Add($(CurrentBuildNumberInt), 1)) - $(NewBuildNumberInt) - - - - - - - - - $(MajorVersion).$(MinorVersion).$(NewBuildNumber) - $(Version) - - - - 1701;1702;8618; - + 1701;1702;8618; + - - 1701;1702;8618; - + + 1701;1702;8618; + - - - - - + + + + + - + diff --git a/EOM.TSHotelManagement.Service/SystemManagement/Base/BaseService.cs b/EOM.TSHotelManagement.Service/SystemManagement/Base/BaseService.cs index 551c689..ac72939 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/Base/BaseService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/Base/BaseService.cs @@ -1272,7 +1272,7 @@ namespace EOM.TSHotelManagement.Service var result = appointmentNoticeTypeRepository.Insert(entity); if (!result) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("insert appointment notice failed.", "公告类型添加失败"), null); + logger.LogError(LocalizationHelper.GetLocalizedString("insert appointment notice failed.", "公告类型添加失败")); return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("insert appointment notice failed.", "公告类型添加失败") }; } } -- Gitee From fbac7bb4cb1f7bc97febaf836a171f93d683ace9 Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sun, 8 Feb 2026 16:15:45 +0800 Subject: [PATCH 6/6] fix soft delete logic. --- .../Repository/GenericRepository.cs | 50 ++++++++---- .../Application/NavBar/NavBarService.cs | 7 +- .../Business/Asset/AssetService.cs | 7 -- .../Business/Customer/CustomerService.cs | 6 -- .../EnergyManagementService.cs | 7 -- .../Business/News/NewsService.cs | 7 -- .../PromotionContentService.cs | 7 -- .../Business/Reser/ReserService.cs | 6 -- .../Business/Room/RoomService.cs | 9 +-- .../Business/Room/RoomTypeService.cs | 8 +- .../Business/Sellthing/SellService.cs | 8 +- .../Administrator/AdminService.cs | 8 +- .../SystemManagement/Base/BaseService.cs | 76 +++++-------------- .../SystemManagement/Menu/MenuService.cs | 8 +- .../SystemManagement/Notice/NoticeService.cs | 8 +- .../SystemManagement/Role/RoleAppService.cs | 41 +++++++++- .../SupervisionStatisticsService.cs | 6 -- .../VipRule/VipRuleAppService.cs | 6 -- 18 files changed, 99 insertions(+), 176 deletions(-) diff --git a/EOM.TSHotelManagement.Data/Repository/GenericRepository.cs b/EOM.TSHotelManagement.Data/Repository/GenericRepository.cs index 9a17c9d..3ae6160 100644 --- a/EOM.TSHotelManagement.Data/Repository/GenericRepository.cs +++ b/EOM.TSHotelManagement.Data/Repository/GenericRepository.cs @@ -202,28 +202,48 @@ namespace EOM.TSHotelManagement.Data public bool SoftDeleteRange(List entities) { if (entities == null || !entities.Any()) - { return false; - } - var baseEntities = entities.OfType().ToList(); - if (baseEntities.Any()) - { - var currentUser = GetCurrentUser(); - var now = DateTime.Now; + var currentUser = GetCurrentUser(); + var now = DateTime.Now; + var hasBaseEntity = false; + + var baseEntities = new List(); - foreach (var baseEntity in baseEntities) + // 更新内存中的实体状态 + foreach (var entity in entities) + { + if (entity is BaseEntity baseEntity) { - if (!baseEntity.DataChgDate.HasValue) - baseEntity.DataChgDate = now; - if (string.IsNullOrEmpty(baseEntity.DataChgUsr)) - baseEntity.DataChgUsr = currentUser; + hasBaseEntity = true; + baseEntity.IsDelete = 1; + baseEntity.DataChgDate = now; + baseEntity.DataChgUsr = currentUser; + baseEntities.Add(baseEntity); } } - return base.Context.Updateable(entities) - .IgnoreColumns(ignoreAllNullColumns: true, false, true) - .ExecuteCommand() > 0; + if (!hasBaseEntity) + return false; + + // 分批次处理 + const int batchSize = 1000; + var totalAffected = 0; + + for (int i = 0; i < baseEntities.Count; i += batchSize) + { + var batch = baseEntities.Skip(i).Take(batchSize).ToList(); + + totalAffected += base.Context.Updateable(batch) + .UpdateColumns(new[] { + nameof(BaseEntity.IsDelete), + nameof(BaseEntity.DataChgUsr), + nameof(BaseEntity.DataChgDate) + }) + .ExecuteCommand(); + } + + return totalAffected > 0; } } } diff --git a/EOM.TSHotelManagement.Service/Application/NavBar/NavBarService.cs b/EOM.TSHotelManagement.Service/Application/NavBar/NavBarService.cs index fc6990a..fe14d8f 100644 --- a/EOM.TSHotelManagement.Service/Application/NavBar/NavBarService.cs +++ b/EOM.TSHotelManagement.Service/Application/NavBar/NavBarService.cs @@ -120,6 +120,7 @@ namespace EOM.TSHotelManagement.Service /// public BaseResponse DeleteNavBar(DeleteNavBarInputDto input) { + // 当DelIds为空列表时,表示删除所有导航条目(全局配置) if (input?.DelIds == null || !input.DelIds.Any()) { return new BaseResponse @@ -140,12 +141,6 @@ namespace EOM.TSHotelManagement.Service }; } - navBars = navBars.Select(nb => - { - nb.IsDelete = 1; - return nb; - }).ToList(); - // 批量软删除 var result = navBarRepository.SoftDeleteRange(navBars); diff --git a/EOM.TSHotelManagement.Service/Business/Asset/AssetService.cs b/EOM.TSHotelManagement.Service/Business/Asset/AssetService.cs index f2f0390..3e21103 100644 --- a/EOM.TSHotelManagement.Service/Business/Asset/AssetService.cs +++ b/EOM.TSHotelManagement.Service/Business/Asset/AssetService.cs @@ -195,13 +195,6 @@ namespace EOM.TSHotelManagement.Service }; } - assets = assets.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - - // 批量软删除 var result = assetRepository.SoftDeleteRange(assets); if (!result) diff --git a/EOM.TSHotelManagement.Service/Business/Customer/CustomerService.cs b/EOM.TSHotelManagement.Service/Business/Customer/CustomerService.cs index 0526a1b..66c1ce1 100644 --- a/EOM.TSHotelManagement.Service/Business/Customer/CustomerService.cs +++ b/EOM.TSHotelManagement.Service/Business/Customer/CustomerService.cs @@ -232,12 +232,6 @@ namespace EOM.TSHotelManagement.Service string.Format(LocalizationHelper.GetLocalizedString("Customer {0} has unsettled bills", "客户{0}有未结算的账单"), customer.CustomerNumber)); } - customers = customers.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - // 批量软删除 custoRepository.SoftDeleteRange(customers); diff --git a/EOM.TSHotelManagement.Service/Business/EnergyManagement/EnergyManagementService.cs b/EOM.TSHotelManagement.Service/Business/EnergyManagement/EnergyManagementService.cs index c51bdd8..a3a7c57 100644 --- a/EOM.TSHotelManagement.Service/Business/EnergyManagement/EnergyManagementService.cs +++ b/EOM.TSHotelManagement.Service/Business/EnergyManagement/EnergyManagementService.cs @@ -165,13 +165,6 @@ namespace EOM.TSHotelManagement.Service }; } - energyManagements = energyManagements.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - - // 批量软删除 var result = wtiRepository.SoftDeleteRange(energyManagements); if (result) diff --git a/EOM.TSHotelManagement.Service/Business/News/NewsService.cs b/EOM.TSHotelManagement.Service/Business/News/NewsService.cs index a55b4bd..7c3ea52 100644 --- a/EOM.TSHotelManagement.Service/Business/News/NewsService.cs +++ b/EOM.TSHotelManagement.Service/Business/News/NewsService.cs @@ -253,13 +253,6 @@ namespace EOM.TSHotelManagement.Service try { - news = news.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - - // 批量软删除 var result = _newsRepository.SoftDeleteRange(news); if (result) diff --git a/EOM.TSHotelManagement.Service/Business/PromotionContent/PromotionContentService.cs b/EOM.TSHotelManagement.Service/Business/PromotionContent/PromotionContentService.cs index 15a82d3..cf21da3 100644 --- a/EOM.TSHotelManagement.Service/Business/PromotionContent/PromotionContentService.cs +++ b/EOM.TSHotelManagement.Service/Business/PromotionContent/PromotionContentService.cs @@ -145,13 +145,6 @@ namespace EOM.TSHotelManagement.Service }; } - promotionContents = promotionContents.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - - // 批量软删除 var result = fontsRepository.SoftDeleteRange(promotionContents); if (result) diff --git a/EOM.TSHotelManagement.Service/Business/Reser/ReserService.cs b/EOM.TSHotelManagement.Service/Business/Reser/ReserService.cs index 5bea6b3..aa8575d 100644 --- a/EOM.TSHotelManagement.Service/Business/Reser/ReserService.cs +++ b/EOM.TSHotelManagement.Service/Business/Reser/ReserService.cs @@ -182,13 +182,7 @@ namespace EOM.TSHotelManagement.Service using (TransactionScope scope = new TransactionScope()) { var roomNumbers = resers.Select(a => a.ReservationRoomNumber).ToList(); - resers = resers.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - // 批量软删除 var result = reserRepository.SoftDeleteRange(resers); if (result) diff --git a/EOM.TSHotelManagement.Service/Business/Room/RoomService.cs b/EOM.TSHotelManagement.Service/Business/Room/RoomService.cs index db32dec..2e0ab01 100644 --- a/EOM.TSHotelManagement.Service/Business/Room/RoomService.cs +++ b/EOM.TSHotelManagement.Service/Business/Room/RoomService.cs @@ -605,14 +605,7 @@ namespace EOM.TSHotelManagement.Service }; } - rooms = rooms.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - - // 批量软删除 - roomRepository.SoftDeleteRange(rooms); + var result = roomRepository.SoftDeleteRange(rooms); return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Room Success", "房间信息删除成功")); } diff --git a/EOM.TSHotelManagement.Service/Business/Room/RoomTypeService.cs b/EOM.TSHotelManagement.Service/Business/Room/RoomTypeService.cs index 7dffc1e..b288eb4 100644 --- a/EOM.TSHotelManagement.Service/Business/Room/RoomTypeService.cs +++ b/EOM.TSHotelManagement.Service/Business/Room/RoomTypeService.cs @@ -192,14 +192,8 @@ namespace EOM.TSHotelManagement.Service }; } - roomTypes = roomTypes.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); + var result = roomTypeRepository.SoftDeleteRange(roomTypes); - // 批量软删除 - roomTypeRepository.SoftDeleteRange(roomTypes); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Service/Business/Sellthing/SellService.cs b/EOM.TSHotelManagement.Service/Business/Sellthing/SellService.cs index 18cc93a..371617d 100644 --- a/EOM.TSHotelManagement.Service/Business/Sellthing/SellService.cs +++ b/EOM.TSHotelManagement.Service/Business/Sellthing/SellService.cs @@ -166,14 +166,8 @@ namespace EOM.TSHotelManagement.Service }; } - sellThings = sellThings.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); + var result = sellThingRepository.SoftDeleteRange(sellThings); - // 批量软删除 - sellThingRepository.SoftDeleteRange(sellThings); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Service/SystemManagement/Administrator/AdminService.cs b/EOM.TSHotelManagement.Service/SystemManagement/Administrator/AdminService.cs index 2b3cf5a..0a4ba1f 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/Administrator/AdminService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/Administrator/AdminService.cs @@ -306,14 +306,8 @@ namespace EOM.TSHotelManagement.Service }; } - administrators = administrators.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); + var result = adminRepository.SoftDeleteRange(administrators); - // 批量软删除 - adminRepository.SoftDeleteRange(administrators); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Service/SystemManagement/Base/BaseService.cs b/EOM.TSHotelManagement.Service/SystemManagement/Base/BaseService.cs index ac72939..e889fa9 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/Base/BaseService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/Base/BaseService.cs @@ -318,14 +318,8 @@ namespace EOM.TSHotelManagement.Service }; } - positions = positions.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); + var result = positionRepository.SoftDeleteRange(positions); - // 批量软删除 - positionRepository.SoftDeleteRange(positions); return new BaseResponse(); } catch (Exception ex) @@ -451,14 +445,8 @@ namespace EOM.TSHotelManagement.Service }; } - nations = nations.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); + var result = nationRepository.SoftDeleteRange(nations); - // 批量软删除 - nationRepository.SoftDeleteRange(nations); return new BaseResponse(); } catch (Exception ex) @@ -580,13 +568,9 @@ namespace EOM.TSHotelManagement.Service Message = LocalizationHelper.GetLocalizedString("Education Not Found", "学历类型未找到") }; } - educations = educations.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - // 批量软删除 - educationRepository.SoftDeleteRange(educations); + + var result = educationRepository.SoftDeleteRange(educations); + return new BaseResponse(); } catch (Exception ex) @@ -740,13 +724,9 @@ namespace EOM.TSHotelManagement.Service Message = LocalizationHelper.GetLocalizedString("Department Not Found", "部门类型未找到") }; } - departments = departments.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - // 批量软删除 - deptRepository.SoftDeleteRange(departments); + + var result = deptRepository.SoftDeleteRange(departments); + return new BaseResponse(); } catch (Exception ex) @@ -887,13 +867,9 @@ namespace EOM.TSHotelManagement.Service Message = LocalizationHelper.GetLocalizedString("Customer Type Not Found", "客户类型未找到") }; } - custoTypes = custoTypes.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - // 批量软删除 - custoTypeRepository.SoftDeleteRange(custoTypes); + + var result = custoTypeRepository.SoftDeleteRange(custoTypes); + return new BaseResponse(); } catch (Exception ex) @@ -1034,13 +1010,9 @@ namespace EOM.TSHotelManagement.Service Message = LocalizationHelper.GetLocalizedString("Passport Type Not Found", "证件类型未找到") }; } - passPortTypes = passPortTypes.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - // 批量软删除 - passPortTypeRepository.SoftDeleteRange(passPortTypes); + + var result = passPortTypeRepository.SoftDeleteRange(passPortTypes); + return new BaseResponse(); } catch (Exception ex) @@ -1181,13 +1153,9 @@ namespace EOM.TSHotelManagement.Service Message = LocalizationHelper.GetLocalizedString("Reward & Punishment Type Not Found", "奖惩类型未找到") }; } - rewardPunishmentTypes = rewardPunishmentTypes.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - // 批量软删除 - goodbadTypeRepository.SoftDeleteRange(rewardPunishmentTypes); + + var result = goodbadTypeRepository.SoftDeleteRange(rewardPunishmentTypes); + return new BaseResponse(); } catch (Exception ex) @@ -1311,13 +1279,9 @@ namespace EOM.TSHotelManagement.Service Message = LocalizationHelper.GetLocalizedString("Appointment Notice Type Not Found", "公告类型未找到") }; } - appointmentNoticeTypes = appointmentNoticeTypes.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - // 批量软删除 - appointmentNoticeTypeRepository.SoftDeleteRange(appointmentNoticeTypes); + + var result = appointmentNoticeTypeRepository.SoftDeleteRange(appointmentNoticeTypes); + return new BaseResponse(); } catch (Exception ex) diff --git a/EOM.TSHotelManagement.Service/SystemManagement/Menu/MenuService.cs b/EOM.TSHotelManagement.Service/SystemManagement/Menu/MenuService.cs index 5a84cae..be42962 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/Menu/MenuService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/Menu/MenuService.cs @@ -312,14 +312,8 @@ namespace EOM.TSHotelManagement.Service }; } - menus = menus.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); + var result = menuRepository.SoftDeleteRange(menus); - // 批量软删除 - menuRepository.SoftDeleteRange(menus); return new BaseResponse(); } catch (Exception ex) diff --git a/EOM.TSHotelManagement.Service/SystemManagement/Notice/NoticeService.cs b/EOM.TSHotelManagement.Service/SystemManagement/Notice/NoticeService.cs index cee54cf..d71f2b7 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/Notice/NoticeService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/Notice/NoticeService.cs @@ -152,14 +152,8 @@ namespace EOM.TSHotelManagement.Service }; } - appointmentNotices = appointmentNotices.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); + var result = noticeRepository.SoftDeleteRange(appointmentNotices); - // 批量软删除 - noticeRepository.SoftDeleteRange(appointmentNotices); return new BaseResponse(); } catch (Exception ex) diff --git a/EOM.TSHotelManagement.Service/SystemManagement/Role/RoleAppService.cs b/EOM.TSHotelManagement.Service/SystemManagement/Role/RoleAppService.cs index 29dc733..e699477 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/Role/RoleAppService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/Role/RoleAppService.cs @@ -50,13 +50,46 @@ namespace EOM.TSHotelManagement.Service { try { - roleRepository.SoftDelete(EntityMapper.Map(deleteRoleInputDto)); - return new BaseResponse(); + if (deleteRoleInputDto?.DelIds == null || !deleteRoleInputDto.DelIds.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.BadRequest, + Message = LocalizationHelper.GetLocalizedString("Parameters Invalid", "参数错误") + }; + } + + var roles = roleRepository.GetList(a => deleteRoleInputDto.DelIds.Contains(a.Id)); + + if (!roles.Any()) + { + return new BaseResponse + { + Code = BusinessStatusCode.NotFound, + Message = LocalizationHelper.GetLocalizedString("Role Information Not Found", "角色信息未找到") + }; + } + + var result = roleRepository.SoftDeleteRange(roles); + + if (!result) + { + return new BaseResponse + { + Code = BusinessStatusCode.InternalServerError, + Message = LocalizationHelper.GetLocalizedString("Delete failure", "删除失败") + }; + } + + return new BaseResponse + { + Code = BusinessStatusCode.Success, + Message = LocalizationHelper.GetLocalizedString("Delete successful", "删除成功") + }; } catch (Exception ex) { - logger.LogError(ex, "Error deleting role: {RoleNumber}", string.Join(",", deleteRoleInputDto.DelIds)); - return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Role Error", "删除角色失败")); + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } } diff --git a/EOM.TSHotelManagement.Service/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs b/EOM.TSHotelManagement.Service/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs index b99f26d..7b545ea 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs @@ -160,12 +160,6 @@ namespace EOM.TSHotelManagement.Service }; } - supervisionStatistics = supervisionStatistics.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - // 批量软删除 var result = checkInfoRepository.SoftDeleteRange(supervisionStatistics); diff --git a/EOM.TSHotelManagement.Service/SystemManagement/VipRule/VipRuleAppService.cs b/EOM.TSHotelManagement.Service/SystemManagement/VipRule/VipRuleAppService.cs index d932697..e50f0aa 100644 --- a/EOM.TSHotelManagement.Service/SystemManagement/VipRule/VipRuleAppService.cs +++ b/EOM.TSHotelManagement.Service/SystemManagement/VipRule/VipRuleAppService.cs @@ -165,12 +165,6 @@ namespace EOM.TSHotelManagement.Service }; } - vipLevelRules = vipLevelRules.Select(a => - { - a.IsDelete = 1; - return a; - }).ToList(); - // 批量软删除 vipRuleRepository.SoftDeleteRange(vipLevelRules); return new BaseResponse(); -- Gitee