From 5d698fe1810358f549aecfc46ff6730b0679569f Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sun, 3 Aug 2025 01:15:45 +0800 Subject: [PATCH 1/4] Refac infrastructure --- .../Application/NavBar/INavBarService.cs | 6 +- .../Application/NavBar/NavBarService.cs | 85 ++-- .../Business/Asset/AssetService.cs | 77 +-- .../Business/Asset/IAssetService.cs | 6 +- .../Customer/CustomerAccountService.cs | 44 +- .../Business/Customer/CustomerService.cs | 122 ++--- .../Business/Customer/ICustomerService.cs | 8 +- .../EnergyManagementService.cs | 41 +- .../IEnergyManagementService.cs | 6 +- .../Business/News/INewsService.cs | 6 +- .../Business/News/NewsService.cs | 87 ++-- .../IPromotionContentService.cs | 6 +- .../PromotionContentService.cs | 75 ++- .../Business/Reser/IReserService.cs | 6 +- .../Business/Reser/ReserService.cs | 110 +++-- .../Business/Room/IRoomService.cs | 18 +- .../Business/Room/IRoomTypeService.cs | 6 +- .../Business/Room/RoomService.cs | 466 ++++++++++-------- .../Business/Room/RoomTypeService.cs | 48 +- .../Business/Sellthing/ISellService.cs | 8 +- .../Business/Sellthing/SellService.cs | 73 ++- .../Business/Spend/ISpendService.cs | 6 +- .../Business/Spend/SpendService.cs | 240 ++++----- .../Dashboard/DashboardService.cs | 38 +- .../Employee/Check/EmployeeCheckService.cs | 29 +- .../Employee/Check/IEmployeeCheckService.cs | 2 +- .../Employee/EmployeeService.cs | 132 +++-- .../History/EmployeeHistoryService.cs | 20 +- .../History/IEmployeeHistoryService.cs | 2 +- .../Employee/IEmployeeService.cs | 10 +- .../Employee/Photo/EmployeePhotoService.cs | 53 +- .../Employee/Photo/IEmployeePhotoService.cs | 4 +- .../IRewardPunishmentService.cs | 2 +- .../RewardPunishmentService.cs | 29 +- .../Administrator/AdminService.cs | 141 ++++-- .../Administrator/IAdminService.cs | 12 +- .../SystemManagement/Base/BaseService.cs | 410 ++++++++------- .../SystemManagement/Base/IBaseService.cs | 48 +- .../SystemManagement/Menu/IMenuService.cs | 8 +- .../SystemManagement/Menu/MenuService.cs | 107 ++-- .../SystemManagement/Notice/INoticeService.cs | 6 +- .../SystemManagement/Notice/NoticeService.cs | 56 ++- .../SystemManagement/Role/IRoleAppService.cs | 6 +- .../SystemManagement/Role/RoleAppService.cs | 46 +- .../ISupervisionStatisticsService.cs | 6 +- .../SupervisionStatisticsService.cs | 40 +- .../VipRule/IVipRuleAppService.cs | 6 +- .../VipRule/VipRuleAppService.cs | 51 +- .../Util/IUtilService.cs | 6 +- .../Util/UtilService.cs | 63 ++- .../NavBar/Dto/ReadNavBarOutputDto.cs | 2 +- .../BaseAuditDto.cs} | 31 +- .../BaseDto/BaseDto.cs | 1 + .../BaseDto/BaseInputDto.cs | 19 +- .../BaseDto/BaseOutputDto.cs | 37 +- .../BaseDto/BaseResponse.cs | 40 ++ ...CodeConstants.cs => BusinessStatusCode.cs} | 40 +- .../BaseDto/ListOutputDto.cs | 9 +- .../BaseDto/MenuDto.cs | 8 +- .../BaseDto/PagedData.cs | 14 + .../BaseDto/SingleOutputDto.cs | 4 +- .../Asset/Dto/Asset/ReadAssetOutputDto.cs | 2 +- .../Dto/CustoType/ReadCustoTypeOutputDto.cs | 2 +- .../Dto/Customer/ReadCustomerOutputDto.cs | 2 +- .../ReadCustomerAccountOutputDto.cs | 2 +- .../Dto/GenderType/ReadGenderTypeOutputDto.cs | 2 +- .../PassportType/ReadPassportTypeOutputDto.cs | 2 +- .../Dto/ReadEnergyManagementOutputDto.cs | 2 +- .../Dto/ReadPromotionContentOutputDto.cs | 2 +- .../Business/Reser/Dto/ReadReserOutputDto.cs | 2 +- .../Room/Dto/Room/ReadRoomOutputDto.cs | 2 +- .../Dto/RoomState/ReadRoomStateOutputDto.cs | 2 +- .../Dto/RoomType/ReadRoomTypeOutputDto.cs | 2 +- .../Sellthing/Dto/DeleteSellThingInputDto.cs | 2 - .../Sellthing/Dto/ReadSellThingOutputDto.cs | 2 +- .../Spend/Dto/Spend/ReadSpendOutputDto.cs | 2 +- .../Dto/Employee/ReadEmployeeOutputDto.cs | 3 +- .../ReadEmployeeCheckOutputDto.cs | 3 +- .../ReadEmployeeHistoryOutputDto.cs | 3 +- .../ReadEmployeePhotoOutputDto.cs | 3 +- .../ReadEmployeeRewardPunishmentOutputDto.cs | 3 +- .../ReadRewardPunishmentTypeOutputDto.cs | 3 +- .../ReadAdministratorOutputDto.cs | 3 +- .../DeleteAdministratorTypeInputDto.cs | 2 +- .../ReadAdministratorTypeOutputDto.cs | 3 +- .../ReadAppointmentNoticeOutputDto.cs | 3 +- .../ReadAppointmentNoticeTypeOutputDto.cs | 6 +- .../Dto/Department/ReadDepartmentOutputDto.cs | 3 +- .../Department/UpdateDepartmentInputDto.cs | 1 - .../Dto/Menu/ReadMenuOutputDto.cs | 3 +- .../Dto/Module/CreateModuleInputDto.cs | 10 - .../Dto/Module/DeleteModuleInputDto.cs | 10 - .../Dto/Module/ReadModuleInputDto.cs | 9 - .../Dto/Module/ReadModuleOutputDto.cs | 12 - .../Dto/Module/UpdateModuleInputDto.cs | 12 - .../CreateModulePermissionInputDto.cs | 12 - .../DeleteModulePermissionInputDto.cs | 11 - .../ReadModulePermissionInputDto.cs | 11 - .../UpdateModulePermissionInputDto.cs | 13 - .../Dto/Nation/ReadNationOutputDto.cs | 3 +- .../Dto/Position/ReadPositionOutputDto.cs | 3 +- .../Qualification/ReadEducationOutputDto.cs | 3 +- .../Dto/Role/ReadRoleOutputDto.cs | 3 +- .../ReadSupervisionStatisticsOutputDto.cs | 3 +- .../ReadSystemInformationOutputDto.cs | 3 +- .../VipLevelRule/ReadVipLevelRuleOutputDto.cs | 1 - .../ReadApplicationVersionOutputDto.cs | 3 +- .../Dto/CardCode/ReadCardCodeOutputDto.cs | 3 +- .../Dashboard/BusinessStatisticsOutputDto.cs | 2 +- .../Dto/Dashboard/HumanResourcesOutputDto.cs | 2 +- .../Dto/Dashboard/LogisticsDataOutputDto.cs | 2 +- .../Dto/Dashboard/RoomStatisticsOutputDto.cs | 2 +- .../OperationLog/ReadOperationLogInputDto.cs | 4 +- .../OperationLog/ReadOperationLogOutputDto.cs | 3 +- .../Dto/RequestLog/ReadRequestLogOutputDto.cs | 6 +- .../BaseEntity.cs | 7 +- .../Business/Room/Room.cs | 2 +- .../GenerateJWT/JWTHelper.cs | 13 +- .../Helper/EntityMapper.cs | 197 ++++++-- .../Helper/MailHelper.cs | 53 +- .../Connector/ISqlSugarClientConnector.cs | 4 +- .../Connector/SqlSugarClientConnector.cs | 41 +- .../DatabaseInitializer.cs | 55 ++- .../IDatabaseInitializer.cs | 8 + ...M.TSHotelManagement.EntityFramework.csproj | 5 +- .../Repository/GenericRepository.cs | 86 +++- .../EOM.TSHotelManagement.Migration.csproj | 4 - .../EntityBuilder.cs | 3 +- EOM.TSHotelManagement.Shared/BrotliHelper.cs | 41 -- .../Config/JwtConfig.cs | 2 - .../{AppConstant => Constant}/Constant.cs | 0 .../ConsumptionConstant.cs} | 8 +- .../Constant/SystemConstants.cs | 6 +- .../DiscountHelper.cs} | 2 +- .../{ => Helper}/EnumHelper.cs | 0 .../Application/NavBar/NavBarController.cs | 6 +- .../Business/Asset/AssetController.cs | 6 +- .../Business/Customer/CustomerController.cs | 8 +- .../EnergyManagementController.cs | 6 +- .../Business/News/NewsController.cs | 9 +- .../PromotionContentController.cs | 6 +- .../Business/Reser/ReserController.cs | 6 +- .../Business/Room/RoomController.cs | 18 +- .../Business/Room/RoomTypeController.cs | 6 +- .../Business/Sellthing/SellthingController.cs | 8 +- .../Business/Spend/SpendController.cs | 8 +- .../Employee/Check/EmployeeCheckController.cs | 2 +- .../Employee/EmployeeController.cs | 10 +- .../History/EmployeeHistoryController.cs | 2 +- .../Employee/Photo/EmployeePhotoController.cs | 4 +- .../RewardPunishmentController.cs | 2 +- .../Administrator/AdminController.cs | 12 +- .../SystemManagement/Base/BaseController.cs | 50 +- .../SystemManagement/Menu/MenuController.cs | 8 +- .../Notice/NoticeController.cs | 2 +- .../SystemManagement/Role/RoleController.cs | 6 +- .../SupervisionStatisticsController.cs | 6 +- .../VipRule/VipRuleController.cs | 6 +- .../Controllers/Util/UtilityController.cs | 6 +- .../EOM.TSHotelManagement.WebApi.csproj | 3 +- .../Extension/DateOnlyJsonConverter.cs | 27 + .../Extension/MvcOptionsExtensions.cs | 2 +- .../{RouteConvention.cs => RouteExtension.cs} | 4 +- .../Factory/JwtConfigFactory.cs | 2 - .../AuthorizeAllControllersConvention.cs | 2 +- .../RequestLoggingMiddleware.cs | 0 EOM.TSHotelManagement.WebApi/Startup.cs | 214 ++++---- 167 files changed, 2394 insertions(+), 1906 deletions(-) rename EOM.TSHotelManagement.Common.Contract/{SystemManagement/Dto/ModulePermission/ReadModulePermissionOutputDto.cs => BaseDto/BaseAuditDto.cs} (34%) create mode 100644 EOM.TSHotelManagement.Common.Contract/BaseDto/BaseResponse.cs rename EOM.TSHotelManagement.Common.Contract/BaseDto/{StatusCodeConstants.cs => BusinessStatusCode.cs} (67%) rename EOM.TSHotelManagement.Common.Core/SystemManagement/MenuViewModel.cs => EOM.TSHotelManagement.Common.Contract/BaseDto/MenuDto.cs (75%) create mode 100644 EOM.TSHotelManagement.Common.Contract/BaseDto/PagedData.cs delete mode 100644 EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/CreateModuleInputDto.cs delete mode 100644 EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/DeleteModuleInputDto.cs delete mode 100644 EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/ReadModuleInputDto.cs delete mode 100644 EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/ReadModuleOutputDto.cs delete mode 100644 EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/UpdateModuleInputDto.cs delete mode 100644 EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/CreateModulePermissionInputDto.cs delete mode 100644 EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/DeleteModulePermissionInputDto.cs delete mode 100644 EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/ReadModulePermissionInputDto.cs delete mode 100644 EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/UpdateModulePermissionInputDto.cs rename EOM.TSHotelManagement.Shared/Interfaces/ISqlSugarClientFactory.cs => EOM.TSHotelManagement.EntityFramework/Connector/ISqlSugarClientConnector.cs (50%) rename EOM.TSHotelManagement.WebApi/Factory/SqlSugarClientFactory.cs => EOM.TSHotelManagement.EntityFramework/Connector/SqlSugarClientConnector.cs (56%) rename EOM.TSHotelManagement.WebApi/MigrationConfig/InitializeConfig.cs => EOM.TSHotelManagement.EntityFramework/DatabaseInitializer/DatabaseInitializer.cs (89%) create mode 100644 EOM.TSHotelManagement.EntityFramework/DatabaseInitializer/IDatabaseInitializer.cs delete mode 100644 EOM.TSHotelManagement.Shared/BrotliHelper.cs rename EOM.TSHotelManagement.Shared/{AppConstant => Constant}/Constant.cs (100%) rename EOM.TSHotelManagement.Shared/{SpendConsts.cs => Constant/ConsumptionConstant.cs} (77%) rename EOM.TSHotelManagement.WebApi/Constant/DatabaseConstants.cs => EOM.TSHotelManagement.Shared/Constant/SystemConstants.cs (69%) rename EOM.TSHotelManagement.Shared/{DiscountConverter.cs => Helper/DiscountHelper.cs} (98%) rename EOM.TSHotelManagement.Shared/{ => Helper}/EnumHelper.cs (100%) create mode 100644 EOM.TSHotelManagement.WebApi/Extension/DateOnlyJsonConverter.cs rename EOM.TSHotelManagement.WebApi/Extension/{RouteConvention.cs => RouteExtension.cs} (93%) rename EOM.TSHotelManagement.WebApi/{Filter => Filters}/AuthorizeAllControllersConvention.cs (96%) rename EOM.TSHotelManagement.WebApi/{Filter => Filters}/RequestLoggingMiddleware.cs (100%) diff --git a/EOM.TSHotelManagement.Application/Application/NavBar/INavBarService.cs b/EOM.TSHotelManagement.Application/Application/NavBar/INavBarService.cs index b673e18..f00f533 100644 --- a/EOM.TSHotelManagement.Application/Application/NavBar/INavBarService.cs +++ b/EOM.TSHotelManagement.Application/Application/NavBar/INavBarService.cs @@ -17,18 +17,18 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddNavBar(CreateNavBarInputDto input); + BaseResponse AddNavBar(CreateNavBarInputDto input); /// /// 更新导航控件 /// /// /// - BaseOutputDto UpdateNavBar(UpdateNavBarInputDto input); + BaseResponse UpdateNavBar(UpdateNavBarInputDto input); /// /// 删除导航控件 /// /// /// - BaseOutputDto DeleteNavBar(DeleteNavBarInputDto input); + BaseResponse DeleteNavBar(DeleteNavBarInputDto input); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/Application/NavBar/NavBarService.cs b/EOM.TSHotelManagement.Application/Application/NavBar/NavBarService.cs index 3ab3ed4..f509d22 100644 --- a/EOM.TSHotelManagement.Application/Application/NavBar/NavBarService.cs +++ b/EOM.TSHotelManagement.Application/Application/NavBar/NavBarService.cs @@ -30,14 +30,16 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto NavBarList() { - var navBarList = navBarRepository.GetList(a => a.IsDelete != 1); - - var listSource = EntityMapper.MapList(navBarList); + var navBars = navBarRepository.GetList(); + var result = EntityMapper.MapList(navBars); return new ListOutputDto { - listSource = listSource, - total = listSource.Count + Data = new PagedData + { + Items = result, + TotalCount = result.Count + } }; } @@ -46,7 +48,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddNavBar(CreateNavBarInputDto input) + public BaseResponse AddNavBar(CreateNavBarInputDto input) { var navBar = new NavBar { @@ -60,22 +62,19 @@ namespace EOM.TSHotelManagement.Application DataInsDate = input.DataInsDate }; var result = navBarRepository.Insert(navBar); - if (result) - { - return new BaseOutputDto - { - StatusCode = StatusCodeConstants.Success, - Message = "添加成功" - }; - } - else + if (!result) { - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.InternalServerError, + Code = BusinessStatusCode.InternalServerError, Message = "添加失败" }; } + return new BaseResponse + { + Code = BusinessStatusCode.Success, + Message = "添加成功" + }; } /// @@ -83,14 +82,14 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateNavBar(UpdateNavBarInputDto input) + public BaseResponse UpdateNavBar(UpdateNavBarInputDto input) { var navBar = navBarRepository.GetById(input.NavigationBarId); if (navBar == null) { - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.NotFound, + Code = BusinessStatusCode.NotFound, Message = "导航控件未找到" }; } @@ -100,22 +99,19 @@ namespace EOM.TSHotelManagement.Application navBar.NavigationBarEvent = input.NavigationBarEvent; navBar.MarginLeft = input.MarginLeft; var result = navBarRepository.Update(navBar); - if (result) + if (!result) { - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.Success, - Message = "更新成功" - }; - } - else - { - return new BaseOutputDto - { - StatusCode = StatusCodeConstants.InternalServerError, + Code = BusinessStatusCode.InternalServerError, Message = "更新失败" }; } + return new BaseResponse + { + Code = BusinessStatusCode.Success, + Message = "更新成功" + }; } /// @@ -123,35 +119,32 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteNavBar(DeleteNavBarInputDto input) + public BaseResponse DeleteNavBar(DeleteNavBarInputDto input) { var navBar = navBarRepository.GetById(input.NavigationBarId); if (navBar == null) { - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.NotFound, + Code = BusinessStatusCode.NotFound, Message = "导航控件未找到" }; } navBar.IsDelete = 1; - var result = navBarRepository.Update(navBar); - if (result) - { - return new BaseOutputDto - { - StatusCode = StatusCodeConstants.Success, - Message = "删除成功" - }; - } - else + var result = navBarRepository.SoftDelete(navBar); + if (!result) { - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.InternalServerError, + Code = BusinessStatusCode.InternalServerError, Message = "删除失败" }; } + return new BaseResponse + { + Code = BusinessStatusCode.Success, + Message = "删除成功" + }; } } } diff --git a/EOM.TSHotelManagement.Application/Business/Asset/AssetService.cs b/EOM.TSHotelManagement.Application/Business/Asset/AssetService.cs index cd62266..dffc2a4 100644 --- a/EOM.TSHotelManagement.Application/Business/Asset/AssetService.cs +++ b/EOM.TSHotelManagement.Application/Business/Asset/AssetService.cs @@ -67,21 +67,26 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddAssetInfo(CreateAssetInputDto asset) + public BaseResponse AddAssetInfo(CreateAssetInputDto asset) { try { if (assetRepository.IsAny(a => a.AssetNumber == asset.AssetNumber)) { - return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString("the asset number already exists.", "资产编号已存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("the asset number already exists.", "资产编号已存在"), Code = BusinessStatusCode.InternalServerError }; + } + var entity = EntityMapper.Map(asset); + var result = assetRepository.Insert(entity); + if (!result) + { + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("insert asset failed.", "资产添加失败"), Code = BusinessStatusCode.InternalServerError }; } - var result = assetRepository.Insert(EntityMapper.Map(asset)); } catch (Exception ex) { - return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -91,38 +96,45 @@ namespace EOM.TSHotelManagement.Application public ListOutputDto SelectAssetInfoAll(ReadAssetInputDto asset) { //查询所有部门信息 - List depts = new List(); - depts = deptRepository.GetList(); + List depts = deptRepository.GetList(); //查询所有员工信息 - List employees = new List(); - employees = employeeRepository.GetList(); - - ListOutputDto cs = new ListOutputDto(); + List employees = employeeRepository.GetList(); var where = Expressionable.Create(); - where = where.And(a => a.IsDelete == asset.IsDelete); - int totalCount = 0; + int count = 0; + List assets = new List(); if (asset.Page != 0 && asset.PageSize != 0) { - cs.listSource = EntityMapper.MapList(assetRepository.AsQueryable().Where(where.ToExpression()).OrderBy(a => a.AssetNumber) - .ToPageList((int)asset.Page, (int)asset.PageSize, ref totalCount)); - cs.total = totalCount; + assets = assetRepository.AsQueryable().Where(where.ToExpression()).OrderBy(a => a.AssetNumber) + .ToPageList((int)asset.Page, (int)asset.PageSize, ref count); } + else + { + assets = assetRepository.AsQueryable().Where(where.ToExpression()).OrderBy(a => a.AssetNumber).ToList(); + count = assets.Count; + } + + var mapped = EntityMapper.MapList(assets); - cs.listSource.ForEach(source => + mapped.ForEach(source => { var dept = depts.SingleOrDefault(a => a.DepartmentNumber.Equals(source.DepartmentCode)); source.DepartmentName = dept == null ? "" : dept.DepartmentName; var worker = employees.SingleOrDefault(a => a.EmployeeId.Equals(source.AcquiredByEmployeeId)); source.AcquiredByEmployeeName = worker == null ? "" : worker.EmployeeName; - source.AssetValueFormatted = source.AssetValue == 0 ? "" : Decimal.Parse(source.AssetValue.ToString()).ToString("#,##0.00").ToString(); - }); - return cs; + return new ListOutputDto + { + Data = new PagedData + { + Items = mapped, + TotalCount = count + } + }; } /// @@ -130,21 +142,26 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdAssetInfo(UpdateAssetInputDto asset) + public BaseResponse UpdAssetInfo(UpdateAssetInputDto asset) { try { if (!assetRepository.IsAny(a => a.AssetNumber == asset.AssetNumber)) { - return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString("asset number does not exist.", "资产编号不存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("asset number does not exist.", "资产编号不存在"), Code = BusinessStatusCode.InternalServerError }; + } + var entity = EntityMapper.Map(asset); + var result = assetRepository.Update(entity); + if (!result) + { + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("update asset failed.", "资产更新失败"), Code = BusinessStatusCode.InternalServerError }; } - assetRepository.Update(EntityMapper.Map(asset)); } catch (Exception ex) { - return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -152,21 +169,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DelAssetInfo(DeleteAssetInputDto asset) + public BaseResponse DelAssetInfo(DeleteAssetInputDto asset) { try { if (!assetRepository.IsAny(a => a.AssetNumber == asset.AssetNumber)) { - return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString("asset number does not exist.", "资产编号不存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("asset number does not exist.", "资产编号不存在"), Code = BusinessStatusCode.InternalServerError }; } - assetRepository.Update(a => new Asset { IsDelete = asset.IsDelete }, a => a.AssetNumber == asset.AssetNumber); + assetRepository.SoftDelete(new Asset { IsDelete = asset.IsDelete, AssetNumber = asset.AssetNumber, Id = asset.Id }); } catch (Exception ex) { - return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } } } diff --git a/EOM.TSHotelManagement.Application/Business/Asset/IAssetService.cs b/EOM.TSHotelManagement.Application/Business/Asset/IAssetService.cs index 09129a4..0f32d1b 100644 --- a/EOM.TSHotelManagement.Application/Business/Asset/IAssetService.cs +++ b/EOM.TSHotelManagement.Application/Business/Asset/IAssetService.cs @@ -35,7 +35,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddAssetInfo(CreateAssetInputDto cash); + BaseResponse AddAssetInfo(CreateAssetInputDto cash); /// /// 查询资产信息 @@ -48,13 +48,13 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto UpdAssetInfo(UpdateAssetInputDto cash); + BaseResponse UpdAssetInfo(UpdateAssetInputDto cash); /// /// 删除资产信息 /// /// /// - BaseOutputDto DelAssetInfo(DeleteAssetInputDto cash); + BaseResponse DelAssetInfo(DeleteAssetInputDto cash); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs b/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs index 5a0f45a..bea567e 100644 --- a/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs +++ b/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs @@ -54,22 +54,24 @@ namespace EOM.TSHotelManagement.Application public SingleOutputDto Login(ReadCustomerAccountInputDto readCustomerAccountInputDto) { if(readCustomerAccountInputDto.Account.IsNullOrEmpty() || readCustomerAccountInputDto.Password.IsNullOrEmpty()) - return new SingleOutputDto() { StatusCode = StatusCodeConstants.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account or Password cannot be empty","账号或密码不能为空"), Source = new ReadCustomerAccountOutputDto()}; + return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account or Password cannot be empty","账号或密码不能为空"), Data = new ReadCustomerAccountOutputDto()}; var customerAccount = customerAccountRepository.AsQueryable().Single(x => x.Account == readCustomerAccountInputDto.Account); if (customerAccount == null) - return new SingleOutputDto() { StatusCode = StatusCodeConstants.NotFound, Message = LocalizationHelper.GetLocalizedString("Account not found","账号不存在"), Source = new ReadCustomerAccountOutputDto() }; + return new SingleOutputDto() { Code = BusinessStatusCode.NotFound, Message = LocalizationHelper.GetLocalizedString("Account not found","账号不存在"), Data = new ReadCustomerAccountOutputDto() }; if (!dataProtector.CompareCustomerData(customerAccount.Password, readCustomerAccountInputDto.Password)) - return new SingleOutputDto() { StatusCode = StatusCodeConstants.Unauthorized, Message = LocalizationHelper.GetLocalizedString("Invalid account or password","账号或密码错误"), Source = new ReadCustomerAccountOutputDto() }; + return new SingleOutputDto() { Code = BusinessStatusCode.Unauthorized, Message = LocalizationHelper.GetLocalizedString("Invalid account or password","账号或密码错误"), Data = new ReadCustomerAccountOutputDto() }; customerAccount.Password = null; - customerAccountRepository.Update(a => new CustomerAccount + customerAccountRepository.Update(new CustomerAccount { + Id = customerAccount.Id, + Account = customerAccount.Account, LastLoginIp = customerAccount.LastLoginIp, LastLoginTime = customerAccount.LastLoginTime - }, a => a.Account == customerAccount.Account); + }); customerAccount.UserToken = jWTHelper.GenerateJWT(new ClaimsIdentity(new Claim[] { @@ -81,9 +83,9 @@ namespace EOM.TSHotelManagement.Application return new SingleOutputDto() { - StatusCode = StatusCodeConstants.Success, + Code = BusinessStatusCode.Success, Message = LocalizationHelper.GetLocalizedString("Login successful","登录成功"), - Source = new ReadCustomerAccountOutputDto + Data = new ReadCustomerAccountOutputDto { Account = customerAccount.Account, EmailAddress = customerAccount.EmailAddress, @@ -104,23 +106,23 @@ namespace EOM.TSHotelManagement.Application public SingleOutputDto Register(ReadCustomerAccountInputDto readCustomerAccountInputDto) { if (readCustomerAccountInputDto.Account.IsNullOrEmpty() || readCustomerAccountInputDto.Password.IsNullOrEmpty()) - return new SingleOutputDto() { StatusCode = StatusCodeConstants.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account or Password cannot be empty", "账号或密码不能为空"), Source = new ReadCustomerAccountOutputDto() }; + return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account or Password cannot be empty", "账号或密码不能为空"), Data = new ReadCustomerAccountOutputDto() }; if (readCustomerAccountInputDto.Account.Length < 3 || readCustomerAccountInputDto.Account.Length > 20) - return new SingleOutputDto() { StatusCode = StatusCodeConstants.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account length must be between 3 and 20 characters", "账号长度必须在3到20个字符之间"), Source = new ReadCustomerAccountOutputDto() }; + return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account length must be between 3 and 20 characters", "账号长度必须在3到20个字符之间"), Data = new ReadCustomerAccountOutputDto() }; var accountRegex = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z0-9_]+$"); if (!accountRegex.IsMatch(readCustomerAccountInputDto.Account)) - return new SingleOutputDto() { StatusCode = StatusCodeConstants.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account can only contain letters, numbers, and underscores", "账号只能包含字母、数字和下划线"), Source = new ReadCustomerAccountOutputDto() }; + return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account can only contain letters, numbers, and underscores", "账号只能包含字母、数字和下划线"), Data = new ReadCustomerAccountOutputDto() }; var passwordRegex = new System.Text.RegularExpressions.Regex(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$"); if (!passwordRegex.IsMatch(readCustomerAccountInputDto.Password)) - return new SingleOutputDto() { StatusCode = StatusCodeConstants.BadRequest, Message = LocalizationHelper.GetLocalizedString("Password must be at least 8 characters long and contain at least one uppercase letter, one lowercase letter, and one number", "密码必须至少8个字符,并且包含至少一个大写字母、一个小写字母和一个数字"), Source = new ReadCustomerAccountOutputDto() }; + return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Password must be at least 8 characters long and contain at least one uppercase letter, one lowercase letter, and one number", "密码必须至少8个字符,并且包含至少一个大写字母、一个小写字母和一个数字"), Data = new ReadCustomerAccountOutputDto() }; var customerAccount = customerAccountRepository.AsQueryable().Single(x => x.Account == readCustomerAccountInputDto.Account); if (customerAccount != null) - return new SingleOutputDto() { StatusCode = StatusCodeConstants.Conflict, Message = LocalizationHelper.GetLocalizedString("Account already exists","账号已存在"), Source = new ReadCustomerAccountOutputDto() }; + return new SingleOutputDto() { Code = BusinessStatusCode.Conflict, Message = LocalizationHelper.GetLocalizedString("Account already exists","账号已存在"), Data = new ReadCustomerAccountOutputDto() }; var password = dataProtector.EncryptCustomerData(readCustomerAccountInputDto.Password); var customerNumber = new UniqueCode().GetNewId("TS-"); @@ -136,14 +138,18 @@ namespace EOM.TSHotelManagement.Application Password = password, Status = 0, LastLoginIp = string.Empty, - LastLoginTime = null, + LastLoginTime = DateTime.Now, DataInsUsr = readCustomerAccountInputDto.Account, DataInsDate = DateTime.Now }; - customerAccountRepository.Insert(customerAccount); + var accountResult = customerAccountRepository.Insert(customerAccount); + if (!accountResult) + { + return new SingleOutputDto() { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Account insert failed", "账号插入失败"), Data = new ReadCustomerAccountOutputDto() }; + } - customerRepository.Insert(new Customer + var customerResult = customerRepository.Insert(new Customer { CustomerNumber = customerNumber, CustomerName = string.Empty, @@ -158,6 +164,10 @@ namespace EOM.TSHotelManagement.Application DataInsUsr = readCustomerAccountInputDto.Account, DataInsDate = DateTime.Now }); + if (!customerResult) + { + return new SingleOutputDto() { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Customer insert failed", "客户插入失败"), Data = new ReadCustomerAccountOutputDto() }; + } customerAccount.UserToken = jWTHelper.GenerateJWT(new ClaimsIdentity(new Claim[] { @@ -171,9 +181,9 @@ namespace EOM.TSHotelManagement.Application return new SingleOutputDto() { - StatusCode = StatusCodeConstants.Success, + Code = BusinessStatusCode.Success, Message = LocalizationHelper.GetLocalizedString("Register successful", "注册成功,稍后将自动登录"), - Source = new ReadCustomerAccountOutputDto + Data = new ReadCustomerAccountOutputDto { Account = customerAccount.Account, EmailAddress = customerAccount.EmailAddress, diff --git a/EOM.TSHotelManagement.Application/Business/Customer/CustomerService.cs b/EOM.TSHotelManagement.Application/Business/Customer/CustomerService.cs index 6f56354..c2f5f72 100644 --- a/EOM.TSHotelManagement.Application/Business/Customer/CustomerService.cs +++ b/EOM.TSHotelManagement.Application/Business/Customer/CustomerService.cs @@ -82,7 +82,7 @@ namespace EOM.TSHotelManagement.Application /// 添加客户信息 /// /// - public BaseOutputDto InsertCustomerInfo(CreateCustomerInputDto custo) + public BaseResponse InsertCustomerInfo(CreateCustomerInputDto custo) { string NewID = dataProtector.EncryptCustomerData(custo.IdCardNumber); string NewTel = dataProtector.EncryptCustomerData(custo.CustomerPhoneNumber); @@ -92,17 +92,23 @@ namespace EOM.TSHotelManagement.Application { if (custoRepository.IsAny(a => a.CustomerNumber == custo.CustomerNumber)) { - return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString("customer number already exist.", "客户编号已存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("customer number already exist.", "客户编号已存在"), Code = BusinessStatusCode.InternalServerError }; + } + var customer = EntityMapper.Map(custo); + var result = custoRepository.Insert(customer); + if (!result) + { + LogHelper.LogError(LocalizationHelper.GetLocalizedString("Insert Customer Failed", "客户信息添加失败"), null); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Customer Failed", "客户信息添加失败")); } - var result = custoRepository.Insert(EntityMapper.Map(custo)); } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("Insert Customer Failed", "客户信息添加失败"), ex); - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Customer Failed", "客户信息添加失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Customer Failed", "客户信息添加失败")); } - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Insert Customer Success", "客户信息添加成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Insert Customer Success", "客户信息添加成功")); } /// @@ -110,7 +116,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdCustomerInfo(UpdateCustomerInputDto custo) + public BaseResponse UpdCustomerInfo(UpdateCustomerInputDto custo) { string NewID = dataProtector.EncryptCustomerData(custo.IdCardNumber); string NewTel = dataProtector.EncryptCustomerData(custo.CustomerPhoneNumber); @@ -120,24 +126,20 @@ namespace EOM.TSHotelManagement.Application { if (!custoRepository.IsAny(a => a.CustomerNumber == custo.CustomerNumber)) { - return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString("customer number does not exist.", "客户编号不存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("customer number does not exist.", "客户编号不存在"), Code = BusinessStatusCode.InternalServerError }; } - var result = custoRepository.Update(EntityMapper.Map(custo)); - - if (result) + var customer = EntityMapper.Map(custo); + var result = custoRepository.Update(customer); + if (!result) { - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Update Customer Success", "客户信息更新成功")); - } - else - { - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "客户信息更新失败")); + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("Update Customer Failed", "客户信息更新失败"), Code = BusinessStatusCode.InternalServerError }; } } catch (Exception ex) { - LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Customer Failed", "客户信息更新失败"), ex); - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "客户信息更新失败")); + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } + return new BaseResponse(); } /// @@ -145,19 +147,19 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DelCustomerInfo(DeleteCustomerInputDto custo) + public BaseResponse DelCustomerInfo(DeleteCustomerInputDto custo) { if (!custoRepository.IsAny(a => a.CustomerNumber == custo.CustomerNumber)) { - return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString("customer number does not exist.", "客户编号不存在"), StatusCode = StatusCodeConstants.InternalServerError }; + 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 == SpendConsts.UnSettle.Code); + var haveUnSettle = custoRepository.Change().IsAny(a => a.CustomerNumber == custo.CustomerNumber && a.SettlementStatus == ConsumptionConstant.UnSettle.Code); if (isOccupied) - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Customer is currently occupying a room", "客户当前正在占用房间")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Customer is currently occupying a room", "客户当前正在占用房间")); if (haveUnSettle) - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Customer has unsettled bills", "客户有未结算的账单")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Customer has unsettled bills", "客户有未结算的账单")); var result = custoRepository.Update(a => new Customer() { @@ -168,11 +170,11 @@ namespace EOM.TSHotelManagement.Application if (result) { - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Delete Customer Success", "客户信息删除成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Customer Success", "客户信息删除成功")); } else { - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Customer Failed", "客户信息删除失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Customer Failed", "客户信息删除失败")); } } @@ -181,29 +183,29 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdCustomerTypeByCustoNo(UpdateCustomerInputDto updateCustomerInputDto) + public BaseResponse UpdCustomerTypeByCustoNo(UpdateCustomerInputDto updateCustomerInputDto) { try { if (!custoRepository.IsAny(a => a.CustomerNumber == updateCustomerInputDto.CustomerNumber)) { - return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString("customer number does not exist.", "客户编号不存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("customer number does not exist.", "客户编号不存在"), Code = BusinessStatusCode.InternalServerError }; } var result = custoRepository.Update(a => new Customer { CustomerType = updateCustomerInputDto.CustomerType }, a => a.CustomerNumber == updateCustomerInputDto.CustomerNumber); if (result) { - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Update Customer Type Success", "客户类型更新成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Update Customer Type Success", "客户类型更新成功")); } else { - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Type Failed", "客户类型更新失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Type Failed", "客户类型更新失败")); } } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Customer Type Failed", "客户类型更新失败"), ex); - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Type Failed", "客户类型更新失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Type Failed", "客户类型更新失败")); } } @@ -213,32 +215,8 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectCustomers(ReadCustomerInputDto readCustomerInputDto) { - ListOutputDto oSelectCustoAllDto = new ListOutputDto(); - - //查询出所有性别类型 - var helper = new EnumHelper(); - var genders = Enum.GetValues(typeof(GenderType)) - .Cast() - .Select(e => new EnumDto - { - Id = (int)e, - Name = e.ToString(), - Description = helper.GetEnumDescription(e) - }) - .ToList(); - //查询出所有证件类型 - List passPortTypes = new List(); - passPortTypes = passPortTypeRepository.GetList(); - //查询出所有客户类型 - List custoTypes = new List(); - custoTypes = custoTypeRepository.GetList(); - //查询出所有客户信息 - List custos = new List(); - var where = Expressionable.Create(); - where = where.And(a => a.IsDelete == readCustomerInputDto.IsDelete); - if (!readCustomerInputDto.CustomerNumber.IsNullOrEmpty()) { where = where.And(a => a.CustomerNumber.Equals(readCustomerInputDto.CustomerNumber)); @@ -255,9 +233,8 @@ namespace EOM.TSHotelManagement.Application { where = where.And(a => a.IdCardNumber.Contains(readCustomerInputDto.IdCardNumber)); } - var count = 0; - + List custos = new List(); if (!readCustomerInputDto.IgnorePaging && readCustomerInputDto.Page != 0 && readCustomerInputDto.PageSize != 0) { custos = custoRepository.AsQueryable().Where(where.ToExpression()).OrderBy(a => a.CustomerNumber) @@ -266,36 +243,31 @@ namespace EOM.TSHotelManagement.Application else { custos = custoRepository.AsQueryable().Where(where.ToExpression()).OrderBy(a => a.CustomerNumber).ToList(); + count = custos.Count; } - var customerOutputDtos = EntityMapper.MapList(custos); - customerOutputDtos.ForEach(source => { - //解密身份证号码 var sourceStr = dataProtector.DecryptCustomerData(source.IdCardNumber); source.IdCardNumber = sourceStr; - //解密联系方式 var sourceTelStr = dataProtector.DecryptCustomerData(source.CustomerPhoneNumber); source.CustomerPhoneNumber = sourceTelStr; - - //性别类型 - var sexType = genders.SingleOrDefault(a => a.Id == source.CustomerGender); + var helper = new EnumHelper(); + var sexType = Enum.GetValues(typeof(GenderType)).Cast().Select(e => new EnumDto { Id = (int)e, Name = e.ToString(), Description = helper.GetEnumDescription(e) }).SingleOrDefault(a => a.Id == source.CustomerGender); source.GenderName = sexType?.Description ?? ""; - - //证件类型 - var passPortType = passPortTypes.SingleOrDefault(a => a.PassportId == source.PassportId); + var passPortType = passPortTypeRepository.AsQueryable().Where(a => a.PassportId == source.PassportId).First(); source.PassportName = passPortType?.PassportName ?? ""; - - //客户类型 - var custoType = custoTypes.SingleOrDefault(a => a.CustomerType == source.CustomerType); + var custoType = custoTypeRepository.AsQueryable().Where(a => a.CustomerType == source.CustomerType).First(); source.CustomerTypeName = custoType?.CustomerTypeName ?? ""; }); - - oSelectCustoAllDto.listSource = customerOutputDtos; - oSelectCustoAllDto.total = count; - - return oSelectCustoAllDto; + return new ListOutputDto + { + Data = new PagedData + { + Items = customerOutputDtos, + TotalCount = count + } + }; } /// @@ -339,7 +311,7 @@ namespace EOM.TSHotelManagement.Application if (customer.IsNullOrEmpty()) { - return new SingleOutputDto { StatusCode = StatusCodeConstants.InternalServerError, Message = "该用户不存在" }; + return new SingleOutputDto { Code = BusinessStatusCode.InternalServerError, Message = "该用户不存在" }; } //解密身份证号码 @@ -358,7 +330,7 @@ namespace EOM.TSHotelManagement.Application var custoType = custoTypes.SingleOrDefault(a => a.CustomerType == customer.CustomerType); customer.CustomerTypeName = custoType.CustomerTypeName.IsNullOrEmpty() ? "" : custoType.CustomerTypeName; - singleOutputDto.Source = EntityMapper.Map(customer); + singleOutputDto.Data = EntityMapper.Map(customer); return singleOutputDto; } diff --git a/EOM.TSHotelManagement.Application/Business/Customer/ICustomerService.cs b/EOM.TSHotelManagement.Application/Business/Customer/ICustomerService.cs index a93a29a..03eb7cc 100644 --- a/EOM.TSHotelManagement.Application/Business/Customer/ICustomerService.cs +++ b/EOM.TSHotelManagement.Application/Business/Customer/ICustomerService.cs @@ -35,27 +35,27 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto InsertCustomerInfo(CreateCustomerInputDto custo); + BaseResponse InsertCustomerInfo(CreateCustomerInputDto custo); /// /// 更新客户信息 /// /// /// - BaseOutputDto UpdCustomerInfo(UpdateCustomerInputDto custo); + BaseResponse UpdCustomerInfo(UpdateCustomerInputDto custo); /// /// 删除客户信息 /// /// /// - BaseOutputDto DelCustomerInfo(DeleteCustomerInputDto custo); + BaseResponse DelCustomerInfo(DeleteCustomerInputDto custo); /// /// 更新客户类型(即会员等级) /// /// - BaseOutputDto UpdCustomerTypeByCustoNo(UpdateCustomerInputDto updateCustomerInputDto); + BaseResponse UpdCustomerTypeByCustoNo(UpdateCustomerInputDto updateCustomerInputDto); /// /// 查询所有客户信息 diff --git a/EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs b/EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs index cf6cc4d..b3500f3 100644 --- a/EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs +++ b/EOM.TSHotelManagement.Application/Business/EnergyManagement/EnergyManagementService.cs @@ -80,12 +80,19 @@ namespace EOM.TSHotelManagement.Application var count = 0; - var listSource = wtiRepository.AsQueryable() + var Data = wtiRepository.AsQueryable() .Where(where.ToExpression()).ToPageList(readEnergyManagementInputDto.Page, readEnergyManagementInputDto.PageSize, ref count); - var readEnergies = EntityMapper.MapList(listSource); + var readEnergies = EntityMapper.MapList(Data); - return new ListOutputDto { listSource = readEnergies, total = count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = readEnergies, + TotalCount = count + } + }; } /// @@ -93,23 +100,23 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto InsertEnergyManagementInfo(CreateEnergyManagementInputDto w) + public BaseResponse InsertEnergyManagementInfo(CreateEnergyManagementInputDto w) { try { if (wtiRepository.IsAny(a => a.InformationId == w.InformationNumber)) { - return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString("information number already exist.", "信息编号已存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("information number already exist.", "信息编号已存在"), Code = BusinessStatusCode.InternalServerError }; } var result = wtiRepository.Insert(EntityMapper.Map(w)); } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("Insert Energy Management Failed", "水电信息添加失败"), ex); - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Energy Management Failed", "水电信息添加失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Energy Management Failed", "水电信息添加失败")); } - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Insert Energy Management Success", "水电信息添加成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Insert Energy Management Success", "水电信息添加成功")); } /// @@ -117,29 +124,29 @@ namespace EOM.TSHotelManagement.Application /// /// 包含要修改的数据,以及EnergyManagementNo作为查询条件 /// - public BaseOutputDto UpdateEnergyManagementInfo(UpdateEnergyManagementInputDto w) + public BaseResponse UpdateEnergyManagementInfo(UpdateEnergyManagementInputDto w) { try { if (!wtiRepository.IsAny(a => a.InformationId == w.InformationId)) { - return new BaseOutputDto() { Message = LocalizationHelper.GetLocalizedString("information number does not exist.", "信息编号不存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("information number does not exist.", "信息编号不存在"), Code = BusinessStatusCode.InternalServerError }; } var result = wtiRepository.Update(EntityMapper.Map(w)); if (result) { - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Update Energy Management Success", "水电费信息更新成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Update Energy Management Success", "水电费信息更新成功")); } else { - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Energy Management Failed", "水电费信息更新失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Energy Management Failed", "水电费信息更新失败")); } } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Energy Management Failed", "水电费信息更新失败"), ex); - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Energy Management Failed", "水电费信息更新失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Energy Management Failed", "水电费信息更新失败")); } } @@ -147,25 +154,25 @@ namespace EOM.TSHotelManagement.Application /// 根据房间编号、使用时间删除水电费信息 /// /// - public BaseOutputDto DeleteEnergyManagementInfo(DeleteEnergyManagementInputDto hydroelectricity) + public BaseResponse DeleteEnergyManagementInfo(DeleteEnergyManagementInputDto hydroelectricity) { try { - var result = wtiRepository.Update(EntityMapper.Map(hydroelectricity)); + var result = wtiRepository.SoftDelete(EntityMapper.Map(hydroelectricity)); if (result) { - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Delete Energy Management Success", "水电费信息删除成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Energy Management Success", "水电费信息删除成功")); } else { - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Energy Management Failed", "水电费信息删除失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Energy Management Failed", "水电费信息删除失败")); } } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("Delete Energy Management Failed", "水电费信息删除失败"), ex); - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Energy Management Failed", "水电费信息删除失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Energy Management Failed", "水电费信息删除失败")); } } } diff --git a/EOM.TSHotelManagement.Application/Business/EnergyManagement/IEnergyManagementService.cs b/EOM.TSHotelManagement.Application/Business/EnergyManagement/IEnergyManagementService.cs index 3ca644d..7a230e4 100644 --- a/EOM.TSHotelManagement.Application/Business/EnergyManagement/IEnergyManagementService.cs +++ b/EOM.TSHotelManagement.Application/Business/EnergyManagement/IEnergyManagementService.cs @@ -42,7 +42,7 @@ public interface IEnergyManagementService /// /// /// - BaseOutputDto InsertEnergyManagementInfo(CreateEnergyManagementInputDto w); + BaseResponse InsertEnergyManagementInfo(CreateEnergyManagementInputDto w); /// /// 修改水电费信息 @@ -50,7 +50,7 @@ public interface IEnergyManagementService /// /// 包含要修改的数据,以及WtiNo作为查询条件 /// - BaseOutputDto UpdateEnergyManagementInfo(UpdateEnergyManagementInputDto w); + BaseResponse UpdateEnergyManagementInfo(UpdateEnergyManagementInputDto w); /// /// 根据房间编号、使用时间删除水电费信息 @@ -58,5 +58,5 @@ public interface IEnergyManagementService /// /// /// - BaseOutputDto DeleteEnergyManagementInfo(DeleteEnergyManagementInputDto deleteEnergyManagementInputDto); + BaseResponse DeleteEnergyManagementInfo(DeleteEnergyManagementInputDto deleteEnergyManagementInputDto); } diff --git a/EOM.TSHotelManagement.Application/Business/News/INewsService.cs b/EOM.TSHotelManagement.Application/Business/News/INewsService.cs index 50b1488..4dd4b18 100644 --- a/EOM.TSHotelManagement.Application/Business/News/INewsService.cs +++ b/EOM.TSHotelManagement.Application/Business/News/INewsService.cs @@ -26,18 +26,18 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddNews(AddNewsInputDto addNewsInputDto); + BaseResponse AddNews(AddNewsInputDto addNewsInputDto); /// /// 更新新闻 /// /// /// - BaseOutputDto UpdateNews(UpdateNewsInputDto updateNewsInputDto); + BaseResponse UpdateNews(UpdateNewsInputDto updateNewsInputDto); /// /// 删除新闻 /// /// /// - BaseOutputDto DeleteNews(DeleteNewsInputDto deleteNewsInputDto); + BaseResponse DeleteNews(DeleteNewsInputDto deleteNewsInputDto); } } diff --git a/EOM.TSHotelManagement.Application/Business/News/NewsService.cs b/EOM.TSHotelManagement.Application/Business/News/NewsService.cs index 2da50e8..3f138d2 100644 --- a/EOM.TSHotelManagement.Application/Business/News/NewsService.cs +++ b/EOM.TSHotelManagement.Application/Business/News/NewsService.cs @@ -29,8 +29,6 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectNews(ReadNewsInputDto readNewsInputDto) { - ListOutputDto listOutputDto = new ListOutputDto(); - var helper = new EnumHelper(); var newsTypes = Enum.GetValues(typeof(NewsType)) .Cast() @@ -63,7 +61,7 @@ namespace EOM.TSHotelManagement.Application } if (!readNewsInputDto.NewsType.IsNullOrEmpty()) { - where = where.And(n => n.NewsType == readNewsInputDto.NewsTitle); + where = where.And(n => n.NewsType == readNewsInputDto.NewsType); } if (!readNewsInputDto.NewsStatus.IsNullOrEmpty()) { @@ -76,15 +74,16 @@ namespace EOM.TSHotelManagement.Application if (readNewsInputDto.IgnorePaging) { newsList = _newsRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = newsList.Count; } else { - newsList = _newsRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readNewsInputDto.Page, readNewsInputDto.PageSize,ref count); + newsList = _newsRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readNewsInputDto.Page, readNewsInputDto.PageSize, ref count); } - listOutputDto.listSource = EntityMapper.MapList(newsList); + var mappedList = EntityMapper.MapList(newsList); - listOutputDto.listSource.ForEach(source => + mappedList.ForEach(source => { var newsType = newsTypes.SingleOrDefault(a => a.Name == source.NewsType); source.NewsTypeDescription = newsType?.Description ?? ""; @@ -92,9 +91,14 @@ namespace EOM.TSHotelManagement.Application source.NewsStatusDescription = newsStatus?.Description ?? ""; }); - listOutputDto.total = count; - - return listOutputDto; + return new ListOutputDto + { + Data = new PagedData + { + Items = mappedList, + TotalCount = count + } + }; } /// @@ -109,7 +113,7 @@ namespace EOM.TSHotelManagement.Application { return new SingleOutputDto { - StatusCode = StatusCodeConstants.NotFound, + Code = BusinessStatusCode.NotFound, Message = "新闻未找到" }; } @@ -139,7 +143,7 @@ namespace EOM.TSHotelManagement.Application return new SingleOutputDto { - Source = outputDto + Data = outputDto }; } @@ -148,7 +152,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddNews(AddNewsInputDto addNewsInputDto) + public BaseResponse AddNews(AddNewsInputDto addNewsInputDto) { var news = new News { @@ -163,19 +167,27 @@ namespace EOM.TSHotelManagement.Application }; try { - _newsRepository.Insert(news); + var result = _newsRepository.Insert(news); + if (!result) + { + return new BaseResponse + { + Code = BusinessStatusCode.InternalServerError, + Message = "新闻添加失败" + }; + } } catch (Exception ex) { - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.InternalServerError, + Code = BusinessStatusCode.InternalServerError, Message = $"新闻添加失败: {ex.Message}" }; } - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.Success, + Code = BusinessStatusCode.Success, Message = "新闻添加成功" }; } @@ -185,14 +197,14 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateNews(UpdateNewsInputDto updateNewsInputDto) + public BaseResponse UpdateNews(UpdateNewsInputDto updateNewsInputDto) { var news = _newsRepository.AsQueryable().Where(a => a.NewId == updateNewsInputDto.NewId).Single(); if (news.IsNullOrEmpty()) { - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.NotFound, + Code = BusinessStatusCode.NotFound, Message = "新闻未找到" }; } @@ -205,19 +217,27 @@ namespace EOM.TSHotelManagement.Application news.NewsImage = updateNewsInputDto.NewsImage; try { - _newsRepository.Update(news); + var result = _newsRepository.Update(news); + if (!result) + { + return new BaseResponse + { + Code = BusinessStatusCode.InternalServerError, + Message = "新闻更新失败" + }; + } } catch (Exception ex) { - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.InternalServerError, + Code = BusinessStatusCode.InternalServerError, Message = $"新闻更新失败: {ex.Message}" }; } - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.Success, + Code = BusinessStatusCode.Success, Message = "新闻更新成功" }; } @@ -227,32 +247,33 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteNews(DeleteNewsInputDto deleteNewsInputDto) + public BaseResponse DeleteNews(DeleteNewsInputDto deleteNewsInputDto) { var news = _newsRepository.AsQueryable().Where(a => a.NewId == deleteNewsInputDto.NewId).Single(); if (news.IsNullOrEmpty()) { - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.NotFound, + Code = BusinessStatusCode.NotFound, Message = "新闻未找到" }; } try { - _newsRepository.Delete(news); + news.IsDelete = 1; + _newsRepository.SoftDelete(news); } catch (Exception ex) { - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.InternalServerError, + Code = BusinessStatusCode.InternalServerError, Message = $"新闻删除失败: {ex.Message}" }; } - return new BaseOutputDto + return new BaseResponse { - StatusCode = StatusCodeConstants.Success, + Code = BusinessStatusCode.Success, Message = "新闻删除成功" }; } diff --git a/EOM.TSHotelManagement.Application/Business/PromotionContent/IPromotionContentService.cs b/EOM.TSHotelManagement.Application/Business/PromotionContent/IPromotionContentService.cs index 0746465..a0b3c16 100644 --- a/EOM.TSHotelManagement.Application/Business/PromotionContent/IPromotionContentService.cs +++ b/EOM.TSHotelManagement.Application/Business/PromotionContent/IPromotionContentService.cs @@ -47,20 +47,20 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddPromotionContent(CreatePromotionContentInputDto createPromotionContentInputDto); + BaseResponse AddPromotionContent(CreatePromotionContentInputDto createPromotionContentInputDto); /// /// 删除宣传联动内容 /// /// /// - BaseOutputDto DeletePromotionContent(DeletePromotionContentInputDto deletePromotionContentInputDto); + BaseResponse DeletePromotionContent(DeletePromotionContentInputDto deletePromotionContentInputDto); /// /// 更新宣传联动内容 /// /// /// - BaseOutputDto UpdatePromotionContent(UpdatePromotionContentInputDto updatePromotionContentInputDto); + BaseResponse UpdatePromotionContent(UpdatePromotionContentInputDto updatePromotionContentInputDto); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/Business/PromotionContent/PromotionContentService.cs b/EOM.TSHotelManagement.Application/Business/PromotionContent/PromotionContentService.cs index 4ffe9a0..074a652 100644 --- a/EOM.TSHotelManagement.Application/Business/PromotionContent/PromotionContentService.cs +++ b/EOM.TSHotelManagement.Application/Business/PromotionContent/PromotionContentService.cs @@ -55,28 +55,33 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectPromotionContentAll(ReadPromotionContentInputDto readPromotionContentInputDto) { - ListOutputDto fonts = new ListOutputDto(); var count = 0; var where = Expressionable.Create(); if (!readPromotionContentInputDto.IsDelete.IsNullOrEmpty()) { where = where.And(a => a.IsDelete == readPromotionContentInputDto.IsDelete); } - var listSource = new List(); + var Data = new List(); if (!readPromotionContentInputDto.IgnorePaging && readPromotionContentInputDto.Page != 0 && readPromotionContentInputDto.PageSize != 0) { - listSource = fontsRepository.AsQueryable() + Data = fontsRepository.AsQueryable() .Where(where.ToExpression()) .ToPageList(readPromotionContentInputDto.Page, readPromotionContentInputDto.PageSize, ref count); } else { - listSource = fontsRepository.AsQueryable().ToList(); + Data = fontsRepository.AsQueryable().ToList(); + count = Data.Count; } - - fonts.listSource = EntityMapper.MapList(listSource); - fonts.total = count; - return fonts; + var mapped = EntityMapper.MapList(Data); + return new ListOutputDto + { + Data = new PagedData + { + Items = mapped, + TotalCount = count + } + }; } /// @@ -85,10 +90,16 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectPromotionContents() { - ListOutputDto fonts = new ListOutputDto(); - var listSource = fontsRepository.AsQueryable().Where(a => a.IsDelete != 1).ToList(); - fonts.listSource = EntityMapper.MapList(listSource); - return fonts; + var Data = fontsRepository.AsQueryable().Where(a => a.IsDelete != 1).ToList(); + var mapped = EntityMapper.MapList(Data); + return new ListOutputDto + { + Data = new PagedData + { + Items = mapped, + TotalCount = mapped.Count + } + }; } /// @@ -96,19 +107,25 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddPromotionContent(CreatePromotionContentInputDto createPromotionContentInputDto) + public BaseResponse AddPromotionContent(CreatePromotionContentInputDto createPromotionContentInputDto) { try { - fontsRepository.Insert(EntityMapper.Map(createPromotionContentInputDto)); + 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", "宣传联动内容添加失败")); + } } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("Insert Promotion Content Failed", "宣传联动内容添加失败"), ex); - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Promotion Content Failed", "宣传联动内容添加失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Insert Promotion Content Failed", "宣传联动内容添加失败")); } - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Insert Promotion Content Success", "宣传联动内容添加成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Insert Promotion Content Success", "宣传联动内容添加成功")); } /// @@ -116,24 +133,26 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeletePromotionContent(DeletePromotionContentInputDto deletePromotionContentInputDto) + public BaseResponse DeletePromotionContent(DeletePromotionContentInputDto deletePromotionContentInputDto) { try { - fontsRepository.Update(a => new PromotionContent + fontsRepository.SoftDelete(new PromotionContent { + Id = deletePromotionContentInputDto.Id, + PromotionContentNumber = deletePromotionContentInputDto.PromotionContentNumber, IsDelete = deletePromotionContentInputDto.IsDelete, DataChgUsr = deletePromotionContentInputDto.DataChgUsr, DataChgDate = deletePromotionContentInputDto.DataChgDate - }, a => a.PromotionContentNumber == deletePromotionContentInputDto.PromotionContentNumber); + }); } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("Delete Promotion Content Failed", "宣传联动内容删除失败"), ex); - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Promotion Content Failed", "宣传联动内容删除失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Promotion Content Failed", "宣传联动内容删除失败")); } - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Delete Promotion Content Success", "宣传联动内容删除成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Promotion Content Success", "宣传联动内容删除成功")); } /// @@ -141,19 +160,25 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdatePromotionContent(UpdatePromotionContentInputDto updatePromotionContentInputDto) + public BaseResponse UpdatePromotionContent(UpdatePromotionContentInputDto updatePromotionContentInputDto) { try { - fontsRepository.Update(EntityMapper.Map(updatePromotionContentInputDto)); + 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", "宣传联动内容更新失败")); + } } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Promotion Content Failed", "宣传联动内容更新失败"), ex); - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Promotion Content Failed", "宣传联动内容更新失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Promotion Content Failed", "宣传联动内容更新失败")); } - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Update Promotion Content Success", "宣传联动内容更新成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Update Promotion Content Success", "宣传联动内容更新成功")); } } diff --git a/EOM.TSHotelManagement.Application/Business/Reser/IReserService.cs b/EOM.TSHotelManagement.Application/Business/Reser/IReserService.cs index 3abca1d..431543c 100644 --- a/EOM.TSHotelManagement.Application/Business/Reser/IReserService.cs +++ b/EOM.TSHotelManagement.Application/Business/Reser/IReserService.cs @@ -49,21 +49,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto DeleteReserInfo(DeleteReserInputDto reser); + BaseResponse DeleteReserInfo(DeleteReserInputDto reser); /// /// 更新预约信息 /// /// /// - BaseOutputDto UpdateReserInfo(UpdateReserInputDto reser); + BaseResponse UpdateReserInfo(UpdateReserInputDto reser); /// /// 添加预约信息 /// /// /// - BaseOutputDto InserReserInfo(CreateReserInputDto r); + BaseResponse InserReserInfo(CreateReserInputDto r); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs b/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs index 722d841..7d787df 100644 --- a/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs +++ b/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs @@ -27,6 +27,7 @@ using EOM.TSHotelManagement.Common.Util; using EOM.TSHotelManagement.EntityFramework; using EOM.TSHotelManagement.Shared; using SqlSugar; +using System.Transactions; namespace EOM.TSHotelManagement.Application { @@ -69,30 +70,23 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectReserAll(ReadReserInputDto readReserInputDto) { - ListOutputDto rss = new ListOutputDto(); - var where = Expressionable.Create(); - where = where.And(a => a.IsDelete == readReserInputDto.IsDelete); - var count = 0; - - var listSource = new List(); - + var Data = new List(); if (!readReserInputDto.IgnorePaging && readReserInputDto.Page != 0 && readReserInputDto.PageSize != 0) { - listSource = reserRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readReserInputDto.Page, readReserInputDto.PageSize, ref count); + Data = reserRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readReserInputDto.Page, readReserInputDto.PageSize, ref count); } else { - listSource = reserRepository.AsQueryable().Where(where.ToExpression()).ToList(); + Data = reserRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = Data.Count; } - - listSource.ForEach(source => + Data.ForEach(source => { try { - //解密联系方式 var sourceTelStr = dataProtector.DecryptReserData(source.ReservationPhoneNumber); source.ReservationPhoneNumber = sourceTelStr; } @@ -101,10 +95,15 @@ namespace EOM.TSHotelManagement.Application source.ReservationPhoneNumber = source.ReservationPhoneNumber; } }); - - rss.listSource = EntityMapper.MapList(listSource); - rss.total = count; - return rss; + var mapped = EntityMapper.MapList(Data); + return new ListOutputDto + { + Data = new PagedData + { + Items = mapped, + TotalCount = count + } + }; } /// @@ -115,14 +114,14 @@ namespace EOM.TSHotelManagement.Application public SingleOutputDto SelectReserInfoByRoomNo(ReadReserInputDto readReserInputDt) { Reser res = null; - res = reserRepository.GetSingle(a => a.ReservationRoomNumber == readReserInputDt.ReservationRoomNumber && a.IsDelete != 1); + res = reserRepository.GetFirst(a => a.ReservationRoomNumber == readReserInputDt.ReservationRoomNumber && a.IsDelete != 1); //解密联系方式 var sourceTelStr = dataProtector.DecryptReserData(res.ReservationPhoneNumber); res.ReservationPhoneNumber = sourceTelStr; var outputReser = EntityMapper.Map(res); - return new SingleOutputDto { Source = outputReser }; + return new SingleOutputDto { Data = outputReser }; } /// @@ -130,24 +129,33 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteReserInfo(DeleteReserInputDto reser) + public BaseResponse DeleteReserInfo(DeleteReserInputDto reser) { - var reserInfo = reserRepository.GetSingle(a => a.ReservationId == reser.ReservationId); - var result = reserRepository.Update(a => new Reser() - { - IsDelete = reser.IsDelete, - DataChgUsr = reser.DataChgUsr, - DataChgDate = reser.DataChgDate - }, a => a.ReservationId == reser.ReservationId); + var reserInfo = reserRepository.GetFirst(a => a.ReservationId == reser.ReservationId); - if (result) - { - roomRepository.Update(a => new Room { RoomStateId = (int)RoomState.Vacant }, a => a.RoomNumber.Equals(reserInfo.ReservationRoomNumber)); - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Delete Reser Success", "预约信息删除成功")); - } - else + using (TransactionScope scope = new TransactionScope()) { - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Reser Failed", "预约信息删除失败")); + var result = reserRepository.SoftDelete(new Reser() + { + Id = reserInfo.Id, + ReservationId = reser.ReservationId, + IsDelete = reser.IsDelete, + DataChgUsr = reser.DataChgUsr, + DataChgDate = reser.DataChgDate + }); + + if (result) + { + 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 + { + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Reser Failed", "预约信息删除失败")); + } } } @@ -156,27 +164,27 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateReserInfo(UpdateReserInputDto reser) + public BaseResponse UpdateReserInfo(UpdateReserInputDto reser) { string NewTel = dataProtector.EncryptReserData(reser.ReservationPhoneNumber); reser.ReservationPhoneNumber = NewTel; try { - var result = reserRepository.Update(EntityMapper.Map(reser)); - + var entity = EntityMapper.Map(reser); + var result = reserRepository.Update(entity); if (result) { - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Update Customer Success", "预约信息更新成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Update Customer Success", "预约信息更新成功")); } else { - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息更新失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息更新失败")); } } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息添加失败"), ex); - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息更新失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Customer Failed", "预约信息更新失败")); } } @@ -185,33 +193,35 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto InserReserInfo(CreateReserInputDto r) + public BaseResponse InserReserInfo(CreateReserInputDto r) { string NewTel = dataProtector.EncryptReserData(r.ReservationPhoneNumber); r.ReservationPhoneNumber = NewTel; try { - var result = reserRepository.Insert(EntityMapper.Map(r)); - + var entity = EntityMapper.Map(r); + var result = reserRepository.Insert(entity); if (result) { - roomRepository.Update(a => new Room() + var room = roomRepository.GetFirst(a => a.RoomNumber == r.ReservationRoomNumber); + room.RoomStateId = new EnumHelper().GetEnumValue(RoomState.Reserved); + var updateResult = roomRepository.Update(room); + + if (!updateResult) { - RoomStateId = new EnumHelper().GetEnumValue(RoomState.Reserved), - DataChgUsr = r.DataChgUsr, - DataChgDate = r.DataChgDate - }, a => a.RoomNumber == r.ReservationRoomNumber); - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Add Customer Success", "预约信息添加成功")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败")); + } + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Add Customer Success", "预约信息添加成功")); } else { - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败")); } } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败"), ex); - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Add Customer Failed", "预约信息添加失败")); } } } diff --git a/EOM.TSHotelManagement.Application/Business/Room/IRoomService.cs b/EOM.TSHotelManagement.Application/Business/Room/IRoomService.cs index af183f5..8824bc2 100644 --- a/EOM.TSHotelManagement.Application/Business/Room/IRoomService.cs +++ b/EOM.TSHotelManagement.Application/Business/Room/IRoomService.cs @@ -87,7 +87,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto UpdateRoomInfo(UpdateRoomInputDto r); + BaseResponse UpdateRoomInfo(UpdateRoomInputDto r); #endregion #region 根据房间编号修改房间信息(预约) @@ -96,7 +96,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto UpdateRoomInfoWithReser(UpdateRoomInputDto r); + BaseResponse UpdateRoomInfoWithReser(UpdateRoomInputDto r); #endregion #region 查询可入住房间数量 @@ -153,7 +153,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto UpdateRoomStateByRoomNo(UpdateRoomInputDto readRoomInputDto); + BaseResponse UpdateRoomStateByRoomNo(UpdateRoomInputDto readRoomInputDto); #endregion /// @@ -161,21 +161,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto TransferRoom(TransferRoomDto transferRoomDto); + BaseResponse TransferRoom(TransferRoomDto transferRoomDto); /// /// 退房操作 /// /// /// - BaseOutputDto CheckoutRoom(CheckoutRoomDto checkoutRoomDto); + BaseResponse CheckoutRoom(CheckoutRoomDto checkoutRoomDto); /// /// 根据预约信息办理入住 /// /// /// - BaseOutputDto CheckinRoomByReservation(CheckinRoomByReservationDto checkinRoomByReservationDto); + BaseResponse CheckinRoomByReservation(CheckinRoomByReservationDto checkinRoomByReservationDto); #region 添加房间 /// @@ -183,7 +183,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto InsertRoom(CreateRoomInputDto rn); + BaseResponse InsertRoom(CreateRoomInputDto rn); #endregion #region 更新房间 @@ -192,7 +192,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto UpdateRoom(UpdateRoomInputDto rn); + BaseResponse UpdateRoom(UpdateRoomInputDto rn); #endregion #region 删除房间 @@ -201,7 +201,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto DeleteRoom(DeleteRoomInputDto rn); + BaseResponse DeleteRoom(DeleteRoomInputDto rn); #endregion } diff --git a/EOM.TSHotelManagement.Application/Business/Room/IRoomTypeService.cs b/EOM.TSHotelManagement.Application/Business/Room/IRoomTypeService.cs index 3196fd4..c385b77 100644 --- a/EOM.TSHotelManagement.Application/Business/Room/IRoomTypeService.cs +++ b/EOM.TSHotelManagement.Application/Business/Room/IRoomTypeService.cs @@ -48,20 +48,20 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto InsertRoomType(CreateRoomTypeInputDto readRoomTypeInputDto); + BaseResponse InsertRoomType(CreateRoomTypeInputDto readRoomTypeInputDto); /// /// 更新房间状态 /// /// /// - BaseOutputDto UpdateRoomType(UpdateRoomTypeInputDto roomType); + BaseResponse UpdateRoomType(UpdateRoomTypeInputDto roomType); /// /// 删除房间状态 /// /// /// - BaseOutputDto DeleteRoomType(DeleteRoomTypeInputDto roomType); + BaseResponse DeleteRoomType(DeleteRoomTypeInputDto roomType); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs b/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs index 315861e..0732def 100644 --- a/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs +++ b/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs @@ -115,32 +115,36 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectRoomByRoomState(ReadRoomInputDto readRoomInputDto) { - List roomStates = new List(); - var helper = new EnumHelper(); - roomStates = Enum.GetValues(typeof(RoomState)) - .Cast() - .Select(e => new EnumDto + var where = Expressionable.Create(); + + if (readRoomInputDto.RoomStateId > 0) { - Id = (int)e, - Name = e.ToString(), - Description = helper.GetEnumDescription(e) - }) - .ToList(); - List roomTypes = new List(); - roomTypes = roomTypeRepository.GetList(a => a.IsDelete != 1); + where = where.And(a => a.RoomStateId == readRoomInputDto.RoomStateId); + } + + var count = 0; List rooms = new List(); - rooms = roomRepository.GetList(a => a.IsDelete != 1 && a.RoomStateId == readRoomInputDto.RoomStateId).OrderBy(a => a.RoomNumber).ToList(); - rooms.ForEach(source => + + if (!readRoomInputDto.IgnorePaging && readRoomInputDto.Page != 0 && readRoomInputDto.PageSize != 0) + { + rooms = roomRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readRoomInputDto.Page, readRoomInputDto.PageSize, ref count); + } + else { - var roomState = roomStates.SingleOrDefault(a => a.Id == source.RoomStateId); - source.RoomState = roomState.Description.IsNullOrEmpty() ? "" : roomState.Description; - var roomType = roomTypes.SingleOrDefault(a => a.RoomTypeId == source.RoomTypeId); - source.RoomName = roomType.RoomTypeName.IsNullOrEmpty() ? "" : roomType.RoomTypeName; - }); + rooms = roomRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = rooms.Count; + } - var listSource = EntityMapper.MapList(rooms); + var result = EntityMapper.MapList(rooms); - return new ListOutputDto { listSource = listSource }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// @@ -149,32 +153,16 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectCanUseRoomAll() { - List roomStates = new List(); - var helper = new EnumHelper(); - roomStates = Enum.GetValues(typeof(RoomState)) - .Cast() - .Select(e => new EnumDto - { - Id = (int)e, - Name = e.ToString(), - Description = helper.GetEnumDescription(e) - }) - .ToList(); - List roomTypes = new List(); - roomTypes = roomTypeRepository.GetList(); - List rooms = new List(); - rooms = roomRepository.GetList(a => a.IsDelete != 1 && a.RoomStateId == (int)RoomState.Vacant).OrderBy(a => a.RoomNumber).ToList(); - rooms.ForEach(source => + var rooms = roomRepository.GetList(a => a.RoomStateId == (int)RoomState.Vacant); + var result = EntityMapper.MapList(rooms); + return new ListOutputDto { - var roomState = roomStates.SingleOrDefault(a => a.Id == source.RoomStateId); - source.RoomState = roomState.Description.IsNullOrEmpty() ? "" : roomState.Description; - var roomType = roomTypes.SingleOrDefault(a => a.RoomTypeId == source.RoomTypeId); - source.RoomName = roomType.RoomTypeName.IsNullOrEmpty() ? "" : roomType.RoomTypeName; - }); - - var listSource = EntityMapper.MapList(rooms); - - return new ListOutputDto { listSource = listSource }; + Data = new PagedData + { + Items = result, + TotalCount = result.Count + } + }; } /// @@ -185,61 +173,50 @@ namespace EOM.TSHotelManagement.Application { var where = Expressionable.Create(); - where = where.And(a => a.IsDelete == readRoomInputDto.IsDelete); - - if (readRoomInputDto.RoomStateId > 0) + if (!readRoomInputDto.IsDelete.IsNullOrEmpty()) { - where = where.And(a => a.RoomStateId == readRoomInputDto.RoomStateId); + where = where.And(a => a.IsDelete == readRoomInputDto.IsDelete); } - List roomStates = new List(); - var helper = new EnumHelper(); - roomStates = Enum.GetValues(typeof(RoomState)) - .Cast() - .Select(e => new EnumDto - { - Id = (int)e, - Name = e.ToString(), - Description = helper.GetEnumDescription(e) - }) - .ToList(); - List roomTypes = new List(); - roomTypes = roomTypeRepository.GetList(); - List rooms = new List(); - var count = 0; + List rooms = new List(); if (!readRoomInputDto.IgnorePaging && readRoomInputDto.Page != 0 && readRoomInputDto.PageSize != 0) { - rooms = roomRepository.AsQueryable().Where(where.ToExpression()).OrderBy(a => a.RoomNumber).ToPageList(readRoomInputDto.Page, readRoomInputDto.PageSize, ref count); + rooms = roomRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readRoomInputDto.Page, readRoomInputDto.PageSize, ref count); } else { - rooms = roomRepository.GetList(a => a.IsDelete != 1).OrderBy(a => a.RoomNumber).ToList(); + rooms = roomRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = rooms.Count; } - var listCustoNo = rooms.Select(a => a.CustomerNumber).Distinct().ToList(); - List custos = new List(); - custos = custoRepository.GetList(a => listCustoNo.Contains(a.CustomerNumber)); - - rooms.ForEach(source => + var result = EntityMapper.MapList(rooms); + var roomTypes = roomTypeRepository.AsQueryable().Where(a => a.IsDelete != 1).ToList(); + foreach (var item in result) { - var roomState = roomStates.SingleOrDefault(a => a.Id == source.RoomStateId); - source.RoomState = roomState.Description.IsNullOrEmpty() ? "" : roomState.Description; - var roomType = roomTypes.SingleOrDefault(a => a.RoomTypeId == source.RoomTypeId); - source.RoomName = roomType.RoomTypeName.IsNullOrEmpty() ? "" : roomType.RoomTypeName; - - var custo = custos.SingleOrDefault(a => a.CustomerNumber.Equals(source.CustomerNumber)); - source.CustomerName = custo.IsNullOrEmpty() ? "" : custo.CustomerName; - - //把入住时间格式化 - source.LastCheckInTimeFormatted = (source.LastCheckInTime + "").IsNullOrEmpty() ? "" - : source.LastCheckInTime.ToString(); - - }); - var listSource = EntityMapper.MapList(rooms); - - return new ListOutputDto { listSource = listSource, total = count }; + var helper = new EnumHelper(); + var roomStates = Enum.GetValues(typeof(RoomState)) + .Cast() + .Select(e => new EnumDto + { + Id = (int)e, + Name = e.ToString(), + Description = helper.GetEnumDescription(e) + }) + .ToList(); + item.RoomState = roomStates.Where(a => a.Id == item.RoomStateId).Single().Description; + var roomType = roomTypes.Single(a => a.RoomTypeId == item.RoomTypeId); + item.RoomName = roomType.RoomTypeName; + } + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// @@ -248,39 +225,37 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectRoomByTypeName(ReadRoomInputDto readRoomInputDto) { - List roomStates = new List(); - var helper = new EnumHelper(); - roomStates = Enum.GetValues(typeof(RoomState)) - .Cast() - .Select(e => new EnumDto + var where = Expressionable.Create(); + + if (!readRoomInputDto.RoomTypeName.IsNullOrEmpty()) { - Id = (int)e, - Name = e.ToString(), - Description = helper.GetEnumDescription(e) - }) - .ToList(); - List roomTypes = new List(); - roomTypes = roomTypeRepository.GetList(a => a.IsDelete != 1 && a.RoomTypeName == readRoomInputDto.RoomTypeName); - var listTypes = roomTypes.Select(a => a.RoomTypeId).Distinct().ToList(); + var roomType = roomTypeRepository.GetFirst(a => a.RoomTypeName == readRoomInputDto.RoomTypeName); + where = where.And(a => a.RoomTypeId == roomType.RoomTypeId); + } + + var count = 0; List rooms = new List(); - rooms = roomRepository.GetList(a => a.IsDelete != 1 && listTypes.Contains(a.RoomTypeId)).OrderBy(a => a.RoomNumber).ToList(); - var listCustoNo = rooms.Select(a => a.CustomerNumber).Distinct().ToList(); - List custos = new List(); - custos = custoRepository.GetList(a => listCustoNo.Contains(a.CustomerNumber)); - rooms.ForEach(source => - { - var roomState = roomStates.SingleOrDefault(a => a.Id == source.RoomStateId); - source.RoomState = roomState.Description.IsNullOrEmpty() ? "" : roomState.Description; - var roomType = roomTypes.SingleOrDefault(a => a.RoomTypeId == source.RoomTypeId); - source.RoomName = roomType.RoomTypeName.IsNullOrEmpty() ? "" : roomType.RoomTypeName; - var custo = custos.SingleOrDefault(a => a.CustomerNumber.Equals(source.CustomerNumber)); - source.CustomerName = custo.IsNullOrEmpty() ? "" : custo.CustomerName; + if (!readRoomInputDto.IgnorePaging && readRoomInputDto.Page != 0 && readRoomInputDto.PageSize != 0) + { + rooms = roomRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readRoomInputDto.Page, readRoomInputDto.PageSize, ref count); + } + else + { + rooms = roomRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = rooms.Count; + } - }); - var listSource = EntityMapper.MapList(rooms); + var result = EntityMapper.MapList(rooms); - return new ListOutputDto { listSource = listSource }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// @@ -302,12 +277,12 @@ namespace EOM.TSHotelManagement.Application }) .ToList(); Room room = new Room(); - room = roomRepository.GetSingle(a => a.IsDelete != 1 && a.RoomNumber == readRoomInputDto.RoomNumber); + room = roomRepository.GetFirst(a => a.IsDelete != 1 && a.RoomNumber == readRoomInputDto.RoomNumber); if (!room.IsNullOrEmpty()) { var roomSate = roomStates.SingleOrDefault(a => a.Id == room.RoomStateId); room.RoomState = roomSate.Description.IsNullOrEmpty() ? "" : roomSate.Description; - var roomType = roomTypeRepository.GetSingle(a => a.RoomTypeId == room.RoomTypeId); + var roomType = roomTypeRepository.GetFirst(a => a.RoomTypeId == room.RoomTypeId); room.RoomName = roomType.RoomTypeName.IsNullOrEmpty() ? "" : roomType.RoomTypeName; } else @@ -315,9 +290,9 @@ namespace EOM.TSHotelManagement.Application room = new Room(); } - var Source = EntityMapper.Map(room); + var Data = EntityMapper.Map(room); - return new SingleOutputDto() { Source = Source }; + return new SingleOutputDto() { Data = Data }; } /// @@ -327,13 +302,13 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto DayByRoomNo(ReadRoomInputDto roomInputDto) { - var room = roomRepository.GetSingle(a => a.RoomNumber == roomInputDto.RoomNumber); + var room = roomRepository.GetFirst(a => a.RoomNumber == roomInputDto.RoomNumber); if (room?.LastCheckInTime != null) { var days = Math.Abs((room.LastCheckInTime.Value.ToDateTime(TimeOnly.MinValue) - DateTime.Now).Days); - return new SingleOutputDto { Source = new ReadRoomOutputDto { StayDays = days } }; + return new SingleOutputDto { Data = new ReadRoomOutputDto { StayDays = days } }; } - return new SingleOutputDto { Source = new ReadRoomOutputDto { StayDays = 0 } }; + return new SingleOutputDto { Data = new ReadRoomOutputDto { StayDays = 0 } }; } /// @@ -341,24 +316,26 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateRoomInfo(UpdateRoomInputDto r) + public BaseResponse UpdateRoomInfo(UpdateRoomInputDto r) { try { - roomRepository.Update(a => new Room() + roomRepository.Update(new Room() { + Id = r.Id, + RoomNumber = r.RoomNumber, LastCheckInTime = r.LastCheckInTime, RoomStateId = r.RoomStateId, CustomerNumber = r.CustomerNumber, DataChgDate = r.DataChgDate, DataChgUsr = r.DataChgUsr, - }, a => a.RoomNumber == r.RoomNumber); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -366,22 +343,24 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateRoomInfoWithReser(UpdateRoomInputDto r) + public BaseResponse UpdateRoomInfoWithReser(UpdateRoomInputDto r) { try { - roomRepository.Update(a => new Room() + roomRepository.Update(new Room() { + Id = r.Id, + RoomNumber = r.RoomNumber, RoomStateId = r.RoomStateId, DataChgUsr = r.DataChgUsr, DataInsDate = r.DataInsDate, - }, a => a.RoomNumber == r.RoomNumber); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -395,7 +374,7 @@ namespace EOM.TSHotelManagement.Application var count = roomRepository.Count(a => a.RoomStateId == (int)RoomState.Vacant && a.IsDelete != 1); return new SingleOutputDto { - Source = new ReadRoomOutputDto { Vacant = count } + Data = new ReadRoomOutputDto { Vacant = count } }; } catch (Exception ex) @@ -403,7 +382,7 @@ namespace EOM.TSHotelManagement.Application return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), - StatusCode = StatusCodeConstants.InternalServerError + Code = BusinessStatusCode.InternalServerError }; } } @@ -419,7 +398,7 @@ namespace EOM.TSHotelManagement.Application var count = roomRepository.Count(a => a.RoomStateId == (int)RoomState.Occupied && a.IsDelete != 1); return new SingleOutputDto { - Source = new ReadRoomOutputDto { Occupied = count } + Data = new ReadRoomOutputDto { Occupied = count } }; } catch (Exception ex) @@ -427,7 +406,7 @@ namespace EOM.TSHotelManagement.Application return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), - StatusCode = StatusCodeConstants.InternalServerError + Code = BusinessStatusCode.InternalServerError }; } } @@ -438,7 +417,7 @@ namespace EOM.TSHotelManagement.Application /// public object SelectRoomByRoomPrice(ReadRoomInputDto r) { - return roomRepository.GetSingle(a => a.RoomNumber == r.RoomNumber).RoomRent; + return roomRepository.GetFirst(a => a.RoomNumber == r.RoomNumber).RoomRent; } /// @@ -452,7 +431,7 @@ namespace EOM.TSHotelManagement.Application var count = roomRepository.Count(a => a.RoomStateId == (int)RoomState.Dirty && a.IsDelete != 1); return new SingleOutputDto { - Source = new ReadRoomOutputDto { Dirty = count } + Data = new ReadRoomOutputDto { Dirty = count } }; } catch (Exception ex) @@ -460,7 +439,7 @@ namespace EOM.TSHotelManagement.Application return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), - StatusCode = StatusCodeConstants.InternalServerError + Code = BusinessStatusCode.InternalServerError }; } } @@ -476,7 +455,7 @@ namespace EOM.TSHotelManagement.Application var count = roomRepository.Count(a => a.RoomStateId == (int)RoomState.Maintenance && a.IsDelete != 1); return new SingleOutputDto { - Source = new ReadRoomOutputDto { Maintenance = count } + Data = new ReadRoomOutputDto { Maintenance = count } }; } catch (Exception ex) @@ -484,7 +463,7 @@ namespace EOM.TSHotelManagement.Application return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), - StatusCode = StatusCodeConstants.InternalServerError + Code = BusinessStatusCode.InternalServerError }; } } @@ -500,7 +479,7 @@ namespace EOM.TSHotelManagement.Application var count = roomRepository.Count(a => a.RoomStateId == (int)RoomState.Reserved && a.IsDelete != 1); return new SingleOutputDto { - Source = new ReadRoomOutputDto { Reserved = count } + Data = new ReadRoomOutputDto { Reserved = count } }; } catch (Exception ex) @@ -508,7 +487,7 @@ namespace EOM.TSHotelManagement.Application return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), - StatusCode = StatusCodeConstants.InternalServerError + Code = BusinessStatusCode.InternalServerError }; } } @@ -518,20 +497,23 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateRoomStateByRoomNo(UpdateRoomInputDto updateRoomInputDto) + public BaseResponse UpdateRoomStateByRoomNo(UpdateRoomInputDto updateRoomInputDto) { try { - roomRepository.Update(a => new Room() + var room = roomRepository.GetFirst(a => a.RoomNumber == updateRoomInputDto.RoomNumber); + roomRepository.Update(new Room() { + Id = room.Id, + RoomNumber = room.RoomNumber, RoomStateId = updateRoomInputDto.RoomStateId - }, a => a.RoomNumber == updateRoomInputDto.RoomNumber); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -539,22 +521,29 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto InsertRoom(CreateRoomInputDto rn) + public BaseResponse InsertRoom(CreateRoomInputDto rn) { try { - var isExist = roomRepository.IsAny(a => a.RoomNumber == rn.RoomNumber); + var isExist = roomRepository.IsAny(a => a.RoomNumber == rn.RoomNumber && a.IsDelete != 1); if (isExist) - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("This room already exists.", "房间已存在。"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("This room already exists.", "房间已存在。"), Code = BusinessStatusCode.InternalServerError }; - roomRepository.Insert(EntityMapper.Map(rn)); + 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 }; + } } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -562,21 +551,27 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateRoom(UpdateRoomInputDto rn) + public BaseResponse UpdateRoom(UpdateRoomInputDto rn) { try { var isExist = roomRepository.IsAny(a => a.RoomNumber == rn.RoomNumber); if (!isExist) - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("This room does not exist.", "房间不存在。"), StatusCode = StatusCodeConstants.InternalServerError }; - roomRepository.Update(EntityMapper.Map(rn)); + 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 }; + } } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -584,21 +579,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteRoom(DeleteRoomInputDto rn) + public BaseResponse DeleteRoom(DeleteRoomInputDto rn) { try { var isExist = roomRepository.IsAny(a => a.RoomNumber == rn.RoomNumber); if (!isExist) - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("This room does not exist.", "房间不存在。"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("This room does not exist.", "房间不存在。"), Code = BusinessStatusCode.InternalServerError }; roomRepository.Update(EntityMapper.Map(rn)); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -606,43 +601,43 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto TransferRoom(TransferRoomDto transferRoomDto) + public BaseResponse TransferRoom(TransferRoomDto transferRoomDto) { try { using (TransactionScope scope = new TransactionScope()) { - var customer = custoRepository.GetSingle(a => a.CustomerNumber == transferRoomDto.CustomerNumber && a.IsDelete != 1); + var customer = custoRepository.GetFirst(a => a.CustomerNumber == transferRoomDto.CustomerNumber && a.IsDelete != 1); if (customer.IsNullOrEmpty()) - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("The customer does not exist", "客户不存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("The customer does not exist", "客户不存在"), Code = BusinessStatusCode.InternalServerError }; var originalSpends = spendRepository.GetList(a => a.RoomNumber == transferRoomDto.OriginalRoomNumber - && a.CustomerNumber == transferRoomDto.CustomerNumber && a.SettlementStatus == SpendConsts.UnSettle.Code + && a.CustomerNumber == transferRoomDto.CustomerNumber && a.SettlementStatus == ConsumptionConstant.UnSettle.Code && a.IsDelete == 0).ToList(); var vipRules = vipLevelRuleRepository.GetList(a => a.IsDelete != 1).ToList(); - var originalRoom = roomRepository.GetSingle(a => a.RoomNumber == transferRoomDto.OriginalRoomNumber); + var originalRoom = roomRepository.GetFirst(a => a.RoomNumber == transferRoomDto.OriginalRoomNumber); if (originalRoom.CustomerNumber != transferRoomDto.CustomerNumber) - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("The customer does not match the original room", "客户与原房间不匹配"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("The customer does not match the original room", "客户与原房间不匹配"), Code = BusinessStatusCode.InternalServerError }; if (!originalRoom.LastCheckInTime.HasValue) - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("The original room lacks check-in time", "原房间缺少入住时间"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("The original room lacks check-in time", "原房间缺少入住时间"), Code = BusinessStatusCode.InternalServerError }; - var targetRoom = roomRepository.GetSingle(a => a.RoomNumber == transferRoomDto.TargetRoomNumber); + var targetRoom = roomRepository.GetFirst(a => a.RoomNumber == transferRoomDto.TargetRoomNumber); if (targetRoom.IsNullOrEmpty()) - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("The room does not exist", "房间不存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("The room does not exist", "房间不存在"), Code = BusinessStatusCode.InternalServerError }; if (targetRoom.RoomStateId != (int)RoomState.Vacant) - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("The room is not vacant", "房间不处于空房状态"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("The room is not vacant", "房间不处于空房状态"), Code = BusinessStatusCode.InternalServerError }; var staySpan = DateTime.Now - originalRoom.LastCheckInTime.Value.ToDateTime(TimeOnly.MinValue); var stayDays = Math.Max((int)Math.Ceiling(staySpan.TotalDays), 1); var originalSpendNumbers = originalSpends.Select(a => a.SpendNumber).ToList(); - var totalSpent = originalSpends.Sum(a => a.ConsumptionAmount); + var TotalCountSpent = originalSpends.Sum(a => a.ConsumptionAmount); var newLevelId = vipRules - .Where(vipRule => totalSpent >= vipRule.RuleValue) + .Where(vipRule => TotalCountSpent >= vipRule.RuleValue) .OrderByDescending(vipRule => vipRule.RuleValue) .ThenByDescending(vipRule => vipRule.VipLevelId) .FirstOrDefault()?.VipLevelId ?? 0; @@ -657,43 +652,51 @@ namespace EOM.TSHotelManagement.Application }, a => a.CustomerNumber == transferRoomDto.CustomerNumber); } - var customerType = custoTypeRepository.GetSingle(a => a.CustomerType == customer.CustomerType); + var customerType = custoTypeRepository.GetFirst(a => a.CustomerType == customer.CustomerType); if (customerType.IsNullOrEmpty()) - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("The customer type does not exist", "客户类型不存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("The customer type does not exist", "客户类型不存在"), Code = BusinessStatusCode.InternalServerError }; decimal discountFactor = customerType.Discount / 100M; decimal originalRoomBill = originalRoom.RoomRent * stayDays * discountFactor; //更新目标房间状态 - roomRepository.Update(a => new Room + roomRepository.Update(new Room { + Id = targetRoom.Id, + RoomNumber = targetRoom.RoomNumber, CustomerNumber = originalRoom.CustomerNumber, LastCheckInTime = DateOnly.FromDateTime(DateTime.Now), RoomStateId = (int)RoomState.Occupied, DataChgDate = transferRoomDto.DataChgDate, DataChgUsr = transferRoomDto.DataChgUsr - }, a => a.RoomNumber == targetRoom.RoomNumber); + }); //更新原房间状态 - roomRepository.Update(a => new Room + roomRepository.Update(new Room { + Id = originalRoom.Id, + RoomNumber = originalRoom.RoomNumber, CustomerNumber = string.Empty, LastCheckInTime = DateOnly.MinValue, LastCheckOutTime = DateOnly.FromDateTime(DateTime.Now), RoomStateId = (int)RoomState.Dirty, DataChgDate = transferRoomDto.DataChgDate, DataChgUsr = transferRoomDto.DataChgUsr - }, a => a.RoomNumber == originalRoom.RoomNumber); + }); //转移原房间消费记录 if (originalSpendNumbers.Count > 0) { - spendRepository.Update(a => new Spend + var originalSpendList = spendRepository.AsQueryable().Where(a => originalSpendNumbers.Contains(a.SpendNumber)).ToList(); + var spends = new List(); + + foreach (var spend in originalSpendList) { - RoomNumber = transferRoomDto.TargetRoomNumber, - DataChgUsr = transferRoomDto.DataChgUsr, - DataChgDate = transferRoomDto.DataChgDate, - }, a => originalSpendNumbers.Contains(a.SpendNumber)); + spend.SpendNumber = spend.SpendNumber; + spend.RoomNumber = transferRoomDto.TargetRoomNumber; + } + + spendRepository.UpdateRange(spends); } //添加旧房间消费记录 @@ -706,7 +709,7 @@ namespace EOM.TSHotelManagement.Application ProductName = "居住" + transferRoomDto.OriginalRoomNumber + "共" + stayDays + "天", ProductPrice = originalRoom.RoomRent, ConsumptionTime = DateTime.Now, - SettlementStatus = SpendConsts.UnSettle.Code, + SettlementStatus = ConsumptionConstant.UnSettle.Code, ConsumptionQuantity = stayDays, ConsumptionAmount = originalRoomBill, ConsumptionType = SpendType.Room.Code, @@ -722,9 +725,9 @@ namespace EOM.TSHotelManagement.Application } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -732,7 +735,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto CheckoutRoom(CheckoutRoomDto checkoutRoomDto) + public BaseResponse CheckoutRoom(CheckoutRoomDto checkoutRoomDto) { try { @@ -740,19 +743,21 @@ namespace EOM.TSHotelManagement.Application { var customer = custoRepository.AsQueryable().Where(a => a.CustomerNumber == checkoutRoomDto.CustomerNumber && a.IsDelete != 1); if (!customer.Any()) - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("The customer does not exist", "客户不存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("The customer does not exist", "客户不存在"), Code = BusinessStatusCode.InternalServerError }; - var room = roomRepository.GetSingle(a => a.RoomNumber == checkoutRoomDto.RoomNumber); + var room = roomRepository.GetFirst(a => a.RoomNumber == checkoutRoomDto.RoomNumber); //更新房间状态 - roomRepository.Update(a => new Room + roomRepository.Update(new Room { + Id = room.Id, + RoomNumber = room.RoomNumber, CustomerNumber = null, LastCheckInTime = DateOnly.MinValue, LastCheckOutTime = DateOnly.FromDateTime(DateTime.Now), RoomStateId = (int)RoomState.Dirty, DataChgDate = checkoutRoomDto.DataChgDate, DataChgUsr = checkoutRoomDto.DataChgUsr - }, a => a.RoomNumber == room.RoomNumber); + }); //添加能源使用记录 var energy = new EnergyManagement @@ -773,16 +778,32 @@ namespace EOM.TSHotelManagement.Application //结算消费记录 var spendNumbers = spendRepository.GetList(a => a.RoomNumber == checkoutRoomDto.RoomNumber - && a.CustomerNumber.Equals(checkoutRoomDto.CustomerNumber) && a.SettlementStatus.Equals(SpendConsts.UnSettle) - && a.IsDelete == 0).Select(a => a.SpendNumber).ToList(); + && a.CustomerNumber.Equals(checkoutRoomDto.CustomerNumber) && a.SettlementStatus.Equals(ConsumptionConstant.UnSettle) + && a.IsDelete == 0).ToList(); if (spendNumbers.Count > 0) { - spendRepository.Update(a => new Spend + var spends = new List(); + foreach (var spend in spendNumbers) { - SettlementStatus = SpendConsts.Settled.Code, - DataChgDate = checkoutRoomDto.DataChgDate, - DataChgUsr = checkoutRoomDto.DataChgUsr - }, a => spendNumbers.Contains(a.SpendNumber)); + spends.Add(new Spend + { + SpendNumber = spend.SpendNumber, + RoomNumber = checkoutRoomDto.RoomNumber, + CustomerNumber = checkoutRoomDto.CustomerNumber, + ProductName = spend.ProductName, + ProductPrice = spend.ProductPrice, + ConsumptionQuantity = spend.ConsumptionQuantity, + ConsumptionAmount = spend.ConsumptionAmount, + ConsumptionTime = DateTime.Now, + SettlementStatus = ConsumptionConstant.Settled.Code, + ConsumptionType = spend.ConsumptionType, + IsDelete = 0, + DataInsDate = checkoutRoomDto.DataChgDate, + DataInsUsr = checkoutRoomDto.DataChgUsr + }); + } + + spendRepository.UpdateRange(spends); } scope.Complete(); @@ -790,9 +811,9 @@ namespace EOM.TSHotelManagement.Application } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -800,7 +821,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto CheckinRoomByReservation(CheckinRoomByReservationDto checkinRoomByReservationDto) + public BaseResponse CheckinRoomByReservation(CheckinRoomByReservationDto checkinRoomByReservationDto) { try { @@ -821,33 +842,52 @@ namespace EOM.TSHotelManagement.Application DataInsUsr = checkinRoomByReservationDto.DataInsUsr, DataInsDate = checkinRoomByReservationDto.DataInsDate }; - custoRepository.Insert(customer); + var customerResult = custoRepository.Insert(customer); + if (!customerResult) + { + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Failed to add customer.", "添加客户失败。"), Code = BusinessStatusCode.InternalServerError }; + } - roomRepository.Update(a => new Room() + var room = roomRepository.GetFirst(a => a.RoomNumber == checkinRoomByReservationDto.RoomNumber && a.IsDelete != 1); + var roomUpdateResult = roomRepository.Update(new Room() { + RoomNumber = room.RoomNumber, + Id = room.Id, LastCheckInTime = DateOnly.FromDateTime(DateTime.Now), CustomerNumber = customer.CustomerNumber, RoomStateId = new EnumHelper().GetEnumValue(RoomState.Occupied), - RoomNumber = checkinRoomByReservationDto.RoomNumber, DataChgDate = checkinRoomByReservationDto.DataChgDate, DataChgUsr = checkinRoomByReservationDto.DataChgUsr - }, a => a.RoomNumber == checkinRoomByReservationDto.RoomNumber); + }); - reserRepository.Update(a => new Reser + if (!roomUpdateResult) { + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Failed to update room.", "更新房间失败。"), Code = BusinessStatusCode.InternalServerError }; + } + + var reser = reserRepository.GetFirst(a => a.ReservationId == checkinRoomByReservationDto.ReservationId && a.IsDelete != 1); + var reserUpdateResult = reserRepository.Update(new Reser + { + ReservationId = reser.ReservationId, + Id = reser.Id, IsDelete = 1, DataChgUsr = checkinRoomByReservationDto.DataChgUsr, DataChgDate = checkinRoomByReservationDto.DataChgDate - }, a => a.ReservationId == checkinRoomByReservationDto.ReservationId); + }); + + if (!reserUpdateResult) + { + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Failed to update reservation.", "更新预约失败。"), Code = BusinessStatusCode.InternalServerError }; + } scope.Complete(); } } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } } } diff --git a/EOM.TSHotelManagement.Application/Business/Room/RoomTypeService.cs b/EOM.TSHotelManagement.Application/Business/Room/RoomTypeService.cs index 465b335..71006dc 100644 --- a/EOM.TSHotelManagement.Application/Business/Room/RoomTypeService.cs +++ b/EOM.TSHotelManagement.Application/Business/Room/RoomTypeService.cs @@ -84,6 +84,7 @@ namespace EOM.TSHotelManagement.Application else { types = roomTypeRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = types.Count; } types.ForEach(t => @@ -91,12 +92,15 @@ namespace EOM.TSHotelManagement.Application t.DeleteMarkDescription = t.IsDelete == 0 ? "否" : "是"; }); - var listSource = EntityMapper.MapList(types); + var mapped = EntityMapper.MapList(types); return new ListOutputDto { - listSource = listSource, - total = listSource.Count + Data = new PagedData + { + Items = mapped, + TotalCount = count + } }; } #endregion @@ -111,12 +115,12 @@ namespace EOM.TSHotelManagement.Application { RoomType roomtype = new RoomType(); Room room = new Room(); - room = roomRepository.GetSingle(a => a.RoomNumber == readRoomTypeInputDto.RoomNumber && a.IsDelete != 1); - roomtype.RoomTypeName = roomTypeRepository.GetSingle(a => a.RoomTypeId == room.RoomTypeId).RoomTypeName; + room = roomRepository.GetFirst(a => a.RoomNumber == readRoomTypeInputDto.RoomNumber && a.IsDelete != 1); + roomtype.RoomTypeName = roomTypeRepository.GetFirst(a => a.RoomTypeId == room.RoomTypeId).RoomTypeName; var source = EntityMapper.Map(roomtype); - return new SingleOutputDto { Source = source }; + return new SingleOutputDto { Data = source }; } #endregion @@ -125,20 +129,20 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto InsertRoomType(CreateRoomTypeInputDto roomType) + public BaseResponse InsertRoomType(CreateRoomTypeInputDto roomType) { try { var existRoomType = roomTypeRepository.IsAny(a => a.RoomTypeId == roomType.RoomTypeId); if (existRoomType) - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("This room type already exists.", "房间类型已存在。"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("This room type already exists.", "房间类型已存在。"), Code = BusinessStatusCode.InternalServerError }; roomTypeRepository.Insert(EntityMapper.Map(roomType)); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -146,25 +150,27 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateRoomType(UpdateRoomTypeInputDto roomType) + public BaseResponse UpdateRoomType(UpdateRoomTypeInputDto roomType) { try { - roomTypeRepository.Update(a => new RoomType + roomTypeRepository.Update(new RoomType { + RoomTypeId = roomType.RoomTypeId, + Id = roomType.Id, RoomTypeName = roomType.RoomTypeName, RoomRent = roomType.RoomRent, RoomDeposit = roomType.RoomDeposit, IsDelete = roomType.IsDelete, DataChgUsr = roomType.DataChgUsr, DataChgDate = roomType.DataChgDate - }, a => a.RoomTypeId == roomType.RoomTypeId); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -172,20 +178,22 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteRoomType(DeleteRoomTypeInputDto roomType) + public BaseResponse DeleteRoomType(DeleteRoomTypeInputDto roomType) { try { - roomTypeRepository.Update(a => new RoomType + roomTypeRepository.SoftDelete(new RoomType { + RoomTypeId = roomType.RoomTypeId, + Id = roomType.Id, IsDelete = 1 - }, a => a.RoomTypeId == roomType.RoomTypeId); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } } } diff --git a/EOM.TSHotelManagement.Application/Business/Sellthing/ISellService.cs b/EOM.TSHotelManagement.Application/Business/Sellthing/ISellService.cs index 089b129..6d778f4 100644 --- a/EOM.TSHotelManagement.Application/Business/Sellthing/ISellService.cs +++ b/EOM.TSHotelManagement.Application/Business/Sellthing/ISellService.cs @@ -41,21 +41,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto UpdateSellThing(UpdateSellThingInputDto updateSellThingInputDto); + BaseResponse UpdateSellThing(UpdateSellThingInputDto updateSellThingInputDto); /// /// 修改商品信息 /// /// /// - BaseOutputDto UpdateSellthingInfo(UpdateSellThingInputDto sellThing); + BaseResponse UpdateSellthingInfo(UpdateSellThingInputDto sellThing); /// /// 撤回客户消费信息 /// /// /// - BaseOutputDto DeleteSellthing(DeleteSellThingInputDto deleteSellThingInputDto); + BaseResponse DeleteSellthing(DeleteSellThingInputDto deleteSellThingInputDto); /// /// 根据商品名称和价格查询商品编号 @@ -69,6 +69,6 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto InsertSellThing(CreateSellThingInputDto st); + BaseResponse InsertSellThing(CreateSellThingInputDto st); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/Business/Sellthing/SellService.cs b/EOM.TSHotelManagement.Application/Business/Sellthing/SellService.cs index 52fa2f1..0a9c788 100644 --- a/EOM.TSHotelManagement.Application/Business/Sellthing/SellService.cs +++ b/EOM.TSHotelManagement.Application/Business/Sellthing/SellService.cs @@ -94,6 +94,7 @@ namespace EOM.TSHotelManagement.Application else { sellThings = sellThingRepository.GetList(exp.ToExpression()); + count = sellThings.Count; } sellThings.ForEach(_sellThing => @@ -101,12 +102,15 @@ namespace EOM.TSHotelManagement.Application _sellThing.ProductPriceFormatted = Decimal.Parse(_sellThing.ProductPrice.ToString()).ToString("#,##0.00").ToString(); }); - var listSource = EntityMapper.MapList(sellThings); + var result = EntityMapper.MapList(sellThings); return new ListOutputDto { - listSource = listSource, - total = count + Data = new PagedData + { + Items = result, + TotalCount = count + } }; } @@ -115,21 +119,27 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateSellThing(UpdateSellThingInputDto updateSellThingInputDto) + public BaseResponse UpdateSellThing(UpdateSellThingInputDto updateSellThingInputDto) { try { - sellThingRepository.Update(a => new SellThing() + var product = sellThingRepository.GetFirst(a => a.ProductNumber == updateSellThingInputDto.ProductNumber); + sellThingRepository.Update(new SellThing() { + Id = updateSellThingInputDto.Id, + Specification = updateSellThingInputDto.Specification, + ProductPrice = updateSellThingInputDto.ProductPrice, + ProductName = updateSellThingInputDto.ProductName, + ProductNumber = product.ProductNumber, Stock = Convert.ToInt32(updateSellThingInputDto.Stock), DataChgDate = DateTime.Now - }, a => a.ProductNumber == updateSellThingInputDto.ProductNumber); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -137,23 +147,24 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateSellthingInfo(UpdateSellThingInputDto sellThing) + public BaseResponse UpdateSellthingInfo(UpdateSellThingInputDto sellThing) { try { - sellThingRepository.Update(a => new SellThing() + var product = sellThingRepository.GetFirst(a => a.ProductNumber == sellThing.ProductNumber); + sellThingRepository.Update(new SellThing() { - ProductName = sellThing.ProductName, - ProductPrice = sellThing.ProductPrice, + ProductName = product.ProductName, + ProductPrice = product.ProductPrice, Stock = sellThing.Stock, Specification = sellThing.Specification, - }, a => a.ProductNumber == sellThing.ProductNumber); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -161,20 +172,23 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteSellthing(DeleteSellThingInputDto deleteSellThingInputDto) + public BaseResponse DeleteSellthing(DeleteSellThingInputDto deleteSellThingInputDto) { try { - sellThingRepository.Update(a => new SellThing() + var product = sellThingRepository.GetFirst(a => a.ProductNumber == deleteSellThingInputDto.ProductNumber); + sellThingRepository.SoftDelete(new SellThing() { - IsDelete = 1, - }, a => a.ProductNumber == deleteSellThingInputDto.ProductNumber); + Id = product.Id, + ProductNumber = deleteSellThingInputDto.ProductNumber, + IsDelete = deleteSellThingInputDto.IsDelete, + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -185,12 +199,12 @@ namespace EOM.TSHotelManagement.Application public SingleOutputDto SelectSellThingByNameAndPrice(ReadSellThingInputDto readSellThingInputDto) { SellThing sellThing = null; - sellThing = sellThingRepository.GetSingle(a => a.ProductNumber == readSellThingInputDto.ProductNumber || (a.ProductName == readSellThingInputDto.ProductName + sellThing = sellThingRepository.GetFirst(a => a.ProductNumber == readSellThingInputDto.ProductNumber || (a.ProductName == readSellThingInputDto.ProductName && a.ProductPrice == Convert.ToDecimal(readSellThingInputDto.ProductPrice))); var source = EntityMapper.Map(sellThing); - return new SingleOutputDto() { Source = source }; + return new SingleOutputDto() { Data = source }; } #region 添加商品 @@ -199,17 +213,22 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto InsertSellThing(CreateSellThingInputDto st) + public BaseResponse InsertSellThing(CreateSellThingInputDto st) { try { - sellThingRepository.Insert(EntityMapper.Map(st)); + var entity = EntityMapper.Map(st); + var result = sellThingRepository.Insert(entity); + if (!result) + { + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("insert sellthing failed.", "商品添加失败"), Code = BusinessStatusCode.InternalServerError }; + } } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } #endregion } diff --git a/EOM.TSHotelManagement.Application/Business/Spend/ISpendService.cs b/EOM.TSHotelManagement.Application/Business/Spend/ISpendService.cs index fcc0788..cc1bbd7 100644 --- a/EOM.TSHotelManagement.Application/Business/Spend/ISpendService.cs +++ b/EOM.TSHotelManagement.Application/Business/Spend/ISpendService.cs @@ -70,20 +70,20 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto UndoCustomerSpend(UpdateSpendInputDto updateSpendInputDto); + BaseResponse UndoCustomerSpend(UpdateSpendInputDto updateSpendInputDto); /// /// 添加客户消费信息 /// /// /// - BaseOutputDto AddCustomerSpend(AddCustomerSpendInputDto addCustomerSpendInputDto); + BaseResponse AddCustomerSpend(AddCustomerSpendInputDto addCustomerSpendInputDto); /// /// 更新消费信息 /// /// /// - BaseOutputDto UpdSpenInfo(UpdateSpendInputDto updateSpendInputDto); + BaseResponse UpdSpendInfo(UpdateSpendInputDto updateSpendInputDto); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/Business/Spend/SpendService.cs b/EOM.TSHotelManagement.Application/Business/Spend/SpendService.cs index b6ef942..3d74451 100644 --- a/EOM.TSHotelManagement.Application/Business/Spend/SpendService.cs +++ b/EOM.TSHotelManagement.Application/Business/Spend/SpendService.cs @@ -99,26 +99,31 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SeletHistorySpendInfoAll(ReadSpendInputDto readSpendInputDto) { - List ls = new List(); - ls = spendRepository.GetList(a => a.CustomerNumber == readSpendInputDto.CustomerNumber && a.SettlementStatus.Equals(SpendConsts.Settled.Code) && a.IsDelete != 1); - ls.ForEach(source => + var where = Expressionable.Create(); + if (!readSpendInputDto.CustomerNumber.IsNullOrEmpty()) { - source.SettlementStatusDescription = source.SettlementStatus.IsNullOrEmpty() ? "" - : source.SettlementStatus.Equals(SpendConsts.Settled) ? "已结算" : "未结算"; - - source.ProductPriceFormatted = (source.ProductPrice + "").IsNullOrEmpty() ? "" - : Decimal.Parse(source.ProductPrice.ToString()).ToString("#,##0.00").ToString(); - - source.ConsumptionAmountFormatted = (source.ConsumptionAmount + "").IsNullOrEmpty() ? "" - : Decimal.Parse(source.ConsumptionAmount.ToString()).ToString("#,##0.00").ToString(); - - source.ConsumptionTypeDescription = source.ConsumptionType == SpendType.Product.Code ? SpendType.Product.Description : - source.ConsumptionType == SpendType.Room.Code ? SpendType.Room.Description : SpendType.Other.Description; - }); - - var listSource = EntityMapper.MapList(ls); - - return new ListOutputDto { listSource = listSource }; + where = where.And(a => a.CustomerNumber == readSpendInputDto.CustomerNumber); + } + var count = 0; + List spends = new List(); + if (!readSpendInputDto.IgnorePaging && readSpendInputDto.Page != 0 && readSpendInputDto.PageSize != 0) + { + spends = spendRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readSpendInputDto.Page, readSpendInputDto.PageSize, ref count); + } + else + { + spends = spendRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = spends.Count; + } + var result = EntityMapper.MapList(spends); + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } #endregion @@ -130,37 +135,31 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectSpendByRoomNo(ReadSpendInputDto readSpendInputDto) { - List ls = new List(); - ls = spendRepository.GetList(a => a.RoomNumber == readSpendInputDto.RoomNumber && a.SettlementStatus.Equals(SpendConsts.UnSettle) && a.IsDelete != 1); - var spendNames = ls.Select(a => a.ProductName).ToList(); - var spendInfos = sellThingRepository.AsQueryable().Where(a => spendNames.Contains(a.ProductName)).ToList(); - ls.ForEach(source => + var where = Expressionable.Create(); + if (!readSpendInputDto.RoomNumber.IsNullOrEmpty()) { - if (source.ProductNumber.IsNullOrEmpty()) + where = where.And(a => a.RoomNumber == readSpendInputDto.RoomNumber); + } + var count = 0; + List spends = new List(); + if (!readSpendInputDto.IgnorePaging && readSpendInputDto.Page != 0 && readSpendInputDto.PageSize != 0) + { + spends = spendRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readSpendInputDto.Page, readSpendInputDto.PageSize, ref count); + } + else + { + spends = spendRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = spends.Count; + } + var result = EntityMapper.MapList(spends); + return new ListOutputDto + { + Data = new PagedData { - var spendInfo = spendInfos.SingleOrDefault(a => a.ProductName.Equals(source.ProductName)); - if (spendInfo != null) - { - source.ProductNumber = spendInfo.ProductNumber; - } + Items = result, + TotalCount = count } - - source.SettlementStatusDescription = source.SettlementStatus.IsNullOrEmpty() ? "" - : source.SettlementStatus.Equals(SpendConsts.Settled) ? "已结算" : "未结算"; - - source.ProductPriceFormatted = (source.ProductPrice + "").IsNullOrEmpty() ? "" - : Decimal.Parse(source.ProductPrice.ToString()).ToString("#,##0.00").ToString(); - - source.ConsumptionAmountFormatted = (source.ConsumptionAmount + "").IsNullOrEmpty() ? "" - : Decimal.Parse(source.ConsumptionAmount.ToString()).ToString("#,##0.00").ToString(); - - source.ConsumptionTypeDescription = source.ConsumptionType == SpendType.Product.Code ? SpendType.Product.Description : - source.ConsumptionType == SpendType.Room.Code ? SpendType.Room.Description : SpendType.Other.Description; - }); - - var listSource = EntityMapper.MapList(ls); - - return new ListOutputDto { listSource = listSource }; + }; } #endregion @@ -172,43 +171,26 @@ namespace EOM.TSHotelManagement.Application public ListOutputDto SelectSpendInfoAll(ReadSpendInputDto readSpendInputDto) { var where = Expressionable.Create(); - - if (!readSpendInputDto.IsDelete.IsNullOrEmpty()) - { - where = where.And(a => a.IsDelete == readSpendInputDto.IsDelete); - } - - List ls = new List(); - var count = 0; - + List spends = new List(); if (!readSpendInputDto.IgnorePaging && readSpendInputDto.Page != 0 && readSpendInputDto.PageSize != 0) { - ls = spendRepository.AsQueryable().Where(where.ToExpression()).OrderByDescending(a => a.ConsumptionTime).ToPageList(readSpendInputDto.Page, readSpendInputDto.PageSize, ref count); + spends = spendRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readSpendInputDto.Page, readSpendInputDto.PageSize, ref count); } else { - ls = spendRepository.AsQueryable().Where(where.ToExpression()).OrderByDescending(a => a.ConsumptionTime).ToList(); + spends = spendRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = spends.Count; } - - ls.ForEach(source => + var result = EntityMapper.MapList(spends); + return new ListOutputDto { - source.SettlementStatusDescription = source.SettlementStatus.IsNullOrEmpty() ? "" - : source.SettlementStatus.Equals(SpendConsts.Settled) ? "已结算" : "未结算"; - - source.ProductPriceFormatted = (source.ProductPrice + "").IsNullOrEmpty() ? "" - : Decimal.Parse(source.ProductPrice.ToString()).ToString("#,##0.00").ToString(); - - source.ConsumptionAmountFormatted = (source.ConsumptionAmount + "").IsNullOrEmpty() ? "" - : Decimal.Parse(source.ConsumptionAmount.ToString()).ToString("#,##0.00").ToString(); - - source.ConsumptionTypeDescription = source.ConsumptionType == SpendType.Product.Code ? SpendType.Product.Description : - source.ConsumptionType == SpendType.Room.Code ? SpendType.Room.Description : SpendType.Other.Description; - }); - - var listSource = EntityMapper.MapList(ls); - - return new ListOutputDto { listSource = listSource, total = count }; + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } #endregion @@ -219,8 +201,7 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectSpendInfoRoomNo(ReadSpendInputDto readSpendInputDto) { - List ls = new List(); - ls = spendRepository.GetList(a => a.RoomNumber == readSpendInputDto.RoomNumber && a.IsDelete != 1 && a.SettlementStatus.Equals(SpendConsts.UnSettle)); + List ls = spendRepository.GetList(a => a.RoomNumber == readSpendInputDto.RoomNumber && a.IsDelete != 1 && a.SettlementStatus.Equals(ConsumptionConstant.UnSettle)); var spendNames = ls.Select(a => a.ProductName).ToList(); var spendInfos = sellThingRepository.AsQueryable().Where(a => spendNames.Contains(a.ProductName)).ToList(); ls.ForEach(source => @@ -235,7 +216,7 @@ namespace EOM.TSHotelManagement.Application } source.SettlementStatusDescription = source.SettlementStatus.IsNullOrEmpty() ? "" - : source.SettlementStatus.Equals(SpendConsts.Settled) ? "已结算" : "未结算"; + : source.SettlementStatus.Equals(ConsumptionConstant.Settled) ? "已结算" : "未结算"; source.ProductPriceFormatted = (source.ProductPrice + "").IsNullOrEmpty() ? "" : Decimal.Parse(source.ProductPrice.ToString()).ToString("#,##0.00").ToString(); @@ -247,9 +228,15 @@ namespace EOM.TSHotelManagement.Application source.ConsumptionType == SpendType.Room.Code ? SpendType.Room.Description : SpendType.Other.Description; }); - var listSource = EntityMapper.MapList(ls); - - return new ListOutputDto { listSource = listSource }; + var mapped = EntityMapper.MapList(ls); + return new ListOutputDto + { + Data = new PagedData + { + Items = mapped, + TotalCount = mapped.Count + } + }; } #endregion @@ -261,8 +248,8 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto SumConsumptionAmount(ReadSpendInputDto readSpendInputDto) { - var totalAmount = spendRepository.GetList(a => a.RoomNumber == readSpendInputDto.RoomNumber && a.CustomerNumber == readSpendInputDto.CustomerNumber && a.SettlementStatus.Equals(SpendConsts.UnSettle)).Sum(a => a.ConsumptionAmount); - return new SingleOutputDto { Source = new ReadSpendInputDto { ConsumptionAmount = totalAmount } }; + var TotalCountAmount = spendRepository.GetList(a => a.RoomNumber == readSpendInputDto.RoomNumber && a.CustomerNumber == readSpendInputDto.CustomerNumber && a.SettlementStatus.Equals(ConsumptionConstant.UnSettle)).Sum(a => a.ConsumptionAmount); + return new SingleOutputDto { Data = new ReadSpendInputDto { ConsumptionAmount = TotalCountAmount } }; } #endregion @@ -271,22 +258,25 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UndoCustomerSpend(UpdateSpendInputDto updateSpendInputDto) + public BaseResponse UndoCustomerSpend(UpdateSpendInputDto updateSpendInputDto) { try { - spendRepository.Update(a => new Spend() + var existingSpend = spendRepository.AsQueryable().Where(a => a.SpendNumber == updateSpendInputDto.SpendNumber && a.IsDelete != 1).Single(); + spendRepository.Update(new Spend() { + Id = existingSpend.Id, + SpendNumber = existingSpend.SpendNumber, IsDelete = 1, DataChgDate = updateSpendInputDto.DataChgDate, DataChgUsr = updateSpendInputDto.DataChgUsr - }, a => a.SpendNumber.Equals(updateSpendInputDto.SpendNumber)); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -294,11 +284,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddCustomerSpend(AddCustomerSpendInputDto addCustomerSpendInputDto) + public BaseResponse AddCustomerSpend(AddCustomerSpendInputDto addCustomerSpendInputDto) { if (addCustomerSpendInputDto?.Quantity <= 0 || addCustomerSpendInputDto.Price <= 0) { - return new BaseOutputDto() { Message = "商品数量和价格必须大于零", StatusCode = StatusCodeConstants.BadRequest }; + return new BaseResponse() { Message = "商品数量和价格必须大于零", Code = BusinessStatusCode.BadRequest }; } using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); @@ -308,22 +298,22 @@ namespace EOM.TSHotelManagement.Application var room = roomRepository.AsQueryable().Single(a => a.RoomNumber == addCustomerSpendInputDto.RoomNumber); if (room == null) { - return new BaseOutputDto() { Message = $"房间 '{addCustomerSpendInputDto.RoomNumber}' 不存在", StatusCode = StatusCodeConstants.BadRequest }; + return new BaseResponse() { Message = $"房间 '{addCustomerSpendInputDto.RoomNumber}' 不存在", Code = BusinessStatusCode.BadRequest }; } var customer = customerRepository.AsQueryable().Single(a => a.CustomerNumber == room.CustomerNumber); if (customer == null) { - return new BaseOutputDto() { Message = $"客户 '{room.CustomerNumber}' 不存在", StatusCode = StatusCodeConstants.BadRequest }; + return new BaseResponse() { Message = $"客户 '{room.CustomerNumber}' 不存在", Code = BusinessStatusCode.BadRequest }; } var customerType = custoTypeRepository.AsQueryable().Single(a => a.CustomerType == customer.CustomerType); decimal discountPercent = customerType?.Discount ?? 100m; decimal originalAmount = addCustomerSpendInputDto.Price * addCustomerSpendInputDto.Quantity; - decimal realAmount = DiscountConverter.RealAmount(discountPercent, originalAmount); + decimal realAmount = DiscountHelper.RealAmount(discountPercent, originalAmount); - var existingSpend = spendRepository.AsQueryable().Single(a => a.RoomNumber == addCustomerSpendInputDto.RoomNumber && a.ProductNumber == addCustomerSpendInputDto.ProductNumber && a.IsDelete != 1 && a.SettlementStatus == SpendConsts.UnSettle.Code); + var existingSpend = spendRepository.AsQueryable().Single(a => a.RoomNumber == addCustomerSpendInputDto.RoomNumber && a.ProductNumber == addCustomerSpendInputDto.ProductNumber && a.IsDelete != 1 && a.SettlementStatus == ConsumptionConstant.UnSettle.Code); if (existingSpend != null) { @@ -333,7 +323,11 @@ namespace EOM.TSHotelManagement.Application existingSpend.DataChgDate = DateTime.Now; existingSpend.DataChgUsr = addCustomerSpendInputDto.WorkerNo; - spendRepository.Update(existingSpend); + var result = spendRepository.Update(existingSpend); + if (!result) + { + return new BaseResponse() { Message = "更新消费记录失败", Code = BusinessStatusCode.InternalServerError }; + } } else { @@ -349,18 +343,29 @@ namespace EOM.TSHotelManagement.Application ConsumptionAmount = realAmount, ConsumptionTime = DateTime.Now, ConsumptionType = SpendType.Product.Code, - SettlementStatus = SpendConsts.UnSettle.Code, + SettlementStatus = ConsumptionConstant.UnSettle.Code, DataInsUsr = addCustomerSpendInputDto.WorkerNo, DataInsDate = DateTime.Now }; - spendRepository.Insert(newSpend); + var result = spendRepository.Insert(newSpend); + if (!result) + { + return new BaseResponse() { Message = "添加消费记录失败", Code = BusinessStatusCode.InternalServerError }; + } } - sellThingRepository.Update(a => new SellThing + var product = sellThingRepository.AsQueryable().Single(a => a.ProductNumber == addCustomerSpendInputDto.ProductNumber); + var updateResult = sellThingRepository.Update(new SellThing + { + ProductNumber = product.ProductNumber, + Id = product.Id, + Stock = product.Stock - addCustomerSpendInputDto.Quantity + }); + if (!updateResult) { - Stock = a.Stock - addCustomerSpendInputDto.Quantity - }, a => a.ProductNumber == addCustomerSpendInputDto.ProductNumber); + return new BaseResponse() { Message = "商品库存更新失败", Code = BusinessStatusCode.InternalServerError }; + } var logContent = $"{addCustomerSpendInputDto.WorkerNo} 添加了消费记录: " + $"房间 {addCustomerSpendInputDto.RoomNumber}, " + @@ -368,7 +373,8 @@ namespace EOM.TSHotelManagement.Application $"数量 {addCustomerSpendInputDto.Quantity}, " + $"金额 {realAmount.ToString("#,##0.00")}"; - operationLogRepository.Insert(new OperationLog + + var log = new OperationLog { OperationTime = Convert.ToDateTime(DateTime.Now), LogContent = logContent, @@ -378,15 +384,20 @@ namespace EOM.TSHotelManagement.Application IsDelete = 0, DataInsUsr = addCustomerSpendInputDto.WorkerNo, DataInsDate = Convert.ToDateTime(DateTime.Now) - }); + }; + var logResult = operationLogRepository.Insert(log); + if (!logResult) + { + return new BaseResponse() { Message = "操作日志添加失败", Code = BusinessStatusCode.InternalServerError }; + } scope.Complete(); - return new BaseOutputDto(); + return new BaseResponse(); } catch (Exception ex) { - return new BaseOutputDto() { Message = $"添加消费记录失败,请稍后重试。{ex.Message}", StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse() { Message = $"添加消费记录失败,请稍后重试。{ex.Message}", Code = BusinessStatusCode.InternalServerError }; } } @@ -395,26 +406,29 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdSpenInfo(UpdateSpendInputDto spend) + public BaseResponse UpdSpendInfo(UpdateSpendInputDto spend) { try { - spendRepository.Update(a => new Spend() + spendRepository.Update(new Spend() { + Id = spend.Id, + SpendNumber = spend.SpendNumber, + SettlementStatus = ConsumptionConstant.UnSettle.Code, + RoomNumber = spend.RoomNumber, + CustomerNumber = spend.CustomerNumber, + ProductName = spend.ProductName, ConsumptionQuantity = spend.ConsumptionQuantity, ConsumptionAmount = spend.ConsumptionAmount, DataChgDate = spend.DataChgDate, DataChgUsr = spend.DataChgUsr - }, a => a.SettlementStatus.Equals(SpendConsts.UnSettle) - && a.RoomNumber.Equals(spend.RoomNumber) - && a.CustomerNumber.Equals(spend.CustomerNumber) - && a.ProductName.Equals(spend.ProductName)); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } } diff --git a/EOM.TSHotelManagement.Application/Dashboard/DashboardService.cs b/EOM.TSHotelManagement.Application/Dashboard/DashboardService.cs index 1fb1a8e..0c3c3e6 100644 --- a/EOM.TSHotelManagement.Application/Dashboard/DashboardService.cs +++ b/EOM.TSHotelManagement.Application/Dashboard/DashboardService.cs @@ -172,7 +172,7 @@ namespace EOM.TSHotelManagement.Application roomStatisticsOutputDto.Types = new List(); roomStatisticsOutputDto.ReservationAlerts = new List(); roomStatisticsOutputDto.Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message); - roomStatisticsOutputDto.StatusCode = StatusCodeConstants.InternalServerError; + roomStatisticsOutputDto.Code = BusinessStatusCode.InternalServerError; } return roomStatisticsOutputDto; @@ -223,7 +223,7 @@ namespace EOM.TSHotelManagement.Application Total = allSpends.Where(a => a.ConsumptionTime.Date == today) .Sum(a => a.ConsumptionAmount), Settled = allSpends.Where(a => a.ConsumptionTime.Date == today && - a.SettlementStatus == SpendConsts.Settled.Code) + a.SettlementStatus == ConsumptionConstant.Settled.Code) .Sum(a => a.ConsumptionAmount) }; @@ -232,7 +232,7 @@ namespace EOM.TSHotelManagement.Application Total = allSpends.Where(a => a.ConsumptionTime.Date >= weekStart) .Sum(a => a.ConsumptionAmount), Settled = allSpends.Where(a => a.ConsumptionTime.Date >= weekStart && - a.SettlementStatus == SpendConsts.Settled.Code) + a.SettlementStatus == ConsumptionConstant.Settled.Code) .Sum(a => a.ConsumptionAmount) }; @@ -241,21 +241,21 @@ namespace EOM.TSHotelManagement.Application Total = allSpends.Where(a => a.ConsumptionTime.Date >= yearStart) .Sum(a => a.ConsumptionAmount), Settled = allSpends.Where(a => a.ConsumptionTime.Date >= yearStart && - a.SettlementStatus == SpendConsts.Settled.Code) + a.SettlementStatus == ConsumptionConstant.Settled.Code) .Sum(a => a.ConsumptionAmount) }; businessStatisticsOutputDto.TotalConsumption = new TempDailyConsumption { Total = allSpends.Sum(a => a.ConsumptionAmount), - Settled = allSpends.Where(a => a.SettlementStatus == SpendConsts.Settled.Code) + Settled = allSpends.Where(a => a.SettlementStatus == ConsumptionConstant.Settled.Code) .Sum(a => a.ConsumptionAmount) }; } catch (Exception ex) { businessStatisticsOutputDto.Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message); - businessStatisticsOutputDto.StatusCode = StatusCodeConstants.InternalServerError; + businessStatisticsOutputDto.Code = BusinessStatusCode.InternalServerError; } return businessStatisticsOutputDto; @@ -274,8 +274,8 @@ namespace EOM.TSHotelManagement.Application .Where(a => a.IsDelete != 1) .ToList(); - var totalCount = sellThings.Count; - if (totalCount == 0) + var TotalCount = sellThings.Count; + if (TotalCount == 0) { dto.TotalProducts = 0; dto.InventoryWarning = new TempInventoryWarning @@ -305,7 +305,7 @@ namespace EOM.TSHotelManagement.Application dto.InventoryWarning = new TempInventoryWarning { Status = "error", - Percent = (int)Math.Round((dangerProducts.Count * 100.0) / totalCount), + Percent = (int)Math.Round((dangerProducts.Count * 100.0) / TotalCount), Text = LocalizationHelper.GetLocalizedString( $"{dangerProducts.Count} products in critical stock", $"{dangerProducts.Count}种商品库存告急"), @@ -317,7 +317,7 @@ namespace EOM.TSHotelManagement.Application dto.InventoryWarning = new TempInventoryWarning { Status = "warning", - Percent = (int)Math.Round((warningProducts.Count * 100.0) / totalCount), + Percent = (int)Math.Round((warningProducts.Count * 100.0) / TotalCount), Text = LocalizationHelper.GetLocalizedString( $"{warningProducts.Count} products in low stock", $"{warningProducts.Count}种商品库存预警"), @@ -349,11 +349,11 @@ namespace EOM.TSHotelManagement.Application Quantity = a.ConsumptionQuantity }).ToList(); - dto.StatusCode = StatusCodeConstants.Success; + dto.Code = BusinessStatusCode.Success; } catch (Exception) { - dto.StatusCode = StatusCodeConstants.InternalServerError; + dto.Code = BusinessStatusCode.InternalServerError; dto.Message = LocalizationHelper.GetLocalizedString( "System error, please try again later", "系统繁忙,请稍后重试" @@ -390,22 +390,10 @@ namespace EOM.TSHotelManagement.Application catch (Exception ex) { humanResourcesOutputDto.Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message); - humanResourcesOutputDto.StatusCode = StatusCodeConstants.InternalServerError; + humanResourcesOutputDto.Code = BusinessStatusCode.InternalServerError; } return humanResourcesOutputDto; } - - private string GetWarningText(int lowStockCount) - { - return lowStockCount switch - { - 0 => LocalizationHelper.GetLocalizedString("Stock normal", "库存正常"), - > 0 and <= 5 => LocalizationHelper.GetLocalizedString("Low stock warning", "库存偏低"), - > 5 => LocalizationHelper.GetLocalizedString("Critical stock", "库存告急"), - _ => LocalizationHelper.GetLocalizedString("Stock abnormal", "库存异常") - }; - } - } } diff --git a/EOM.TSHotelManagement.Application/Employee/Check/EmployeeCheckService.cs b/EOM.TSHotelManagement.Application/Employee/Check/EmployeeCheckService.cs index 5624b21..5aed864 100644 --- a/EOM.TSHotelManagement.Application/Employee/Check/EmployeeCheckService.cs +++ b/EOM.TSHotelManagement.Application/Employee/Check/EmployeeCheckService.cs @@ -83,6 +83,7 @@ namespace EOM.TSHotelManagement.Application workerChecks = workerCheckRepository.AsQueryable().Where(where.ToExpression()) .OrderByDescending(a => a.CheckTime) .ToList(); + count = workerChecks.Count; } workerChecks.ForEach(source => @@ -93,8 +94,11 @@ namespace EOM.TSHotelManagement.Application return new ListOutputDto { - listSource = source, - total = count + Data = new PagedData + { + Items = source, + TotalCount = count + } }; } @@ -113,12 +117,12 @@ namespace EOM.TSHotelManagement.Application } catch (Exception) { - return new SingleOutputDto { StatusCode = StatusCodeConstants.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Query employee sign-in days failed", "查询员工签到天数失败") }; + return new SingleOutputDto { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("Query employee sign-in days failed", "查询员工签到天数失败") }; } return new SingleOutputDto { - Source = new ReadEmployeeCheckOutputDto + Data = new ReadEmployeeCheckOutputDto { CheckDay = checkDay } @@ -144,9 +148,9 @@ namespace EOM.TSHotelManagement.Application } catch (Exception ex) { - return new SingleOutputDto { StatusCode = StatusCodeConstants.InternalServerError, Message = LocalizationHelper.GetLocalizedString($"Error:\n{ex.Message}", $"错误:\n{ex.Message}") }; + return new SingleOutputDto { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString($"Error:\n{ex.Message}", $"错误:\n{ex.Message}") }; } - return new SingleOutputDto { Source = new ReadEmployeeCheckOutputDto { IsChecked = isChecked } }; + return new SingleOutputDto { Data = new ReadEmployeeCheckOutputDto { IsChecked = isChecked } }; } /// @@ -154,17 +158,22 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddCheckInfo(CreateEmployeeCheckInputDto workerCheck) + public BaseResponse AddCheckInfo(CreateEmployeeCheckInputDto workerCheck) { try { - workerCheckRepository.Insert(EntityMapper.Map(workerCheck)); + var entity = EntityMapper.Map(workerCheck); + var result = workerCheckRepository.Insert(entity); + if (!result) + { + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("insert employee check failed.", "员工打卡添加失败"), Code = BusinessStatusCode.InternalServerError }; + } } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } } } diff --git a/EOM.TSHotelManagement.Application/Employee/Check/IEmployeeCheckService.cs b/EOM.TSHotelManagement.Application/Employee/Check/IEmployeeCheckService.cs index e852513..70ada87 100644 --- a/EOM.TSHotelManagement.Application/Employee/Check/IEmployeeCheckService.cs +++ b/EOM.TSHotelManagement.Application/Employee/Check/IEmployeeCheckService.cs @@ -56,6 +56,6 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddCheckInfo(CreateEmployeeCheckInputDto workerCheck); + BaseResponse AddCheckInfo(CreateEmployeeCheckInputDto workerCheck); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs b/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs index 265281d..e503aac 100644 --- a/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs +++ b/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs @@ -104,7 +104,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateEmployee(UpdateEmployeeInputDto updateEmployeeInputDto) + public BaseResponse UpdateEmployee(UpdateEmployeeInputDto updateEmployeeInputDto) { try { @@ -123,16 +123,16 @@ namespace EOM.TSHotelManagement.Application updateEmployeeInputDto.PhoneNumber = sourceTelStr; updateEmployeeInputDto.IdCardNumber = sourceIdStr; - var password = workerRepository.GetSingle(a => a.EmployeeId == updateEmployeeInputDto.EmployeeId).Password; + var password = workerRepository.GetFirst(a => a.EmployeeId == updateEmployeeInputDto.EmployeeId).Password; updateEmployeeInputDto.Password = password; workerRepository.Update(EntityMapper.Map(updateEmployeeInputDto)); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } @@ -141,7 +141,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto ManagerEmployeeAccount(UpdateEmployeeInputDto updateEmployeeInputDto) + public BaseResponse ManagerEmployeeAccount(UpdateEmployeeInputDto updateEmployeeInputDto) { try { @@ -152,9 +152,9 @@ namespace EOM.TSHotelManagement.Application } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -162,7 +162,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddEmployee(CreateEmployeeInputDto createEmployeeInputDto) + public BaseResponse AddEmployee(CreateEmployeeInputDto createEmployeeInputDto) { try { @@ -183,22 +183,25 @@ namespace EOM.TSHotelManagement.Application var newPassword = new RandomStringGenerator().GenerateSecurePassword(); sourcePwdStr = dataProtector.EncryptEmployeeData(newPassword); + var emailTemplate = EmailTemplate.GetNewRegistrationTemplate(newPassword); + var result = mailHelper.SendMail(new List { createEmployeeInputDto.EmailAddress }, emailTemplate.Subject, emailTemplate.Body, new List { createEmployeeInputDto.EmailAddress }); + if (!result) + { + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("E-Mail Config Invaild, Add Employee Faild", "电子邮件配置无效,添加员工失败"), Code = BusinessStatusCode.InternalServerError }; + } + createEmployeeInputDto.PhoneNumber = sourceTelStr; createEmployeeInputDto.IdCardNumber = sourceIdStr; createEmployeeInputDto.Password = sourcePwdStr; workerRepository.Insert(EntityMapper.Map(createEmployeeInputDto)); - var emailTemplate = EmailTemplate.GetNewRegistrationTemplate(newPassword); - - mailHelper.SendMail(new List { createEmployeeInputDto.EmailAddress }, emailTemplate.Subject, emailTemplate.Body, new List { createEmployeeInputDto.EmailAddress }); - } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -253,6 +256,7 @@ namespace EOM.TSHotelManagement.Application employees = workerRepository.AsQueryable().Where(where.ToExpression()) .OrderBy(a => a.EmployeeId) .ToList(); + count = employees.Count; } employees.ForEach(source => @@ -284,9 +288,16 @@ namespace EOM.TSHotelManagement.Application source.PoliticalAffiliationName = new EnumHelper().GetDescriptionByName(source.PoliticalAffiliation); }); - var listSource = EntityMapper.MapList(employees); + var Data = EntityMapper.MapList(employees); - return new ListOutputDto { listSource = listSource, total = count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = Data, + TotalCount = count + } + }; } /// @@ -307,7 +318,7 @@ namespace EOM.TSHotelManagement.Application Description = helper.GetEnumDescription(e) }) .ToList(); - w = workerRepository.GetSingle(a => a.EmployeeId == readEmployeeInputDto.EmployeeId); + w = workerRepository.GetFirst(a => a.EmployeeId == readEmployeeInputDto.EmployeeId); //解密身份证号码 var sourceStr = w.IdCardNumber.IsNullOrEmpty() ? "" : dataProtector.DecryptEmployeeData(w.IdCardNumber); w.IdCardNumber = sourceStr; @@ -318,29 +329,29 @@ namespace EOM.TSHotelManagement.Application var sexType = genders.SingleOrDefault(a => a.Id == w.Gender); w.GenderName = sexType.Description.IsNullOrEmpty() ? "" : sexType.Description; //教育程度 - var eduction = educationRepository.GetSingle(a => a.EducationNumber == w.EducationLevel); + var eduction = educationRepository.GetFirst(a => a.EducationNumber == w.EducationLevel); w.EducationLevelName = eduction.EducationName.IsNullOrEmpty() ? "" : eduction.EducationName; //民族类型 - var nation = nationRepository.GetSingle(a => a.NationNumber == w.Ethnicity); + var nation = nationRepository.GetFirst(a => a.NationNumber == w.Ethnicity); w.EthnicityName = nation.NationName.IsNullOrEmpty() ? "" : nation.NationName; //部门 - var dept = deptRepository.GetSingle(a => a.DepartmentNumber == w.Department); + var dept = deptRepository.GetFirst(a => a.DepartmentNumber == w.Department); w.DepartmentName = dept.DepartmentName.IsNullOrEmpty() ? "" : dept.DepartmentName; //职位 - var position = positionRepository.GetSingle(a => a.PositionNumber == w.Position); + var position = positionRepository.GetFirst(a => a.PositionNumber == w.Position); w.PositionName = position.PositionName.IsNullOrEmpty() ? "" : position.PositionName; - var passport = passportTypeRepository.GetSingle(a => a.PassportId == w.IdCardType); + var passport = passportTypeRepository.GetFirst(a => a.PassportId == w.IdCardType); w.IdCardTypeName = passport.IsNullOrEmpty() ? "" : passport.PassportName; //面貌 w.PoliticalAffiliationName = new EnumHelper().GetDescriptionByName(w.PoliticalAffiliation); var source = EntityMapper.Map(w); - var employeePhoto = photoRepository.GetSingle(a => a.EmployeeId.Equals(source.EmployeeId)); + var employeePhoto = photoRepository.GetFirst(a => a.EmployeeId.Equals(source.EmployeeId)); if (employeePhoto != null && !string.IsNullOrEmpty(employeePhoto.PhotoPath)) source.PhotoUrl = employeePhoto.PhotoPath ?? string.Empty; - return new SingleOutputDto { Source = source }; + return new SingleOutputDto { Data = source }; } /// @@ -361,11 +372,11 @@ namespace EOM.TSHotelManagement.Application Description = helper.GetEnumDescription(e) }) .ToList(); - w = workerRepository.GetSingle(a => a.EmployeeId == readEmployeeInputDto.EmployeeId || a.EmailAddress == readEmployeeInputDto.EmailAddress); + w = workerRepository.GetFirst(a => a.EmployeeId == readEmployeeInputDto.EmployeeId || a.EmailAddress == readEmployeeInputDto.EmailAddress); if (w == null) { w = null; - return new SingleOutputDto { Source = null, Message = LocalizationHelper.GetLocalizedString("Employee does not exist or entered incorrectly", "员工不存在或输入有误") }; + return new SingleOutputDto { Data = null, Message = LocalizationHelper.GetLocalizedString("Employee does not exist or entered incorrectly", "员工不存在或输入有误") }; } var dbPwd = string.Empty; @@ -374,28 +385,28 @@ namespace EOM.TSHotelManagement.Application if (dbPwd != readEmployeeInputDto.Password) { w = null; - return new SingleOutputDto { Source = EntityMapper.Map(w) }; + return new SingleOutputDto { Data = EntityMapper.Map(w) }; } w.Password = ""; //性别类型 var sexType = genders.SingleOrDefault(a => a.Id == w.Gender); w.GenderName = sexType.Description.IsNullOrEmpty() ? "" : sexType.Description; //教育程度 - var eduction = educationRepository.GetSingle(a => a.EducationNumber == w.EducationLevel); + var eduction = educationRepository.GetFirst(a => a.EducationNumber == w.EducationLevel); w.EducationLevelName = eduction.EducationName.IsNullOrEmpty() ? "" : eduction.EducationName; //民族类型 - var nation = nationRepository.GetSingle(a => a.NationNumber == w.Ethnicity); + var nation = nationRepository.GetFirst(a => a.NationNumber == w.Ethnicity); w.EthnicityName = nation.NationName.IsNullOrEmpty() ? "" : nation.NationName; //部门 - var dept = deptRepository.GetSingle(a => a.DepartmentNumber == w.Department); + var dept = deptRepository.GetFirst(a => a.DepartmentNumber == w.Department); w.DepartmentName = dept.DepartmentName.IsNullOrEmpty() ? "" : dept.DepartmentName; //职位 - var position = positionRepository.GetSingle(a => a.PositionNumber == w.Position); + var position = positionRepository.GetFirst(a => a.PositionNumber == w.Position); w.PositionName = position.PositionName.IsNullOrEmpty() ? "" : position.PositionName; w.UserToken = jWTHelper.GenerateJWT(new ClaimsIdentity(new List { new Claim(ClaimTypes.Name, w.EmployeeName), new Claim(ClaimTypes.SerialNumber, w.EmployeeId) })); - return new SingleOutputDto { Source = EntityMapper.Map(w) }; + return new SingleOutputDto { Data = EntityMapper.Map(w) }; } /// @@ -403,18 +414,18 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateEmployeeAccountPassword(UpdateEmployeeInputDto updateEmployeeInputDto) + public BaseResponse UpdateEmployeeAccountPassword(UpdateEmployeeInputDto updateEmployeeInputDto) { try { - var employee = workerRepository.GetSingle(a => a.EmployeeId == updateEmployeeInputDto.EmployeeId); + var employee = workerRepository.GetFirst(a => a.EmployeeId == updateEmployeeInputDto.EmployeeId); if (employee.IsNullOrEmpty()) { - return new BaseOutputDto() + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("This employee does not exists", "员工不存在"), - StatusCode = StatusCodeConstants.InternalServerError + Code = BusinessStatusCode.InternalServerError }; } @@ -422,19 +433,19 @@ namespace EOM.TSHotelManagement.Application if (!updateEmployeeInputDto.OldPassword.Equals(currentPassword)) { - return new BaseOutputDto() + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("The old password is incorrect", "旧密码不正确"), - StatusCode = StatusCodeConstants.InternalServerError + Code = BusinessStatusCode.InternalServerError }; } if (updateEmployeeInputDto.Password.Equals(currentPassword)) { - return new BaseOutputDto() + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("The new password cannot be the same as the old password", "新密码不能与旧密码相同"), - StatusCode = StatusCodeConstants.InternalServerError + Code = BusinessStatusCode.InternalServerError }; } @@ -447,20 +458,22 @@ namespace EOM.TSHotelManagement.Application mailHelper.SendMail(new List { employee.EmailAddress }, mailTemplate.Subject, mailTemplate.Body, new List { employee.EmailAddress }); } - workerRepository.Update(a => new Employee() + workerRepository.Update(new Employee() { + Id = employee.Id, + EmployeeId = employee.EmployeeId, Password = encrypted, IsInitialize = 1, DataChgUsr = updateEmployeeInputDto.DataChgUsr, DataChgDate = updateEmployeeInputDto.DataChgDate - }, a => a.EmployeeId == updateEmployeeInputDto.EmployeeId); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -468,41 +481,52 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto ResetEmployeeAccountPassword(UpdateEmployeeInputDto updateEmployeeInputDto) + public BaseResponse ResetEmployeeAccountPassword(UpdateEmployeeInputDto updateEmployeeInputDto) { try { var newPwd = new RandomStringGenerator().GenerateSecurePassword(); string encrypted = dataProtector.EncryptEmployeeData(newPwd); - var employeeMailAddress = workerRepository.GetSingle(a => a.EmployeeId == updateEmployeeInputDto.EmployeeId).EmailAddress; + var employee = workerRepository.GetFirst(a => a.EmployeeId == updateEmployeeInputDto.EmployeeId); - if (employeeMailAddress.IsNullOrEmpty()) + var emailAddress = employee.EmailAddress; + + if (emailAddress.IsNullOrEmpty()) { - return new BaseOutputDto() + return new BaseResponse() { Message = LocalizationHelper.GetLocalizedString("No bound email address was found for the employee. Password reset cannot be completed." , "未找到员工绑定的电子邮箱,无法重置密码。"), - StatusCode = StatusCodeConstants.InternalServerError + Code = BusinessStatusCode.InternalServerError }; } var mailTemplate = EmailTemplate.GetResetPasswordTemplate(newPwd); - mailHelper.SendMail(new List { employeeMailAddress }, mailTemplate.Subject, mailTemplate.Body, new List { employeeMailAddress }); - workerRepository.Update(a => new Employee() + var result = mailHelper.SendMail(new List { emailAddress }, + mailTemplate.Subject, mailTemplate.Body, + new List { emailAddress }); + if (!result) { + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("E-Mail Config Invaild, Reset Password Faild", "电子邮件配置无效,重置密码失败"), Code = BusinessStatusCode.InternalServerError }; + } + + workerRepository.Update(new Employee() + { + Id = employee.Id, + EmployeeId = employee.EmployeeId, Password = encrypted, DataChgUsr = updateEmployeeInputDto.DataChgUsr, DataChgDate = updateEmployeeInputDto.DataChgDate - }, a => a.EmployeeId == updateEmployeeInputDto.EmployeeId); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } } } diff --git a/EOM.TSHotelManagement.Application/Employee/History/EmployeeHistoryService.cs b/EOM.TSHotelManagement.Application/Employee/History/EmployeeHistoryService.cs index a6c7d0f..ea4ed21 100644 --- a/EOM.TSHotelManagement.Application/Employee/History/EmployeeHistoryService.cs +++ b/EOM.TSHotelManagement.Application/Employee/History/EmployeeHistoryService.cs @@ -52,7 +52,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddHistoryByEmployeeId(CreateEmployeeHistoryInputDto workerHistory) + public BaseResponse AddHistoryByEmployeeId(CreateEmployeeHistoryInputDto workerHistory) { try { @@ -60,9 +60,9 @@ namespace EOM.TSHotelManagement.Application } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -72,10 +72,16 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectHistoryByEmployeeId(ReadEmployeeHistoryInputDto wid) { - List why = new List(); - why = workerHistoryRepository.GetList(a => a.IsDelete != 1 && a.EmployeeId == wid.EmployeeId); - var source = EntityMapper.MapList(why); - return new ListOutputDto { listSource = source, total = source.Count }; + List why = workerHistoryRepository.GetList(a => a.IsDelete != 1 && a.EmployeeId == wid.EmployeeId); + var result = EntityMapper.MapList(why); + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = result.Count + } + }; } } } diff --git a/EOM.TSHotelManagement.Application/Employee/History/IEmployeeHistoryService.cs b/EOM.TSHotelManagement.Application/Employee/History/IEmployeeHistoryService.cs index 380a8b5..2ab1cc2 100644 --- a/EOM.TSHotelManagement.Application/Employee/History/IEmployeeHistoryService.cs +++ b/EOM.TSHotelManagement.Application/Employee/History/IEmployeeHistoryService.cs @@ -35,7 +35,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddHistoryByEmployeeId(CreateEmployeeHistoryInputDto workerHistory); + BaseResponse AddHistoryByEmployeeId(CreateEmployeeHistoryInputDto workerHistory); /// /// 根据工号查询履历信息 diff --git a/EOM.TSHotelManagement.Application/Employee/IEmployeeService.cs b/EOM.TSHotelManagement.Application/Employee/IEmployeeService.cs index c703691..83697fc 100644 --- a/EOM.TSHotelManagement.Application/Employee/IEmployeeService.cs +++ b/EOM.TSHotelManagement.Application/Employee/IEmployeeService.cs @@ -35,21 +35,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto UpdateEmployee(UpdateEmployeeInputDto updateEmployeeInputDto); + BaseResponse UpdateEmployee(UpdateEmployeeInputDto updateEmployeeInputDto); /// /// 员工账号禁/启用 /// /// /// - BaseOutputDto ManagerEmployeeAccount(UpdateEmployeeInputDto updateEmployeeInputDto); + BaseResponse ManagerEmployeeAccount(UpdateEmployeeInputDto updateEmployeeInputDto); /// /// 添加员工信息 /// /// /// - BaseOutputDto AddEmployee(CreateEmployeeInputDto createEmployeeInputDto); + BaseResponse AddEmployee(CreateEmployeeInputDto createEmployeeInputDto); /// /// 获取所有工作人员信息 @@ -76,13 +76,13 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto UpdateEmployeeAccountPassword(UpdateEmployeeInputDto updateEmployeeInputDto); + BaseResponse UpdateEmployeeAccountPassword(UpdateEmployeeInputDto updateEmployeeInputDto); /// /// 重置员工账号密码 /// /// /// - BaseOutputDto ResetEmployeeAccountPassword(UpdateEmployeeInputDto updateEmployeeInputDto); + BaseResponse ResetEmployeeAccountPassword(UpdateEmployeeInputDto updateEmployeeInputDto); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/Employee/Photo/EmployeePhotoService.cs b/EOM.TSHotelManagement.Application/Employee/Photo/EmployeePhotoService.cs index f75c0e2..5fb53cd 100644 --- a/EOM.TSHotelManagement.Application/Employee/Photo/EmployeePhotoService.cs +++ b/EOM.TSHotelManagement.Application/Employee/Photo/EmployeePhotoService.cs @@ -40,15 +40,15 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto EmployeePhoto(ReadEmployeePhotoInputDto readEmployeePhotoInputDto) { - var workerPicSource = new EmployeePhoto(); + var workerPicData = new EmployeePhoto(); - workerPicSource = workerPicRepository.GetSingle(a => a.EmployeeId.Equals(readEmployeePhotoInputDto.EmployeeId)); + workerPicData = workerPicRepository.GetFirst(a => a.EmployeeId.Equals(readEmployeePhotoInputDto.EmployeeId)); - if (workerPicSource.IsNullOrEmpty()) + if (workerPicData.IsNullOrEmpty()) { return new SingleOutputDto { - Source = new ReadEmployeePhotoOutputDto + Data = new ReadEmployeePhotoOutputDto { PhotoId = 0, PhotoPath = "", @@ -59,7 +59,7 @@ namespace EOM.TSHotelManagement.Application return new SingleOutputDto { - Source = EntityMapper.Map(workerPicSource) + Data = EntityMapper.Map(workerPicData) }; } /// @@ -74,7 +74,7 @@ namespace EOM.TSHotelManagement.Application { if (file == null || file.Length == 0) { - return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString("File cannot null", "文件不能为空"), StatusCode = StatusCodeConstants.BadRequest }; + return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString("File cannot null", "文件不能为空"), Code = BusinessStatusCode.BadRequest }; } if (file.Length > 1048576) @@ -82,7 +82,7 @@ namespace EOM.TSHotelManagement.Application return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString("Image size exceeds 1MB limit", "图片大小不能超过1MB"), - StatusCode = StatusCodeConstants.BadRequest + Code = BusinessStatusCode.BadRequest }; } if (file.ContentType != "image/jpeg" && file.ContentType != "image/png") @@ -90,14 +90,14 @@ namespace EOM.TSHotelManagement.Application return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString("Invalid image format", "图片格式不正确"), - StatusCode = StatusCodeConstants.BadRequest + Code = BusinessStatusCode.BadRequest }; } var token = lskyHelper.GetImageStorageTokenAsync().Result; if (string.IsNullOrEmpty(token)) { - return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString("Get Token Fail", "获取Token失败"), StatusCode = StatusCodeConstants.InternalServerError }; + return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString("Get Token Fail", "获取Token失败"), Code = BusinessStatusCode.InternalServerError }; } using var stream = file.OpenReadStream(); @@ -110,11 +110,11 @@ namespace EOM.TSHotelManagement.Application ).Result; if (string.IsNullOrEmpty(imageUrl)) { - return new SingleOutputDto { Message = "图片上传失败", StatusCode = StatusCodeConstants.InternalServerError }; + return new SingleOutputDto { Message = "图片上传失败", Code = BusinessStatusCode.InternalServerError }; } - var workerPicSource = workerPicRepository.GetSingle(a => a.EmployeeId.Equals(createEmployeePhotoInputDto.EmployeeId)); - if (workerPicSource.IsNullOrEmpty()) + var workerPicData = workerPicRepository.GetFirst(a => a.EmployeeId.Equals(createEmployeePhotoInputDto.EmployeeId)); + if (workerPicData.IsNullOrEmpty()) { workerPicRepository.Insert(new EmployeePhoto { @@ -124,15 +124,17 @@ namespace EOM.TSHotelManagement.Application } else { - workerPicRepository.Update(a => new EmployeePhoto + workerPicRepository.Update(new EmployeePhoto { + Id = workerPicData.Id, + EmployeeId = workerPicData.EmployeeId, PhotoPath = imageUrl - }, a => a.EmployeeId.Equals(createEmployeePhotoInputDto.EmployeeId)); + }); } return new SingleOutputDto { - Source = new ReadEmployeePhotoOutputDto + Data = new ReadEmployeePhotoOutputDto { PhotoId = 0, PhotoPath = imageUrl, @@ -142,7 +144,7 @@ namespace EOM.TSHotelManagement.Application } catch (Exception ex) { - return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new SingleOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } } @@ -151,7 +153,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteWorkerPhoto(DeleteEmployeePhotoInputDto deleteEmployeePhotoInputDto) + public BaseResponse DeleteWorkerPhoto(DeleteEmployeePhotoInputDto deleteEmployeePhotoInputDto) { try { @@ -159,9 +161,9 @@ namespace EOM.TSHotelManagement.Application } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -169,20 +171,23 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateWorkerPhoto(UpdateEmployeePhotoInputDto updateEmployeePhotoInputDto) + public BaseResponse UpdateWorkerPhoto(UpdateEmployeePhotoInputDto updateEmployeePhotoInputDto) { try { - workerPicRepository.Update(a => new EmployeePhoto + var workerPicData = workerPicRepository.GetFirst(a => a.EmployeeId.Equals(updateEmployeePhotoInputDto.EmployeeId)); + workerPicRepository.Update(new EmployeePhoto { + Id = workerPicData.Id, + EmployeeId = workerPicData.EmployeeId, PhotoPath = updateEmployeePhotoInputDto.PhotoUrl - }, a => a.EmployeeId.Equals(updateEmployeePhotoInputDto.EmployeeId)); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } } } diff --git a/EOM.TSHotelManagement.Application/Employee/Photo/IEmployeePhotoService.cs b/EOM.TSHotelManagement.Application/Employee/Photo/IEmployeePhotoService.cs index c521cfc..7f2e62e 100644 --- a/EOM.TSHotelManagement.Application/Employee/Photo/IEmployeePhotoService.cs +++ b/EOM.TSHotelManagement.Application/Employee/Photo/IEmployeePhotoService.cs @@ -26,12 +26,12 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto DeleteWorkerPhoto(DeleteEmployeePhotoInputDto deleteEmployeePhotoInputDto); + BaseResponse DeleteWorkerPhoto(DeleteEmployeePhotoInputDto deleteEmployeePhotoInputDto); /// /// 更新员工照片 /// /// /// - BaseOutputDto UpdateWorkerPhoto(UpdateEmployeePhotoInputDto updateEmployeePhotoInputDto); + BaseResponse UpdateWorkerPhoto(UpdateEmployeePhotoInputDto updateEmployeePhotoInputDto); } } diff --git a/EOM.TSHotelManagement.Application/Employee/RewardPunishment/IRewardPunishmentService.cs b/EOM.TSHotelManagement.Application/Employee/RewardPunishment/IRewardPunishmentService.cs index 8ab8a00..a5fd27b 100644 --- a/EOM.TSHotelManagement.Application/Employee/RewardPunishment/IRewardPunishmentService.cs +++ b/EOM.TSHotelManagement.Application/Employee/RewardPunishment/IRewardPunishmentService.cs @@ -35,7 +35,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddRewardPunishment(CreateEmployeeRewardPunishmentInputDto goodBad); + BaseResponse AddRewardPunishment(CreateEmployeeRewardPunishmentInputDto goodBad); /// /// 根据工号查找所有的奖惩记录信息 diff --git a/EOM.TSHotelManagement.Application/Employee/RewardPunishment/RewardPunishmentService.cs b/EOM.TSHotelManagement.Application/Employee/RewardPunishment/RewardPunishmentService.cs index 311d2d9..f820321 100644 --- a/EOM.TSHotelManagement.Application/Employee/RewardPunishment/RewardPunishmentService.cs +++ b/EOM.TSHotelManagement.Application/Employee/RewardPunishment/RewardPunishmentService.cs @@ -68,17 +68,22 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddRewardPunishment(CreateEmployeeRewardPunishmentInputDto goodBad) + public BaseResponse AddRewardPunishment(CreateEmployeeRewardPunishmentInputDto goodBad) { try { - rewardPunishmentRepository.Insert(EntityMapper.Map(goodBad)); + var entity = EntityMapper.Map(goodBad); + var result = rewardPunishmentRepository.Insert(entity); + if (!result) + { + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Add reward punishment failed", "员工奖惩记录添加失败"), Code = BusinessStatusCode.InternalServerError }; + } } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -101,10 +106,8 @@ namespace EOM.TSHotelManagement.Application } //查询所有超级管理员 - List admins = new List(); - admins = adminRepository.GetList(a => a.IsDelete != 1); - List gBTypes = new List(); - gBTypes = goodbadTypeRepository.GetList(a => a.IsDelete != 1); + List admins = adminRepository.GetList(a => a.IsDelete != 1); + List gBTypes = goodbadTypeRepository.GetList(a => a.IsDelete != 1); List gb = new List(); var count = 0; @@ -120,6 +123,7 @@ namespace EOM.TSHotelManagement.Application gb = rewardPunishmentRepository.AsQueryable().Where(where.ToExpression()) .OrderByDescending(a => a.RewardPunishmentTime) .ToList(); + count = gb.Count; } gb.ForEach(source => @@ -133,10 +137,15 @@ namespace EOM.TSHotelManagement.Application source.OperatorName = admin.Name.IsNullOrEmpty() ? "" : admin.Name; }); + var mapped = EntityMapper.MapList(gb); + return new ListOutputDto { - listSource = EntityMapper.MapList(gb), - total = count + Data = new PagedData + { + Items = mapped, + TotalCount = count + } }; } } diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Administrator/AdminService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Administrator/AdminService.cs index f2ac3cb..680e0c3 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Administrator/AdminService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Administrator/AdminService.cs @@ -91,7 +91,7 @@ namespace EOM.TSHotelManagement.Application throw new ArgumentNullException(nameof(readAdministratorInputDto)); } - var existingAdmin = adminRepository.GetSingle(a => a.Account == readAdministratorInputDto.Account); + var existingAdmin = adminRepository.GetFirst(a => a.Account == readAdministratorInputDto.Account); if (existingAdmin == null) { @@ -116,8 +116,9 @@ namespace EOM.TSHotelManagement.Application } catch (Exception) { - var originalPwd = dataProtector.DecryptAdministratorData(existingAdmin.Password); - var passed = originalPwd == existingAdmin.Password; + var originalPwd = dataProtector.DecryptAdministratorData(readAdministratorInputDto.Password); + var currentPwd = dataProtector.DecryptAdministratorData(existingAdmin.Password); + var passed = originalPwd == currentPwd; if (!passed) { return null; @@ -133,14 +134,14 @@ namespace EOM.TSHotelManagement.Application existingAdmin.UserToken = jWTHelper.GenerateJWT(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, existingAdmin.Name), - new Claim(ClaimTypes.SerialNumber, existingAdmin.Account) + new Claim(ClaimTypes.SerialNumber, existingAdmin.Number) })); var source = EntityMapper.Map(existingAdmin); return new SingleOutputDto { - Source = source + Data = source }; } @@ -156,38 +157,36 @@ namespace EOM.TSHotelManagement.Application { where = where.And(a => a.IsDelete == readAdministratorInputDto.IsDelete); } + var count = 0; - var listAdmins = new List(); - var listAdminType = adminTypeRepository.GetList(a => a.IsDelete != 1); + List administrators = new List(); if (!readAdministratorInputDto.IgnorePaging && readAdministratorInputDto.Page != 0 && readAdministratorInputDto.PageSize != 0) { - listAdmins = adminRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readAdministratorInputDto.Page, readAdministratorInputDto.PageSize, ref count); + administrators = adminRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readAdministratorInputDto.Page, readAdministratorInputDto.PageSize, ref count); } else { - listAdmins = adminRepository.AsQueryable().Where(where.ToExpression()).ToList(); + administrators = adminRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = administrators.Count; } - listAdmins.ForEach(admins => + administrators.ForEach(admin => { - var isAdminType = admins.IsSuperAdmin == 1 ? "是" : "否"; - admins.IsSuperAdminDescription = isAdminType; - - var adminType = listAdminType.SingleOrDefault(a => a.TypeId.Equals(admins.Type)); - admins.TypeName = adminType == null ? "" : adminType.TypeName; - - var adminDelete = admins.IsDelete == 1 ? "是" : "否"; - admins.DeleteDescription = adminDelete; - + var type = adminTypeRepository.GetFirst(a => a.TypeId == admin.Type); + admin.TypeName = type?.TypeName ?? ""; + admin.IsSuperAdminDescription = admin.IsSuperAdmin == 1 ? "是" : "否"; }); - var listSouce = EntityMapper.MapList(listAdmins); + var result = EntityMapper.MapList(administrators); - return new ListOutputDto - { - listSource = listSouce, - total = count + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } }; } @@ -196,29 +195,34 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddAdmin(CreateAdministratorInputDto createAdministratorInputDto) + public BaseResponse AddAdmin(CreateAdministratorInputDto createAdministratorInputDto) { try { var haveSuperAdmin = adminRepository.IsAny(a => a.IsSuperAdmin == createAdministratorInputDto.IsSuperAdmin && a.IsDelete != 1); if (haveSuperAdmin) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("Super Administrator already exists", "超级管理员已存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Super Administrator already exists", "超级管理员已存在"), Code = BusinessStatusCode.InternalServerError }; } var haveAdmin = adminRepository.IsAny(a => a.Account == createAdministratorInputDto.Account); if (haveAdmin) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("Administrator already exists", "管理员已存在"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Administrator already exists", "管理员已存在"), Code = BusinessStatusCode.InternalServerError }; } createAdministratorInputDto.Password = dataProtector.EncryptAdministratorData(createAdministratorInputDto.Password); - adminRepository.Insert(EntityMapper.Map(createAdministratorInputDto)); + var admin = EntityMapper.Map(createAdministratorInputDto); + var result = adminRepository.Insert(admin); + if (!result) + { + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Add Administrator Failed", "添加管理员失败"), Code = BusinessStatusCode.InternalServerError }; + } } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -226,18 +230,23 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdAdmin(UpdateAdministratorInputDto updateAdministratorInputDto) + public BaseResponse UpdAdmin(UpdateAdministratorInputDto updateAdministratorInputDto) { try { updateAdministratorInputDto.Password = dataProtector.EncryptAdministratorData(updateAdministratorInputDto.Password); - adminRepository.Insert(EntityMapper.Map(updateAdministratorInputDto)); + var admin = EntityMapper.Map(updateAdministratorInputDto); + var result = adminRepository.Update(admin); + if (!result) + { + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Update Administrator Failed", "更新管理员失败"), Code = BusinessStatusCode.InternalServerError }; + } } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -245,22 +254,22 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DelAdmin(DeleteAdministratorInputDto deleteAdministratorInputDto) + public BaseResponse DelAdmin(DeleteAdministratorInputDto deleteAdministratorInputDto) { try { var isSuperAdmin = adminRepository.IsAny(a => a.Number == deleteAdministratorInputDto.Number && a.IsSuperAdmin == 1); if (isSuperAdmin) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("Super Administrator cannot be deleted", "超级管理员无法删除"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Super Administrator cannot be deleted", "超级管理员无法删除"), Code = BusinessStatusCode.InternalServerError }; } - adminRepository.Delete(EntityMapper.Map(deleteAdministratorInputDto)); + adminRepository.SoftDelete(EntityMapper.Map(deleteAdministratorInputDto)); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -269,13 +278,35 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto GetAllAdminTypes(ReadAdministratorTypeInputDto readAdministratorTypeInputDto) { - var listAdminTypes = adminTypeRepository.GetList(a => a.IsDelete != 1); + var where = Expressionable.Create(); - var listSouce = EntityMapper.MapList(listAdminTypes); + if (!readAdministratorTypeInputDto.IsDelete.IsNullOrEmpty()) + { + where = where.And(a => a.IsDelete == readAdministratorTypeInputDto.IsDelete); + } + + var count = 0; + List administratorTypes = new List(); - return new ListOutputDto + if (!readAdministratorTypeInputDto.IgnorePaging && readAdministratorTypeInputDto.Page != 0 && readAdministratorTypeInputDto.PageSize != 0) + { + administratorTypes = adminTypeRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readAdministratorTypeInputDto.Page, readAdministratorTypeInputDto.PageSize, ref count); + } + else { - listSource = listSouce + administratorTypes = adminTypeRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = administratorTypes.Count; + } + + var result = EntityMapper.MapList(administratorTypes); + + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } }; } @@ -284,7 +315,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddAdminType(CreateAdministratorTypeInputDto createAdministratorTypeInputDto) + public BaseResponse AddAdminType(CreateAdministratorTypeInputDto createAdministratorTypeInputDto) { try { @@ -292,9 +323,9 @@ namespace EOM.TSHotelManagement.Application } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -302,17 +333,17 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdAdminType(UpdateAdministratorTypeInputDto updateAdministratorTypeInputDto) + public BaseResponse UpdAdminType(UpdateAdministratorTypeInputDto updateAdministratorTypeInputDto) { try { - adminTypeRepository.Insert(EntityMapper.Map(updateAdministratorTypeInputDto)); + adminTypeRepository.Update(EntityMapper.Map(updateAdministratorTypeInputDto)); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -320,17 +351,19 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DelAdminType(DeleteAdministratorTypeInputDto deleteAdministratorTypeInputDto) + public BaseResponse DelAdminType(DeleteAdministratorTypeInputDto deleteAdministratorTypeInputDto) { try { - adminTypeRepository.Delete(EntityMapper.Map(deleteAdministratorTypeInputDto)); + var adminType = adminTypeRepository.GetFirst(a => a.TypeId == deleteAdministratorTypeInputDto.TypeId); + adminType.IsDelete = deleteAdministratorTypeInputDto.IsDelete; + adminTypeRepository.SoftDelete(adminType); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } } } diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Administrator/IAdminService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Administrator/IAdminService.cs index fb10e4f..03bb441 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Administrator/IAdminService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Administrator/IAdminService.cs @@ -48,21 +48,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddAdmin(CreateAdministratorInputDto createAdministratorInputDto); + BaseResponse AddAdmin(CreateAdministratorInputDto createAdministratorInputDto); /// /// 更新管理员 /// /// /// - BaseOutputDto UpdAdmin(UpdateAdministratorInputDto updateAdministratorInputDto); + BaseResponse UpdAdmin(UpdateAdministratorInputDto updateAdministratorInputDto); /// /// 删除管理员 /// /// /// - BaseOutputDto DelAdmin(DeleteAdministratorInputDto deleteAdministratorInputDto); + BaseResponse DelAdmin(DeleteAdministratorInputDto deleteAdministratorInputDto); /// /// 获取所有管理员类型 @@ -75,20 +75,20 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddAdminType(CreateAdministratorTypeInputDto createAdministratorTypeInputDto); + BaseResponse AddAdminType(CreateAdministratorTypeInputDto createAdministratorTypeInputDto); /// /// 更新管理员类型 /// /// /// - BaseOutputDto UpdAdminType(UpdateAdministratorTypeInputDto updateAdministratorTypeInputDto); + BaseResponse UpdAdminType(UpdateAdministratorTypeInputDto updateAdministratorTypeInputDto); /// /// 删除管理员类型 /// /// /// - BaseOutputDto DelAdminType(DeleteAdministratorTypeInputDto deleteAdministratorTypeInputDto); + BaseResponse DelAdminType(DeleteAdministratorTypeInputDto deleteAdministratorTypeInputDto); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Base/BaseService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Base/BaseService.cs index fa7c408..0b65ad2 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Base/BaseService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Base/BaseService.cs @@ -134,8 +134,11 @@ namespace EOM.TSHotelManagement.Application return new ListOutputDto { - listSource = enumList, - total = enumList.Count + Data = new PagedData + { + Items = enumList, + TotalCount = enumList.Count + } }; } @@ -162,8 +165,11 @@ namespace EOM.TSHotelManagement.Application return new ListOutputDto { - listSource = enumList, - total = enumList.Count + Data = new PagedData + { + Items = enumList, + TotalCount = enumList.Count + } }; } @@ -189,8 +195,11 @@ namespace EOM.TSHotelManagement.Application return new ListOutputDto { - listSource = enumList, - total = enumList.Count + Data = new PagedData + { + Items = enumList, + TotalCount = enumList.Count + } }; } #endregion @@ -223,10 +232,18 @@ namespace EOM.TSHotelManagement.Application else { positions = positionRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = positions.Count; } var result = EntityMapper.MapList(positions); - return new ListOutputDto { listSource = result, total = count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// @@ -235,9 +252,9 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto SelectPosition(ReadPositionInputDto positionInputDto) { - var position = positionRepository.GetSingle(a => a.Id == positionInputDto.PositionId); + var position = positionRepository.GetFirst(a => a.Id == positionInputDto.PositionId); var result = EntityMapper.Map(position); - return new SingleOutputDto { Source = result }; + return new SingleOutputDto { Data = result }; } /// @@ -245,11 +262,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddPosition(CreatePositionInputDto createPositionInputDto) + public BaseResponse AddPosition(CreatePositionInputDto createPositionInputDto) { var position = EntityMapper.Map(createPositionInputDto); var result = positionRepository.Insert(position); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -257,15 +274,10 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DelPosition(DeletePositionInputDto deletePositionInputDto) + public BaseResponse DelPosition(DeletePositionInputDto deletePositionInputDto) { - var result = positionRepository.Update(a => new Position() - { - IsDelete = deletePositionInputDto.IsDelete, - DataChgUsr = deletePositionInputDto.DataChgUsr, - DataChgDate = deletePositionInputDto.DataChgDate - }, a => a.PositionNumber == deletePositionInputDto.PositionNumber); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var result = positionRepository.SoftDelete(EntityMapper.Map(deletePositionInputDto)); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -273,15 +285,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdPosition(UpdatePositionInputDto updatePositionInputDto) + public BaseResponse UpdPosition(UpdatePositionInputDto updatePositionInputDto) { - var result = positionRepository.Update(a => new Position() - { - PositionName = updatePositionInputDto.PositionName, - DataChgUsr = updatePositionInputDto.DataChgUsr, - DataChgDate = updatePositionInputDto.DataChgDate - }, a => a.PositionNumber == updatePositionInputDto.PositionNumber); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var position = EntityMapper.Map(updatePositionInputDto); + var result = positionRepository.Update(position); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } #endregion @@ -311,10 +319,18 @@ namespace EOM.TSHotelManagement.Application else { nations = nationRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = nations.Count; } var result = EntityMapper.MapList(nations); - return new ListOutputDto { listSource = result, total = count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// @@ -323,9 +339,9 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto SelectNation(ReadNationInputDto nationInputDto) { - var nation = nationRepository.GetSingle(a => a.Id == nationInputDto.NationId); + var nation = nationRepository.GetFirst(a => a.Id == nationInputDto.NationId); var result = EntityMapper.Map(nation); - return new SingleOutputDto { Source = result }; + return new SingleOutputDto { Data = result }; } /// @@ -333,11 +349,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddNation(CreateNationInputDto createNationInputDto) + public BaseResponse AddNation(CreateNationInputDto createNationInputDto) { var nation = EntityMapper.Map(createNationInputDto); var result = nationRepository.Insert(nation); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -345,15 +361,10 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DelNation(DeleteNationInputDto deleteNationInputDto) + public BaseResponse DelNation(DeleteNationInputDto deleteNationInputDto) { - var result = nationRepository.Update(a => new Nation() - { - IsDelete = deleteNationInputDto.IsDelete, - DataChgUsr = deleteNationInputDto.DataChgUsr, - DataChgDate = deleteNationInputDto.DataChgDate - }, a => a.NationNumber == deleteNationInputDto.NationNumber); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var result = nationRepository.SoftDelete(EntityMapper.Map(deleteNationInputDto)); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -361,15 +372,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdNation(UpdateNationInputDto updateNationInputDto) + public BaseResponse UpdNation(UpdateNationInputDto updateNationInputDto) { - var result = nationRepository.Update(a => new Nation() - { - NationName = updateNationInputDto.NationName, - DataChgUsr = updateNationInputDto.DataChgUsr, - DataChgDate = updateNationInputDto.DataChgDate - }, a => a.NationNumber == updateNationInputDto.NationNumber); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var nation = EntityMapper.Map(updateNationInputDto); + var result = nationRepository.Update(nation); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } #endregion @@ -398,10 +405,18 @@ namespace EOM.TSHotelManagement.Application else { educations = educationRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = educations.Count; } var result = EntityMapper.MapList(educations); - return new ListOutputDto { listSource = result, total = count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// @@ -410,9 +425,9 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto SelectEducation(ReadEducationInputDto educationInputDto) { - var education = educationRepository.GetSingle(a => a.EducationNumber == educationInputDto.EducationNumber); + var education = educationRepository.GetFirst(a => a.EducationNumber == educationInputDto.EducationNumber); var result = EntityMapper.Map(education); - return new SingleOutputDto { Source = result }; + return new SingleOutputDto { Data = result }; } /// @@ -420,11 +435,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddEducation(CreateEducationInputDto createEducationInputDto) + public BaseResponse AddEducation(CreateEducationInputDto createEducationInputDto) { var education = EntityMapper.Map(createEducationInputDto); var result = educationRepository.Insert(education); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -432,15 +447,10 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DelEducation(DeleteEducationInputDto deleteEducationInputDto) + public BaseResponse DelEducation(DeleteEducationInputDto deleteEducationInputDto) { - var result = educationRepository.Update(a => new Education() - { - IsDelete = deleteEducationInputDto.IsDelete, - DataChgUsr = deleteEducationInputDto.DataChgUsr, - DataChgDate = deleteEducationInputDto.DataChgDate - }, a => a.EducationNumber == deleteEducationInputDto.EducationNumber); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var result = educationRepository.SoftDelete(EntityMapper.Map(deleteEducationInputDto)); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -448,15 +458,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdEducation(UpdateEducationInputDto education) + public BaseResponse UpdEducation(UpdateEducationInputDto education) { - var result = educationRepository.Update(a => new Education() - { - EducationName = education.EducationName, - DataChgUsr = education.DataChgUsr, - DataChgDate = education.DataChgDate - }, a => a.EducationNumber == education.EducationNumber); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var entity = EntityMapper.Map(education); + var result = educationRepository.Update(entity); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } #endregion @@ -471,7 +477,14 @@ namespace EOM.TSHotelManagement.Application { var depts = deptRepository.GetList(a => a.IsDelete != 1); var result = EntityMapper.MapList(depts); - return new ListOutputDto { listSource = result, total = result.Count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = result.Count + } + }; } /// @@ -495,6 +508,7 @@ namespace EOM.TSHotelManagement.Application else { depts = deptRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = depts.Count; } var parentDepartmentNumbers = depts.Where(a => !a.ParentDepartmentNumber.IsNullOrEmpty()).Select(a => a.ParentDepartmentNumber).ToList(); @@ -511,7 +525,14 @@ namespace EOM.TSHotelManagement.Application source.LeaderName = departmentLeader.IsNullOrEmpty() ? "" : departmentLeader.EmployeeName; }); var result = EntityMapper.MapList(depts); - return new ListOutputDto { listSource = result, total = count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// @@ -520,9 +541,9 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto SelectDept(ReadDepartmentInputDto dept) { - var department = deptRepository.GetSingle(a => a.Id == dept.Id); + var department = deptRepository.GetFirst(a => a.Id == dept.Id); var result = EntityMapper.Map(department); - return new SingleOutputDto { Source = result }; + return new SingleOutputDto { Data = result }; } /// @@ -530,11 +551,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddDept(CreateDepartmentInputDto dept) + public BaseResponse AddDept(CreateDepartmentInputDto dept) { var department = EntityMapper.Map(dept); var result = deptRepository.Insert(department); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -542,15 +563,10 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DelDept(DeleteDepartmentInputDto dept) + public BaseResponse DelDept(DeleteDepartmentInputDto dept) { - var result = deptRepository.Update(a => new Department() - { - IsDelete = dept.IsDelete, - DataChgUsr = dept.DataChgUsr, - DataChgDate = dept.DataChgDate - }, a => a.Id == dept.Id); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var result = deptRepository.SoftDelete(EntityMapper.Map(dept)); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -558,19 +574,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdDept(UpdateDepartmentInputDto dept) + public BaseResponse UpdDept(UpdateDepartmentInputDto dept) { - var result = deptRepository.Update(a => new Department() - { - DepartmentName = dept.DepartmentName, - DepartmentDescription = dept.DepartmentDescription, - DepartmentLeader = dept.DepartmentLeader, - ParentDepartmentNumber = dept.ParentDepartmentNumber, - DepartmentCreationDate = dept.DepartmentCreationDate, - DataChgUsr = dept.DataChgUsr, - DataChgDate = dept.DataChgDate - }, a => a.DepartmentNumber == dept.DepartmentNumber); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var department = EntityMapper.Map(dept); + var result = deptRepository.Update(department); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } #endregion @@ -585,7 +593,14 @@ namespace EOM.TSHotelManagement.Application { var custoTypes = custoTypeRepository.GetList(a => a.IsDelete != 1); var result = EntityMapper.MapList(custoTypes); - return new ListOutputDto { listSource = result, total = result.Count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = result.Count + } + }; } /// @@ -609,10 +624,18 @@ namespace EOM.TSHotelManagement.Application else { custoTypes = custoTypeRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = custoTypes.Count; } var result = EntityMapper.MapList(custoTypes); - return new ListOutputDto { listSource = result, total = count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// @@ -622,9 +645,9 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto SelectCustoTypeByTypeId(ReadCustoTypeInputDto custoType) { - var custoTypeEntity = custoTypeRepository.GetSingle(a => a.CustomerType == custoType.CustomerType && a.IsDelete != 1); + var custoTypeEntity = custoTypeRepository.GetFirst(a => a.CustomerType == custoType.CustomerType && a.IsDelete != 1); var result = EntityMapper.Map(custoTypeEntity); - return new SingleOutputDto { Source = result }; + return new SingleOutputDto { Data = result }; } /// @@ -632,11 +655,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto InsertCustoType(CreateCustoTypeInputDto custoType) + public BaseResponse InsertCustoType(CreateCustoTypeInputDto custoType) { var custoTypeEntity = EntityMapper.Map(custoType); var result = custoTypeRepository.Insert(custoTypeEntity); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -644,14 +667,10 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteCustoType(DeleteCustoTypeInputDto custoType) + public BaseResponse DeleteCustoType(DeleteCustoTypeInputDto custoType) { - var result = custoTypeRepository.Update(a => new CustoType() - { - IsDelete = 1, - DataChgUsr = custoType.DataChgUsr - }, a => a.CustomerType == custoType.CustomerType); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var result = custoTypeRepository.SoftDelete(EntityMapper.Map(custoType)); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -659,16 +678,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateCustoType(UpdateCustoTypeInputDto custoType) + public BaseResponse UpdateCustoType(UpdateCustoTypeInputDto custoType) { - var result = custoTypeRepository.Update(a => new CustoType() - { - CustomerTypeName = custoType.CustomerTypeName, - Discount = custoType.Discount, - DataChgUsr = custoType.DataChgUsr, - DataChgDate = custoType.DataChgDate - }, a => a.CustomerType == custoType.CustomerType); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var entity = EntityMapper.Map(custoType); + var result = custoTypeRepository.Update(entity); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } #endregion @@ -683,7 +697,14 @@ namespace EOM.TSHotelManagement.Application { var passPortTypes = passPortTypeRepository.GetList(a => a.IsDelete != 1); var result = EntityMapper.MapList(passPortTypes); - return new ListOutputDto { listSource = result, total = result.Count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = result.Count + } + }; } /// @@ -707,10 +728,18 @@ namespace EOM.TSHotelManagement.Application else { passPortTypes = passPortTypeRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = passPortTypes.Count; } var result = EntityMapper.MapList(passPortTypes); - return new ListOutputDto { listSource = result, total = count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// @@ -720,9 +749,9 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto SelectPassPortTypeByTypeId(ReadPassportTypeInputDto passPortType) { - var passPortTypeEntity = passPortTypeRepository.GetSingle(a => a.PassportId == passPortType.PassportId && a.IsDelete != 1); + var passPortTypeEntity = passPortTypeRepository.GetFirst(a => a.PassportId == passPortType.PassportId && a.IsDelete != 1); var result = EntityMapper.Map(passPortTypeEntity); - return new SingleOutputDto { Source = result }; + return new SingleOutputDto { Data = result }; } /// @@ -730,11 +759,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto InsertPassPortType(CreatePassportTypeInputDto passPortType) + public BaseResponse InsertPassPortType(CreatePassportTypeInputDto passPortType) { var passPortTypeEntity = EntityMapper.Map(passPortType); var result = passPortTypeRepository.Insert(passPortTypeEntity); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -742,14 +771,10 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeletePassPortType(DeletePassportTypeInputDto portType) + public BaseResponse DeletePassPortType(DeletePassportTypeInputDto portType) { - var result = passPortTypeRepository.Update(a => new PassportType() - { - IsDelete = 1, - DataChgUsr = portType.DataChgUsr, - }, a => a.PassportId == portType.PassportId); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var result = passPortTypeRepository.SoftDelete(EntityMapper.Map(portType)); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -757,15 +782,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdatePassPortType(UpdatePassportTypeInputDto portType) + public BaseResponse UpdatePassPortType(UpdatePassportTypeInputDto portType) { - var result = passPortTypeRepository.Update(a => new PassportType() - { - PassportName = portType.PassportName, - DataChgUsr = portType.DataChgUsr, - DataChgDate = portType.DataChgDate - }, a => a.PassportId == portType.PassportId); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var entity = EntityMapper.Map(portType); + var result = passPortTypeRepository.Update(entity); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } #endregion @@ -780,7 +801,14 @@ namespace EOM.TSHotelManagement.Application { var gBTypes = goodbadTypeRepository.GetList(a => a.IsDelete != 1); var result = EntityMapper.MapList(gBTypes); - return new ListOutputDto { listSource = result, total = result.Count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = result.Count + } + }; } /// @@ -804,10 +832,18 @@ namespace EOM.TSHotelManagement.Application else { gBTypes = goodbadTypeRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = gBTypes.Count; } var result = EntityMapper.MapList(gBTypes); - return new ListOutputDto { listSource = result, total = count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// @@ -817,9 +853,9 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto SelectRewardPunishmentTypeByTypeId(ReadRewardPunishmentTypeInputDto gBType) { - var gBTypeEntity = goodbadTypeRepository.GetSingle(a => a.RewardPunishmentTypeId == gBType.RewardPunishmentTypeId && a.IsDelete != 1); + var gBTypeEntity = goodbadTypeRepository.GetFirst(a => a.RewardPunishmentTypeId == gBType.RewardPunishmentTypeId && a.IsDelete != 1); var result = EntityMapper.Map(gBTypeEntity); - return new SingleOutputDto { Source = result }; + return new SingleOutputDto { Data = result }; } /// @@ -827,11 +863,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto InsertRewardPunishmentType(CreateRewardPunishmentTypeInputDto gBType) + public BaseResponse InsertRewardPunishmentType(CreateRewardPunishmentTypeInputDto gBType) { var gBTypeEntity = EntityMapper.Map(gBType); var result = goodbadTypeRepository.Insert(gBTypeEntity); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -839,14 +875,10 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteRewardPunishmentType(DeleteRewardPunishmentTypeInputDto gBType) + public BaseResponse DeleteRewardPunishmentType(DeleteRewardPunishmentTypeInputDto gBType) { - var result = goodbadTypeRepository.Update(a => new RewardPunishmentType() - { - IsDelete = 1, - DataChgUsr = gBType.DataChgUsr, - }, a => a.RewardPunishmentTypeId == gBType.RewardPunishmentTypeId); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var result = goodbadTypeRepository.SoftDelete(EntityMapper.Map(gBType)); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } /// @@ -854,15 +886,11 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateRewardPunishmentType(UpdateRewardPunishmentTypeInputDto gBType) + public BaseResponse UpdateRewardPunishmentType(UpdateRewardPunishmentTypeInputDto gBType) { - var result = goodbadTypeRepository.Update(a => new RewardPunishmentType() - { - RewardPunishmentTypeName = gBType.RewardPunishmentTypeName, - DataChgUsr = gBType.DataChgUsr, - DataChgDate = gBType.DataChgDate - }, a => a.RewardPunishmentTypeId == gBType.RewardPunishmentTypeId); - return new BaseOutputDto { StatusCode = result ? StatusCodeConstants.Success : StatusCodeConstants.InternalServerError }; + var entity = EntityMapper.Map(gBType); + var result = goodbadTypeRepository.Update(entity); + return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } #endregion @@ -875,7 +903,7 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectAppointmentNoticeTypeAll(ReadAppointmentNoticeTypeInputDto readAppointmentNoticeTypeInputDto) { - var listSource = new List(); + var Data = new List(); var where = Expressionable.Create(); @@ -888,17 +916,24 @@ namespace EOM.TSHotelManagement.Application if (!readAppointmentNoticeTypeInputDto.IgnorePaging && readAppointmentNoticeTypeInputDto.Page != 0 && readAppointmentNoticeTypeInputDto.PageSize != 0) { - listSource = appointmentNoticeTypeRepository.AsQueryable().Where(where.ToExpression()) + Data = appointmentNoticeTypeRepository.AsQueryable().Where(where.ToExpression()) .ToPageList(readAppointmentNoticeTypeInputDto.Page, readAppointmentNoticeTypeInputDto.PageSize, ref count); } else { - listSource = appointmentNoticeTypeRepository.AsQueryable().Where(where.ToExpression()).ToList(); + Data = appointmentNoticeTypeRepository.AsQueryable().Where(where.ToExpression()).ToList(); } - var result = EntityMapper.MapList(listSource); + var result = EntityMapper.MapList(Data); - return new ListOutputDto { listSource = result, total = count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// @@ -906,23 +941,29 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto CreateAppointmentNoticeType(CreateAppointmentNoticeTypeInputDto createAppointmentNoticeTypeInputDto) + public BaseResponse CreateAppointmentNoticeType(CreateAppointmentNoticeTypeInputDto createAppointmentNoticeTypeInputDto) { try { if (appointmentNoticeTypeRepository.IsAny(a => a.NoticeTypeNumber == createAppointmentNoticeTypeInputDto.NoticeTypeNumber)) { - return new BaseOutputDto { StatusCode = StatusCodeConstants.InternalServerError, Message = LocalizationHelper.GetLocalizedString("appointment notice number already exits.", "公告类型编号已存在") }; + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("appointment notice number already exits.", "公告类型编号已存在") }; + } + var entity = EntityMapper.Map(createAppointmentNoticeTypeInputDto); + var result = appointmentNoticeTypeRepository.Insert(entity); + if (!result) + { + LogHelper.LogError(LocalizationHelper.GetLocalizedString("insert appointment notice failed.", "公告类型添加失败"), null); + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("insert appointment notice failed.", "公告类型添加失败") }; } - appointmentNoticeTypeRepository.Insert(EntityMapper.Map(createAppointmentNoticeTypeInputDto)); } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("insert appointment notice failed.", "公告类型添加失败"), ex); - return new BaseOutputDto { StatusCode = StatusCodeConstants.InternalServerError, Message = LocalizationHelper.GetLocalizedString("insert appointment notice failed.", "公告类型添加失败") }; + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("insert appointment notice failed.", "公告类型添加失败") }; } - return new BaseOutputDto { StatusCode = StatusCodeConstants.Success, Message = LocalizationHelper.GetLocalizedString("insert appointment notice successful.", "公告类型添加成功") }; + return new BaseResponse { Code = BusinessStatusCode.Success, Message = LocalizationHelper.GetLocalizedString("insert appointment notice successful.", "公告类型添加成功") }; } /// @@ -930,28 +971,23 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteAppointmentNoticeType(DeleteAppointmentNoticeTypeInputDto deleteAppointmentNoticeTypeInputDto) + public BaseResponse DeleteAppointmentNoticeType(DeleteAppointmentNoticeTypeInputDto deleteAppointmentNoticeTypeInputDto) { try { if (!appointmentNoticeTypeRepository.IsAny(a => a.NoticeTypeNumber == deleteAppointmentNoticeTypeInputDto.NoticeTypeNumber)) { - return new BaseOutputDto { StatusCode = StatusCodeConstants.InternalServerError, Message = LocalizationHelper.GetLocalizedString("appointment notice number does not already.", "公告类型编号不存在") }; + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("appointment notice number does not already.", "公告类型编号不存在") }; } - appointmentNoticeTypeRepository.Update(a => new AppointmentNoticeType - { - IsDelete = 1, - DataChgUsr = deleteAppointmentNoticeTypeInputDto.DataChgUsr, - DataChgDate = deleteAppointmentNoticeTypeInputDto.DataChgDate - }, a => a.NoticeTypeNumber == deleteAppointmentNoticeTypeInputDto.NoticeTypeNumber); + appointmentNoticeTypeRepository.SoftDelete(EntityMapper.Map(deleteAppointmentNoticeTypeInputDto)); } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("delete appointment notice failed.", "公告类型删除失败"), ex); - return new BaseOutputDto { StatusCode = StatusCodeConstants.InternalServerError, Message = LocalizationHelper.GetLocalizedString("delete appointment notice failed.", "公告类型删除失败") }; + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("delete appointment notice failed.", "公告类型删除失败") }; } - return new BaseOutputDto { StatusCode = StatusCodeConstants.Success, Message = LocalizationHelper.GetLocalizedString("delete appointment notice successful.", "公告类型删除成功") }; + return new BaseResponse { Code = BusinessStatusCode.Success, Message = LocalizationHelper.GetLocalizedString("delete appointment notice successful.", "公告类型删除成功") }; } /// @@ -959,23 +995,29 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateAppointmentNoticeType(UpdateAppointmentNoticeTypeInputDto updateAppointmentNoticeTypeInputDto) + public BaseResponse UpdateAppointmentNoticeType(UpdateAppointmentNoticeTypeInputDto updateAppointmentNoticeTypeInputDto) { try { if (!appointmentNoticeTypeRepository.IsAny(a => a.NoticeTypeNumber == updateAppointmentNoticeTypeInputDto.NoticeTypeNumber)) { - return new BaseOutputDto { StatusCode = StatusCodeConstants.InternalServerError, Message = LocalizationHelper.GetLocalizedString("appointment notice number does not already.", "公告类型编号不存在") }; + 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(EntityMapper.Map(updateAppointmentNoticeTypeInputDto)); } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("update appointment notice failed.", "公告类型更新失败"), ex); - return new BaseOutputDto { StatusCode = StatusCodeConstants.InternalServerError, Message = LocalizationHelper.GetLocalizedString("update appointment notice failed.", "公告类型更新失败") }; + return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("update appointment notice failed.", "公告类型更新失败") }; } - return new BaseOutputDto { StatusCode = StatusCodeConstants.Success, Message = LocalizationHelper.GetLocalizedString("update appointment notice successful.", "公告类型更新成功") }; + return new BaseResponse { Code = BusinessStatusCode.Success, Message = LocalizationHelper.GetLocalizedString("update appointment notice successful.", "公告类型更新成功") }; } #endregion diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Base/IBaseService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Base/IBaseService.cs index 1109716..2ecafd4 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Base/IBaseService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Base/IBaseService.cs @@ -76,21 +76,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddPosition(CreatePositionInputDto position); + BaseResponse AddPosition(CreatePositionInputDto position); /// /// 删除职位类型 /// /// /// - BaseOutputDto DelPosition(DeletePositionInputDto position); + BaseResponse DelPosition(DeletePositionInputDto position); /// /// 更新职位类型 /// /// /// - BaseOutputDto UpdPosition(UpdatePositionInputDto position); + BaseResponse UpdPosition(UpdatePositionInputDto position); #endregion @@ -113,21 +113,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddNation(CreateNationInputDto nation); + BaseResponse AddNation(CreateNationInputDto nation); /// /// 删除民族类型 /// /// /// - BaseOutputDto DelNation(DeleteNationInputDto nation); + BaseResponse DelNation(DeleteNationInputDto nation); /// /// 更新民族类型 /// /// /// - BaseOutputDto UpdNation(UpdateNationInputDto nation); + BaseResponse UpdNation(UpdateNationInputDto nation); #endregion @@ -150,21 +150,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddEducation(CreateEducationInputDto education); + BaseResponse AddEducation(CreateEducationInputDto education); /// /// 删除学历类型 /// /// /// - BaseOutputDto DelEducation(DeleteEducationInputDto education); + BaseResponse DelEducation(DeleteEducationInputDto education); /// /// 更新学历类型 /// /// /// - BaseOutputDto UpdEducation(UpdateEducationInputDto education); + BaseResponse UpdEducation(UpdateEducationInputDto education); #endregion @@ -193,21 +193,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddDept(CreateDepartmentInputDto dept); + BaseResponse AddDept(CreateDepartmentInputDto dept); /// /// 删除部门类型 /// /// /// - BaseOutputDto DelDept(DeleteDepartmentInputDto dept); + BaseResponse DelDept(DeleteDepartmentInputDto dept); /// /// 更新部门类型 /// /// /// - BaseOutputDto UpdDept(UpdateDepartmentInputDto dept); + BaseResponse UpdDept(UpdateDepartmentInputDto dept); #endregion @@ -237,21 +237,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto InsertCustoType(CreateCustoTypeInputDto custoType); + BaseResponse InsertCustoType(CreateCustoTypeInputDto custoType); /// /// 删除客户类型 /// /// /// - BaseOutputDto DeleteCustoType(DeleteCustoTypeInputDto custoType); + BaseResponse DeleteCustoType(DeleteCustoTypeInputDto custoType); /// /// 更新客户类型 /// /// /// - BaseOutputDto UpdateCustoType(UpdateCustoTypeInputDto custoType); + BaseResponse UpdateCustoType(UpdateCustoTypeInputDto custoType); #endregion @@ -281,21 +281,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto InsertPassPortType(CreatePassportTypeInputDto passPortType); + BaseResponse InsertPassPortType(CreatePassportTypeInputDto passPortType); /// /// 删除证件类型 /// /// /// - BaseOutputDto DeletePassPortType(DeletePassportTypeInputDto portType); + BaseResponse DeletePassPortType(DeletePassportTypeInputDto portType); /// /// 更新证件类型 /// /// /// - BaseOutputDto UpdatePassPortType(UpdatePassportTypeInputDto portType); + BaseResponse UpdatePassPortType(UpdatePassportTypeInputDto portType); #endregion @@ -325,21 +325,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto InsertRewardPunishmentType(CreateRewardPunishmentTypeInputDto gBType); + BaseResponse InsertRewardPunishmentType(CreateRewardPunishmentTypeInputDto gBType); /// /// 删除奖惩类型 /// /// /// - BaseOutputDto DeleteRewardPunishmentType(DeleteRewardPunishmentTypeInputDto gBType); + BaseResponse DeleteRewardPunishmentType(DeleteRewardPunishmentTypeInputDto gBType); /// /// 更新奖惩类型 /// /// /// - BaseOutputDto UpdateRewardPunishmentType(UpdateRewardPunishmentTypeInputDto gBType); + BaseResponse UpdateRewardPunishmentType(UpdateRewardPunishmentTypeInputDto gBType); #endregion @@ -356,21 +356,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto CreateAppointmentNoticeType(CreateAppointmentNoticeTypeInputDto createAppointmentNoticeTypeInputDto); + BaseResponse CreateAppointmentNoticeType(CreateAppointmentNoticeTypeInputDto createAppointmentNoticeTypeInputDto); /// /// 删除公告类型 /// /// /// - BaseOutputDto DeleteAppointmentNoticeType(DeleteAppointmentNoticeTypeInputDto deleteAppointmentNoticeTypeInputDto); + BaseResponse DeleteAppointmentNoticeType(DeleteAppointmentNoticeTypeInputDto deleteAppointmentNoticeTypeInputDto); /// /// 更新公告类型 /// /// /// - BaseOutputDto UpdateAppointmentNoticeType(UpdateAppointmentNoticeTypeInputDto updateAppointmentNoticeTypeInputDto); + BaseResponse UpdateAppointmentNoticeType(UpdateAppointmentNoticeTypeInputDto updateAppointmentNoticeTypeInputDto); #endregion } diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Menu/IMenuService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Menu/IMenuService.cs index fb0b88d..754e4c1 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Menu/IMenuService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Menu/IMenuService.cs @@ -41,27 +41,27 @@ namespace EOM.TSHotelManagement.Application /// 构建菜单树 /// /// - List BuildMenuAll(BaseInputDto baseInputDto); + ListOutputDto BuildMenuAll(BaseInputDto baseInputDto); /// /// 插入菜单 /// /// /// - BaseOutputDto InsertMenu(CreateMenuInputDto menu); + BaseResponse InsertMenu(CreateMenuInputDto menu); /// /// 更新菜单 /// /// /// - BaseOutputDto UpdateMenu(UpdateMenuInputDto menu); + BaseResponse UpdateMenu(UpdateMenuInputDto menu); /// /// 删除菜单 /// /// /// - BaseOutputDto DeleteMenu(DeleteMenuInputDto menu); + BaseResponse DeleteMenu(DeleteMenuInputDto menu); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Menu/MenuService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Menu/MenuService.cs index 9cbeaf4..1affeed 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Menu/MenuService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Menu/MenuService.cs @@ -60,7 +60,7 @@ namespace EOM.TSHotelManagement.Application /// 构建菜单树 /// /// - public List BuildMenuAll(BaseInputDto baseInputDto) + public ListOutputDto BuildMenuAll(BaseInputDto baseInputDto) { var token = baseInputDto.UserToken; @@ -68,7 +68,7 @@ namespace EOM.TSHotelManagement.Application List allMenus = menuRepository.GetList(a => a.IsDelete != 1).OrderBy(a => a.Id).ToList(); - List result = BuildMenuTree(allMenus, null); + ListOutputDto result = BuildMenuTree(allMenus); return result; } @@ -100,14 +100,18 @@ namespace EOM.TSHotelManagement.Application else { allMenus = menuRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = allMenus.Count; } List result = EntityMapper.MapList(allMenus); return new ListOutputDto { - listSource = result, - total = count + Data = new PagedData + { + Items = result, + TotalCount = count + } }; } @@ -116,22 +120,22 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto InsertMenu(CreateMenuInputDto menu) + public BaseResponse InsertMenu(CreateMenuInputDto menu) { try { if (menuRepository.IsAny(a => a.Key == menu.Key && a.IsDelete == 0)) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("This menu already exists.", "菜单已存在。"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("This menu already exists.", "菜单已存在。"), Code = BusinessStatusCode.InternalServerError }; } menuRepository.Insert(EntityMapper.Map(menu)); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -139,7 +143,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateMenu(UpdateMenuInputDto menu) + public BaseResponse UpdateMenu(UpdateMenuInputDto menu) { try { @@ -147,9 +151,9 @@ namespace EOM.TSHotelManagement.Application } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -157,49 +161,90 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteMenu(DeleteMenuInputDto menu) + public BaseResponse DeleteMenu(DeleteMenuInputDto menu) { try { - menuRepository.Update(EntityMapper.Map(menu)); + menuRepository.SoftDelete(EntityMapper.Map(menu)); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// /// 递归构建菜单树 /// /// - /// /// - private List BuildMenuTree(List menus, int? parentId) + private ListOutputDto BuildMenuTree(List menus) { - List result = new List(); + try + { + var menuDict = menus.ToDictionary(m => m.Id); + var rootNodes = new List(); + + var processedIds = new HashSet(); - var filteredMenus = menus.Where(m => m.Parent == parentId).ToList(); + foreach (var menu in menus.Where(m => m.Parent == null)) + { + var node = BuildTreeNode(menu, menuDict, processedIds); + if (node != null) rootNodes.Add(node); + } - foreach (var menu in filteredMenus) + return new ListOutputDto + { + Code = 0, + Message = "菜单树构建成功", + Data = new PagedData + { + Items = rootNodes, + TotalCount = rootNodes.Count + } + }; + } + catch (Exception ex) { - MenuViewModel viewModel = new MenuViewModel + return new ListOutputDto { - Key = menu.Key, - Title = menu.Title, - Path = menu.Path, - Icon = menu.Icon, - Children = BuildMenuTree(menus, menu.Id) + Code = 5001, + Message = $"菜单树构建失败: {ex.Message}", + Data = null }; - if (viewModel.Children.Count == 0) + } + } + + private MenuDto BuildTreeNode( + Menu menu, + Dictionary menuDict, + HashSet processedIds) + { + processedIds.Add(menu.Id); + + var node = new MenuDto + { + Key = menu.Key, + Title = menu.Title, + Path = menu.Path, + Icon = menu.Icon, + Children = new List() + }; + + var childMenus = menuDict.Values + .Where(m => m.Parent == menu.Id) + .ToList(); + + foreach (var child in childMenus) + { + var childNode = BuildTreeNode(child, menuDict, processedIds); + if (childNode != null) { - viewModel.Children = null; + node.Children.Add(childNode); } - result.Add(viewModel); } - - return result; + return node; } } } diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Notice/INoticeService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Notice/INoticeService.cs index a809f06..aa8a358 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Notice/INoticeService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Notice/INoticeService.cs @@ -48,21 +48,21 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto InsertNotice(CreateAppointmentNoticeInputDto createAppointmentNoticeInputDto); + BaseResponse InsertNotice(CreateAppointmentNoticeInputDto createAppointmentNoticeInputDto); /// /// 删除公告信息 /// /// /// - BaseOutputDto DeleteNotice(DeleteAppointmentNoticeInputDto deleteAppointmentNoticeInputDto); + BaseResponse DeleteNotice(DeleteAppointmentNoticeInputDto deleteAppointmentNoticeInputDto); /// /// 更新公告信息 /// /// /// - BaseOutputDto UpdateNotice(UpdateAppointmentNoticeInputDto updateAppointmentNoticeInputDto); + BaseResponse UpdateNotice(UpdateAppointmentNoticeInputDto updateAppointmentNoticeInputDto); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Notice/NoticeService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Notice/NoticeService.cs index 5587894..1475c7b 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Notice/NoticeService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Notice/NoticeService.cs @@ -55,7 +55,7 @@ namespace EOM.TSHotelManagement.Application /// public ListOutputDto SelectNoticeAll(ReadAppointmentNoticeInputDto readAppointmentNoticeInputDto) { - List ntc = new List(); + var ntc = new List(); var where = Expressionable.Create(); if (!string.IsNullOrEmpty(readAppointmentNoticeInputDto.NoticeTheme)) { @@ -83,13 +83,14 @@ namespace EOM.TSHotelManagement.Application break; } }); - - var listSource = EntityMapper.MapList(ntc); - + var mapped = EntityMapper.MapList(ntc); return new ListOutputDto { - listSource = listSource, - total = listSource.Count + Data = new PagedData + { + Items = mapped, + TotalCount = count + } }; } @@ -101,7 +102,7 @@ namespace EOM.TSHotelManagement.Application public ReadAppointmentNoticeOutputDto SelectNoticeByNoticeNo(ReadAppointmentNoticeInputDto readAppointmentNoticeInputDto) { AppointmentNotice notice = new AppointmentNotice(); - notice = noticeRepository.GetSingle(a => a.NoticeNumber == readAppointmentNoticeInputDto.NoticeId); + notice = noticeRepository.GetFirst(a => a.NoticeNumber == readAppointmentNoticeInputDto.NoticeId); switch (notice.NoticeType) { case "PersonnelChanges": @@ -121,17 +122,22 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto InsertNotice(CreateAppointmentNoticeInputDto notice) + public BaseResponse InsertNotice(CreateAppointmentNoticeInputDto notice) { try { - noticeRepository.Insert(EntityMapper.Map(notice)); + 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 }; + } } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -139,18 +145,24 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteNotice(DeleteAppointmentNoticeInputDto deleteAppointmentNoticeInputDto) + public BaseResponse DeleteNotice(DeleteAppointmentNoticeInputDto deleteAppointmentNoticeInputDto) { try { - noticeRepository.Update(EntityMapper.Map(deleteAppointmentNoticeInputDto)); + var entity = EntityMapper.Map(deleteAppointmentNoticeInputDto); + var result = noticeRepository.SoftDelete(entity); + if (!result) + { + LogHelper.LogError(LocalizationHelper.GetLocalizedString("delete appointment notice failed", "删除公告失败"), null); + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("delete appointment notice failed", "删除公告失败"), Code = BusinessStatusCode.InternalServerError }; + } } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("delete appointment notice failed", "删除公告失败"), ex); - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("delete appointment notice failed", "删除公告失败"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("delete appointment notice failed", "删除公告失败"), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -158,18 +170,24 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateNotice(UpdateAppointmentNoticeInputDto updateAppointmentNoticeInputDto) + public BaseResponse UpdateNotice(UpdateAppointmentNoticeInputDto updateAppointmentNoticeInputDto) { try { - noticeRepository.Update(EntityMapper.Map(updateAppointmentNoticeInputDto)); + 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 }; + } } catch (Exception ex) { LogHelper.LogError(LocalizationHelper.GetLocalizedString("update appointment notice failed", "更新公告失败"), ex); - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString("update appointment notice failed", "更新公告失败"), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("update appointment notice failed", "更新公告失败"), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } } diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Role/IRoleAppService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Role/IRoleAppService.cs index cd24178..f5052da 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Role/IRoleAppService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Role/IRoleAppService.cs @@ -18,18 +18,18 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto InsertRole(CreateRoleInputDto createRoleInputDto); + BaseResponse InsertRole(CreateRoleInputDto createRoleInputDto); /// /// 更新角色 /// /// /// - BaseOutputDto UpdateRole(UpdateRoleInputDto updateRoleInputDto); + BaseResponse UpdateRole(UpdateRoleInputDto updateRoleInputDto); /// /// 删除角色 /// /// /// - BaseOutputDto DeleteRole(DeleteRoleInputDto deleteRoleInputDto); + BaseResponse DeleteRole(DeleteRoleInputDto deleteRoleInputDto); } } diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Role/RoleAppService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Role/RoleAppService.cs index 3c7a148..fffe7fd 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Role/RoleAppService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Role/RoleAppService.cs @@ -32,17 +32,17 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteRole(DeleteRoleInputDto deleteRoleInputDto) + public BaseResponse DeleteRole(DeleteRoleInputDto deleteRoleInputDto) { try { - roleRepository.Delete(EntityMapper.Map(deleteRoleInputDto)); + roleRepository.SoftDelete(EntityMapper.Map(deleteRoleInputDto)); } catch (Exception) { - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Role Error", "删除角色失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Role Error", "删除角色失败")); } - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Delete Role Success", "删除角色成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Role Success", "删除角色成功")); } /// @@ -83,17 +83,19 @@ namespace EOM.TSHotelManagement.Application else { roles = roleRepository.AsQueryable().Where(where.ToExpression()).ToList(); + count = roles.Count; } var roleList = EntityMapper.MapList(roles); - var listOutputDto = new ListOutputDto + return new ListOutputDto { - total = count, - listSource = roleList + Data = new PagedData + { + Items = roleList, + TotalCount = count + } }; - - return listOutputDto; } /// @@ -102,17 +104,22 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto InsertRole(CreateRoleInputDto createRoleInputDto) + public BaseResponse InsertRole(CreateRoleInputDto createRoleInputDto) { try { - roleRepository.Insert(EntityMapper.Map(createRoleInputDto)); + var entity = EntityMapper.Map(createRoleInputDto); + var result = roleRepository.Insert(entity); + if (!result) + { + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Create Role Error", "创建角色失败")); + } } catch (Exception) { - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Create Role Error", "创建角色失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Create Role Error", "创建角色失败")); } - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Create Role Success", "创建角色成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Create Role Success", "创建角色成功")); } /// @@ -121,17 +128,22 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateRole(UpdateRoleInputDto updateRoleInputDto) + public BaseResponse UpdateRole(UpdateRoleInputDto updateRoleInputDto) { try { - roleRepository.Update(EntityMapper.Map(updateRoleInputDto)); + var entity = EntityMapper.Map(updateRoleInputDto); + var result = roleRepository.Update(entity); + if (!result) + { + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Role Error", "更新角色失败")); + } } catch (Exception) { - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Update Role Error", "更新角色失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Update Role Error", "更新角色失败")); } - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Update Role Success", "更新角色成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Update Role Success", "更新角色成功")); } } } diff --git a/EOM.TSHotelManagement.Application/SystemManagement/SupervisionStatistics/ISupervisionStatisticsService.cs b/EOM.TSHotelManagement.Application/SystemManagement/SupervisionStatistics/ISupervisionStatisticsService.cs index 85bc35e..d22f35d 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/SupervisionStatistics/ISupervisionStatisticsService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/SupervisionStatistics/ISupervisionStatisticsService.cs @@ -41,20 +41,20 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto InsertSupervisionStatistics(CreateSupervisionStatisticsInputDto checkInfo); + BaseResponse InsertSupervisionStatistics(CreateSupervisionStatisticsInputDto checkInfo); /// /// 更新监管统计信息 /// /// /// - BaseOutputDto UpdateSupervisionStatistics(UpdateSupervisionStatisticsInputDto checkInfo); + BaseResponse UpdateSupervisionStatistics(UpdateSupervisionStatisticsInputDto checkInfo); /// /// 删除监管统计信息 /// /// /// - BaseOutputDto DeleteSupervisionStatistics(DeleteSupervisionStatisticsInputDto checkInfo); + BaseResponse DeleteSupervisionStatistics(DeleteSupervisionStatisticsInputDto checkInfo); } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Application/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs b/EOM.TSHotelManagement.Application/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs index 42344a6..772e270 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/SupervisionStatistics/SupervisionStatisticsService.cs @@ -70,12 +70,15 @@ namespace EOM.TSHotelManagement.Application c.SupervisingDepartmentName = !dept.IsNullOrEmpty() ? dept.DepartmentName : string.Empty; }); - var listSource = EntityMapper.MapList(cif); + var Data = EntityMapper.MapList(cif); return new ListOutputDto { - listSource = listSource, - total = listSource.Count + Data = new PagedData + { + Items = Data, + TotalCount = count + } }; } @@ -84,7 +87,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto InsertSupervisionStatistics(CreateSupervisionStatisticsInputDto checkInfo) + public BaseResponse InsertSupervisionStatistics(CreateSupervisionStatisticsInputDto checkInfo) { try { @@ -92,9 +95,9 @@ namespace EOM.TSHotelManagement.Application } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -102,12 +105,15 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdateSupervisionStatistics(UpdateSupervisionStatisticsInputDto checkInfo) + public BaseResponse UpdateSupervisionStatistics(UpdateSupervisionStatisticsInputDto checkInfo) { try { - checkInfoRepository.Update(a => new SupervisionStatistics + var supervisionStatistics = checkInfoRepository.GetFirst(a => a.StatisticsNumber == checkInfo.StatisticsNumber); + checkInfoRepository.Update(new SupervisionStatistics { + Id = supervisionStatistics.Id, + StatisticsNumber = supervisionStatistics.StatisticsNumber, SupervisingDepartment = checkInfo.SupervisingDepartment, SupervisionLoss = checkInfo.SupervisionLoss, SupervisionScore = checkInfo.SupervisionScore, @@ -117,13 +123,13 @@ namespace EOM.TSHotelManagement.Application IsDelete = 0, DataChgUsr = checkInfo.DataChgUsr, DataChgDate = checkInfo.DataChgDate - }, a => a.StatisticsNumber == checkInfo.StatisticsNumber); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -131,22 +137,24 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DeleteSupervisionStatistics(DeleteSupervisionStatisticsInputDto checkInfo) + public BaseResponse DeleteSupervisionStatistics(DeleteSupervisionStatisticsInputDto checkInfo) { try { - checkInfoRepository.Update(a => new SupervisionStatistics + checkInfoRepository.SoftDelete(new SupervisionStatistics { + StatisticsNumber = checkInfo.StatisticsNumber, + Id = checkInfo.Id, IsDelete = 1, DataChgUsr = checkInfo.DataChgUsr, DataChgDate = checkInfo.DataChgDate - }, a => a.StatisticsNumber == checkInfo.StatisticsNumber); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } } } diff --git a/EOM.TSHotelManagement.Application/SystemManagement/VipRule/IVipRuleAppService.cs b/EOM.TSHotelManagement.Application/SystemManagement/VipRule/IVipRuleAppService.cs index be70198..18e1853 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/VipRule/IVipRuleAppService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/VipRule/IVipRuleAppService.cs @@ -49,20 +49,20 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddVipRule(CreateVipLevelRuleInputDto vipRule); + BaseResponse AddVipRule(CreateVipLevelRuleInputDto vipRule); /// /// 删除会员等级规则 /// /// /// - BaseOutputDto DelVipRule(DeleteVipLevelRuleInputDto vipRule); + BaseResponse DelVipRule(DeleteVipLevelRuleInputDto vipRule); /// /// 更新会员等级规则 /// /// /// - BaseOutputDto UpdVipRule(UpdateVipLevelRuleInputDto vipRule); + BaseResponse UpdVipRule(UpdateVipLevelRuleInputDto vipRule); } } diff --git a/EOM.TSHotelManagement.Application/SystemManagement/VipRule/VipRuleAppService.cs b/EOM.TSHotelManagement.Application/SystemManagement/VipRule/VipRuleAppService.cs index 5c2001e..6ae5a6c 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/VipRule/VipRuleAppService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/VipRule/VipRuleAppService.cs @@ -69,22 +69,25 @@ namespace EOM.TSHotelManagement.Application where = where.And(a => a.IsDelete == readVipLevelRuleInputDto.IsDelete); } var count = 0; - var listSource = vipRuleRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readVipLevelRuleInputDto.Page, readVipLevelRuleInputDto.PageSize, ref count); + var Data = vipRuleRepository.AsQueryable().Where(where.ToExpression()).ToPageList(readVipLevelRuleInputDto.Page, readVipLevelRuleInputDto.PageSize, ref count); var listUserType = custoTypeRepository.GetList(a => a.IsDelete != 1); - listSource.ForEach(source => + Data.ForEach(source => { var userType = listUserType.SingleOrDefault(a => a.CustomerType == source.VipLevelId); source.VipLevelName = userType == null ? "" : userType.CustomerTypeName; }); - var viprules = EntityMapper.MapList(listSource); + var viprules = EntityMapper.MapList(Data); return new ListOutputDto { - listSource = viprules, - total = count + Data = new PagedData + { + Items = viprules, + TotalCount = count + } }; } @@ -97,16 +100,16 @@ namespace EOM.TSHotelManagement.Application { VipLevelRule vipRule1 = new VipLevelRule(); - var source = vipRuleRepository.GetSingle(a => a.RuleSerialNumber.Equals(vipRule.RuleSerialNumber)); + var source = vipRuleRepository.GetFirst(a => a.RuleSerialNumber.Equals(vipRule.RuleSerialNumber)); - var userType = custoTypeRepository.GetSingle(a => a.CustomerType == source.VipLevelId); + var userType = custoTypeRepository.GetFirst(a => a.CustomerType == source.VipLevelId); source.VipLevelName = userType == null ? "" : userType.CustomerTypeName; var vipLevel = EntityMapper.Map(source); return new SingleOutputDto { - Source = vipLevel + Data = vipLevel }; } @@ -115,7 +118,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddVipRule(CreateVipLevelRuleInputDto vipRule) + public BaseResponse AddVipRule(CreateVipLevelRuleInputDto vipRule) { try { @@ -131,9 +134,9 @@ namespace EOM.TSHotelManagement.Application } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -141,21 +144,23 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto DelVipRule(DeleteVipLevelRuleInputDto vipRule) + public BaseResponse DelVipRule(DeleteVipLevelRuleInputDto vipRule) { try { - vipRuleRepository.Update(a => new VipLevelRule + vipRuleRepository.SoftDelete(new VipLevelRule { - IsDelete = 1, + Id = vipRule.Id, + RuleSerialNumber = vipRule.RuleSerialNumber, + IsDelete = vipRule.IsDelete, DataChgUsr = vipRule.DataChgUsr, - }, a => a.RuleSerialNumber == vipRule.RuleSerialNumber); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -163,24 +168,26 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto UpdVipRule(UpdateVipLevelRuleInputDto vipRule) + public BaseResponse UpdVipRule(UpdateVipLevelRuleInputDto vipRule) { try { - vipRuleRepository.Update(a => new VipLevelRule + vipRuleRepository.Update(new VipLevelRule { + Id = vipRule.Id, + RuleSerialNumber = vipRule.RuleSerialNumber, RuleName = vipRule.RuleName, RuleValue = vipRule.RuleValue, IsDelete = vipRule.IsDelete, DataChgUsr = vipRule.DataChgUsr, DataChgDate = vipRule.DataChgDate - }, a => a.RuleSerialNumber == vipRule.RuleSerialNumber); + }); } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } } } diff --git a/EOM.TSHotelManagement.Application/Util/IUtilService.cs b/EOM.TSHotelManagement.Application/Util/IUtilService.cs index e41e4e4..a7e841f 100644 --- a/EOM.TSHotelManagement.Application/Util/IUtilService.cs +++ b/EOM.TSHotelManagement.Application/Util/IUtilService.cs @@ -19,7 +19,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - BaseOutputDto AddLog(CreateOperationLogInputDto opr); + BaseResponse AddLog(CreateOperationLogInputDto opr); /// /// 查询所有操作日志 @@ -38,12 +38,12 @@ namespace EOM.TSHotelManagement.Application /// 删除指定时间范围的操作日志 /// /// - BaseOutputDto DeleteOperationlogByRange(ReadOperationLogInputDto readOperationLogInputDto); + BaseResponse DeleteOperationlogByRange(ReadOperationLogInputDto readOperationLogInputDto); /// /// 删除操作日志 /// /// - BaseOutputDto DeleteOperationlog(DeleteOperationLogInputDto deleteOperationLogInputDto); + BaseResponse DeleteOperationlog(DeleteOperationLogInputDto deleteOperationLogInputDto); } } diff --git a/EOM.TSHotelManagement.Application/Util/UtilService.cs b/EOM.TSHotelManagement.Application/Util/UtilService.cs index 52d3229..c4aebf9 100644 --- a/EOM.TSHotelManagement.Application/Util/UtilService.cs +++ b/EOM.TSHotelManagement.Application/Util/UtilService.cs @@ -3,6 +3,7 @@ using EOM.TSHotelManagement.Common.Core; using EOM.TSHotelManagement.Common.Util; using EOM.TSHotelManagement.EntityFramework; using jvncorelib.EntityLib; +using Microsoft.AspNetCore.Http; using SqlSugar; namespace EOM.TSHotelManagement.Application @@ -27,12 +28,6 @@ namespace EOM.TSHotelManagement.Application /// private readonly GenericRepository requestLogRepository; - /// - /// - /// - /// - /// - /// public UtilService(GenericRepository cardCodesRepository, GenericRepository operationLogRepository, GenericRepository requestLogRepository) { this.cardCodesRepository = cardCodesRepository; @@ -50,9 +45,9 @@ namespace EOM.TSHotelManagement.Application if (!readCardCodeInputDto.IdentityCardNumber.IsNullOrEmpty()) { var cardid = readCardCodeInputDto.IdentityCardNumber.Substring(0, 6).ToString(); - var cardcodes = cardCodesRepository.GetSingle(a => a.AreaCode == cardid); + var cardcodes = cardCodesRepository.GetFirst(a => a.AreaCode == cardid); var source = EntityMapper.Map(cardcodes); - return new SingleOutputDto() { Source = source }; + return new SingleOutputDto() { Data = source }; } return new SingleOutputDto(); } @@ -62,17 +57,22 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseOutputDto AddLog(CreateOperationLogInputDto opr) + public BaseResponse AddLog(CreateOperationLogInputDto opr) { try { - operationLogRepository.Insert(EntityMapper.Map(opr)); + var log = EntityMapper.Map(opr); + var result = operationLogRepository.Insert(log); + if (!result) + { + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString("Add Log Failed", "添加日志失败"), Code = BusinessStatusCode.InternalServerError }; + } } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto(); + return new BaseResponse(); } /// @@ -105,6 +105,7 @@ namespace EOM.TSHotelManagement.Application else { operationLogs = operationLogRepository.AsQueryable().Where(where.ToExpression()).OrderByDescending(a => a.OperationTime).ToList(); + count = operationLogs.Count; } operationLogs.ForEach(source => @@ -112,9 +113,16 @@ namespace EOM.TSHotelManagement.Application source.LogLevelName = source.LogLevel == LogLevel.Normal ? LocalizationHelper.GetLocalizedString("INFO", "常规操作") : source.LogLevel == LogLevel.Warning ? LocalizationHelper.GetLocalizedString("WARNING", "敏感操作") : LocalizationHelper.GetLocalizedString("ERROR", "严重操作"); }); - var listSource = EntityMapper.MapList(operationLogs); + var result = EntityMapper.MapList(operationLogs); - return new ListOutputDto { listSource = listSource, total = count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// @@ -141,24 +149,32 @@ namespace EOM.TSHotelManagement.Application else { requestLogs = requestLogRepository.AsQueryable().Where(where.ToExpression()).OrderByDescending(a => a.RequestTime).ToList(); + count = requestLogs.Count; } - var listSource = EntityMapper.MapList(requestLogs); + var result = EntityMapper.MapList(requestLogs); - return new ListOutputDto { listSource = listSource, total = count }; + return new ListOutputDto + { + Data = new PagedData + { + Items = result, + TotalCount = count + } + }; } /// /// 删除指定时间范围的操作日志 /// /// - public BaseOutputDto DeleteOperationlogByRange(ReadOperationLogInputDto readOperationLogInputDto) + public BaseResponse DeleteOperationlogByRange(ReadOperationLogInputDto readOperationLogInputDto) { try { var where = Expressionable.Create(); - if (readOperationLogInputDto.StartTime != DateTime.MinValue && readOperationLogInputDto.EndTime != DateTime.MinValue) + if (readOperationLogInputDto.StartTime.HasValue && readOperationLogInputDto.EndTime.HasValue) { where = where.And(a => a.OperationTime >= readOperationLogInputDto.StartTime && a.OperationTime <= readOperationLogInputDto.EndTime); } @@ -172,28 +188,27 @@ namespace EOM.TSHotelManagement.Application } catch (Exception ex) { - return new BaseOutputDto { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), StatusCode = StatusCodeConstants.InternalServerError }; + return new BaseResponse { Message = LocalizationHelper.GetLocalizedString(ex.Message, ex.Message), Code = BusinessStatusCode.InternalServerError }; } - return new BaseOutputDto { Message = "操作日志删除成功", StatusCode = StatusCodeConstants.Success }; + return new BaseResponse { Message = "操作日志删除成功", Code = BusinessStatusCode.Success }; } /// /// 删除操作日志 /// /// - public BaseOutputDto DeleteOperationlog(DeleteOperationLogInputDto deleteOperationLogInputDto) + public BaseResponse DeleteOperationlog(DeleteOperationLogInputDto deleteOperationLogInputDto) { var result = operationLogRepository.Delete(a => a.OperationId == deleteOperationLogInputDto.OperationId); if (result) { - return new BaseOutputDto(StatusCodeConstants.Success, LocalizationHelper.GetLocalizedString("Delete Operation Log Success", "操作日志删除成功")); + return new BaseResponse(BusinessStatusCode.Success, LocalizationHelper.GetLocalizedString("Delete Operation Log Success", "操作日志删除成功")); } else { - return new BaseOutputDto(StatusCodeConstants.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Operation Log Failed", "操作日志删除失败")); + return new BaseResponse(BusinessStatusCode.InternalServerError, LocalizationHelper.GetLocalizedString("Delete Operation Log Failed", "操作日志删除失败")); } } - } } diff --git a/EOM.TSHotelManagement.Common.Contract/Application/NavBar/Dto/ReadNavBarOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Application/NavBar/Dto/ReadNavBarOutputDto.cs index 31a23b6..8ca1e4d 100644 --- a/EOM.TSHotelManagement.Common.Contract/Application/NavBar/Dto/ReadNavBarOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Application/NavBar/Dto/ReadNavBarOutputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadNavBarOutputDto + public class ReadNavBarOutputDto : BaseOutputDto { public int Id { get; set; } public int NavigationBarId { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/ReadModulePermissionOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseAuditDto.cs similarity index 34% rename from EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/ReadModulePermissionOutputDto.cs rename to EOM.TSHotelManagement.Common.Contract/BaseDto/BaseAuditDto.cs index 5f819b1..c66b3e3 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/ReadModulePermissionOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseAuditDto.cs @@ -1,29 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + namespace EOM.TSHotelManagement.Common.Contract { - public class ReadModulePermissionOutputDto + public class BaseAuditDto: BaseDto { - public int Id { get; set; } /// - /// ģID (Module ID) + /// 资料创建人 /// - public int ModuleId { get; set; } - + public string DataInsUsr { get; set; } /// - /// Ա˺ (Administrator Account) + /// 资料创建时间 /// - public string AdministratorAccount { get; set; } - + public DateTime? DataInsDate { get; set; } /// - /// ģ (Module Name) + /// 资料更新人 /// - public string ModuleName { get; set; } - + public string DataChgUsr { get; set; } /// - /// Ƿ (Is Enabled) + /// 资料更新时间 /// - public int ModuleEnabled { get; set; } + public DateTime? DataChgDate { get; set; } } } - - - diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseDto.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseDto.cs index ee5b8c2..b937dca 100644 --- a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseDto.cs @@ -2,6 +2,7 @@ { public class BaseDto { + public int Id { get; set; } /// /// Token /// diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseInputDto.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseInputDto.cs index fea47ad..c96540f 100644 --- a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseInputDto.cs @@ -1,27 +1,10 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class BaseInputDto : BaseDto + public class BaseInputDto : BaseAuditDto { - public int Id { get; set; } /// /// 删除标识 /// public int? IsDelete { get; set; } = 0; - /// - /// 资料创建人 - /// - public string DataInsUsr { get; set; } - /// - /// 资料创建时间 - /// - public DateTime? DataInsDate { get; set; } - /// - /// 资料更新人 - /// - public string DataChgUsr { get; set; } - /// - /// 资料更新时间 - /// - public DateTime? DataChgDate { get; set; } } } diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseOutputDto.cs index be52c5c..c3d6e7d 100644 --- a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseOutputDto.cs @@ -1,37 +1,12 @@ -using EOM.TSHotelManagement.Common.Util; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; namespace EOM.TSHotelManagement.Common.Contract { - public class BaseOutputDto + public class BaseOutputDto: BaseAuditDto { - /// - /// 状态码,例如 200 表示成功,500 表示服务器错误,400 表示客户端错误等 - /// - public int StatusCode { get; set; } = StatusCodeConstants.Success; - - /// - /// 返回消息,用于描述请求结果 - /// - public string Message { get; set; } = LocalizationHelper.GetLocalizedString("Success", "成功"); - - /// - /// - /// - public BaseOutputDto() - { - StatusCode = 200; - Message = LocalizationHelper.GetLocalizedString("Success", "成功"); - } - - /// - /// 带状态码和消息的构造函数 - /// - /// 状态码 - /// 消息 - public BaseOutputDto(int statusCode, string message) - { - StatusCode = statusCode; - Message = message; - } } } diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseResponse.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseResponse.cs new file mode 100644 index 0000000..5ad5694 --- /dev/null +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseResponse.cs @@ -0,0 +1,40 @@ +using EOM.TSHotelManagement.Common.Util; +using System.Net; + +namespace EOM.TSHotelManagement.Common.Contract +{ + public class BaseResponse + { + public bool Success => Code == 0; + + /// + /// 状态码,例如 0 表示成功 + /// + public int Code { get; set; } = 0; + + /// + /// 返回消息,用于描述请求结果 + /// + public string Message { get; set; } = LocalizationHelper.GetLocalizedString("Success", "成功"); + + /// + /// + /// + public BaseResponse() + { + Code = 0; + Message = LocalizationHelper.GetLocalizedString("Success", "成功"); + } + + /// + /// 带状态码和消息的构造函数 + /// + /// 状态码 + /// 消息 + public BaseResponse(int statusCode, string message) + { + Code = statusCode; + Message = message; + } + } +} diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/StatusCodeConstants.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/BusinessStatusCode.cs similarity index 67% rename from EOM.TSHotelManagement.Common.Contract/BaseDto/StatusCodeConstants.cs rename to EOM.TSHotelManagement.Common.Contract/BaseDto/BusinessStatusCode.cs index 1ebed1e..a9698ab 100644 --- a/EOM.TSHotelManagement.Common.Contract/BaseDto/StatusCodeConstants.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/BusinessStatusCode.cs @@ -1,105 +1,105 @@ namespace EOM.TSHotelManagement.Common.Contract { - public static class StatusCodeConstants + public static class BusinessStatusCode { // 2xx Success /// /// 请求成功 /// - public const int Success = 200; + public const int Success = 0; /// /// 创建成功(常用于 POST 请求) /// - public const int Created = 201; + public const int Created = 1201; /// /// 已接受(请求已接收但未处理完成) /// - public const int Accepted = 202; + public const int Accepted = 1202; /// /// 无内容(响应体为空) /// - public const int NoContent = 204; + public const int NoContent = 1204; // 3xx Redirection /// /// 永久重定向 /// - public const int MovedPermanently = 301; + public const int MovedPermanently = 1301; /// /// 临时重定向 /// - public const int Found = 302; + public const int Found = 1302; /// /// 查看其他地址(常用于 POST 后重定向) /// - public const int SeeOther = 303; + public const int SeeOther = 1303; /// /// 资源未修改(缓存用) /// - public const int NotModified = 304; + public const int NotModified = 1304; // 4xx Client Errors /// /// 错误请求(参数或格式错误) /// - public const int BadRequest = 400; + public const int BadRequest = 1400; /// /// 未授权(身份验证失败) /// - public const int Unauthorized = 401; + public const int Unauthorized = 1401; /// /// 禁止访问(无权限) /// - public const int Forbidden = 403; + public const int Forbidden = 1403; /// /// 未找到资源 /// - public const int NotFound = 404; + public const int NotFound = 1404; /// /// 方法不允许(如 GET 接口用 POST 访问) /// - public const int MethodNotAllowed = 405; + public const int MethodNotAllowed = 1405; /// /// 请求超时 /// - public const int RequestTimeout = 408; + public const int RequestTimeout = 1408; /// /// 资源冲突(如重复提交) /// - public const int Conflict = 409; + public const int Conflict = 1409; // 5xx Server Errors /// /// 服务器内部错误 /// - public const int InternalServerError = 500; + public const int InternalServerError = 1500; /// /// 网关错误(上游服务异常) /// - public const int BadGateway = 502; + public const int BadGateway = 1502; /// /// 服务不可用(维护或过载) /// - public const int ServiceUnavailable = 503; + public const int ServiceUnavailable = 1503; /// /// 网关超时(上游服务响应超时) /// - public const int GatewayTimeout = 504; + public const int GatewayTimeout = 1504; } } diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/ListOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/ListOutputDto.cs index 4455a60..0d78236 100644 --- a/EOM.TSHotelManagement.Common.Contract/BaseDto/ListOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/ListOutputDto.cs @@ -26,16 +26,11 @@ namespace EOM.TSHotelManagement.Common.Contract /// /// 带总数的列表输出Dto /// - public class ListOutputDto : BaseOutputDto + public class ListOutputDto : BaseResponse { /// /// 数据源 /// - public List listSource { get; set; } - - /// - /// 总数 - /// - public int total { get; set; } = 0; + public PagedData Data { get; set; } } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.Common.Core/SystemManagement/MenuViewModel.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/MenuDto.cs similarity index 75% rename from EOM.TSHotelManagement.Common.Core/SystemManagement/MenuViewModel.cs rename to EOM.TSHotelManagement.Common.Contract/BaseDto/MenuDto.cs index fac79c6..7929bc8 100644 --- a/EOM.TSHotelManagement.Common.Core/SystemManagement/MenuViewModel.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/MenuDto.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; -namespace EOM.TSHotelManagement.Common.Core +namespace EOM.TSHotelManagement.Common.Contract { /// - /// 菜单视图模型 (Menu View Model) + /// 菜单 /// - public class MenuViewModel + public class MenuDto { /// /// 菜单主键 (Menu Key) @@ -30,6 +30,6 @@ namespace EOM.TSHotelManagement.Common.Core /// /// 子菜单 (Child Menus) /// - public List Children { get; set; } = new List(); + public List Children { get; set; } = new List(); } } diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/PagedData.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/PagedData.cs new file mode 100644 index 0000000..4e1869b --- /dev/null +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/PagedData.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EOM.TSHotelManagement.Common.Contract +{ + public class PagedData + { + public List Items { get; set; } + public int TotalCount { get; set; } + } +} diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/SingleOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/SingleOutputDto.cs index ce2acaa..8511d97 100644 --- a/EOM.TSHotelManagement.Common.Contract/BaseDto/SingleOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/SingleOutputDto.cs @@ -1,10 +1,10 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class SingleOutputDto : BaseOutputDto + public class SingleOutputDto : BaseResponse { /// /// 数据源 /// - public T Source { get; set; } + public T Data { get; set; } } } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Asset/Dto/Asset/ReadAssetOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Asset/Dto/Asset/ReadAssetOutputDto.cs index f46b34b..a39f3f8 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Asset/Dto/Asset/ReadAssetOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Asset/Dto/Asset/ReadAssetOutputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadAssetOutputDto + public class ReadAssetOutputDto : BaseOutputDto { public int Id { get; set; } public string AssetNumber { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustoType/ReadCustoTypeOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustoType/ReadCustoTypeOutputDto.cs index 40b0332..cf5423e 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustoType/ReadCustoTypeOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustoType/ReadCustoTypeOutputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadCustoTypeOutputDto + public class ReadCustoTypeOutputDto : BaseOutputDto { public int Id { get; set; } public int CustomerType { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/Customer/ReadCustomerOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/Customer/ReadCustomerOutputDto.cs index e299e7b..5166172 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/Customer/ReadCustomerOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/Customer/ReadCustomerOutputDto.cs @@ -3,7 +3,7 @@ using EOM.TSHotelManagement.Common.Util; namespace EOM.TSHotelManagement.Common.Contract { - public class ReadCustomerOutputDto + public class ReadCustomerOutputDto : BaseOutputDto { [UIDisplay("", true, false)] public int Id { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustomerAccount/ReadCustomerAccountOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustomerAccount/ReadCustomerAccountOutputDto.cs index 9d5ce93..2d21f66 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustomerAccount/ReadCustomerAccountOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustomerAccount/ReadCustomerAccountOutputDto.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace EOM.TSHotelManagement.Common.Contract { - public class ReadCustomerAccountOutputDto:BaseDto + public class ReadCustomerAccountOutputDto : BaseOutputDto { /// /// 账号 (Account) diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/GenderType/ReadGenderTypeOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/GenderType/ReadGenderTypeOutputDto.cs index 4db59c8..71aef2f 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/GenderType/ReadGenderTypeOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/GenderType/ReadGenderTypeOutputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadGenderTypeOutputDto + public class ReadGenderTypeOutputDto : BaseOutputDto { public int Id { get; set; } public string Name { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/PassportType/ReadPassportTypeOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/PassportType/ReadPassportTypeOutputDto.cs index cbb29c2..a7e24ad 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/PassportType/ReadPassportTypeOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/PassportType/ReadPassportTypeOutputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadPassportTypeOutputDto + public class ReadPassportTypeOutputDto : BaseOutputDto { public int Id { get; set; } public int PassportId { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/EnergyManagement/Dto/ReadEnergyManagementOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/EnergyManagement/Dto/ReadEnergyManagementOutputDto.cs index d39719f..87c289f 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/EnergyManagement/Dto/ReadEnergyManagementOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/EnergyManagement/Dto/ReadEnergyManagementOutputDto.cs @@ -2,7 +2,7 @@ using EOM.TSHotelManagement.Common.Util; namespace EOM.TSHotelManagement.Common.Contract { - public class ReadEnergyManagementOutputDto + public class ReadEnergyManagementOutputDto : BaseOutputDto { public int Id { get; set; } public string InformationId { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/PromotionContent/Dto/ReadPromotionContentOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/PromotionContent/Dto/ReadPromotionContentOutputDto.cs index 13fdc67..2906b5a 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/PromotionContent/Dto/ReadPromotionContentOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/PromotionContent/Dto/ReadPromotionContentOutputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadPromotionContentOutputDto + public class ReadPromotionContentOutputDto : BaseOutputDto { public int Id { get; set; } public string PromotionContentNumber { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Reser/Dto/ReadReserOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Reser/Dto/ReadReserOutputDto.cs index d3f7f37..b36b8dc 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Reser/Dto/ReadReserOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Reser/Dto/ReadReserOutputDto.cs @@ -2,7 +2,7 @@ using EOM.TSHotelManagement.Common.Util; namespace EOM.TSHotelManagement.Common.Contract { - public class ReadReserOutputDto + public class ReadReserOutputDto : BaseOutputDto { public int Id { get; set; } [UIDisplay("ԤԼ")] diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/Room/ReadRoomOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/Room/ReadRoomOutputDto.cs index 6c6b49e..af30116 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/Room/ReadRoomOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/Room/ReadRoomOutputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadRoomOutputDto + public class ReadRoomOutputDto : BaseOutputDto { public int Id { get; set; } public string RoomNumber { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/RoomState/ReadRoomStateOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/RoomState/ReadRoomStateOutputDto.cs index d9d96da..a24222a 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/RoomState/ReadRoomStateOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/RoomState/ReadRoomStateOutputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadRoomStateOutputDto + public class ReadRoomStateOutputDto : BaseOutputDto { public int RoomStateId { get; set; } public string RoomStateName { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/RoomType/ReadRoomTypeOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/RoomType/ReadRoomTypeOutputDto.cs index 7d19e71..3bca11a 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/RoomType/ReadRoomTypeOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Room/Dto/RoomType/ReadRoomTypeOutputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadRoomTypeOutputDto + public class ReadRoomTypeOutputDto : BaseOutputDto { public int Id { get; set; } public int RoomTypeId { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/DeleteSellThingInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/DeleteSellThingInputDto.cs index 24b5e59..171681d 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/DeleteSellThingInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/DeleteSellThingInputDto.cs @@ -2,8 +2,6 @@ namespace EOM.TSHotelManagement.Common.Contract { public class DeleteSellThingInputDto : BaseInputDto { - public string RoomNumber { get; set; } - public string CustomerNumber { get; set; } public string ProductNumber { get; set; } public string ProductName { get; set; } public decimal ProductPrice { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/ReadSellThingOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/ReadSellThingOutputDto.cs index 0b8a1c5..2863127 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/ReadSellThingOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Sellthing/Dto/ReadSellThingOutputDto.cs @@ -2,7 +2,7 @@ using EOM.TSHotelManagement.Common.Util; namespace EOM.TSHotelManagement.Common.Contract { - public class ReadSellThingOutputDto + public class ReadSellThingOutputDto : BaseOutputDto { public int Id { get; set; } [UIDisplay("Ʒ")] diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Spend/Dto/Spend/ReadSpendOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Spend/Dto/Spend/ReadSpendOutputDto.cs index 854a559..ae09f7f 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Spend/Dto/Spend/ReadSpendOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Spend/Dto/Spend/ReadSpendOutputDto.cs @@ -2,7 +2,7 @@ using EOM.TSHotelManagement.Common.Util; namespace EOM.TSHotelManagement.Common.Contract { - public class ReadSpendOutputDto + public class ReadSpendOutputDto : BaseOutputDto { public int Id { get; set; } [UIDisplay("ѱ", false, false)] diff --git a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/ReadEmployeeOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/ReadEmployeeOutputDto.cs index adbb6d1..fdbb950 100644 --- a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/ReadEmployeeOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/Employee/ReadEmployeeOutputDto.cs @@ -1,9 +1,8 @@  namespace EOM.TSHotelManagement.Common.Contract { - public class ReadEmployeeOutputDto : BaseDto + public class ReadEmployeeOutputDto : BaseOutputDto { - public int Id { get; set; } public string EmployeeId { get; set; } public string EmployeeName { get; set; } public int Gender { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeCheck/ReadEmployeeCheckOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeCheck/ReadEmployeeCheckOutputDto.cs index 5230b06..9935d3b 100644 --- a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeCheck/ReadEmployeeCheckOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeCheck/ReadEmployeeCheckOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadEmployeeCheckOutputDto + public class ReadEmployeeCheckOutputDto : BaseOutputDto { - public int Id { get; set; } public string EmployeeId { get; set; } public DateTime CheckTime { get; set; } public string CheckStatus { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeHistory/ReadEmployeeHistoryOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeHistory/ReadEmployeeHistoryOutputDto.cs index df39b38..8d949b4 100644 --- a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeHistory/ReadEmployeeHistoryOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeHistory/ReadEmployeeHistoryOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadEmployeeHistoryOutputDto + public class ReadEmployeeHistoryOutputDto : BaseOutputDto { - public int Id { get; set; } public string EmployeeId { get; set; } public DateTime StartDate { get; set; } public DateTime EndDate { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeePhoto/ReadEmployeePhotoOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeePhoto/ReadEmployeePhotoOutputDto.cs index 0821230..89d1088 100644 --- a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeePhoto/ReadEmployeePhotoOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeePhoto/ReadEmployeePhotoOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadEmployeePhotoOutputDto + public class ReadEmployeePhotoOutputDto : BaseOutputDto { - public int Id { get; set; } public int PhotoId { get; set; } public string EmployeeId { get; set; } public string PhotoPath { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeRewardPunishment/ReadEmployeeRewardPunishmentOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeRewardPunishment/ReadEmployeeRewardPunishmentOutputDto.cs index 0c669f5..80a7ba3 100644 --- a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeRewardPunishment/ReadEmployeeRewardPunishmentOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeRewardPunishment/ReadEmployeeRewardPunishmentOutputDto.cs @@ -1,9 +1,8 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadEmployeeRewardPunishmentOutputDto + public class ReadEmployeeRewardPunishmentOutputDto : BaseOutputDto { - public int Id { get; set; } public string EmployeeId { get; set; } public DateTime RewardPunishmentTime { get; set; } public int RewardPunishmentType { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/RewardPunishmentType/ReadRewardPunishmentTypeOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/RewardPunishmentType/ReadRewardPunishmentTypeOutputDto.cs index bc3bf0b..042ea87 100644 --- a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/RewardPunishmentType/ReadRewardPunishmentTypeOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/RewardPunishmentType/ReadRewardPunishmentTypeOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadRewardPunishmentTypeOutputDto + public class ReadRewardPunishmentTypeOutputDto : BaseOutputDto { - public int Id { get; set; } public int GBTypeId { get; set; } public string GBTypeName { get; set; } } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Administrator/ReadAdministratorOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Administrator/ReadAdministratorOutputDto.cs index dd33d40..1e6ab26 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Administrator/ReadAdministratorOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Administrator/ReadAdministratorOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadAdministratorOutputDto : BaseDto + public class ReadAdministratorOutputDto : BaseOutputDto { - public int Id { get; set; } public string Number { get; set; } public string Account { get; set; } public string Password { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AdministratorType/DeleteAdministratorTypeInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AdministratorType/DeleteAdministratorTypeInputDto.cs index 381cdc1..3deabac 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AdministratorType/DeleteAdministratorTypeInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AdministratorType/DeleteAdministratorTypeInputDto.cs @@ -2,7 +2,7 @@ namespace EOM.TSHotelManagement.Common.Contract { public class DeleteAdministratorTypeInputDto : BaseInputDto { - public int Id { get; set; } + public string TypeId { get; set; } } } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AdministratorType/ReadAdministratorTypeOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AdministratorType/ReadAdministratorTypeOutputDto.cs index f810717..dbeb9ee 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AdministratorType/ReadAdministratorTypeOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AdministratorType/ReadAdministratorTypeOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadAdministratorTypeOutputDto + public class ReadAdministratorTypeOutputDto : BaseOutputDto { - public int Id { get; set; } public string TypeId { get; set; } public string TypeName { get; set; } } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AppointmentNotice/ReadAppointmentNoticeOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AppointmentNotice/ReadAppointmentNoticeOutputDto.cs index 64aae89..36596af 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AppointmentNotice/ReadAppointmentNoticeOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AppointmentNotice/ReadAppointmentNoticeOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadAppointmentNoticeOutputDto + public class ReadAppointmentNoticeOutputDto : BaseOutputDto { - public int Id { get; set; } public string NoticeId { get; set; } public string NoticeTheme { get; set; } public string NoticeType { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AppointmentNoticeType/ReadAppointmentNoticeTypeOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AppointmentNoticeType/ReadAppointmentNoticeTypeOutputDto.cs index a84ce05..dd6fbb9 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AppointmentNoticeType/ReadAppointmentNoticeTypeOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/AppointmentNoticeType/ReadAppointmentNoticeTypeOutputDto.cs @@ -1,11 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadAppointmentNoticeTypeOutputDto + public class ReadAppointmentNoticeTypeOutputDto : BaseOutputDto { - /// - /// ID - /// - public int Id { get; set; } /// /// 公告类型编号 (AppointmentNotice Type Number) /// diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/ReadDepartmentOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/ReadDepartmentOutputDto.cs index ac030be..dd9722c 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/ReadDepartmentOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/ReadDepartmentOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadDepartmentOutputDto + public class ReadDepartmentOutputDto : BaseOutputDto { - public int Id { get; set; } public string DepartmentNumber { get; set; } public string DepartmentName { get; set; } public string DepartmentDescription { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/UpdateDepartmentInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/UpdateDepartmentInputDto.cs index 1b951fa..79af88a 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/UpdateDepartmentInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Department/UpdateDepartmentInputDto.cs @@ -2,7 +2,6 @@ namespace EOM.TSHotelManagement.Common.Contract { public class UpdateDepartmentInputDto : BaseInputDto { - public int Id { get; set; } public string DepartmentNumber { get; set; } public string DepartmentName { get; set; } public string DepartmentDescription { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Menu/ReadMenuOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Menu/ReadMenuOutputDto.cs index d1c0ac6..12213da 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Menu/ReadMenuOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Menu/ReadMenuOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadMenuOutputDto + public class ReadMenuOutputDto : BaseOutputDto { - public int Id { get; set; } public string Key { get; set; } public string Title { get; set; } public string Path { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/CreateModuleInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/CreateModuleInputDto.cs deleted file mode 100644 index a057872..0000000 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/CreateModuleInputDto.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace EOM.TSHotelManagement.Common.Contract -{ - public class CreateModuleInputDto : BaseInputDto - { - public string ModuleName { get; set; } - public string ModuleDescription { get; set; } - } -} - - diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/DeleteModuleInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/DeleteModuleInputDto.cs deleted file mode 100644 index 6c7514d..0000000 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/DeleteModuleInputDto.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace EOM.TSHotelManagement.Common.Contract -{ - public class DeleteModuleInputDto : BaseInputDto - { - public int ModuleId { get; set; } - } -} - - - diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/ReadModuleInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/ReadModuleInputDto.cs deleted file mode 100644 index 023e4a6..0000000 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/ReadModuleInputDto.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace EOM.TSHotelManagement.Common.Contract -{ - public class ReadModuleInputDto : ListInputDto - { - public int ModuleId { get; set; } - } -} - - diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/ReadModuleOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/ReadModuleOutputDto.cs deleted file mode 100644 index f416f64..0000000 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/ReadModuleOutputDto.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace EOM.TSHotelManagement.Common.Contract -{ - public class ReadModuleOutputDto - { - public int Id { get; set; } - public int ModuleId { get; set; } - public string ModuleName { get; set; } - public string ModuleDescription { get; set; } - } -} - - diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/UpdateModuleInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/UpdateModuleInputDto.cs deleted file mode 100644 index 8a7210a..0000000 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Module/UpdateModuleInputDto.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace EOM.TSHotelManagement.Common.Contract -{ - public class UpdateModuleInputDto : BaseInputDto - { - public int ModuleId { get; set; } - public string ModuleName { get; set; } - public string ModuleDescription { get; set; } - } -} - - - diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/CreateModulePermissionInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/CreateModulePermissionInputDto.cs deleted file mode 100644 index 8e64ba6..0000000 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/CreateModulePermissionInputDto.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace EOM.TSHotelManagement.Common.Contract -{ - public class CreateModulePermissionInputDto : BaseInputDto - { - public int ModuleId { get; set; } - public string PermissionName { get; set; } - public string PermissionDescription { get; set; } - } -} - - - diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/DeleteModulePermissionInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/DeleteModulePermissionInputDto.cs deleted file mode 100644 index d43fc6f..0000000 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/DeleteModulePermissionInputDto.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace EOM.TSHotelManagement.Common.Contract -{ - public class DeleteModulePermissionInputDto : BaseInputDto - { - public int PermissionId { get; set; } - public string AdministratorAccount { get; set; } - } -} - - - diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/ReadModulePermissionInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/ReadModulePermissionInputDto.cs deleted file mode 100644 index 81cb27f..0000000 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/ReadModulePermissionInputDto.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace EOM.TSHotelManagement.Common.Contract -{ - public class ReadModulePermissionInputDto : ListInputDto - { - public int PermissionId { get; set; } - public string Account { get; set; } - } -} - - - diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/UpdateModulePermissionInputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/UpdateModulePermissionInputDto.cs deleted file mode 100644 index 439b75b..0000000 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/ModulePermission/UpdateModulePermissionInputDto.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace EOM.TSHotelManagement.Common.Contract -{ - public class UpdateModulePermissionInputDto : BaseInputDto - { - public int PermissionId { get; set; } - public int ModuleId { get; set; } - public string PermissionName { get; set; } - public string PermissionDescription { get; set; } - } -} - - - diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Nation/ReadNationOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Nation/ReadNationOutputDto.cs index 0e0d788..dfa7f51 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Nation/ReadNationOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Nation/ReadNationOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadNationOutputDto + public class ReadNationOutputDto : BaseOutputDto { - public int Id { get; set; } public string NationNumber { get; set; } public string NationName { get; set; } } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Position/ReadPositionOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Position/ReadPositionOutputDto.cs index dc7f24b..5708caa 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Position/ReadPositionOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Position/ReadPositionOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadPositionOutputDto + public class ReadPositionOutputDto : BaseOutputDto { - public int Id { get; set; } public string PositionNumber { get; set; } public string PositionName { get; set; } } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Qualification/ReadEducationOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Qualification/ReadEducationOutputDto.cs index 7fb20b5..2600f67 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Qualification/ReadEducationOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Qualification/ReadEducationOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadEducationOutputDto + public class ReadEducationOutputDto : BaseOutputDto { - public int Id { get; set; } public string EducationNumber { get; set; } public string EducationName { get; set; } } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Role/ReadRoleOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Role/ReadRoleOutputDto.cs index a641af7..3da4e1e 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Role/ReadRoleOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/Role/ReadRoleOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadRoleOutputDto + public class ReadRoleOutputDto : BaseOutputDto { - public int Id { get; set; } /// /// ע:ɫ /// Ĭֵ: diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/SupervisionStatistics/ReadSupervisionStatisticsOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/SupervisionStatistics/ReadSupervisionStatisticsOutputDto.cs index 3601845..7a6172c 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/SupervisionStatistics/ReadSupervisionStatisticsOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/SupervisionStatistics/ReadSupervisionStatisticsOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadSupervisionStatisticsOutputDto + public class ReadSupervisionStatisticsOutputDto : BaseOutputDto { - public int Id { get; set; } public string StatisticsNumber { get; set; } public string SupervisingDepartment { get; set; } public string SupervisingDepartmentName { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/SystemInformation/ReadSystemInformationOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/SystemInformation/ReadSystemInformationOutputDto.cs index 3afb115..dcbabe2 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/SystemInformation/ReadSystemInformationOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/SystemInformation/ReadSystemInformationOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadSystemInformationOutputDto + public class ReadSystemInformationOutputDto : BaseOutputDto { - public int Id { get; set; } public int UrlNumber { get; set; } public string UrlAddress { get; set; } } diff --git a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/VipLevelRule/ReadVipLevelRuleOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/VipLevelRule/ReadVipLevelRuleOutputDto.cs index 1f3a26a..8e2cfea 100644 --- a/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/VipLevelRule/ReadVipLevelRuleOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/SystemManagement/Dto/VipLevelRule/ReadVipLevelRuleOutputDto.cs @@ -2,7 +2,6 @@ namespace EOM.TSHotelManagement.Common.Contract { public class ReadVipLevelRuleOutputDto : BaseOutputDto { - public int Id { get; set; } public string RuleSerialNumber { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Util/Dto/ApplicationVersion/ReadApplicationVersionOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Util/Dto/ApplicationVersion/ReadApplicationVersionOutputDto.cs index 6e518df..fe01132 100644 --- a/EOM.TSHotelManagement.Common.Contract/Util/Dto/ApplicationVersion/ReadApplicationVersionOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Util/Dto/ApplicationVersion/ReadApplicationVersionOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadApplicationVersionOutputDto + public class ReadApplicationVersionOutputDto : BaseOutputDto { - public int Id { get; set; } public int ApplicationVersionId { get; set; } public string VersionNumber { get; set; } public string VersionDescription { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Util/Dto/CardCode/ReadCardCodeOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Util/Dto/CardCode/ReadCardCodeOutputDto.cs index d7e18de..7e42cd3 100644 --- a/EOM.TSHotelManagement.Common.Contract/Util/Dto/CardCode/ReadCardCodeOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Util/Dto/CardCode/ReadCardCodeOutputDto.cs @@ -1,8 +1,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadCardCodeOutputDto + public class ReadCardCodeOutputDto : BaseOutputDto { - public long Id { get; set; } public string Province { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/BusinessStatisticsOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/BusinessStatisticsOutputDto.cs index 939a55a..12bdb3a 100644 --- a/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/BusinessStatisticsOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/BusinessStatisticsOutputDto.cs @@ -2,7 +2,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class BusinessStatisticsOutputDto : BaseOutputDto + public class BusinessStatisticsOutputDto : BaseResponse { [JsonPropertyName("genderRatio")] public TempGenderRatio GenderRatio { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/HumanResourcesOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/HumanResourcesOutputDto.cs index a6349aa..2c5273e 100644 --- a/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/HumanResourcesOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/HumanResourcesOutputDto.cs @@ -3,7 +3,7 @@ using System.Text.Json.Serialization; namespace EOM.TSHotelManagement.Common.Contract { - public class HumanResourcesOutputDto : BaseOutputDto + public class HumanResourcesOutputDto : BaseResponse { [JsonPropertyName("totalEmployees")] public int TotalEmployees { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/LogisticsDataOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/LogisticsDataOutputDto.cs index 0620d61..3e7ca87 100644 --- a/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/LogisticsDataOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/LogisticsDataOutputDto.cs @@ -2,7 +2,7 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class LogisticsDataOutputDto : BaseOutputDto + public class LogisticsDataOutputDto : BaseResponse { [JsonPropertyName("totalProducts")] public int TotalProducts { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/RoomStatisticsOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/RoomStatisticsOutputDto.cs index b3c93d4..cc7f24e 100644 --- a/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/RoomStatisticsOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Util/Dto/Dashboard/RoomStatisticsOutputDto.cs @@ -3,7 +3,7 @@ using System.Text.Json.Serialization; namespace EOM.TSHotelManagement.Common.Contract { - public class RoomStatisticsOutputDto : BaseOutputDto + public class RoomStatisticsOutputDto : BaseResponse { [JsonPropertyName("status")] public TempRoomStatus Status { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Util/Dto/OperationLog/ReadOperationLogInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Util/Dto/OperationLog/ReadOperationLogInputDto.cs index 2494471..c04f8e4 100644 --- a/EOM.TSHotelManagement.Common.Contract/Util/Dto/OperationLog/ReadOperationLogInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Util/Dto/OperationLog/ReadOperationLogInputDto.cs @@ -6,8 +6,8 @@ namespace EOM.TSHotelManagement.Common.Contract public string OperationId { get; set; } public int? LogLevel { get; set; } - public DateTime StartTime { get; set; } - public DateTime EndTime { get; set; } + public DateTime? StartTime { get; set; } + public DateTime? EndTime { get; set; } } } diff --git a/EOM.TSHotelManagement.Common.Contract/Util/Dto/OperationLog/ReadOperationLogOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Util/Dto/OperationLog/ReadOperationLogOutputDto.cs index eb5cbbb..9a0d9ce 100644 --- a/EOM.TSHotelManagement.Common.Contract/Util/Dto/OperationLog/ReadOperationLogOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Util/Dto/OperationLog/ReadOperationLogOutputDto.cs @@ -2,9 +2,8 @@ using EOM.TSHotelManagement.Common.Core; namespace EOM.TSHotelManagement.Common.Contract { - public class ReadOperationLogOutputDto + public class ReadOperationLogOutputDto : BaseOutputDto { - public int Id { get; set; } public string OperationId { get; set; } public DateTime OperationTime { get; set; } public string LogContent { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Util/Dto/RequestLog/ReadRequestLogOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Util/Dto/RequestLog/ReadRequestLogOutputDto.cs index 8554a6b..b98983f 100644 --- a/EOM.TSHotelManagement.Common.Contract/Util/Dto/RequestLog/ReadRequestLogOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Util/Dto/RequestLog/ReadRequestLogOutputDto.cs @@ -7,12 +7,8 @@ using System.Threading.Tasks; namespace EOM.TSHotelManagement.Common.Contract { - public class ReadRequestLogOutputDto + public class ReadRequestLogOutputDto : BaseOutputDto { - /// - /// 编号 (ID) - /// - public int Id { get; set; } /// /// 请求路径 (URL Path) diff --git a/EOM.TSHotelManagement.Common.Core/BaseEntity.cs b/EOM.TSHotelManagement.Common.Core/BaseEntity.cs index 9868eeb..45045d7 100644 --- a/EOM.TSHotelManagement.Common.Core/BaseEntity.cs +++ b/EOM.TSHotelManagement.Common.Core/BaseEntity.cs @@ -1,4 +1,5 @@ -using System; +using EOM.TSHotelManagement.Common.Util; +using System; namespace EOM.TSHotelManagement.Common.Core { @@ -17,7 +18,7 @@ namespace EOM.TSHotelManagement.Common.Core /// /// 资料创建时间 /// - [SqlSugar.SugarColumn(ColumnName = "datains_date", IsOnlyIgnoreUpdate = true, InsertServerTime = true, IsNullable = true)] + [SqlSugar.SugarColumn(ColumnName = "datains_date", IsOnlyIgnoreUpdate = true, IsNullable = true)] public DateTime? DataInsDate { get; set; } /// /// 资料更新人 @@ -27,7 +28,7 @@ namespace EOM.TSHotelManagement.Common.Core /// /// 资料更新时间 /// - [SqlSugar.SugarColumn(ColumnName = "datachg_date", IsOnlyIgnoreInsert = true, InsertServerTime = true, IsNullable = true)] + [SqlSugar.SugarColumn(ColumnName = "datachg_date", IsOnlyIgnoreInsert = true, IsNullable = true)] public DateTime? DataChgDate { get; set; } /// /// Token diff --git a/EOM.TSHotelManagement.Common.Core/Business/Room/Room.cs b/EOM.TSHotelManagement.Common.Core/Business/Room/Room.cs index 55e61e6..8ee2e47 100644 --- a/EOM.TSHotelManagement.Common.Core/Business/Room/Room.cs +++ b/EOM.TSHotelManagement.Common.Core/Business/Room/Room.cs @@ -50,7 +50,7 @@ namespace EOM.TSHotelManagement.Common.Core IsNullable = false, Length = 128 )] - [NeedValid] // 假设此特性用于业务验证 + [NeedValid] public string RoomNumber { get; set; } /// diff --git a/EOM.TSHotelManagement.Common.Util/GenerateJWT/JWTHelper.cs b/EOM.TSHotelManagement.Common.Util/GenerateJWT/JWTHelper.cs index 227a7af..8aef43e 100644 --- a/EOM.TSHotelManagement.Common.Util/GenerateJWT/JWTHelper.cs +++ b/EOM.TSHotelManagement.Common.Util/GenerateJWT/JWTHelper.cs @@ -42,9 +42,7 @@ namespace EOM.TSHotelManagement.Common.Util Expires = DateTime.Now.AddMinutes(expiryMinutes), SigningCredentials = new SigningCredentials( new SymmetricSecurityKey(key), - SecurityAlgorithms.HmacSha256Signature), - Audience = jwtConfig.Audience, - Issuer = jwtConfig.Issuer + SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); @@ -61,13 +59,10 @@ namespace EOM.TSHotelManagement.Common.Util var validationParameters = new TokenValidationParameters { - ValidateIssuer = true, - ValidIssuer = jwtConfig.Issuer, - ValidateAudience = true, - ValidAudience = jwtConfig.Audience, - ValidateLifetime = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtConfig.Key)), - ValidateIssuerSigningKey = true, + ValidateIssuerSigningKey = false, + ValidateIssuer = false, + ValidateAudience = false, NameClaimType = ClaimTypes.Name, RoleClaimType = ClaimTypes.Role, ClockSkew = TimeSpan.Zero diff --git a/EOM.TSHotelManagement.Common.Util/Helper/EntityMapper.cs b/EOM.TSHotelManagement.Common.Util/Helper/EntityMapper.cs index 38b55d2..41b4b22 100644 --- a/EOM.TSHotelManagement.Common.Util/Helper/EntityMapper.cs +++ b/EOM.TSHotelManagement.Common.Util/Helper/EntityMapper.cs @@ -10,10 +10,6 @@ namespace EOM.TSHotelManagement.Common.Util /// /// ӳ䵥ʵ /// - /// Դ - /// Ŀ - /// Դ - /// Ŀ public static TDestination Map(TSource source) where TDestination : new() { @@ -37,7 +33,30 @@ namespace EOM.TSHotelManagement.Common.Util if (destinationProperty == null || !destinationProperty.CanWrite) continue; var sourceValue = sourceProperty.GetValue(source); - if (sourceValue == null) continue; + + if (sourceValue is DateOnly dateOnlyValue && + destinationProperty.PropertyType == typeof(DateTime?)) + { + if (dateOnlyValue == DateOnly.MinValue || dateOnlyValue == new DateOnly(1900, 1, 1)) + { + destinationProperty.SetValue(destination, null); + } + else + { + destinationProperty.SetValue(destination, dateOnlyValue.ToDateTime(TimeOnly.MinValue)); + } + continue; + } + + if (sourceValue == null) + { + if (destinationProperty.PropertyType.IsValueType && + Nullable.GetUnderlyingType(destinationProperty.PropertyType) != null) + { + destinationProperty.SetValue(destination, null); + } + continue; + } if (NeedConversion(sourceProperty.PropertyType, destinationProperty.PropertyType)) { @@ -51,103 +70,191 @@ namespace EOM.TSHotelManagement.Common.Util } /// - /// Զת + /// ת /// - /// - /// - /// - /// private static object SmartConvert(object value, Type targetType) { - var underlyingTargetType = Nullable.GetUnderlyingType(targetType) ?? targetType; - if (value is DateOnly dateOnly) { - return HandleDateOnlyConversion(dateOnly, underlyingTargetType); + return HandleDateOnlyConversion(dateOnly, targetType); } if (value is DateTime dateTime) { - return HandleDateTimeConversion(dateTime, underlyingTargetType); + return HandleDateTimeConversion(dateTime, targetType); } if (value is string dateString) { - return HandleStringConversion(dateString, underlyingTargetType); + return HandleStringConversion(dateString, targetType); + } + + if (IsMinValue(value)) + { + return ConvertMinValueToNull(value, targetType); } try { - return Convert.ChangeType(value, underlyingTargetType); + return Convert.ChangeType(value, targetType); } catch (InvalidCastException) { + var underlyingType = Nullable.GetUnderlyingType(targetType); + if (underlyingType != null) + { + try + { + return Convert.ChangeType(value, underlyingType); + } + catch + { + + } + } + throw new InvalidOperationException( $"Cannot convert {value.GetType()} to {targetType}"); } } - private static object HandleDateOnlyConversion(DateOnly dateOnly, Type targetType) + /// + /// ǷΪСֵ + /// + private static bool IsMinValue(object value) { - return targetType switch + return value switch { - _ when targetType == typeof(DateTime) => dateOnly.ToDateTime(TimeOnly.MinValue), - _ when targetType == typeof(DateTimeOffset) => new DateTimeOffset(dateOnly.ToDateTime(TimeOnly.MinValue)), - _ when targetType == typeof(string) => dateOnly.ToString("yyyy-MM-dd"), - _ when targetType == typeof(DateOnly) => dateOnly, - _ => throw new InvalidCastException($"Unsupported DateOnly conversion to {targetType}") + DateTime dt => dt == DateTime.MinValue || dt == new DateTime(1900, 1, 1), + DateOnly d => d == DateOnly.MinValue || d == new DateOnly(1900, 1, 1), + DateTimeOffset dto => dto == DateTimeOffset.MinValue || dto == new DateTimeOffset(1900, 1, 1, 0, 0, 0, TimeSpan.Zero), + _ => false }; } + /// + /// СֵתΪֵ + /// + private static object ConvertMinValueToNull(object value, Type targetType) + { + if (Nullable.GetUnderlyingType(targetType) != null) + { + return null; + } + + if (targetType == typeof(string)) + { + return string.Empty; + } + + return value; + } + + /// + /// DateOnly ת + /// + private static object HandleDateOnlyConversion(DateOnly dateOnly, Type targetType) + { + if (IsMinValue(dateOnly)) + { + return ConvertMinValueToNull(dateOnly, targetType); + } + + var underlyingType = Nullable.GetUnderlyingType(targetType) ?? targetType; + + switch (underlyingType.Name) + { + case nameof(DateTime): + return dateOnly.ToDateTime(TimeOnly.MinValue); + + case nameof(DateTimeOffset): + return new DateTimeOffset(dateOnly.ToDateTime(TimeOnly.MinValue)); + + case nameof(String): + return dateOnly.ToString("yyyy-MM-dd"); + + case nameof(DateOnly): + return dateOnly; + + default: + throw new InvalidCastException($"Unsupported DateOnly conversion to {targetType}"); + } + } + + /// + /// DateTime ת + /// private static object HandleDateTimeConversion(DateTime dateTime, Type targetType) { - return targetType switch + if (IsMinValue(dateTime)) { - _ when targetType == typeof(DateOnly) => DateOnly.FromDateTime(dateTime), - _ when targetType == typeof(DateTimeOffset) => new DateTimeOffset(dateTime), - _ when targetType == typeof(string) => dateTime.ToString("yyyy-MM-dd HH:mm:ss"), - _ => dateTime // ֱӷԭʼֵ - }; + return ConvertMinValueToNull(dateTime, targetType); + } + + var underlyingType = Nullable.GetUnderlyingType(targetType) ?? targetType; + + switch (underlyingType.Name) + { + case nameof(DateOnly): + return DateOnly.FromDateTime(dateTime); + + case nameof(DateTimeOffset): + return new DateTimeOffset(dateTime); + + case nameof(String): + return dateTime.ToString("yyyy-MM-dd HH:mm:ss"); + + case nameof(DateTime): + return dateTime; + + default: + return dateTime; + } } + /// + /// ַת + /// private static object HandleStringConversion(string dateString, Type targetType) { if (DateTime.TryParse(dateString, out DateTime dt)) { - return targetType switch - { - _ when targetType == typeof(DateOnly) => DateOnly.FromDateTime(dt), - _ when targetType == typeof(DateTime) => dt, - _ => dt - }; + return HandleDateTimeConversion(dt, targetType); } + + if (DateOnly.TryParse(dateString, out DateOnly d)) + { + return HandleDateOnlyConversion(d, targetType); + } + + if (string.IsNullOrWhiteSpace(dateString)) + { + return ConvertMinValueToNull(DateTime.MinValue, targetType); + } + throw new FormatException($"Invalid date string: {dateString}"); } /// - /// ת + /// жǷҪת /// - /// - /// - /// private static bool NeedConversion(Type sourceType, Type targetType) { var underlyingSource = Nullable.GetUnderlyingType(sourceType) ?? sourceType; var underlyingTarget = Nullable.GetUnderlyingType(targetType) ?? targetType; - return underlyingSource != underlyingTarget; + + if (underlyingSource == underlyingTarget) return false; + + return true; } /// /// ӳʵб /// - /// Դ - /// Ŀ - /// Դб - /// Ŀб public static List MapList(List sourceList) where TDestination : new() { return sourceList?.Select(Map).ToList(); } } -} +} \ No newline at end of file diff --git a/EOM.TSHotelManagement.Common.Util/Helper/MailHelper.cs b/EOM.TSHotelManagement.Common.Util/Helper/MailHelper.cs index 9a8eeb1..a0d5a32 100644 --- a/EOM.TSHotelManagement.Common.Util/Helper/MailHelper.cs +++ b/EOM.TSHotelManagement.Common.Util/Helper/MailHelper.cs @@ -19,7 +19,7 @@ namespace EOM.TSHotelManagement.Common.Util this.mailConfigFactory = mailConfigFactory; } - public void SendMail( + public bool SendMail( List toEmails, string subject, string body, @@ -28,6 +28,11 @@ namespace EOM.TSHotelManagement.Common.Util List attachments = null, bool isBodyHtml = true) { + if (!IsMailConfigValid()) + { + return false; + } + var mailConfig = mailConfigFactory.GetMailConfig(); var message = new MimeMessage(); @@ -63,6 +68,8 @@ namespace EOM.TSHotelManagement.Common.Util client.Authenticate(mailConfig.UserName, mailConfig.Password); client.Send(message); + + return true; } catch (AuthenticationException ex) { @@ -84,6 +91,50 @@ namespace EOM.TSHotelManagement.Common.Util #region Private Methods + private bool IsMailConfigValid() + { + try + { + var config = mailConfigFactory.GetMailConfig(); + + if (config == null) + { + return false; + } + + if (string.IsNullOrWhiteSpace(config.Host)) + { + return false; + } + + if (config.Port <= 0 || config.Port > 65535) + { + return false; + } + + if (string.IsNullOrWhiteSpace(config.UserName)) + { + return false; + } + + if (string.IsNullOrWhiteSpace(config.Password)) + { + return false; + } + + if (string.IsNullOrWhiteSpace(config.DisplayName)) + { + return false; + } + + return true; + } + catch (Exception ex) + { + return false; + } + } + private void AddRecipients(InternetAddressList list, List emails) { emails?.Where(email => !string.IsNullOrWhiteSpace(email)) diff --git a/EOM.TSHotelManagement.Shared/Interfaces/ISqlSugarClientFactory.cs b/EOM.TSHotelManagement.EntityFramework/Connector/ISqlSugarClientConnector.cs similarity index 50% rename from EOM.TSHotelManagement.Shared/Interfaces/ISqlSugarClientFactory.cs rename to EOM.TSHotelManagement.EntityFramework/Connector/ISqlSugarClientConnector.cs index edb0d38..0b7c369 100644 --- a/EOM.TSHotelManagement.Shared/Interfaces/ISqlSugarClientFactory.cs +++ b/EOM.TSHotelManagement.EntityFramework/Connector/ISqlSugarClientConnector.cs @@ -1,8 +1,8 @@ using SqlSugar; -namespace EOM.TSHotelManagement.Shared +namespace EOM.TSHotelManagement.EntityFramework { - public interface ISqlSugarClientFactory + public interface ISqlSugarClientConnector { ISqlSugarClient CreateClient(string dbName = null); } diff --git a/EOM.TSHotelManagement.WebApi/Factory/SqlSugarClientFactory.cs b/EOM.TSHotelManagement.EntityFramework/Connector/SqlSugarClientConnector.cs similarity index 56% rename from EOM.TSHotelManagement.WebApi/Factory/SqlSugarClientFactory.cs rename to EOM.TSHotelManagement.EntityFramework/Connector/SqlSugarClientConnector.cs index a552ec9..8f723df 100644 --- a/EOM.TSHotelManagement.WebApi/Factory/SqlSugarClientFactory.cs +++ b/EOM.TSHotelManagement.EntityFramework/Connector/SqlSugarClientConnector.cs @@ -1,16 +1,21 @@ using EOM.TSHotelManagement.Shared; -using EOM.TSHotelManagement.WebApi.Constant; using Microsoft.Extensions.Configuration; using SqlSugar; using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; -namespace EOM.TSHotelManagement.WebApi +namespace EOM.TSHotelManagement.EntityFramework { - public class SqlSugarClientFactory : ISqlSugarClientFactory + public class SqlSugarClientConnector : ISqlSugarClientConnector { private readonly IConfiguration _configuration; - public SqlSugarClientFactory(IConfiguration configuration) + public SqlSugarClientConnector(IConfiguration configuration) { _configuration = configuration; } @@ -18,17 +23,17 @@ namespace EOM.TSHotelManagement.WebApi public ISqlSugarClient CreateClient(string dbName = null) { // 读取默认数据库名称 - dbName ??= _configuration[DatabaseConstants.DefaultDatabase]; + dbName ??= _configuration[SystemConstants.DefaultDatabase]; string connectionString; - if (Environment.GetEnvironmentVariable(DatabaseConstants.DockerEnv) != null) + if (Environment.GetEnvironmentVariable(SystemConstants.DockerEnv) != null) { - connectionString = Environment.GetEnvironmentVariable(DatabaseConstants.DefaultDatabase) switch + connectionString = Environment.GetEnvironmentVariable(SystemConstants.DefaultDatabase) switch { - DatabaseConstants.PgSql => Environment.GetEnvironmentVariable($"{DatabaseConstants.PgSql}ConnectStr"), //Test passed - DatabaseConstants.MySql => Environment.GetEnvironmentVariable($"{DatabaseConstants.MySql}ConnectStr"), //Test passed - DatabaseConstants.SqlServer => Environment.GetEnvironmentVariable($"{DatabaseConstants.SqlServer}ConnectStr"), //Test passed - DatabaseConstants.Oracle => Environment.GetEnvironmentVariable($"{DatabaseConstants.Oracle}ConnectStr"), //Please manually test - DatabaseConstants.MariaDB => Environment.GetEnvironmentVariable($"{DatabaseConstants.MariaDB}ConnectStr"), //Test passed + SystemConstants.PgSql => Environment.GetEnvironmentVariable($"{SystemConstants.PgSql}ConnectStr"), //Test passed + SystemConstants.MySql => Environment.GetEnvironmentVariable($"{SystemConstants.MySql}ConnectStr"), //Test passed + SystemConstants.SqlServer => Environment.GetEnvironmentVariable($"{SystemConstants.SqlServer}ConnectStr"), //Test passed + SystemConstants.Oracle => Environment.GetEnvironmentVariable($"{SystemConstants.Oracle}ConnectStr"), //Please manually test + SystemConstants.MariaDB => Environment.GetEnvironmentVariable($"{SystemConstants.MariaDB}ConnectStr"), //Test passed _ => throw new ArgumentException("Unsupported database", nameof(dbName)), }; } @@ -55,7 +60,7 @@ namespace EOM.TSHotelManagement.WebApi { PgSqlIsAutoToLower = true, PgSqlIsAutoToLowerCodeFirst = true, - DisableMillisecond = true + DisableMillisecond = true, }; break; case DbType.SqlServer: @@ -74,11 +79,11 @@ namespace EOM.TSHotelManagement.WebApi { return dbName switch { - DatabaseConstants.PgSql => DbType.PostgreSQL, - DatabaseConstants.MySql => DbType.MySql, - DatabaseConstants.Oracle => DbType.Oracle, - DatabaseConstants.SqlServer => DbType.SqlServer, - DatabaseConstants.MariaDB => DbType.MySqlConnector, + SystemConstants.PgSql => DbType.PostgreSQL, + SystemConstants.MySql => DbType.MySql, + SystemConstants.Oracle => DbType.Oracle, + SystemConstants.SqlServer => DbType.SqlServer, + SystemConstants.MariaDB => DbType.MySqlConnector, _ => throw new ArgumentException("Unsupported database", nameof(dbName)) }; } diff --git a/EOM.TSHotelManagement.WebApi/MigrationConfig/InitializeConfig.cs b/EOM.TSHotelManagement.EntityFramework/DatabaseInitializer/DatabaseInitializer.cs similarity index 89% rename from EOM.TSHotelManagement.WebApi/MigrationConfig/InitializeConfig.cs rename to EOM.TSHotelManagement.EntityFramework/DatabaseInitializer/DatabaseInitializer.cs index 9f34fd7..baee303 100644 --- a/EOM.TSHotelManagement.WebApi/MigrationConfig/InitializeConfig.cs +++ b/EOM.TSHotelManagement.EntityFramework/DatabaseInitializer/DatabaseInitializer.cs @@ -1,42 +1,36 @@ -using EOM.TSHotelManagement.Common.Core; +using EOM.TSHotelManagement.Common.Core; using EOM.TSHotelManagement.Migration; using EOM.TSHotelManagement.Shared; -using EOM.TSHotelManagement.WebApi.Constant; -using Microsoft.AspNetCore.Builder; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using MySqlConnector; using Npgsql; using Oracle.ManagedDataAccess.Client; using SqlSugar; -using System; -using System.Collections.Generic; -using System.Linq; -namespace EOM.TSHotelManagement.WebApi +namespace EOM.TSHotelManagement.EntityFramework { - public class InitializeConfig + public class DatabaseInitializer : IDatabaseInitializer { - private readonly IConfiguration config; - - public InitializeConfig(IConfiguration configuration) + private readonly ISqlSugarClient _client; + private readonly ISqlSugarClientConnector _connector; + private readonly IConfiguration _configuration; + public DatabaseInitializer(ISqlSugarClient client, ISqlSugarClientConnector connector, IConfiguration configuration) { - config = configuration; + _client = client; + _connector = connector; + _configuration = configuration; } #region initlize database - public void InitializeDatabase(IApplicationBuilder app) + public void InitializeDatabase() { - using var scope = app.ApplicationServices.CreateScope(); - var logger = scope.ServiceProvider.GetRequiredService>(); - var config = scope.ServiceProvider.GetRequiredService(); - var factory = scope.ServiceProvider.GetRequiredService(); + var config = _configuration; + var factory = _connector; try { - var dbName = config[DatabaseConstants.DefaultDatabase] ?? DatabaseConstants.MariaDB; + var dbName = config[SystemConstants.DefaultDatabase] ?? SystemConstants.MariaDB; var dbSettings = GetDatabaseSettings(config, dbName); using (var masterDb = CreateMasterConnection(config, dbName, dbSettings.DbType)) @@ -101,7 +95,7 @@ namespace EOM.TSHotelManagement.WebApi private (string Database, DbType DbType) GetDatabaseSettings(IConfiguration config, string dbName) { - var dbType = SqlSugarClientFactory.GetDbType(dbName); + var dbType = GetDbType(dbName); var connectionString = GetConnectionString(config, dbName); switch (dbType) @@ -183,7 +177,7 @@ namespace EOM.TSHotelManagement.WebApi private string GetConnectionString(IConfiguration config, string dbName) { - if (Environment.GetEnvironmentVariable(DatabaseConstants.DockerEnv) != null) + if (Environment.GetEnvironmentVariable(SystemConstants.DockerEnv) != null) { return Environment.GetEnvironmentVariable($"{dbName}ConnectStr") ?? throw new ArgumentException($"Environment variable {dbName}ConnectStr not found"); @@ -335,10 +329,23 @@ namespace EOM.TSHotelManagement.WebApi finally { Console.WriteLine("Database data initialization completed"); - Console.WriteLine($"administrator account:admin"); - Console.WriteLine($"administrator password:admin"); + Console.WriteLine($"administrator accountadmin"); + Console.WriteLine($"administrator passwordadmin"); } } + + public static DbType GetDbType(string dbName) + { + return dbName switch + { + SystemConstants.PgSql => DbType.PostgreSQL, + SystemConstants.MySql => DbType.MySql, + SystemConstants.Oracle => DbType.Oracle, + SystemConstants.SqlServer => DbType.SqlServer, + SystemConstants.MariaDB => DbType.MySqlConnector, + _ => throw new ArgumentException("Unsupported database", nameof(dbName)) + }; + } #endregion } } diff --git a/EOM.TSHotelManagement.EntityFramework/DatabaseInitializer/IDatabaseInitializer.cs b/EOM.TSHotelManagement.EntityFramework/DatabaseInitializer/IDatabaseInitializer.cs new file mode 100644 index 0000000..9dd316d --- /dev/null +++ b/EOM.TSHotelManagement.EntityFramework/DatabaseInitializer/IDatabaseInitializer.cs @@ -0,0 +1,8 @@ + +namespace EOM.TSHotelManagement.EntityFramework +{ + public interface IDatabaseInitializer + { + void InitializeDatabase(); + } +} diff --git a/EOM.TSHotelManagement.EntityFramework/EOM.TSHotelManagement.EntityFramework.csproj b/EOM.TSHotelManagement.EntityFramework/EOM.TSHotelManagement.EntityFramework.csproj index 6f5a89c..3f276d5 100644 --- a/EOM.TSHotelManagement.EntityFramework/EOM.TSHotelManagement.EntityFramework.csproj +++ b/EOM.TSHotelManagement.EntityFramework/EOM.TSHotelManagement.EntityFramework.csproj @@ -7,15 +7,18 @@ + - + + + diff --git a/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs b/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs index 01a9fe4..9ad3b14 100644 --- a/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs +++ b/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs @@ -1,12 +1,92 @@ -using SqlSugar; +using EOM.TSHotelManagement.Common.Core; +using EOM.TSHotelManagement.Common.Util; +using Microsoft.AspNetCore.Http; +using Newtonsoft.Json.Linq; +using SqlSugar; +using System.Linq.Expressions; namespace EOM.TSHotelManagement.EntityFramework { public class GenericRepository : SimpleClient where T : class, new() { - public GenericRepository(ISqlSugarClient client) : base(client) + + /// + /// HTTP上下文访问器 + /// + private readonly IHttpContextAccessor _httpContextAccessor; + + private readonly JWTHelper _jWTHelper; + + public GenericRepository(ISqlSugarClient client, IHttpContextAccessor httpContextAccessor,JWTHelper jWTHelper) : base(client) + { + base.Context = client; + _httpContextAccessor = httpContextAccessor; + _jWTHelper = jWTHelper; + } + + private string GetCurrentUser() + { + try + { + var authHeader = _httpContextAccessor?.HttpContext?.Request?.Headers["Authorization"]; + if (string.IsNullOrEmpty(authHeader)) return "System"; + + var token = authHeader.ToString().Replace("Bearer ", "", StringComparison.OrdinalIgnoreCase); + + return _jWTHelper.GetSerialNumber(token); + } + catch + { + return "System"; + } + } + + public override bool Insert(T entity) + { + if (entity is BaseEntity baseEntity) + { + var currentUser = GetCurrentUser(); + baseEntity.DataInsDate = DateTime.Now; + baseEntity.DataInsUsr = currentUser; + } + return base.Insert(entity); + } + + public override bool Update(T entity) + { + if (entity is BaseEntity baseEntity) + { + var currentUser = GetCurrentUser(); + baseEntity.DataChgDate = DateTime.Now; + baseEntity.DataChgUsr = currentUser; + } + return base.Context.Updateable(entity).IgnoreColumns(ignoreAllNullColumns:true,false,true).ExecuteCommand() > 0; + } + + public override bool UpdateRange(List updateObjs) + { + foreach (var entity in updateObjs) + { + if (entity is BaseEntity baseEntity) + { + var currentUser = GetCurrentUser(); + baseEntity.DataChgDate = DateTime.Now; + baseEntity.DataChgUsr = currentUser; + } + } + + return base.Context.Updateable(updateObjs).IgnoreColumns(ignoreAllNullColumns: true, false, true).ExecuteCommand() > 0; + } + + public bool SoftDelete(T entity) { - base.Context.Aop.OnError = (ex) => { }; + if (entity is BaseEntity baseEntity) + { + var currentUser = GetCurrentUser(); + baseEntity.DataChgDate = DateTime.Now; + baseEntity.DataChgUsr = currentUser; + } + return base.Context.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true, false, true).ExecuteCommand() > 0; } } } diff --git a/EOM.TSHotelManagement.Migration/EOM.TSHotelManagement.Migration.csproj b/EOM.TSHotelManagement.Migration/EOM.TSHotelManagement.Migration.csproj index 030f286..6ce7f3d 100644 --- a/EOM.TSHotelManagement.Migration/EOM.TSHotelManagement.Migration.csproj +++ b/EOM.TSHotelManagement.Migration/EOM.TSHotelManagement.Migration.csproj @@ -6,10 +6,6 @@ enable - - - - diff --git a/EOM.TSHotelManagement.Migration/EntityBuilder.cs b/EOM.TSHotelManagement.Migration/EntityBuilder.cs index 04f688c..65be0a2 100644 --- a/EOM.TSHotelManagement.Migration/EntityBuilder.cs +++ b/EOM.TSHotelManagement.Migration/EntityBuilder.cs @@ -43,7 +43,8 @@ namespace EOM.TSHotelManagement.Migration typeof(SystemInformation), typeof(UserRole), typeof(VipLevelRule), - typeof(RequestLog) + typeof(RequestLog), + typeof(News) }; private readonly List entityDatas = new() diff --git a/EOM.TSHotelManagement.Shared/BrotliHelper.cs b/EOM.TSHotelManagement.Shared/BrotliHelper.cs deleted file mode 100644 index dfc510d..0000000 --- a/EOM.TSHotelManagement.Shared/BrotliHelper.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.IO.Compression; -using System.Text; - -namespace EOM.TSHotelManagement.Shared -{ - public static class BrotliHelper - { - public static string CompressString(string input) - { - byte[] inputBytes = Encoding.UTF8.GetBytes(input); - - using var outputStream = new MemoryStream(); - using (var brotliStream = new BrotliStream(outputStream, CompressionLevel.Optimal)) - { - int bufferSize = 81920; - for (int i = 0; i < inputBytes.Length; i += bufferSize) - { - int chunkSize = Math.Min(bufferSize, inputBytes.Length - i); - brotliStream.Write(inputBytes, i, chunkSize); - } - } - - return Convert.ToBase64String(outputStream.ToArray()); - } - - - public static string DecompressString(string input) - { - var compressedData = Convert.FromBase64String(input); - - using var inputStream = new MemoryStream(compressedData); - using var outputStream = new MemoryStream(); - using (var brotliStream = new BrotliStream(inputStream, CompressionMode.Decompress)) - { - brotliStream.CopyTo(outputStream); - } - - return Encoding.UTF8.GetString(outputStream.ToArray()); - } - } -} diff --git a/EOM.TSHotelManagement.Shared/Config/JwtConfig.cs b/EOM.TSHotelManagement.Shared/Config/JwtConfig.cs index 18935b7..a207d1e 100644 --- a/EOM.TSHotelManagement.Shared/Config/JwtConfig.cs +++ b/EOM.TSHotelManagement.Shared/Config/JwtConfig.cs @@ -3,8 +3,6 @@ public class JwtConfig { public string Key { get; set; } - public string Issuer { get; set; } - public string Audience { get; set; } public int ExpiryMinutes { get; set; } } } diff --git a/EOM.TSHotelManagement.Shared/AppConstant/Constant.cs b/EOM.TSHotelManagement.Shared/Constant/Constant.cs similarity index 100% rename from EOM.TSHotelManagement.Shared/AppConstant/Constant.cs rename to EOM.TSHotelManagement.Shared/Constant/Constant.cs diff --git a/EOM.TSHotelManagement.Shared/SpendConsts.cs b/EOM.TSHotelManagement.Shared/Constant/ConsumptionConstant.cs similarity index 77% rename from EOM.TSHotelManagement.Shared/SpendConsts.cs rename to EOM.TSHotelManagement.Shared/Constant/ConsumptionConstant.cs index 7e58df8..fed5758 100644 --- a/EOM.TSHotelManagement.Shared/SpendConsts.cs +++ b/EOM.TSHotelManagement.Shared/Constant/ConsumptionConstant.cs @@ -27,12 +27,12 @@ namespace EOM.TSHotelManagement.Shared /// /// 结算状态常量 /// - public class SpendConsts : Constant + public class ConsumptionConstant : Constant { - public static readonly SpendConsts Settled = new SpendConsts("Settled", "已结算"); - public static readonly SpendConsts UnSettle = new SpendConsts("UnSettle", "未结算"); + public static readonly ConsumptionConstant Settled = new ConsumptionConstant("Settled", "已结算"); + public static readonly ConsumptionConstant UnSettle = new ConsumptionConstant("UnSettle", "未结算"); - protected SpendConsts(string code, string description) : base(code, description) + protected ConsumptionConstant(string code, string description) : base(code, description) { } } diff --git a/EOM.TSHotelManagement.WebApi/Constant/DatabaseConstants.cs b/EOM.TSHotelManagement.Shared/Constant/SystemConstants.cs similarity index 69% rename from EOM.TSHotelManagement.WebApi/Constant/DatabaseConstants.cs rename to EOM.TSHotelManagement.Shared/Constant/SystemConstants.cs index 7fe085c..83cbd60 100644 --- a/EOM.TSHotelManagement.WebApi/Constant/DatabaseConstants.cs +++ b/EOM.TSHotelManagement.Shared/Constant/SystemConstants.cs @@ -1,6 +1,6 @@ -namespace EOM.TSHotelManagement.WebApi.Constant +namespace EOM.TSHotelManagement.Shared { - public class DatabaseConstants + public class SystemConstants { public const string MariaDB = "MariaDB"; public const string PgSql = "PgSql"; @@ -10,5 +10,7 @@ public const string Sqlite = "Sqlite"; public const string DefaultDatabase = "DefaultDatabase"; public const string DockerEnv = "DOCKER_ENV"; + public const string Env = "ASPNETCORE_ENVIRONMENT"; + public const string Docker = "docker"; } } diff --git a/EOM.TSHotelManagement.Shared/DiscountConverter.cs b/EOM.TSHotelManagement.Shared/Helper/DiscountHelper.cs similarity index 98% rename from EOM.TSHotelManagement.Shared/DiscountConverter.cs rename to EOM.TSHotelManagement.Shared/Helper/DiscountHelper.cs index 98d953d..1e171f7 100644 --- a/EOM.TSHotelManagement.Shared/DiscountConverter.cs +++ b/EOM.TSHotelManagement.Shared/Helper/DiscountHelper.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Shared { - public static class DiscountConverter + public static class DiscountHelper { /// /// 最大允许的折扣百分比值(默认100%) diff --git a/EOM.TSHotelManagement.Shared/EnumHelper.cs b/EOM.TSHotelManagement.Shared/Helper/EnumHelper.cs similarity index 100% rename from EOM.TSHotelManagement.Shared/EnumHelper.cs rename to EOM.TSHotelManagement.Shared/Helper/EnumHelper.cs diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Application/NavBar/NavBarController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Application/NavBar/NavBarController.cs index b2496d0..306ac56 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Application/NavBar/NavBarController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Application/NavBar/NavBarController.cs @@ -38,7 +38,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto AddNavBar([FromBody]CreateNavBarInputDto input) + public BaseResponse AddNavBar([FromBody]CreateNavBarInputDto input) { return navBarService.AddNavBar(input); } @@ -48,7 +48,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateNavBar([FromBody] UpdateNavBarInputDto input) + public BaseResponse UpdateNavBar([FromBody] UpdateNavBarInputDto input) { return navBarService.UpdateNavBar(input); } @@ -58,7 +58,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteNavBar([FromBody] DeleteNavBarInputDto input) + public BaseResponse DeleteNavBar([FromBody] DeleteNavBarInputDto input) { return navBarService.DeleteNavBar(input); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/Asset/AssetController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/Asset/AssetController.cs index 0022e1f..4483be2 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/Asset/AssetController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/Asset/AssetController.cs @@ -29,7 +29,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto AddAssetInfo([FromBody] CreateAssetInputDto asset) + public BaseResponse AddAssetInfo([FromBody] CreateAssetInputDto asset) { return assetService.AddAssetInfo(asset); } @@ -50,7 +50,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdAssetInfo([FromBody] UpdateAssetInputDto asset) + public BaseResponse UpdAssetInfo([FromBody] UpdateAssetInputDto asset) { return assetService.UpdAssetInfo(asset); } @@ -61,7 +61,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DelAssetInfo([FromBody] DeleteAssetInputDto asset) + public BaseResponse DelAssetInfo([FromBody] DeleteAssetInputDto asset) { return assetService.DelAssetInfo(asset); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/Customer/CustomerController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/Customer/CustomerController.cs index e4c4445..97b00ce 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/Customer/CustomerController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/Customer/CustomerController.cs @@ -29,7 +29,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto InsertCustomerInfo([FromBody] CreateCustomerInputDto custo) + public BaseResponse InsertCustomerInfo([FromBody] CreateCustomerInputDto custo) { return customerService.InsertCustomerInfo(custo); } @@ -40,7 +40,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdCustomerInfo([FromBody] UpdateCustomerInputDto custo) + public BaseResponse UpdCustomerInfo([FromBody] UpdateCustomerInputDto custo) { return customerService.UpdCustomerInfo(custo); } @@ -51,7 +51,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DelCustomerInfo([FromBody] DeleteCustomerInputDto custo) + public BaseResponse DelCustomerInfo([FromBody] DeleteCustomerInputDto custo) { return customerService.DelCustomerInfo(custo); } @@ -62,7 +62,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdCustomerTypeByCustoNo([FromBody] UpdateCustomerInputDto updateCustomerInputDto) + public BaseResponse UpdCustomerTypeByCustoNo([FromBody] UpdateCustomerInputDto updateCustomerInputDto) { return customerService.UpdCustomerTypeByCustoNo(updateCustomerInputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/EnergyManagement/EnergyManagementController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/EnergyManagement/EnergyManagementController.cs index 2af8bad..447a0de 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/EnergyManagement/EnergyManagementController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/EnergyManagement/EnergyManagementController.cs @@ -41,7 +41,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto InsertEnergyManagementInfo([FromBody] CreateEnergyManagementInputDto w) + public BaseResponse InsertEnergyManagementInfo([FromBody] CreateEnergyManagementInputDto w) { return this.hydroelectricPowerService.InsertEnergyManagementInfo(w); } @@ -53,7 +53,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// 包含要修改的数据,以及WtiNo作为查询条件 /// [HttpPost] - public BaseOutputDto UpdateEnergyManagementInfo([FromBody] UpdateEnergyManagementInputDto w) + public BaseResponse UpdateEnergyManagementInfo([FromBody] UpdateEnergyManagementInputDto w) { return this.hydroelectricPowerService.UpdateEnergyManagementInfo(w); } @@ -66,7 +66,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteEnergyManagementInfo([FromBody] DeleteEnergyManagementInputDto deleteEnergyManagementInputDto) + public BaseResponse DeleteEnergyManagementInfo([FromBody] DeleteEnergyManagementInputDto deleteEnergyManagementInputDto) { return this.hydroelectricPowerService.DeleteEnergyManagementInfo(deleteEnergyManagementInputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/News/NewsController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/News/NewsController.cs index c9d9b8d..be27d25 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/News/NewsController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/News/NewsController.cs @@ -1,5 +1,6 @@ using EOM.TSHotelManagement.Application; using EOM.TSHotelManagement.Common.Contract; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -17,6 +18,7 @@ namespace EOM.TSHotelManagement.WebApi /// /// /// + [AllowAnonymous] [HttpGet] public ListOutputDto SelectNews([FromQuery]ReadNewsInputDto readNewsInputDto) { @@ -27,6 +29,7 @@ namespace EOM.TSHotelManagement.WebApi /// /// /// + [AllowAnonymous] [HttpGet] public SingleOutputDto News([FromQuery]ReadNewsInputDto readNewsInputDto) { @@ -38,7 +41,7 @@ namespace EOM.TSHotelManagement.WebApi /// /// [HttpPost] - public BaseOutputDto AddNews([FromBody] AddNewsInputDto addNewsInputDto) + public BaseResponse AddNews([FromBody] AddNewsInputDto addNewsInputDto) { return newsService.AddNews(addNewsInputDto); } @@ -48,7 +51,7 @@ namespace EOM.TSHotelManagement.WebApi /// /// [HttpPost] - public BaseOutputDto UpdateNews([FromBody] UpdateNewsInputDto updateNewsInputDto) + public BaseResponse UpdateNews([FromBody] UpdateNewsInputDto updateNewsInputDto) { return newsService.UpdateNews(updateNewsInputDto); } @@ -58,7 +61,7 @@ namespace EOM.TSHotelManagement.WebApi /// /// [HttpPost] - public BaseOutputDto DeleteNews([FromBody]DeleteNewsInputDto deleteNewsInputDto) + public BaseResponse DeleteNews([FromBody]DeleteNewsInputDto deleteNewsInputDto) { return newsService.DeleteNews(deleteNewsInputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/PromotionContent/PromotionContentController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/PromotionContent/PromotionContentController.cs index fb5dbcd..782c1d9 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/PromotionContent/PromotionContentController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/PromotionContent/PromotionContentController.cs @@ -49,7 +49,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto AddPromotionContent([FromBody] CreatePromotionContentInputDto createPromotionContentInputDto) + public BaseResponse AddPromotionContent([FromBody] CreatePromotionContentInputDto createPromotionContentInputDto) { return fontsService.AddPromotionContent(createPromotionContentInputDto); } @@ -60,7 +60,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeletePromotionContent([FromBody] DeletePromotionContentInputDto deletePromotionContentInputDto) + public BaseResponse DeletePromotionContent([FromBody] DeletePromotionContentInputDto deletePromotionContentInputDto) { return fontsService.DeletePromotionContent(deletePromotionContentInputDto); } @@ -71,7 +71,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdatePromotionContent([FromBody] UpdatePromotionContentInputDto updatePromotionContentInputDto) + public BaseResponse UpdatePromotionContent([FromBody] UpdatePromotionContentInputDto updatePromotionContentInputDto) { return fontsService.UpdatePromotionContent(updatePromotionContentInputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/Reser/ReserController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/Reser/ReserController.cs index f65a5fd..85c0894 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/Reser/ReserController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/Reser/ReserController.cs @@ -50,7 +50,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteReserInfo([FromBody] DeleteReserInputDto reser) + public BaseResponse DeleteReserInfo([FromBody] DeleteReserInputDto reser) { return reserService.DeleteReserInfo(reser); } @@ -61,7 +61,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateReserInfo([FromBody] UpdateReserInputDto r) + public BaseResponse UpdateReserInfo([FromBody] UpdateReserInputDto r) { return reserService.UpdateReserInfo(r); } @@ -72,7 +72,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto InserReserInfo([FromBody] CreateReserInputDto r) + public BaseResponse InserReserInfo([FromBody] CreateReserInputDto r) { return reserService.InserReserInfo(r); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/Room/RoomController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/Room/RoomController.cs index 4bd2f0c..5ef1fd0 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/Room/RoomController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/Room/RoomController.cs @@ -86,7 +86,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateRoomInfo([FromBody] UpdateRoomInputDto inputDto) + public BaseResponse UpdateRoomInfo([FromBody] UpdateRoomInputDto inputDto) { return roomService.UpdateRoomInfo(inputDto); } @@ -97,7 +97,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateRoomInfoWithReser([FromBody] UpdateRoomInputDto inputDto) + public BaseResponse UpdateRoomInfoWithReser([FromBody] UpdateRoomInputDto inputDto) { return roomService.UpdateRoomInfoWithReser(inputDto); } @@ -169,7 +169,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateRoomStateByRoomNo([FromBody] UpdateRoomInputDto inputDto) + public BaseResponse UpdateRoomStateByRoomNo([FromBody] UpdateRoomInputDto inputDto) { return roomService.UpdateRoomStateByRoomNo(inputDto); } @@ -180,7 +180,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto InsertRoom([FromBody] CreateRoomInputDto inputDto) + public BaseResponse InsertRoom([FromBody] CreateRoomInputDto inputDto) { return roomService.InsertRoom(inputDto); } @@ -191,7 +191,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateRoom([FromBody] UpdateRoomInputDto inputDto) + public BaseResponse UpdateRoom([FromBody] UpdateRoomInputDto inputDto) { return roomService.UpdateRoom(inputDto); } @@ -202,7 +202,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteRoom([FromBody] DeleteRoomInputDto inputDto) + public BaseResponse DeleteRoom([FromBody] DeleteRoomInputDto inputDto) { return roomService.DeleteRoom(inputDto); } @@ -213,7 +213,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto TransferRoom([FromBody] TransferRoomDto transferRoomDto) + public BaseResponse TransferRoom([FromBody] TransferRoomDto transferRoomDto) { return roomService.TransferRoom(transferRoomDto); } @@ -224,7 +224,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto CheckoutRoom([FromBody] CheckoutRoomDto checkoutRoomDto) + public BaseResponse CheckoutRoom([FromBody] CheckoutRoomDto checkoutRoomDto) { return roomService.CheckoutRoom(checkoutRoomDto); } @@ -235,7 +235,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto CheckinRoomByReservation([FromBody] CheckinRoomByReservationDto checkinRoomByReservationDto) + public BaseResponse CheckinRoomByReservation([FromBody] CheckinRoomByReservationDto checkinRoomByReservationDto) { return roomService.CheckinRoomByReservation(checkinRoomByReservationDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/Room/RoomTypeController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/Room/RoomTypeController.cs index af0aa50..7114024 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/Room/RoomTypeController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/Room/RoomTypeController.cs @@ -44,7 +44,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto InsertRoomType([FromBody] CreateRoomTypeInputDto inputDto) + public BaseResponse InsertRoomType([FromBody] CreateRoomTypeInputDto inputDto) { return roomTypeService.InsertRoomType(inputDto); } @@ -55,7 +55,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateRoomType([FromBody] UpdateRoomTypeInputDto inputDto) + public BaseResponse UpdateRoomType([FromBody] UpdateRoomTypeInputDto inputDto) { return roomTypeService.UpdateRoomType(inputDto); } @@ -66,7 +66,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteRoomType([FromBody] DeleteRoomTypeInputDto inputDto) + public BaseResponse DeleteRoomType([FromBody] DeleteRoomTypeInputDto inputDto) { return roomTypeService.DeleteRoomType(inputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/Sellthing/SellthingController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/Sellthing/SellthingController.cs index 81453cb..2965edf 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/Sellthing/SellthingController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/Sellthing/SellthingController.cs @@ -33,7 +33,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateSellThing([FromBody] UpdateSellThingInputDto updateSellThingInputDto) + public BaseResponse UpdateSellThing([FromBody] UpdateSellThingInputDto updateSellThingInputDto) { return sellService.UpdateSellThing(updateSellThingInputDto); } @@ -44,7 +44,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateSellthingInfo([FromBody] UpdateSellThingInputDto sellThing) + public BaseResponse UpdateSellthingInfo([FromBody] UpdateSellThingInputDto sellThing) { return sellService.UpdateSellthingInfo(sellThing); } @@ -55,7 +55,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteSellthing([FromQuery] DeleteSellThingInputDto deleteSellThingInputDto) + public BaseResponse DeleteSellthing([FromBody] DeleteSellThingInputDto deleteSellThingInputDto) { return sellService.DeleteSellthing(deleteSellThingInputDto); } @@ -77,7 +77,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto InsertSellThing([FromBody] CreateSellThingInputDto st) + public BaseResponse InsertSellThing([FromBody] CreateSellThingInputDto st) { return sellService.InsertSellThing(st); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/Spend/SpendController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/Spend/SpendController.cs index 8a60c3e..e944c83 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/Spend/SpendController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/Spend/SpendController.cs @@ -65,7 +65,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UndoCustomerSpend([FromBody] UpdateSpendInputDto updateSpendInputDto) + public BaseResponse UndoCustomerSpend([FromBody] UpdateSpendInputDto updateSpendInputDto) { return spendService.UndoCustomerSpend(updateSpendInputDto); } @@ -76,7 +76,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto AddCustomerSpend([FromBody] AddCustomerSpendInputDto addCustomerSpendInputDto) + public BaseResponse AddCustomerSpend([FromBody] AddCustomerSpendInputDto addCustomerSpendInputDto) { return spendService.AddCustomerSpend(addCustomerSpendInputDto); } @@ -87,9 +87,9 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdSpenInfo([FromBody] UpdateSpendInputDto inputDto) + public BaseResponse UpdSpendInfo([FromBody] UpdateSpendInputDto inputDto) { - return spendService.UpdSpenInfo(inputDto); + return spendService.UpdSpendInfo(inputDto); } } } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Employee/Check/EmployeeCheckController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Employee/Check/EmployeeCheckController.cs index 6686a29..b3d8467 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Employee/Check/EmployeeCheckController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Employee/Check/EmployeeCheckController.cs @@ -55,7 +55,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto AddCheckInfo([FromBody] CreateEmployeeCheckInputDto workerCheck) + public BaseResponse AddCheckInfo([FromBody] CreateEmployeeCheckInputDto workerCheck) { return workerCheckService.AddCheckInfo(workerCheck); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Employee/EmployeeController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Employee/EmployeeController.cs index 736bcab..922ecdc 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Employee/EmployeeController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Employee/EmployeeController.cs @@ -23,7 +23,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateEmployee([FromBody] UpdateEmployeeInputDto worker) + public BaseResponse UpdateEmployee([FromBody] UpdateEmployeeInputDto worker) { return workerService.UpdateEmployee(worker); } @@ -34,7 +34,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto ManagerEmployeeAccount([FromBody] UpdateEmployeeInputDto worker) + public BaseResponse ManagerEmployeeAccount([FromBody] UpdateEmployeeInputDto worker) { return workerService.ManagerEmployeeAccount(worker); } @@ -45,7 +45,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto AddEmployee([FromBody] CreateEmployeeInputDto worker) + public BaseResponse AddEmployee([FromBody] CreateEmployeeInputDto worker) { return workerService.AddEmployee(worker); } @@ -90,7 +90,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateEmployeeAccountPassword([FromBody] UpdateEmployeeInputDto updateEmployeeInputDto) + public BaseResponse UpdateEmployeeAccountPassword([FromBody] UpdateEmployeeInputDto updateEmployeeInputDto) { return workerService.UpdateEmployeeAccountPassword(updateEmployeeInputDto); } @@ -100,7 +100,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto ResetEmployeeAccountPassword([FromBody] UpdateEmployeeInputDto updateEmployeeInputDto) + public BaseResponse ResetEmployeeAccountPassword([FromBody] UpdateEmployeeInputDto updateEmployeeInputDto) { return workerService.ResetEmployeeAccountPassword(updateEmployeeInputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Employee/History/EmployeeHistoryController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Employee/History/EmployeeHistoryController.cs index af883fa..c6e7e88 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Employee/History/EmployeeHistoryController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Employee/History/EmployeeHistoryController.cs @@ -22,7 +22,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto AddHistoryByEmployeeId([FromBody] CreateEmployeeHistoryInputDto workerHistory) + public BaseResponse AddHistoryByEmployeeId([FromBody] CreateEmployeeHistoryInputDto workerHistory) { return workerHistoryService.AddHistoryByEmployeeId(workerHistory); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Employee/Photo/EmployeePhotoController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Employee/Photo/EmployeePhotoController.cs index 0465696..8421cf9 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Employee/Photo/EmployeePhotoController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Employee/Photo/EmployeePhotoController.cs @@ -46,7 +46,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteWorkerPhoto([FromBody] DeleteEmployeePhotoInputDto inputDto) + public BaseResponse DeleteWorkerPhoto([FromBody] DeleteEmployeePhotoInputDto inputDto) { return workerPicService.DeleteWorkerPhoto(inputDto); } @@ -57,7 +57,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateWorkerPhoto([FromBody] UpdateEmployeePhotoInputDto inputDto) + public BaseResponse UpdateWorkerPhoto([FromBody] UpdateEmployeePhotoInputDto inputDto) { return workerPicService.UpdateWorkerPhoto(inputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Employee/RewardPunishment/RewardPunishmentController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Employee/RewardPunishment/RewardPunishmentController.cs index 4148dca..6b3847d 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Employee/RewardPunishment/RewardPunishmentController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Employee/RewardPunishment/RewardPunishmentController.cs @@ -29,7 +29,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto AddRewardPunishment([FromBody] CreateEmployeeRewardPunishmentInputDto goodBad) + public BaseResponse AddRewardPunishment([FromBody] CreateEmployeeRewardPunishmentInputDto goodBad) { return workerGoodBadService.AddRewardPunishment(goodBad); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Administrator/AdminController.cs b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Administrator/AdminController.cs index fe64793..f2a1b61 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Administrator/AdminController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Administrator/AdminController.cs @@ -52,7 +52,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto AddAdmin([FromBody] CreateAdministratorInputDto admin) + public BaseResponse AddAdmin([FromBody] CreateAdministratorInputDto admin) { return adminService.AddAdmin(admin); } @@ -63,7 +63,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdAdmin([FromBody] UpdateAdministratorInputDto updateAdministratorInputDto) + public BaseResponse UpdAdmin([FromBody] UpdateAdministratorInputDto updateAdministratorInputDto) { return adminService.UpdAdmin(updateAdministratorInputDto); } @@ -74,7 +74,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DelAdmin([FromBody] DeleteAdministratorInputDto deleteAdministratorInputDto) + public BaseResponse DelAdmin([FromBody] DeleteAdministratorInputDto deleteAdministratorInputDto) { return adminService.DelAdmin(deleteAdministratorInputDto); } @@ -95,7 +95,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto AddAdminType([FromBody] CreateAdministratorTypeInputDto createAdministratorTypeInputDto) + public BaseResponse AddAdminType([FromBody] CreateAdministratorTypeInputDto createAdministratorTypeInputDto) { return adminService.AddAdminType(createAdministratorTypeInputDto); } @@ -106,7 +106,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdAdminType([FromBody] UpdateAdministratorTypeInputDto updateAdministratorTypeInputDto) + public BaseResponse UpdAdminType([FromBody] UpdateAdministratorTypeInputDto updateAdministratorTypeInputDto) { return adminService.UpdAdminType(updateAdministratorTypeInputDto); } @@ -117,7 +117,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DelAdminType([FromBody] DeleteAdministratorTypeInputDto deleteAdministratorTypeInputDto) + public BaseResponse DelAdminType([FromBody] DeleteAdministratorTypeInputDto deleteAdministratorTypeInputDto) { return adminService.DelAdminType(deleteAdministratorTypeInputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Base/BaseController.cs b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Base/BaseController.cs index 0d7a80b..5d6ddbc 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Base/BaseController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Base/BaseController.cs @@ -1,6 +1,8 @@ using EOM.TSHotelManagement.Application; using EOM.TSHotelManagement.Common.Contract; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System.IO; namespace EOM.TSHotelManagement.WebApi.Controllers { @@ -66,19 +68,19 @@ namespace EOM.TSHotelManagement.WebApi.Controllers } [HttpPost] - public BaseOutputDto AddPosition([FromBody] CreatePositionInputDto position) + public BaseResponse AddPosition([FromBody] CreatePositionInputDto position) { return baseService.AddPosition(position); } [HttpPost] - public BaseOutputDto DelPosition([FromBody] DeletePositionInputDto position) + public BaseResponse DelPosition([FromBody] DeletePositionInputDto position) { return baseService.DelPosition(position); } [HttpPost] - public BaseOutputDto UpdPosition([FromBody] UpdatePositionInputDto position) + public BaseResponse UpdPosition([FromBody] UpdatePositionInputDto position) { return baseService.UpdPosition(position); } @@ -100,19 +102,19 @@ namespace EOM.TSHotelManagement.WebApi.Controllers } [HttpPost] - public BaseOutputDto AddNation([FromBody] CreateNationInputDto nation) + public BaseResponse AddNation([FromBody] CreateNationInputDto nation) { return baseService.AddNation(nation); } [HttpPost] - public BaseOutputDto DelNation([FromBody] DeleteNationInputDto nation) + public BaseResponse DelNation([FromBody] DeleteNationInputDto nation) { return baseService.DelNation(nation); } [HttpPost] - public BaseOutputDto UpdNation([FromBody] UpdateNationInputDto nation) + public BaseResponse UpdNation([FromBody] UpdateNationInputDto nation) { return baseService.UpdNation(nation); } @@ -134,19 +136,19 @@ namespace EOM.TSHotelManagement.WebApi.Controllers } [HttpPost] - public BaseOutputDto AddEducation([FromBody] CreateEducationInputDto education) + public BaseResponse AddEducation([FromBody] CreateEducationInputDto education) { return baseService.AddEducation(education); } [HttpPost] - public BaseOutputDto DelEducation([FromBody] DeleteEducationInputDto education) + public BaseResponse DelEducation([FromBody] DeleteEducationInputDto education) { return baseService.DelEducation(education); } [HttpPost] - public BaseOutputDto UpdEducation([FromBody] UpdateEducationInputDto education) + public BaseResponse UpdEducation([FromBody] UpdateEducationInputDto education) { return baseService.UpdEducation(education); } @@ -174,19 +176,19 @@ namespace EOM.TSHotelManagement.WebApi.Controllers } [HttpPost] - public BaseOutputDto AddDept([FromBody] CreateDepartmentInputDto dept) + public BaseResponse AddDept([FromBody] CreateDepartmentInputDto dept) { return baseService.AddDept(dept); } [HttpPost] - public BaseOutputDto DelDept([FromBody] DeleteDepartmentInputDto dept) + public BaseResponse DelDept([FromBody] DeleteDepartmentInputDto dept) { return baseService.DelDept(dept); } [HttpPost] - public BaseOutputDto UpdDept([FromBody] UpdateDepartmentInputDto dept) + public BaseResponse UpdDept([FromBody] UpdateDepartmentInputDto dept) { return baseService.UpdDept(dept); } @@ -214,19 +216,19 @@ namespace EOM.TSHotelManagement.WebApi.Controllers } [HttpPost] - public BaseOutputDto InsertCustoType([FromBody] CreateCustoTypeInputDto custoType) + public BaseResponse InsertCustoType([FromBody] CreateCustoTypeInputDto custoType) { return baseService.InsertCustoType(custoType); } [HttpPost] - public BaseOutputDto DeleteCustoType([FromBody] DeleteCustoTypeInputDto custoType) + public BaseResponse DeleteCustoType([FromBody] DeleteCustoTypeInputDto custoType) { return baseService.DeleteCustoType(custoType); } [HttpPost] - public BaseOutputDto UpdateCustoType([FromBody] UpdateCustoTypeInputDto custoType) + public BaseResponse UpdateCustoType([FromBody] UpdateCustoTypeInputDto custoType) { return baseService.UpdateCustoType(custoType); } @@ -254,19 +256,19 @@ namespace EOM.TSHotelManagement.WebApi.Controllers } [HttpPost] - public BaseOutputDto InsertPassPortType([FromBody] CreatePassportTypeInputDto passPortType) + public BaseResponse InsertPassPortType([FromBody] CreatePassportTypeInputDto passPortType) { return baseService.InsertPassPortType(passPortType); } [HttpPost] - public BaseOutputDto DeletePassPortType([FromBody] DeletePassportTypeInputDto portType) + public BaseResponse DeletePassPortType([FromBody] DeletePassportTypeInputDto portType) { return baseService.DeletePassPortType(portType); } [HttpPost] - public BaseOutputDto UpdatePassPortType([FromBody] UpdatePassportTypeInputDto portType) + public BaseResponse UpdatePassPortType([FromBody] UpdatePassportTypeInputDto portType) { return baseService.UpdatePassPortType(portType); } @@ -294,19 +296,19 @@ namespace EOM.TSHotelManagement.WebApi.Controllers } [HttpPost] - public BaseOutputDto InsertRewardPunishmentType([FromBody] CreateRewardPunishmentTypeInputDto createRewardPunishmentTypeInputDto) + public BaseResponse InsertRewardPunishmentType([FromBody] CreateRewardPunishmentTypeInputDto createRewardPunishmentTypeInputDto) { return baseService.InsertRewardPunishmentType(createRewardPunishmentTypeInputDto); } [HttpPost] - public BaseOutputDto DeleteRewardPunishmentType([FromBody] DeleteRewardPunishmentTypeInputDto deleteRewardPunishmentTypeInputDto) + public BaseResponse DeleteRewardPunishmentType([FromBody] DeleteRewardPunishmentTypeInputDto deleteRewardPunishmentTypeInputDto) { return baseService.DeleteRewardPunishmentType(deleteRewardPunishmentTypeInputDto); } [HttpPost] - public BaseOutputDto UpdateRewardPunishmentType([FromBody] UpdateRewardPunishmentTypeInputDto updateRewardPunishmentTypeInputDto) + public BaseResponse UpdateRewardPunishmentType([FromBody] UpdateRewardPunishmentTypeInputDto updateRewardPunishmentTypeInputDto) { return baseService.UpdateRewardPunishmentType(updateRewardPunishmentTypeInputDto); } @@ -331,7 +333,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto CreateAppointmentNoticeType([FromBody] CreateAppointmentNoticeTypeInputDto createAppointmentNoticeTypeInputDto) + public BaseResponse CreateAppointmentNoticeType([FromBody] CreateAppointmentNoticeTypeInputDto createAppointmentNoticeTypeInputDto) { return baseService.CreateAppointmentNoticeType(createAppointmentNoticeTypeInputDto); } @@ -342,7 +344,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteAppointmentNoticeType([FromBody] DeleteAppointmentNoticeTypeInputDto deleteAppointmentNoticeTypeInputDto) + public BaseResponse DeleteAppointmentNoticeType([FromBody] DeleteAppointmentNoticeTypeInputDto deleteAppointmentNoticeTypeInputDto) { return baseService.DeleteAppointmentNoticeType(deleteAppointmentNoticeTypeInputDto); } @@ -353,7 +355,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateAppointmentNoticeType([FromBody] UpdateAppointmentNoticeTypeInputDto updateAppointmentNoticeTypeInputDto) + public BaseResponse UpdateAppointmentNoticeType([FromBody] UpdateAppointmentNoticeTypeInputDto updateAppointmentNoticeTypeInputDto) { return baseService.UpdateAppointmentNoticeType(updateAppointmentNoticeTypeInputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Menu/MenuController.cs b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Menu/MenuController.cs index 55f7544..e943b09 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Menu/MenuController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Menu/MenuController.cs @@ -33,7 +33,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public List BuildMenuAll([FromBody] BaseInputDto baseInputDto) + public ListOutputDto BuildMenuAll([FromBody] BaseInputDto baseInputDto) { return menuService.BuildMenuAll(baseInputDto); } @@ -44,7 +44,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto InsertMenu([FromBody] CreateMenuInputDto menu) + public BaseResponse InsertMenu([FromBody] CreateMenuInputDto menu) { return menuService.InsertMenu(menu); } @@ -55,7 +55,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateMenu([FromBody] UpdateMenuInputDto menu) + public BaseResponse UpdateMenu([FromBody] UpdateMenuInputDto menu) { return menuService.UpdateMenu(menu); } @@ -66,7 +66,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteMenu([FromBody] DeleteMenuInputDto menu) + public BaseResponse DeleteMenu([FromBody] DeleteMenuInputDto menu) { return menuService.DeleteMenu(menu); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Notice/NoticeController.cs b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Notice/NoticeController.cs index ed31874..583158d 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Notice/NoticeController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Notice/NoticeController.cs @@ -47,7 +47,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto InsertNotice([FromBody] CreateAppointmentNoticeInputDto inputDto) + public BaseResponse InsertNotice([FromBody] CreateAppointmentNoticeInputDto inputDto) { return noticeService.InsertNotice(inputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Role/RoleController.cs b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Role/RoleController.cs index 17e3989..c9b7cae 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Role/RoleController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Role/RoleController.cs @@ -30,7 +30,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto InsertRole([FromBody] CreateRoleInputDto createRoleInputDto) + public BaseResponse InsertRole([FromBody] CreateRoleInputDto createRoleInputDto) { return _roleAppService.InsertRole(createRoleInputDto); } @@ -41,7 +41,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateRole([FromBody] UpdateRoleInputDto updateRoleInputDto) + public BaseResponse UpdateRole([FromBody] UpdateRoleInputDto updateRoleInputDto) { return _roleAppService.UpdateRole(updateRoleInputDto); } @@ -52,7 +52,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteRole([FromBody] DeleteRoleInputDto deleteRoleInputDto) + public BaseResponse DeleteRole([FromBody] DeleteRoleInputDto deleteRoleInputDto) { return _roleAppService.DeleteRole(deleteRoleInputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/SupervisionStatistics/SupervisionStatisticsController.cs b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/SupervisionStatistics/SupervisionStatisticsController.cs index 00e4808..1fb4fec 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/SupervisionStatistics/SupervisionStatisticsController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/SupervisionStatistics/SupervisionStatisticsController.cs @@ -33,7 +33,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto InsertSupervisionStatistics([FromBody] CreateSupervisionStatisticsInputDto inputDto) + public BaseResponse InsertSupervisionStatistics([FromBody] CreateSupervisionStatisticsInputDto inputDto) { return checkInfoService.InsertSupervisionStatistics(inputDto); } @@ -44,7 +44,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdateSupervisionStatistics([FromBody] UpdateSupervisionStatisticsInputDto inputDto) + public BaseResponse UpdateSupervisionStatistics([FromBody] UpdateSupervisionStatisticsInputDto inputDto) { return checkInfoService.UpdateSupervisionStatistics(inputDto); } @@ -55,7 +55,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteSupervisionStatistics([FromBody] DeleteSupervisionStatisticsInputDto inputDto) + public BaseResponse DeleteSupervisionStatistics([FromBody] DeleteSupervisionStatisticsInputDto inputDto) { return checkInfoService.DeleteSupervisionStatistics(inputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/VipRule/VipRuleController.cs b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/VipRule/VipRuleController.cs index 0d8f600..205a1f5 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/VipRule/VipRuleController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/VipRule/VipRuleController.cs @@ -44,7 +44,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto AddVipRule([FromBody] CreateVipLevelRuleInputDto inputDto) + public BaseResponse AddVipRule([FromBody] CreateVipLevelRuleInputDto inputDto) { return vipRuleAppService.AddVipRule(inputDto); } @@ -55,7 +55,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DelVipRule([FromBody] DeleteVipLevelRuleInputDto inputDto) + public BaseResponse DelVipRule([FromBody] DeleteVipLevelRuleInputDto inputDto) { return vipRuleAppService.DelVipRule(inputDto); } @@ -66,7 +66,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto UpdVipRule([FromBody] UpdateVipLevelRuleInputDto inputDto) + public BaseResponse UpdVipRule([FromBody] UpdateVipLevelRuleInputDto inputDto) { return vipRuleAppService.UpdVipRule(inputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Util/UtilityController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Util/UtilityController.cs index b52e06b..23a8603 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Util/UtilityController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Util/UtilityController.cs @@ -34,7 +34,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto AddLog([FromBody] CreateOperationLogInputDto opr) + public BaseResponse AddLog([FromBody] CreateOperationLogInputDto opr) { return utilService.AddLog(opr); } @@ -66,7 +66,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteOperationlogByRange([FromBody] ReadOperationLogInputDto readOperationLogInputDto) + public BaseResponse DeleteOperationlogByRange([FromBody] ReadOperationLogInputDto readOperationLogInputDto) { return utilService.DeleteOperationlogByRange(readOperationLogInputDto); } @@ -77,7 +77,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseOutputDto DeleteOperationlog([FromBody] DeleteOperationLogInputDto deleteOperationLogInputDto) + public BaseResponse DeleteOperationlog([FromBody] DeleteOperationLogInputDto deleteOperationLogInputDto) { return utilService.DeleteOperationlog(deleteOperationLogInputDto); } diff --git a/EOM.TSHotelManagement.WebApi/EOM.TSHotelManagement.WebApi.csproj b/EOM.TSHotelManagement.WebApi/EOM.TSHotelManagement.WebApi.csproj index f219ab6..fcaf0bb 100644 --- a/EOM.TSHotelManagement.WebApi/EOM.TSHotelManagement.WebApi.csproj +++ b/EOM.TSHotelManagement.WebApi/EOM.TSHotelManagement.WebApi.csproj @@ -24,8 +24,7 @@ - - + diff --git a/EOM.TSHotelManagement.WebApi/Extension/DateOnlyJsonConverter.cs b/EOM.TSHotelManagement.WebApi/Extension/DateOnlyJsonConverter.cs new file mode 100644 index 0000000..1dcce1d --- /dev/null +++ b/EOM.TSHotelManagement.WebApi/Extension/DateOnlyJsonConverter.cs @@ -0,0 +1,27 @@ +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace EOM.TSHotelManagement.WebApi +{ + public class DateOnlyJsonConverter : JsonConverter + { + private const string DateFormat = "yyyy-MM-dd"; + + public override DateOnly Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options) + { + return DateOnly.Parse(reader.GetString()); + } + + public override void Write( + Utf8JsonWriter writer, + DateOnly value, + JsonSerializerOptions options) + { + writer.WriteStringValue(value.ToString(DateFormat)); + } + } +} diff --git a/EOM.TSHotelManagement.WebApi/Extension/MvcOptionsExtensions.cs b/EOM.TSHotelManagement.WebApi/Extension/MvcOptionsExtensions.cs index a94a579..3f4ba50 100644 --- a/EOM.TSHotelManagement.WebApi/Extension/MvcOptionsExtensions.cs +++ b/EOM.TSHotelManagement.WebApi/Extension/MvcOptionsExtensions.cs @@ -16,7 +16,7 @@ namespace EOM.TSHotelManagement.WebApi public static void UseCentralRoutePrefix(this MvcOptions opts, IRouteTemplateProvider routeAttribute) { // 添加我们自定义 实现IApplicationModelConvention的RouteConvention - opts.Conventions.Insert(0, new RouteConvention(routeAttribute)); + opts.Conventions.Insert(0, new RouteExtension(routeAttribute)); } } } diff --git a/EOM.TSHotelManagement.WebApi/Extension/RouteConvention.cs b/EOM.TSHotelManagement.WebApi/Extension/RouteExtension.cs similarity index 93% rename from EOM.TSHotelManagement.WebApi/Extension/RouteConvention.cs rename to EOM.TSHotelManagement.WebApi/Extension/RouteExtension.cs index 3aa73aa..fd270fd 100644 --- a/EOM.TSHotelManagement.WebApi/Extension/RouteConvention.cs +++ b/EOM.TSHotelManagement.WebApi/Extension/RouteExtension.cs @@ -7,7 +7,7 @@ namespace EOM.TSHotelManagement.WebApi /// /// 全局路由前缀配置 /// - public class RouteConvention : IApplicationModelConvention + public class RouteExtension : IApplicationModelConvention { /// /// 定义一个路由前缀变量 @@ -18,7 +18,7 @@ namespace EOM.TSHotelManagement.WebApi /// 调用时传入指定的路由前缀 /// /// - public RouteConvention(IRouteTemplateProvider routeTemplateProvider) + public RouteExtension(IRouteTemplateProvider routeTemplateProvider) { _centralPrefix = new AttributeRouteModel(routeTemplateProvider); } diff --git a/EOM.TSHotelManagement.WebApi/Factory/JwtConfigFactory.cs b/EOM.TSHotelManagement.WebApi/Factory/JwtConfigFactory.cs index e70013a..d8ab921 100644 --- a/EOM.TSHotelManagement.WebApi/Factory/JwtConfigFactory.cs +++ b/EOM.TSHotelManagement.WebApi/Factory/JwtConfigFactory.cs @@ -17,8 +17,6 @@ namespace EOM.TSHotelManagement.WebApi var jwtConfig = new JwtConfig { Key = _configuration["Jwt:Key"], - Issuer = _configuration["Jwt:Issuer"], - Audience = _configuration["Jwt:Audience"], ExpiryMinutes = int.Parse(_configuration["Jwt:ExpiryMinutes"]) }; return jwtConfig; diff --git a/EOM.TSHotelManagement.WebApi/Filter/AuthorizeAllControllersConvention.cs b/EOM.TSHotelManagement.WebApi/Filters/AuthorizeAllControllersConvention.cs similarity index 96% rename from EOM.TSHotelManagement.WebApi/Filter/AuthorizeAllControllersConvention.cs rename to EOM.TSHotelManagement.WebApi/Filters/AuthorizeAllControllersConvention.cs index c98f4c7..948a982 100644 --- a/EOM.TSHotelManagement.WebApi/Filter/AuthorizeAllControllersConvention.cs +++ b/EOM.TSHotelManagement.WebApi/Filters/AuthorizeAllControllersConvention.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc.ApplicationModels; using Microsoft.AspNetCore.Mvc.Authorization; using System.Linq; -namespace EOM.TSHotelManagement.WebApi.Filter +namespace EOM.TSHotelManagement.WebApi.Filters { public class AuthorizeAllControllersConvention : IApplicationModelConvention { diff --git a/EOM.TSHotelManagement.WebApi/Filter/RequestLoggingMiddleware.cs b/EOM.TSHotelManagement.WebApi/Filters/RequestLoggingMiddleware.cs similarity index 100% rename from EOM.TSHotelManagement.WebApi/Filter/RequestLoggingMiddleware.cs rename to EOM.TSHotelManagement.WebApi/Filters/RequestLoggingMiddleware.cs diff --git a/EOM.TSHotelManagement.WebApi/Startup.cs b/EOM.TSHotelManagement.WebApi/Startup.cs index 84cc004..107bdcc 100644 --- a/EOM.TSHotelManagement.WebApi/Startup.cs +++ b/EOM.TSHotelManagement.WebApi/Startup.cs @@ -2,7 +2,7 @@ using Autofac; using EOM.TSHotelManagement.Common.Util; using EOM.TSHotelManagement.EntityFramework; using EOM.TSHotelManagement.Shared; -using EOM.TSHotelManagement.WebApi.Filter; +using EOM.TSHotelManagement.WebApi.Filters; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; @@ -12,45 +12,77 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; -using Microsoft.OpenApi.Models; -using Newtonsoft.Json.Serialization; using SqlSugar; using System; using System.IO; using System.Reflection; using System.Text; +using System.Text.Json; +using System.Text.Json.Serialization; namespace EOM.TSHotelManagement.WebApi { public class Startup { private readonly IConfiguration _configuration; + private static readonly string[] origins = [ + "http://localhost:5173", + "http://localhost:5174", + "https://tshotel.oscode.top" + ]; public Startup(IConfiguration configuration) { _configuration = configuration; } - // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - // DataProtection - if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "docker") + ConfigureDataProtection(services); + RegisterSingletonServices(services); + ConfigureAuthentication(services); + ConfigureControllers(services); + ConfigureSwagger(services); + ConfigureCors(services); + ConfigureHttpContextAccessor(services); + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + InitializeDatabase(app); + ConfigureEnvironment(app, env); + ConfigureMiddlewares(app); + ConfigureEndpoints(app); + ConfigureSwaggerUI(app); + } + + #region Private Helper Methods + + private void ConfigureDataProtection(IServiceCollection services) + { + if (Environment.GetEnvironmentVariable(SystemConstants.Env) == SystemConstants.Docker) { services.AddDataProtection() - .PersistKeysToFileSystem(new DirectoryInfo("/app/keys")) - .SetApplicationName("TSHotelManagementSystem"); + .PersistKeysToFileSystem(new DirectoryInfo("/app/keys")) + .SetApplicationName("TSHotelManagementSystem"); } else { services.AddDataProtection().SetApplicationName("TSHotelManagementSystem"); } + } + private void RegisterSingletonServices(IServiceCollection services) + { services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + } + private void ConfigureAuthentication(IServiceCollection services) + { services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; @@ -59,118 +91,98 @@ namespace EOM.TSHotelManagement.WebApi { options.TokenValidationParameters = new TokenValidationParameters { - ValidateIssuer = true, - ValidateAudience = true, - ValidateLifetime = true, ValidateIssuerSigningKey = true, - ValidIssuer = _configuration["Jwt:Issuer"], - ValidAudience = _configuration["Jwt:Audience"], + ValidateIssuer = false, + ValidateAudience = false, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["Jwt:Key"])) }; }); services.AddAuthorization(options => { - // һΪApiAccessIJ options.AddPolicy("ApiAccess", policy => { policy.AuthenticationSchemes.Add("Bearer"); policy.RequireAuthenticatedUser(); }); - - // ʹ涨ġApiAccessΪĬϲ options.DefaultPolicy = options.GetPolicy("ApiAccess"); }); + } - + private void ConfigureControllers(IServiceCollection services) + { services.AddControllers(options => { options.Conventions.Add(new AuthorizeAllControllersConvention()); options.RespectBrowserAcceptHeader = true; - }).AddNewtonsoftJson(opt => + }).AddJsonOptions(options => { - //ʱʽӦ - //opt.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; - opt.SerializerSettings.ContractResolver = new DefaultContractResolver(); + options.JsonSerializerOptions.PropertyNamingPolicy = null; + options.JsonSerializerOptions.DictionaryKeyPolicy = null; + + options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; + options.JsonSerializerOptions.Converters.Add(new DateOnlyJsonConverter()); }); - #region ȫ· - //ڸǰ׺ûض·ǰǰ׺ + // ȫ· services.AddMvc(opt => - { - opt.UseCentralRoutePrefix(new RouteAttribute("api/[controller]/[action]")); - }); - #endregion + opt.UseCentralRoutePrefix(new RouteAttribute("api/[controller]/[action]"))); + } + + private void ConfigureHttpContextAccessor(IServiceCollection services) + { + services.AddHttpContextAccessor(); + } - #region עSwagger - services.AddSwaggerGen(s => + private void ConfigureSwagger(IServiceCollection services) + { + services.AddOpenApiDocument(config => { - #region ע Swagger - s.SwaggerDoc("v1", new OpenApiInfo() - { - Title = "EOM.TSHotelManagement.Web", //Swaggerĵ - Version = "version-1.0.0", //Swaggerĵİ汾 - Description = "Api Document", //Swaggerĵ - License = new OpenApiLicense() - { - Name = "MIT", - Url = new Uri("https://mit-license.org/") - }, //SwaggerĵĿԴȨЭ - TermsOfService = new Uri("https://www.oscode.top/"), //Swaggerĵķ֧ҳ - Contact = new OpenApiContact - { - Name = "Easy-Open-Meta", - Email = "eom-official@oscode.top", - Url = new Uri("https://www.oscode.top/") - } - }); - //ȡͬ¸ֲxmlעͣһȡҵ߼㡢ʵͽӿڲ㼴 - s.IncludeXmlComments(AppContext.BaseDirectory + "EOM.TSHotelManagement.Application.xml"); - s.IncludeXmlComments(AppContext.BaseDirectory + "EOM.TSHotelManagement.Common.Core.xml"); - s.IncludeXmlComments(AppContext.BaseDirectory + "EOM.TSHotelManagement.WebApi.xml"); - #endregion - - #region ʽʱ - //s.IncludeXmlComments("EOM.TSHotelManagement.Application.xml"); - //s.IncludeXmlComments("EOM.TSHotelManagement.Core.xml"); - //s.IncludeXmlComments("EOM.TSHotelManagement.WebApi.xml"); - #endregion + config.Title = "EOM.TSHotelManagement.Web"; + config.Version = "v1"; + config.DocumentName = "v1"; }); - #endregion + } + private void ConfigureCors(IServiceCollection services) + { services.AddCors(options => { options.AddPolicy("MyCorsPolicy", policy => { - policy.WithOrigins(new string[] { - "http://localhost:5173", - "http://localhost:5174", - "https://tshotel.oscode.top" - }) - .AllowAnyMethod() - .AllowAnyHeader() - .AllowCredentials() - .SetPreflightMaxAge(TimeSpan.FromMinutes(10)); + policy.WithOrigins(origins) + .AllowAnyMethod() + .AllowAnyHeader() + .AllowCredentials() + .SetPreflightMaxAge(TimeSpan.FromMinutes(10)); }); }); - } - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + private void InitializeDatabase(IApplicationBuilder app) { try { - new InitializeConfig(_configuration).InitializeDatabase(app); + app.ApplicationServices.GetService()?.InitializeDatabase(); } catch (Exception ex) { - Console.WriteLine(LocalizationHelper.GetLocalizedString($"Database initialization failed: {ex.Message}. " + - "Please manually initialize the database or fix the error and retry.", $"ݿʼʧܣ{ex.Message}ִֶгʼ޸ԡ ")); - throw new Exception(LocalizationHelper.GetLocalizedString($"Database initialization failed: {ex.Message}. " + - "Please manually initialize the database or fix the error and retry.", $"ݿʼʧܣ{ex.Message}ִֶгʼ޸ԡ ")); + var message = LocalizationHelper.GetLocalizedString( + $"Database initialization failed: {ex.Message}. Please manually initialize or fix the error.", + $"ݿʼʧܣ{ex.Message}ֶʼ޸"); + Console.WriteLine(message); + throw new Exception(message); } + finally + { + Console.WriteLine(LocalizationHelper.GetLocalizedString( + "Database initialization completed.", + "ݿʼɡ")); + } + } + private void ConfigureEnvironment(IApplicationBuilder app, IWebHostEnvironment env) + { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); @@ -180,34 +192,36 @@ namespace EOM.TSHotelManagement.WebApi { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); + } + private void ConfigureMiddlewares(IApplicationBuilder app) + { app.UseRouting(); - app.UseCors("MyCorsPolicy"); - app.UseAuthentication(); - app.UseAuthorization(); - app.UseRequestLogging(); + } + private void ConfigureEndpoints(IApplicationBuilder app) + { app.UseEndpoints(endpoints => { endpoints.MapControllers(); - endpoints.MapGet("/version", () => - $"Software Version: {Environment.GetEnvironmentVariable("SoftwareVersion") ?? "Unknown"}"); - }); - - #region ʹSwaggerм - app.UseSwagger(); - app.UseSwaggerUI(s => - { - s.SwaggerEndpoint("/swagger/v1/swagger.json", "EOM.TSHotelManagement Api Document"); + endpoints.MapGet("version", () => + $"Software Version: {Environment.GetEnvironmentVariable("SoftwareVersion") ?? "Local Mode"}"); }); - #endregion + } + private void ConfigureSwaggerUI(IApplicationBuilder app) + { + app.UseOpenApi(); + app.UseSwaggerUi(); + app.UseReDoc(); } + #endregion + /// /// AutoFac /// @@ -217,17 +231,15 @@ namespace EOM.TSHotelManagement.WebApi #region AutoFac IOC,ʵע try { - builder.RegisterType() - .As() - .SingleInstance(); + builder.Register(c => + { + var factory = c.Resolve(); + return factory.CreateClient(); + }).As().InstancePerLifetimeScope(); - builder.Register(c => c.Resolve().CreateClient()) - .As() - .InstancePerLifetimeScope(); + builder.RegisterType().As().InstancePerLifetimeScope(); - builder.RegisterGeneric(typeof(GenericRepository<>)) - .AsSelf() - .InstancePerLifetimeScope(); + builder.RegisterType().As().SingleInstance(); builder.RegisterType() .InstancePerDependency(); @@ -237,6 +249,8 @@ namespace EOM.TSHotelManagement.WebApi builder.RegisterType().AsSelf().InstancePerLifetimeScope(); builder.RegisterType().AsSelf().InstancePerLifetimeScope(); + builder.RegisterGeneric(typeof(GenericRepository<>)).AsSelf().InstancePerLifetimeScope(); + //ע var assemblyService = Assembly.LoadFrom(Path.Combine(AppContext.BaseDirectory, "EOM.TSHotelManagement.Application.dll")); builder.RegisterAssemblyTypes(assemblyService) -- Gitee From 825d34f97870fede73a8904ab145da5d2facd33b Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sat, 9 Aug 2025 17:09:43 +0800 Subject: [PATCH 2/4] housekeep. Refac Infrastructure. --- .../Customer/CustomerAccountService.cs | 22 +++---- .../Customer/ICustomerAccountService.cs | 5 -- .../Business/News/INewsService.cs | 5 -- .../Business/News/NewsService.cs | 9 +-- .../Business/Reser/ReserService.cs | 2 +- .../Business/Room/RoomService.cs | 4 ++ .../EOM.TSHotelManagement.Application.csproj | 9 +++ .../Employee/Check/EmployeeCheckService.cs | 34 +++++++++-- .../Employee/EmployeeService.cs | 4 +- .../Administrator/AdminService.cs | 8 +-- .../SystemManagement/Base/BaseService.cs | 58 +++++++++---------- .../SystemManagement/Menu/IMenuService.cs | 1 - .../Util/UtilService.cs | 9 ++- .../BaseDto/BaseAuditDto.cs | 10 +--- .../BaseDto/BaseOutputDto.cs | 10 +--- .../BaseDto/BaseResponse.cs | 1 - .../BaseDto/MenuDto.cs | 4 +- .../BaseDto/PagedData.cs | 8 +-- .../ReadCustomerAccountInputDto.cs | 10 +--- .../ReadCustomerAccountOutputDto.cs | 8 +-- .../Business/News/Dto/AddNewsInputDto.cs | 2 +- .../Business/News/Dto/DeleteNewsInputDto.cs | 2 +- .../Business/News/Dto/ReadNewsInputDto.cs | 2 +- .../Business/News/Dto/ReadNewsOuputDto.cs | 2 +- .../Business/News/Dto/UpdateNewsInputDto.cs | 2 +- ...M.TSHotelManagement.Common.Contract.csproj | 1 + .../ReadEmployeeCheckOutputDto.cs | 4 +- .../Dto/RequestLog/ReadRequestLogInputDto.cs | 10 +--- .../Dto/RequestLog/ReadRequestLogOutputDto.cs | 9 +-- .../BaseEntity.cs | 3 +- .../Business/Customer/CustomerAccount.cs | 5 -- .../Business/News/News.cs | 4 -- .../Business/News/NewsStatus.cs | 7 +-- .../Business/News/NewsType.cs | 7 +-- .../EOM.TSHotelManagement.Common.Core.csproj | 1 + .../EOM.TSHotelManagement.Common.Util.csproj | 1 + .../Helper/MailHelper.cs | 2 +- .../Connector/SqlSugarClientConnector.cs | 7 --- ...M.TSHotelManagement.EntityFramework.csproj | 1 + .../Repository/GenericRepository.cs | 8 +-- .../EOM.TSHotelManagement.Migration.csproj | 1 + .../EOM.TSHotelManagement.Shared.csproj | 1 + .../Application/NavBar/NavBarController.cs | 2 +- .../Customer/CustomerAccountController.cs | 1 - .../Business/News/NewsController.cs | 7 +-- .../SystemManagement/Base/BaseController.cs | 2 - .../SystemManagement/Menu/MenuController.cs | 2 - .../Controllers/Util/UtilityController.cs | 1 - .../EOM.TSHotelManagement.WebApi.csproj | 13 +++++ .../Filters/RequestLoggingMiddleware.cs | 53 ++++++++++++++++- EOM.TSHotelManagement.WebApi/Startup.cs | 18 +++++- EOM.TSHotelManagement.WebApi/appsettings.json | 2 - 52 files changed, 208 insertions(+), 196 deletions(-) diff --git a/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs b/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs index bea567e..0a277bd 100644 --- a/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs +++ b/EOM.TSHotelManagement.Application/Business/Customer/CustomerAccountService.cs @@ -4,19 +4,13 @@ using EOM.TSHotelManagement.Common.Util; using EOM.TSHotelManagement.EntityFramework; using jvncorelib.CodeLib; using jvncorelib.EntityLib; -using System; -using System.Collections.Generic; -using System.Linq; using System.Security.Claims; -using System.Text; using System.Text.Json; -using System.Text.Json.Serialization; -using System.Threading.Tasks; using System.Transactions; namespace EOM.TSHotelManagement.Application { - public class CustomerAccountService:ICustomerAccountService + public class CustomerAccountService : ICustomerAccountService { /// /// 客户账号 @@ -53,15 +47,15 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto Login(ReadCustomerAccountInputDto readCustomerAccountInputDto) { - if(readCustomerAccountInputDto.Account.IsNullOrEmpty() || readCustomerAccountInputDto.Password.IsNullOrEmpty()) - return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account or Password cannot be empty","账号或密码不能为空"), Data = new ReadCustomerAccountOutputDto()}; + if (readCustomerAccountInputDto.Account.IsNullOrEmpty() || readCustomerAccountInputDto.Password.IsNullOrEmpty()) + return new SingleOutputDto() { Code = BusinessStatusCode.BadRequest, Message = LocalizationHelper.GetLocalizedString("Account or Password cannot be empty", "账号或密码不能为空"), Data = new ReadCustomerAccountOutputDto() }; var customerAccount = customerAccountRepository.AsQueryable().Single(x => x.Account == readCustomerAccountInputDto.Account); if (customerAccount == null) - return new SingleOutputDto() { Code = BusinessStatusCode.NotFound, Message = LocalizationHelper.GetLocalizedString("Account not found","账号不存在"), Data = new ReadCustomerAccountOutputDto() }; + return new SingleOutputDto() { Code = BusinessStatusCode.NotFound, Message = LocalizationHelper.GetLocalizedString("Account not found", "账号不存在"), Data = new ReadCustomerAccountOutputDto() }; if (!dataProtector.CompareCustomerData(customerAccount.Password, readCustomerAccountInputDto.Password)) - return new SingleOutputDto() { Code = BusinessStatusCode.Unauthorized, Message = LocalizationHelper.GetLocalizedString("Invalid account or password","账号或密码错误"), Data = new ReadCustomerAccountOutputDto() }; + return new SingleOutputDto() { Code = BusinessStatusCode.Unauthorized, Message = LocalizationHelper.GetLocalizedString("Invalid account or password", "账号或密码错误"), Data = new ReadCustomerAccountOutputDto() }; customerAccount.Password = null; @@ -84,7 +78,7 @@ namespace EOM.TSHotelManagement.Application return new SingleOutputDto() { Code = BusinessStatusCode.Success, - Message = LocalizationHelper.GetLocalizedString("Login successful","登录成功"), + Message = LocalizationHelper.GetLocalizedString("Login successful", "登录成功"), Data = new ReadCustomerAccountOutputDto { Account = customerAccount.Account, @@ -122,8 +116,8 @@ namespace EOM.TSHotelManagement.Application var customerAccount = customerAccountRepository.AsQueryable().Single(x => x.Account == readCustomerAccountInputDto.Account); if (customerAccount != null) - return new SingleOutputDto() { Code = BusinessStatusCode.Conflict, Message = LocalizationHelper.GetLocalizedString("Account already exists","账号已存在"), Data = new ReadCustomerAccountOutputDto() }; - + return new SingleOutputDto() { Code = BusinessStatusCode.Conflict, Message = LocalizationHelper.GetLocalizedString("Account already exists", "账号已存在"), Data = new ReadCustomerAccountOutputDto() }; + var password = dataProtector.EncryptCustomerData(readCustomerAccountInputDto.Password); var customerNumber = new UniqueCode().GetNewId("TS-"); diff --git a/EOM.TSHotelManagement.Application/Business/Customer/ICustomerAccountService.cs b/EOM.TSHotelManagement.Application/Business/Customer/ICustomerAccountService.cs index 62a739d..fa1407c 100644 --- a/EOM.TSHotelManagement.Application/Business/Customer/ICustomerAccountService.cs +++ b/EOM.TSHotelManagement.Application/Business/Customer/ICustomerAccountService.cs @@ -1,9 +1,4 @@ using EOM.TSHotelManagement.Common.Contract; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EOM.TSHotelManagement.Application { diff --git a/EOM.TSHotelManagement.Application/Business/News/INewsService.cs b/EOM.TSHotelManagement.Application/Business/News/INewsService.cs index 4dd4b18..b38c967 100644 --- a/EOM.TSHotelManagement.Application/Business/News/INewsService.cs +++ b/EOM.TSHotelManagement.Application/Business/News/INewsService.cs @@ -1,9 +1,4 @@ using EOM.TSHotelManagement.Common.Contract; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EOM.TSHotelManagement.Application { diff --git a/EOM.TSHotelManagement.Application/Business/News/NewsService.cs b/EOM.TSHotelManagement.Application/Business/News/NewsService.cs index 3f138d2..6e6dfd5 100644 --- a/EOM.TSHotelManagement.Application/Business/News/NewsService.cs +++ b/EOM.TSHotelManagement.Application/Business/News/NewsService.cs @@ -5,15 +5,10 @@ using EOM.TSHotelManagement.Common.Util; using EOM.TSHotelManagement.EntityFramework; using EOM.TSHotelManagement.Shared; using jvncorelib.EntityLib; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EOM.TSHotelManagement.Application { - public class NewsService:INewsService + public class NewsService : INewsService { private readonly GenericRepository _newsRepository; @@ -152,7 +147,7 @@ namespace EOM.TSHotelManagement.Application /// /// /// - public BaseResponse AddNews(AddNewsInputDto addNewsInputDto) + public BaseResponse AddNews(AddNewsInputDto addNewsInputDto) { var news = new News { diff --git a/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs b/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs index 7d787df..d174671 100644 --- a/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs +++ b/EOM.TSHotelManagement.Application/Business/Reser/ReserService.cs @@ -206,7 +206,7 @@ namespace EOM.TSHotelManagement.Application 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", "预约信息添加失败")); diff --git a/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs b/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs index 0732def..1c3b931 100644 --- a/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs +++ b/EOM.TSHotelManagement.Application/Business/Room/RoomService.cs @@ -117,6 +117,10 @@ namespace EOM.TSHotelManagement.Application { var where = Expressionable.Create(); + if (!readRoomInputDto.IsDelete.IsNullOrEmpty()) + { + where = where.And(a => a.IsDelete == readRoomInputDto.IsDelete); + } if (readRoomInputDto.RoomStateId > 0) { where = where.And(a => a.RoomStateId == readRoomInputDto.RoomStateId); diff --git a/EOM.TSHotelManagement.Application/EOM.TSHotelManagement.Application.csproj b/EOM.TSHotelManagement.Application/EOM.TSHotelManagement.Application.csproj index 025a8ff..642d27f 100644 --- a/EOM.TSHotelManagement.Application/EOM.TSHotelManagement.Application.csproj +++ b/EOM.TSHotelManagement.Application/EOM.TSHotelManagement.Application.csproj @@ -5,16 +5,25 @@ enable disable True + AnyCPU;x64 1701;1702;8618; + + 1701;1702;8618; + + 1701;1702;8618; + + 1701;1702;8618; + + diff --git a/EOM.TSHotelManagement.Application/Employee/Check/EmployeeCheckService.cs b/EOM.TSHotelManagement.Application/Employee/Check/EmployeeCheckService.cs index 5aed864..b4cafdb 100644 --- a/EOM.TSHotelManagement.Application/Employee/Check/EmployeeCheckService.cs +++ b/EOM.TSHotelManagement.Application/Employee/Check/EmployeeCheckService.cs @@ -88,7 +88,7 @@ namespace EOM.TSHotelManagement.Application workerChecks.ForEach(source => { - source.CheckStatusDescription = source.CheckStatus == 0 ? "打卡成功" : "打卡失败"; + source.CheckStatusDescription = source.CheckStatus == 0 ? "早班" : "晚班"; }); var source = EntityMapper.MapList(workerChecks); @@ -137,20 +137,42 @@ namespace EOM.TSHotelManagement.Application /// public SingleOutputDto SelectToDayCheckInfoByWorkerNo(ReadEmployeeCheckInputDto wkn) { - var isChecked = false; try { var today = DateTime.Today; - isChecked = workerCheckRepository.AsQueryable() + var tomorrow = today.AddDays(1); + var morningChecked = workerCheckRepository.AsQueryable() .Any(a => a.EmployeeId == wkn.EmployeeId && a.IsDelete != 1 - && a.CheckTime >= today && a.CheckTime < today.AddDays(1)); + && a.CheckStatus == 0 + && a.CheckTime >= today && a.CheckTime < tomorrow); + + var eveningChecked = workerCheckRepository.AsQueryable() + .Any(a => a.EmployeeId == wkn.EmployeeId + && a.IsDelete != 1 + && a.CheckStatus == 1 + && a.CheckTime >= today && a.CheckTime < tomorrow); + + var checkDay = workerCheckRepository.AsQueryable().Count(a => a.EmployeeId == wkn.EmployeeId && a.IsDelete != 1); + + return new SingleOutputDto + { + Data = new ReadEmployeeCheckOutputDto + { + MorningChecked = morningChecked, + EveningChecked = eveningChecked, + CheckDay = checkDay + } + }; } catch (Exception ex) { - return new SingleOutputDto { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString($"Error:\n{ex.Message}", $"错误:\n{ex.Message}") }; + return new SingleOutputDto + { + Code = BusinessStatusCode.InternalServerError, + Message = LocalizationHelper.GetLocalizedString($"Error:\n{ex.Message}", $"错误:\n{ex.Message}") + }; } - return new SingleOutputDto { Data = new ReadEmployeeCheckOutputDto { IsChecked = isChecked } }; } /// diff --git a/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs b/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs index e503aac..71f7d88 100644 --- a/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs +++ b/EOM.TSHotelManagement.Application/Employee/EmployeeService.cs @@ -504,8 +504,8 @@ namespace EOM.TSHotelManagement.Application var mailTemplate = EmailTemplate.GetResetPasswordTemplate(newPwd); - var result = mailHelper.SendMail(new List { emailAddress }, - mailTemplate.Subject, mailTemplate.Body, + var result = mailHelper.SendMail(new List { emailAddress }, + mailTemplate.Subject, mailTemplate.Body, new List { emailAddress }); if (!result) { diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Administrator/AdminService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Administrator/AdminService.cs index 680e0c3..1f27014 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Administrator/AdminService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Administrator/AdminService.cs @@ -180,8 +180,8 @@ namespace EOM.TSHotelManagement.Application var result = EntityMapper.MapList(administrators); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -299,8 +299,8 @@ namespace EOM.TSHotelManagement.Application } var result = EntityMapper.MapList(administratorTypes); - - return new ListOutputDto + + return new ListOutputDto { Data = new PagedData { diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Base/BaseService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Base/BaseService.cs index 0b65ad2..ed739fc 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Base/BaseService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Base/BaseService.cs @@ -134,7 +134,7 @@ namespace EOM.TSHotelManagement.Application return new ListOutputDto { - Data = new PagedData + Data = new PagedData { Items = enumList, TotalCount = enumList.Count @@ -236,8 +236,8 @@ namespace EOM.TSHotelManagement.Application } var result = EntityMapper.MapList(positions); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -276,7 +276,7 @@ namespace EOM.TSHotelManagement.Application /// public BaseResponse DelPosition(DeletePositionInputDto deletePositionInputDto) { - var result = positionRepository.SoftDelete(EntityMapper.Map(deletePositionInputDto)); + var result = positionRepository.SoftDelete(EntityMapper.Map(deletePositionInputDto)); return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } @@ -323,8 +323,8 @@ namespace EOM.TSHotelManagement.Application } var result = EntityMapper.MapList(nations); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -409,8 +409,8 @@ namespace EOM.TSHotelManagement.Application } var result = EntityMapper.MapList(educations); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -477,8 +477,8 @@ namespace EOM.TSHotelManagement.Application { var depts = deptRepository.GetList(a => a.IsDelete != 1); var result = EntityMapper.MapList(depts); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -525,8 +525,8 @@ namespace EOM.TSHotelManagement.Application source.LeaderName = departmentLeader.IsNullOrEmpty() ? "" : departmentLeader.EmployeeName; }); var result = EntityMapper.MapList(depts); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -565,7 +565,7 @@ namespace EOM.TSHotelManagement.Application /// public BaseResponse DelDept(DeleteDepartmentInputDto dept) { - var result = deptRepository.SoftDelete(EntityMapper.Map(dept)); + var result = deptRepository.SoftDelete(EntityMapper.Map(dept)); return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } @@ -593,8 +593,8 @@ namespace EOM.TSHotelManagement.Application { var custoTypes = custoTypeRepository.GetList(a => a.IsDelete != 1); var result = EntityMapper.MapList(custoTypes); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -628,8 +628,8 @@ namespace EOM.TSHotelManagement.Application } var result = EntityMapper.MapList(custoTypes); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -697,8 +697,8 @@ namespace EOM.TSHotelManagement.Application { var passPortTypes = passPortTypeRepository.GetList(a => a.IsDelete != 1); var result = EntityMapper.MapList(passPortTypes); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -732,8 +732,8 @@ namespace EOM.TSHotelManagement.Application } var result = EntityMapper.MapList(passPortTypes); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -801,8 +801,8 @@ namespace EOM.TSHotelManagement.Application { var gBTypes = goodbadTypeRepository.GetList(a => a.IsDelete != 1); var result = EntityMapper.MapList(gBTypes); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -836,8 +836,8 @@ namespace EOM.TSHotelManagement.Application } var result = EntityMapper.MapList(gBTypes); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -877,7 +877,7 @@ namespace EOM.TSHotelManagement.Application /// public BaseResponse DeleteRewardPunishmentType(DeleteRewardPunishmentTypeInputDto gBType) { - var result = goodbadTypeRepository.SoftDelete(EntityMapper.Map(gBType)); + var result = goodbadTypeRepository.SoftDelete(EntityMapper.Map(gBType)); return new BaseResponse { Code = result ? BusinessStatusCode.Success : BusinessStatusCode.InternalServerError }; } @@ -926,8 +926,8 @@ namespace EOM.TSHotelManagement.Application var result = EntityMapper.MapList(Data); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -979,7 +979,7 @@ namespace EOM.TSHotelManagement.Application { return new BaseResponse { Code = BusinessStatusCode.InternalServerError, Message = LocalizationHelper.GetLocalizedString("appointment notice number does not already.", "公告类型编号不存在") }; } - appointmentNoticeTypeRepository.SoftDelete(EntityMapper.Map(deleteAppointmentNoticeTypeInputDto)); + appointmentNoticeTypeRepository.SoftDelete(EntityMapper.Map(deleteAppointmentNoticeTypeInputDto)); } catch (Exception ex) { diff --git a/EOM.TSHotelManagement.Application/SystemManagement/Menu/IMenuService.cs b/EOM.TSHotelManagement.Application/SystemManagement/Menu/IMenuService.cs index 754e4c1..2a2329c 100644 --- a/EOM.TSHotelManagement.Application/SystemManagement/Menu/IMenuService.cs +++ b/EOM.TSHotelManagement.Application/SystemManagement/Menu/IMenuService.cs @@ -22,7 +22,6 @@ * */ using EOM.TSHotelManagement.Common.Contract; -using EOM.TSHotelManagement.Common.Core; namespace EOM.TSHotelManagement.Application { diff --git a/EOM.TSHotelManagement.Application/Util/UtilService.cs b/EOM.TSHotelManagement.Application/Util/UtilService.cs index c4aebf9..dca2c63 100644 --- a/EOM.TSHotelManagement.Application/Util/UtilService.cs +++ b/EOM.TSHotelManagement.Application/Util/UtilService.cs @@ -3,7 +3,6 @@ using EOM.TSHotelManagement.Common.Core; using EOM.TSHotelManagement.Common.Util; using EOM.TSHotelManagement.EntityFramework; using jvncorelib.EntityLib; -using Microsoft.AspNetCore.Http; using SqlSugar; namespace EOM.TSHotelManagement.Application @@ -115,8 +114,8 @@ namespace EOM.TSHotelManagement.Application var result = EntityMapper.MapList(operationLogs); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, @@ -154,8 +153,8 @@ namespace EOM.TSHotelManagement.Application var result = EntityMapper.MapList(requestLogs); - return new ListOutputDto - { + return new ListOutputDto + { Data = new PagedData { Items = result, diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseAuditDto.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseAuditDto.cs index c66b3e3..4e30551 100644 --- a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseAuditDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseAuditDto.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace EOM.TSHotelManagement.Common.Contract +namespace EOM.TSHotelManagement.Common.Contract { - public class BaseAuditDto: BaseDto + public class BaseAuditDto : BaseDto { /// /// 资料创建人 diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseOutputDto.cs index c3d6e7d..b3557f3 100644 --- a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseOutputDto.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace EOM.TSHotelManagement.Common.Contract +namespace EOM.TSHotelManagement.Common.Contract { - public class BaseOutputDto: BaseAuditDto + public class BaseOutputDto : BaseAuditDto { } } diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseResponse.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseResponse.cs index 5ad5694..248acb2 100644 --- a/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseResponse.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/BaseResponse.cs @@ -1,5 +1,4 @@ using EOM.TSHotelManagement.Common.Util; -using System.Net; namespace EOM.TSHotelManagement.Common.Contract { diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/MenuDto.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/MenuDto.cs index 7929bc8..6231229 100644 --- a/EOM.TSHotelManagement.Common.Contract/BaseDto/MenuDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/MenuDto.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - -namespace EOM.TSHotelManagement.Common.Contract +namespace EOM.TSHotelManagement.Common.Contract { /// /// 菜单 diff --git a/EOM.TSHotelManagement.Common.Contract/BaseDto/PagedData.cs b/EOM.TSHotelManagement.Common.Contract/BaseDto/PagedData.cs index 4e1869b..22e47f1 100644 --- a/EOM.TSHotelManagement.Common.Contract/BaseDto/PagedData.cs +++ b/EOM.TSHotelManagement.Common.Contract/BaseDto/PagedData.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace EOM.TSHotelManagement.Common.Contract +namespace EOM.TSHotelManagement.Common.Contract { public class PagedData { diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustomerAccount/ReadCustomerAccountInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustomerAccount/ReadCustomerAccountInputDto.cs index 2785a7e..0e1635e 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustomerAccount/ReadCustomerAccountInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustomerAccount/ReadCustomerAccountInputDto.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace EOM.TSHotelManagement.Common.Contract +namespace EOM.TSHotelManagement.Common.Contract { - public class ReadCustomerAccountInputDto:BaseInputDto + public class ReadCustomerAccountInputDto : BaseInputDto { /// /// 账号 (Account) diff --git a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustomerAccount/ReadCustomerAccountOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustomerAccount/ReadCustomerAccountOutputDto.cs index 2d21f66..74a829b 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustomerAccount/ReadCustomerAccountOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/Customer/Dto/CustomerAccount/ReadCustomerAccountOutputDto.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace EOM.TSHotelManagement.Common.Contract +namespace EOM.TSHotelManagement.Common.Contract { public class ReadCustomerAccountOutputDto : BaseOutputDto { diff --git a/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/AddNewsInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/AddNewsInputDto.cs index 172639d..3812f28 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/AddNewsInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/AddNewsInputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class AddNewsInputDto: BaseInputDto + public class AddNewsInputDto : BaseInputDto { public string NewId { get; set; } public string NewsTitle { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/DeleteNewsInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/DeleteNewsInputDto.cs index 3f76f5d..7a34586 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/DeleteNewsInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/DeleteNewsInputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class DeleteNewsInputDto: BaseInputDto + public class DeleteNewsInputDto : BaseInputDto { public string NewId { get; set; } public string NewsTitle { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/ReadNewsInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/ReadNewsInputDto.cs index ac07640..9553087 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/ReadNewsInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/ReadNewsInputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadNewsInputDto:ListInputDto + public class ReadNewsInputDto : ListInputDto { public string NewId { get; set; } public string NewsTitle { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/ReadNewsOuputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/ReadNewsOuputDto.cs index 40af968..4a2ea22 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/ReadNewsOuputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/ReadNewsOuputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class ReadNewsOuputDto:BaseDto + public class ReadNewsOuputDto : BaseDto { public int Id { get; set; } public string NewId { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/UpdateNewsInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/UpdateNewsInputDto.cs index 0f39534..bbf96d3 100644 --- a/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/UpdateNewsInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Business/News/Dto/UpdateNewsInputDto.cs @@ -1,6 +1,6 @@ namespace EOM.TSHotelManagement.Common.Contract { - public class UpdateNewsInputDto: BaseInputDto + public class UpdateNewsInputDto : BaseInputDto { public string NewId { get; set; } public string NewsTitle { get; set; } diff --git a/EOM.TSHotelManagement.Common.Contract/EOM.TSHotelManagement.Common.Contract.csproj b/EOM.TSHotelManagement.Common.Contract/EOM.TSHotelManagement.Common.Contract.csproj index abdeb04..52e1575 100644 --- a/EOM.TSHotelManagement.Common.Contract/EOM.TSHotelManagement.Common.Contract.csproj +++ b/EOM.TSHotelManagement.Common.Contract/EOM.TSHotelManagement.Common.Contract.csproj @@ -5,6 +5,7 @@ enable enable True + AnyCPU;x64 diff --git a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeCheck/ReadEmployeeCheckOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeCheck/ReadEmployeeCheckOutputDto.cs index 9935d3b..9db2be1 100644 --- a/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeCheck/ReadEmployeeCheckOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Employee/Dto/EmployeeCheck/ReadEmployeeCheckOutputDto.cs @@ -7,7 +7,9 @@ namespace EOM.TSHotelManagement.Common.Contract public string CheckStatus { get; set; } public string CheckMethod { get; set; } - public bool IsChecked { get; set; } + public bool MorningChecked { get; set; } + + public bool EveningChecked { get; set; } public int CheckDay { get; set; } } } diff --git a/EOM.TSHotelManagement.Common.Contract/Util/Dto/RequestLog/ReadRequestLogInputDto.cs b/EOM.TSHotelManagement.Common.Contract/Util/Dto/RequestLog/ReadRequestLogInputDto.cs index f91d415..6d9d215 100644 --- a/EOM.TSHotelManagement.Common.Contract/Util/Dto/RequestLog/ReadRequestLogInputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Util/Dto/RequestLog/ReadRequestLogInputDto.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace EOM.TSHotelManagement.Common.Contract +namespace EOM.TSHotelManagement.Common.Contract { - public class ReadRequestLogInputDto:ListInputDto + public class ReadRequestLogInputDto : ListInputDto { } diff --git a/EOM.TSHotelManagement.Common.Contract/Util/Dto/RequestLog/ReadRequestLogOutputDto.cs b/EOM.TSHotelManagement.Common.Contract/Util/Dto/RequestLog/ReadRequestLogOutputDto.cs index b98983f..2b4bcf3 100644 --- a/EOM.TSHotelManagement.Common.Contract/Util/Dto/RequestLog/ReadRequestLogOutputDto.cs +++ b/EOM.TSHotelManagement.Common.Contract/Util/Dto/RequestLog/ReadRequestLogOutputDto.cs @@ -1,11 +1,4 @@ -using SqlSugar; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace EOM.TSHotelManagement.Common.Contract +namespace EOM.TSHotelManagement.Common.Contract { public class ReadRequestLogOutputDto : BaseOutputDto { diff --git a/EOM.TSHotelManagement.Common.Core/BaseEntity.cs b/EOM.TSHotelManagement.Common.Core/BaseEntity.cs index 45045d7..8e5e8fd 100644 --- a/EOM.TSHotelManagement.Common.Core/BaseEntity.cs +++ b/EOM.TSHotelManagement.Common.Core/BaseEntity.cs @@ -1,5 +1,4 @@ -using EOM.TSHotelManagement.Common.Util; -using System; +using System; namespace EOM.TSHotelManagement.Common.Core { diff --git a/EOM.TSHotelManagement.Common.Core/Business/Customer/CustomerAccount.cs b/EOM.TSHotelManagement.Common.Core/Business/Customer/CustomerAccount.cs index 03b71d8..c8be1af 100644 --- a/EOM.TSHotelManagement.Common.Core/Business/Customer/CustomerAccount.cs +++ b/EOM.TSHotelManagement.Common.Core/Business/Customer/CustomerAccount.cs @@ -1,9 +1,4 @@ using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EOM.TSHotelManagement.Common.Core { diff --git a/EOM.TSHotelManagement.Common.Core/Business/News/News.cs b/EOM.TSHotelManagement.Common.Core/Business/News/News.cs index 20af3db..5d3327f 100644 --- a/EOM.TSHotelManagement.Common.Core/Business/News/News.cs +++ b/EOM.TSHotelManagement.Common.Core/Business/News/News.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EOM.TSHotelManagement.Common.Core { diff --git a/EOM.TSHotelManagement.Common.Core/Business/News/NewsStatus.cs b/EOM.TSHotelManagement.Common.Core/Business/News/NewsStatus.cs index 95e5183..6d4a49e 100644 --- a/EOM.TSHotelManagement.Common.Core/Business/News/NewsStatus.cs +++ b/EOM.TSHotelManagement.Common.Core/Business/News/NewsStatus.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel; namespace EOM.TSHotelManagement.Common.Core { diff --git a/EOM.TSHotelManagement.Common.Core/Business/News/NewsType.cs b/EOM.TSHotelManagement.Common.Core/Business/News/NewsType.cs index 9aab8db..7e5d92f 100644 --- a/EOM.TSHotelManagement.Common.Core/Business/News/NewsType.cs +++ b/EOM.TSHotelManagement.Common.Core/Business/News/NewsType.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel; namespace EOM.TSHotelManagement.Common.Core.Business { diff --git a/EOM.TSHotelManagement.Common.Core/EOM.TSHotelManagement.Common.Core.csproj b/EOM.TSHotelManagement.Common.Core/EOM.TSHotelManagement.Common.Core.csproj index 1c3bb57..866569c 100644 --- a/EOM.TSHotelManagement.Common.Core/EOM.TSHotelManagement.Common.Core.csproj +++ b/EOM.TSHotelManagement.Common.Core/EOM.TSHotelManagement.Common.Core.csproj @@ -3,6 +3,7 @@ net8.0 True + AnyCPU;x64 diff --git a/EOM.TSHotelManagement.Common.Util/EOM.TSHotelManagement.Common.Util.csproj b/EOM.TSHotelManagement.Common.Util/EOM.TSHotelManagement.Common.Util.csproj index 0a5cfb3..a885042 100644 --- a/EOM.TSHotelManagement.Common.Util/EOM.TSHotelManagement.Common.Util.csproj +++ b/EOM.TSHotelManagement.Common.Util/EOM.TSHotelManagement.Common.Util.csproj @@ -2,6 +2,7 @@ net8.0 + AnyCPU;x64 diff --git a/EOM.TSHotelManagement.Common.Util/Helper/MailHelper.cs b/EOM.TSHotelManagement.Common.Util/Helper/MailHelper.cs index a0d5a32..7458df5 100644 --- a/EOM.TSHotelManagement.Common.Util/Helper/MailHelper.cs +++ b/EOM.TSHotelManagement.Common.Util/Helper/MailHelper.cs @@ -129,7 +129,7 @@ namespace EOM.TSHotelManagement.Common.Util return true; } - catch (Exception ex) + catch (Exception) { return false; } diff --git a/EOM.TSHotelManagement.EntityFramework/Connector/SqlSugarClientConnector.cs b/EOM.TSHotelManagement.EntityFramework/Connector/SqlSugarClientConnector.cs index 8f723df..92d7e94 100644 --- a/EOM.TSHotelManagement.EntityFramework/Connector/SqlSugarClientConnector.cs +++ b/EOM.TSHotelManagement.EntityFramework/Connector/SqlSugarClientConnector.cs @@ -1,13 +1,6 @@ using EOM.TSHotelManagement.Shared; using Microsoft.Extensions.Configuration; using SqlSugar; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EOM.TSHotelManagement.EntityFramework { diff --git a/EOM.TSHotelManagement.EntityFramework/EOM.TSHotelManagement.EntityFramework.csproj b/EOM.TSHotelManagement.EntityFramework/EOM.TSHotelManagement.EntityFramework.csproj index 3f276d5..9251206 100644 --- a/EOM.TSHotelManagement.EntityFramework/EOM.TSHotelManagement.EntityFramework.csproj +++ b/EOM.TSHotelManagement.EntityFramework/EOM.TSHotelManagement.EntityFramework.csproj @@ -4,6 +4,7 @@ net8.0 enable disable + AnyCPU;x64 diff --git a/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs b/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs index 9ad3b14..0c7cdfe 100644 --- a/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs +++ b/EOM.TSHotelManagement.EntityFramework/Repository/GenericRepository.cs @@ -1,9 +1,7 @@ using EOM.TSHotelManagement.Common.Core; using EOM.TSHotelManagement.Common.Util; using Microsoft.AspNetCore.Http; -using Newtonsoft.Json.Linq; using SqlSugar; -using System.Linq.Expressions; namespace EOM.TSHotelManagement.EntityFramework { @@ -17,7 +15,7 @@ namespace EOM.TSHotelManagement.EntityFramework private readonly JWTHelper _jWTHelper; - public GenericRepository(ISqlSugarClient client, IHttpContextAccessor httpContextAccessor,JWTHelper jWTHelper) : base(client) + public GenericRepository(ISqlSugarClient client, IHttpContextAccessor httpContextAccessor, JWTHelper jWTHelper) : base(client) { base.Context = client; _httpContextAccessor = httpContextAccessor; @@ -60,7 +58,7 @@ namespace EOM.TSHotelManagement.EntityFramework baseEntity.DataChgDate = DateTime.Now; baseEntity.DataChgUsr = currentUser; } - return base.Context.Updateable(entity).IgnoreColumns(ignoreAllNullColumns:true,false,true).ExecuteCommand() > 0; + return base.Context.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true, false, true).ExecuteCommand() > 0; } public override bool UpdateRange(List updateObjs) @@ -74,7 +72,7 @@ namespace EOM.TSHotelManagement.EntityFramework baseEntity.DataChgUsr = currentUser; } } - + return base.Context.Updateable(updateObjs).IgnoreColumns(ignoreAllNullColumns: true, false, true).ExecuteCommand() > 0; } diff --git a/EOM.TSHotelManagement.Migration/EOM.TSHotelManagement.Migration.csproj b/EOM.TSHotelManagement.Migration/EOM.TSHotelManagement.Migration.csproj index 6ce7f3d..60d2bc7 100644 --- a/EOM.TSHotelManagement.Migration/EOM.TSHotelManagement.Migration.csproj +++ b/EOM.TSHotelManagement.Migration/EOM.TSHotelManagement.Migration.csproj @@ -4,6 +4,7 @@ net8.0 enable enable + AnyCPU;x64 diff --git a/EOM.TSHotelManagement.Shared/EOM.TSHotelManagement.Shared.csproj b/EOM.TSHotelManagement.Shared/EOM.TSHotelManagement.Shared.csproj index 4f1739b..bda4122 100644 --- a/EOM.TSHotelManagement.Shared/EOM.TSHotelManagement.Shared.csproj +++ b/EOM.TSHotelManagement.Shared/EOM.TSHotelManagement.Shared.csproj @@ -4,6 +4,7 @@ net8.0 enable enable + AnyCPU;x64 diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Application/NavBar/NavBarController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Application/NavBar/NavBarController.cs index 306ac56..4cfb9a9 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Application/NavBar/NavBarController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Application/NavBar/NavBarController.cs @@ -38,7 +38,7 @@ namespace EOM.TSHotelManagement.WebApi.Controllers /// /// [HttpPost] - public BaseResponse AddNavBar([FromBody]CreateNavBarInputDto input) + public BaseResponse AddNavBar([FromBody] CreateNavBarInputDto input) { return navBarService.AddNavBar(input); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/Customer/CustomerAccountController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/Customer/CustomerAccountController.cs index 6fc4391..2debffc 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/Customer/CustomerAccountController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/Customer/CustomerAccountController.cs @@ -1,7 +1,6 @@ using EOM.TSHotelManagement.Application; using EOM.TSHotelManagement.Common.Contract; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace EOM.TSHotelManagement.WebApi.Controllers diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Business/News/NewsController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Business/News/NewsController.cs index be27d25..39088d3 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Business/News/NewsController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Business/News/NewsController.cs @@ -1,7 +1,6 @@ using EOM.TSHotelManagement.Application; using EOM.TSHotelManagement.Common.Contract; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace EOM.TSHotelManagement.WebApi @@ -20,7 +19,7 @@ namespace EOM.TSHotelManagement.WebApi /// [AllowAnonymous] [HttpGet] - public ListOutputDto SelectNews([FromQuery]ReadNewsInputDto readNewsInputDto) + public ListOutputDto SelectNews([FromQuery] ReadNewsInputDto readNewsInputDto) { return newsService.SelectNews(readNewsInputDto); } @@ -31,7 +30,7 @@ namespace EOM.TSHotelManagement.WebApi /// [AllowAnonymous] [HttpGet] - public SingleOutputDto News([FromQuery]ReadNewsInputDto readNewsInputDto) + public SingleOutputDto News([FromQuery] ReadNewsInputDto readNewsInputDto) { return newsService.News(readNewsInputDto); } @@ -61,7 +60,7 @@ namespace EOM.TSHotelManagement.WebApi /// /// [HttpPost] - public BaseResponse DeleteNews([FromBody]DeleteNewsInputDto deleteNewsInputDto) + public BaseResponse DeleteNews([FromBody] DeleteNewsInputDto deleteNewsInputDto) { return newsService.DeleteNews(deleteNewsInputDto); } diff --git a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Base/BaseController.cs b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Base/BaseController.cs index 5d6ddbc..666d018 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Base/BaseController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Base/BaseController.cs @@ -1,8 +1,6 @@ using EOM.TSHotelManagement.Application; using EOM.TSHotelManagement.Common.Contract; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using System.IO; namespace EOM.TSHotelManagement.WebApi.Controllers { diff --git a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Menu/MenuController.cs b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Menu/MenuController.cs index e943b09..941a9e6 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Menu/MenuController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/SystemManagement/Menu/MenuController.cs @@ -1,8 +1,6 @@ using EOM.TSHotelManagement.Application; using EOM.TSHotelManagement.Common.Contract; -using EOM.TSHotelManagement.Common.Core; using Microsoft.AspNetCore.Mvc; -using System.Collections.Generic; namespace EOM.TSHotelManagement.WebApi.Controllers { diff --git a/EOM.TSHotelManagement.WebApi/Controllers/Util/UtilityController.cs b/EOM.TSHotelManagement.WebApi/Controllers/Util/UtilityController.cs index 23a8603..29d05c2 100644 --- a/EOM.TSHotelManagement.WebApi/Controllers/Util/UtilityController.cs +++ b/EOM.TSHotelManagement.WebApi/Controllers/Util/UtilityController.cs @@ -1,6 +1,5 @@ using EOM.TSHotelManagement.Application; using EOM.TSHotelManagement.Common.Contract; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace EOM.TSHotelManagement.WebApi.Controllers diff --git a/EOM.TSHotelManagement.WebApi/EOM.TSHotelManagement.WebApi.csproj b/EOM.TSHotelManagement.WebApi/EOM.TSHotelManagement.WebApi.csproj index fcaf0bb..6a750ef 100644 --- a/EOM.TSHotelManagement.WebApi/EOM.TSHotelManagement.WebApi.csproj +++ b/EOM.TSHotelManagement.WebApi/EOM.TSHotelManagement.WebApi.csproj @@ -6,6 +6,7 @@ True Linux false + AnyCPU;x64 @@ -16,10 +17,22 @@ True + + + + Off + 1701;1702;1591; + True + + False + + False + + diff --git a/EOM.TSHotelManagement.WebApi/Filters/RequestLoggingMiddleware.cs b/EOM.TSHotelManagement.WebApi/Filters/RequestLoggingMiddleware.cs index d13b6de..8c2b7ac 100644 --- a/EOM.TSHotelManagement.WebApi/Filters/RequestLoggingMiddleware.cs +++ b/EOM.TSHotelManagement.WebApi/Filters/RequestLoggingMiddleware.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging; using System; using System.Diagnostics; using System.IO; +using System.Linq; using System.Text; using System.Text.Json; using System.Threading.Tasks; @@ -54,7 +55,7 @@ public class RequestLoggingMiddleware { Path = context.Request.Path, Method = context.Request.Method, - ClientIP = context.Connection.RemoteIpAddress?.ToString(), + ClientIP = GetClientIp(context), Parameters = requestParameters, UserAgent = context.Request.Headers["User-Agent"].ToString(), UserName = context.User.Identity?.Name ?? "Anonymous", @@ -181,4 +182,54 @@ public class RequestLoggingMiddleware return "Unable to read request body"; } } + + private string GetClientIp(HttpContext context) + { + var xForwardedFor = context.Request.Headers["X-Forwarded-For"].FirstOrDefault(); + if (!string.IsNullOrEmpty(xForwardedFor)) + { + var ips = xForwardedFor.Split(',', StringSplitOptions.RemoveEmptyEntries); + foreach (var ip in ips) + { + var cleanIp = ip.Trim(); + if (!IsLocalIp(cleanIp)) + { + return cleanIp; + } + } + return ips.FirstOrDefault()?.Trim() ?? string.Empty; + } + + var xRealIp = context.Request.Headers["X-Real-IP"].FirstOrDefault(); + if (!string.IsNullOrEmpty(xRealIp) && !IsLocalIp(xRealIp)) + { + return xRealIp.Trim(); + } + + return context.Connection.RemoteIpAddress?.ToString(); + } + + private bool IsLocalIp(string ip) + { + return ip == "::1" || + ip == "127.0.0.1" || + ip.StartsWith("192.168.") || + ip.StartsWith("10.") || + ip.StartsWith("172.16.") || + ip.StartsWith("172.17.") || + ip.StartsWith("172.18.") || + ip.StartsWith("172.19.") || + ip.StartsWith("172.20.") || + ip.StartsWith("172.21.") || + ip.StartsWith("172.22.") || + ip.StartsWith("172.23.") || + ip.StartsWith("172.24.") || + ip.StartsWith("172.25.") || + ip.StartsWith("172.26.") || + ip.StartsWith("172.27.") || + ip.StartsWith("172.28.") || + ip.StartsWith("172.29.") || + ip.StartsWith("172.30.") || + ip.StartsWith("172.31."); + } } \ No newline at end of file diff --git a/EOM.TSHotelManagement.WebApi/Startup.cs b/EOM.TSHotelManagement.WebApi/Startup.cs index 107bdcc..2b5216e 100644 --- a/EOM.TSHotelManagement.WebApi/Startup.cs +++ b/EOM.TSHotelManagement.WebApi/Startup.cs @@ -12,14 +12,12 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; using SqlSugar; using System; using System.IO; using System.Reflection; using System.Text; -using System.Text.Json; using System.Text.Json.Serialization; namespace EOM.TSHotelManagement.WebApi @@ -47,6 +45,7 @@ namespace EOM.TSHotelManagement.WebApi ConfigureSwagger(services); ConfigureCors(services); ConfigureHttpContextAccessor(services); + ConfigureXForward(services); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) @@ -74,6 +73,18 @@ namespace EOM.TSHotelManagement.WebApi } } + private void ConfigureXForward(IServiceCollection services) + { + services.Configure(options => + { + options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | + ForwardedHeaders.XForwardedProto; + + options.KnownNetworks.Clear(); + options.KnownProxies.Clear(); + }); + } + private void RegisterSingletonServices(IServiceCollection services) { services.AddSingleton(); @@ -196,6 +207,7 @@ namespace EOM.TSHotelManagement.WebApi private void ConfigureMiddlewares(IApplicationBuilder app) { + app.UseForwardedHeaders(); app.UseRouting(); app.UseCors("MyCorsPolicy"); app.UseAuthentication(); @@ -208,7 +220,7 @@ namespace EOM.TSHotelManagement.WebApi app.UseEndpoints(endpoints => { endpoints.MapControllers(); - endpoints.MapGet("version", () => + endpoints.MapGet("api/version", () => $"Software Version: {Environment.GetEnvironmentVariable("SoftwareVersion") ?? "Local Mode"}"); }); } diff --git a/EOM.TSHotelManagement.WebApi/appsettings.json b/EOM.TSHotelManagement.WebApi/appsettings.json index 8a1cbee..f334974 100644 --- a/EOM.TSHotelManagement.WebApi/appsettings.json +++ b/EOM.TSHotelManagement.WebApi/appsettings.json @@ -17,8 +17,6 @@ "AllowedHosts": "*", "Jwt": { "Key": "", - "Issuer": "", - "Audience": "", "ExpiryMinutes": 20 }, "Mail": { -- Gitee From eb31646ab9897f7e9828eb91b5e2fd8daf7c1450 Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sat, 9 Aug 2025 17:39:29 +0800 Subject: [PATCH 3/4] update gitignore and build.ps1 --- .gitignore | 1 + build.ps1 | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.gitignore b/.gitignore index aa670e3..b95bb29 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ bld/ [Oo]bj/ [Ll]og/ [Ll]ogs/ +docker-images/ # Visual Studio 2015/2017 cache/options directory .vs/ diff --git a/build.ps1 b/build.ps1 index b456e7b..759dc74 100644 --- a/build.ps1 +++ b/build.ps1 @@ -35,6 +35,22 @@ docker build ` -t "$imageName`:$timestampedVersion" ` -t "$imageName`:latest" . +# 5. 导出镜像到当前文件夹 +# 创建导出目录(如果不存在) +$exportDir = "docker-images" +if (-not (Test-Path $exportDir)) { + New-Item -ItemType Directory -Path $exportDir | Out-Null +} + +# 导出带时间戳的版本 +$exportFileName = "tshotel-management-system-api_$($timestampedVersion).tar" +Write-Host "Exporting image to $exportDir\$exportFileName" +docker save -o "$exportDir\$exportFileName" "$imageName`:$timestampedVersion" + +# 计算导出文件大小 +$fileSize = (Get-Item "$exportDir\$exportFileName").Length / 1MB +$fileSize = [Math]::Round($fileSize, 2) + # 5. 可选的推送命令 # docker push "$imageName`:$baseVersion" # docker push "$imageName`:$timestampedVersion" @@ -45,6 +61,7 @@ Write-Host "Build completed:" Write-Host " - Base version: $baseVersion" Write-Host " - Timestamped version: $timestampedVersion" Write-Host " - Latest" +Write-Host " - Exported to: $exportDir\$exportFileName ($fileSize MB)" Write-Host "Build complete. Press any key to exit..." [void][System.Console]::ReadKey($true) -- Gitee From 30baeee06bb4ba5ee41d20198b63a7c4a7b9726c Mon Sep 17 00:00:00 2001 From: ck_yeun9 Date: Sat, 9 Aug 2025 19:08:05 +0800 Subject: [PATCH 4/4] Fix the timing of initializing the database. --- EOM.TSHotelManagement.WebApi/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EOM.TSHotelManagement.WebApi/Startup.cs b/EOM.TSHotelManagement.WebApi/Startup.cs index 2b5216e..3fcf99c 100644 --- a/EOM.TSHotelManagement.WebApi/Startup.cs +++ b/EOM.TSHotelManagement.WebApi/Startup.cs @@ -50,9 +50,9 @@ namespace EOM.TSHotelManagement.WebApi public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { - InitializeDatabase(app); ConfigureEnvironment(app, env); ConfigureMiddlewares(app); + InitializeDatabase(app); ConfigureEndpoints(app); ConfigureSwaggerUI(app); } -- Gitee