From 5dc1780ef17e5560367dc3488ce2f0b63a0a1e41 Mon Sep 17 00:00:00 2001
From: fuenmao <980740792@qq.com>
Date: Mon, 29 Sep 2025 13:48:36 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.editorconfig | 41 +
.template.config/template.json | 13 +
Directory.Build.props | 13 +
.../Application.Development.json | 13 +
.../Application.Production.json | 13 +
.../Const/ApplicationConst.cs | 29 +
SimpleAdmin.Application/Entity/GenTest.cs | 56 +
SimpleAdmin.Application/Entity/Medicinal.cs | 36 +
.../Entity/MedicinalAddLog.cs | 48 +
SimpleAdmin.Application/Entity/Person.cs | 43 +
.../Entity/Prescription.cs | 43 +
.../Entity/PrescriptionHerb.cs | 37 +
SimpleAdmin.Application/GlobalUsings.cs | 29 +
.../Options/ApplicationSettingsOptions.cs | 20 +
.../Services/Medicinal/Dto/MedicinalDto.cs | 93 +
.../Services/Medicinal/IMedicinalService.cs | 72 +
.../Services/Medicinal/MedicinalService.cs | 412 +
.../Services/Organization/Org/IOrgService.cs | 66 +
.../Services/Organization/Org/OrgService.cs | 149 +
.../Organization/Position/IPositionService.cs | 66 +
.../Organization/Position/PositionService.cs | 131 +
.../Organization/Role/IRoleService.cs | 115 +
.../Services/Organization/Role/RoleService.cs | 286 +
.../Organization/User/Dto/UserInput.cs | 18 +
.../Organization/User/Dto/UserOutput.cs | 18 +
.../Organization/User/IUserService.cs | 155 +
.../Services/Organization/User/UserService.cs | 332 +
.../Prescription/Dto/PrescriptionDtos.cs | 162 +
.../Prescription/IPrescriptionService.cs | 58 +
.../Prescription/PrescriptionService.cs | 551 ++
.../SimpleAdmin.Application.csproj | 22 +
.../SimpleAdmin.Application.xml | 838 ++
SimpleAdmin.Application/Startup.cs | 37 +
SimpleAdmin.Cache/Cache.Development.json | 12 +
SimpleAdmin.Cache/Cache.Production.json | 12 +
SimpleAdmin.Cache/GlobalUsing.cs | 19 +
.../Interface/ISimpleCacheHashService.cs | 70 +
.../Interface/ISimpleCacheQueueService.cs | 108 +
.../Interface/ISimpleCacheService.cs | 191 +
.../Options/CacheSettingsOptions.cs | 55 +
.../Service/MemoryCacheHashService.cs | 98 +
.../Service/MemoryCacheQueueService.cs | 74 +
.../Service/MemoryCacheService.cs | 229 +
.../Service/RedisCacheHashService.cs | 54 +
.../Service/RedisCacheQueueService.cs | 74 +
.../Service/RedisCacheService.cs | 201 +
SimpleAdmin.Cache/SimpleAdmin.Cache.csproj | 24 +
SimpleAdmin.Cache/SimpleAdmin.Cache.xml | 637 ++
SimpleAdmin.Cache/Startup.cs | 58 +
.../Attributes/CodeGenAttribute.cs | 18 +
.../Attributes/IgnoreInitTableAttribute.cs | 18 +
.../Attributes/IgnoreSeedDataAttribute.cs | 25 +
.../Attributes/RolePermissionAttribute.cs | 25 +
.../Attributes/SuperAdminAttribute.cs | 25 +
.../ValidationAttribute/IdNotNull.cs | 39 +
SimpleAdmin.Core/BaseInput/BaseFileInput.cs | 23 +
SimpleAdmin.Core/BaseInput/BaseIdInput.cs | 42 +
SimpleAdmin.Core/BaseInput/BasePageInput.cs | 70 +
.../BaseOutput/BaseSelectorOutput.cs | 27 +
.../Components/GzipCompressionComponent.cs | 33 +
.../Components/LoggingConsoleComponent.cs | 147 +
.../Components/LoggingFileComponent.cs | 99 +
SimpleAdmin.Core/Const/CacheConst.cs | 47 +
SimpleAdmin.Core/Const/ClaimConst.cs | 44 +
SimpleAdmin.Core/Const/MqttConst.cs | 40 +
SimpleAdmin.Core/Const/SimpleAdminConst.cs | 19 +
SimpleAdmin.Core/Core.Development.json | 25 +
SimpleAdmin.Core/Core.Production.json | 25 +
SimpleAdmin.Core/Dto/MqttMessage.cs | 48 +
SimpleAdmin.Core/Dto/TokenInfo.cs | 57 +
.../Enum/Auth/AuthDeviceTypeEnum.cs | 35 +
.../Enum/Auth/LoginClientTypeEnum.cs | 29 +
SimpleAdmin.Core/Enum/ErrorCodeEnum.cs | 48 +
SimpleAdmin.Core/Extension/LinqExtension.cs | 30 +
SimpleAdmin.Core/Extension/ObjectExtension.cs | 53 +
SimpleAdmin.Core/GlobalUsings.cs | 53 +
SimpleAdmin.Core/Options/BaseOptions.cs | 27 +
SimpleAdmin.Core/Options/LoggingSetting.cs | 64 +
SimpleAdmin.Core/SimpleAdmin.Core.csproj | 29 +
SimpleAdmin.Core/SimpleAdmin.Core.xml | 1294 +++
SimpleAdmin.Core/Startup.cs | 36 +
.../UnifyResult/SimpleAdminResult.cs | 43 +
.../UnifyResult/SimpleAdminResultProvider.cs | 107 +
SimpleAdmin.Core/Utils/Captcha/CaptchaInfo.cs | 35 +
SimpleAdmin.Core/Utils/Captcha/CaptchaType.cs | 35 +
SimpleAdmin.Core/Utils/Captcha/CaptchaUtil.cs | 142 +
SimpleAdmin.Core/Utils/CommonUtils.cs | 26 +
.../Utils/Cryptogram/CryptogramUtil.cs | 92 +
SimpleAdmin.Core/Utils/Cryptogram/SM2Util.cs | 48 +
SimpleAdmin.Core/Utils/Cryptogram/SM4Util.cs | 170 +
.../Utils/Cryptogram/Sm/SM2CryptoUtil.cs | 399 +
.../Utils/Cryptogram/Sm/SM4CryptoUtil.cs | 425 +
SimpleAdmin.Core/Utils/Image/AvatarUtil.cs | 116 +
SimpleAdmin.Core/Utils/Image/ImageUtil.cs | 223 +
SimpleAdmin.Core/Utils/Pwd/PwdUtil.cs | 62 +
SimpleAdmin.Core/Utils/Zip/ZipUtils.cs | 533 +
SimpleAdmin.MessageCenter/GlobalUsing.cs | 1 +
SimpleAdmin.MessageCenter/MessageWorker.cs | 91 +
SimpleAdmin.MessageCenter/Program.cs | 19 +
.../Properties/launchSettings.json | 12 +
.../SimpleAdmin.MessageCenter.csproj | 31 +
.../SimpleAdmin.MessageCenter.xml | 8 +
.../appsettings.Development.json | 10 +
.../appsettings.Production.json | 10 +
.../Aop/GlobalDispatchProxy.cs | 423 +
.../Attributes/CacheAttribute.cs | 42 +
.../SimpleAdmin.Plugin.Aop/GlobalUsing.cs | 18 +
.../SimpleAdmin.Plugin.Aop.csproj | 7 +
.../SimpleAdmin.Plugin.Aop.xml | 134 +
.../Const/MobileConst.cs | 32 +
.../Controllers/MobileButtonController.cs | 86 +
.../Controllers/MobileMenuController.cs | 158 +
.../Controllers/MobileModuleController.cs | 86 +
.../Controllers/MobileUserCenterController.cs | 96 +
.../Entity/MobileResource.cs | 112 +
.../SimpleAdmin.Plugin.Mobile/GlobalUsing.cs | 35 +
.../Mobile.Development.json | 12 +
.../Mobile.Production.json | 12 +
.../Options/MobileSettingsOptions.cs | 20 +
.../SeedData/Json/seed_mobile_resource.json | 604 ++
.../Json/seed_sys_relation_mobile.json | 39 +
.../Json/seed_sys_resource_mobile.json | 73 +
.../SeedData/MobileResourceSeedData.cs | 22 +
.../SeedData/SysRelationSeedData.cs | 22 +
.../SeedData/SysResourceSeedData.cs | 22 +
.../Resource/Button/Dto/ButtonInput.cs | 44 +
.../Resource/Button/IMobileButtonService.cs | 52 +
.../Button/MobileMobileButtonService.cs | 187 +
.../Resource/Menu/Dto/MobileMenuInput.cs | 59 +
.../Resource/Menu/IMobileMenuService.cs | 74 +
.../Resource/Menu/MobileMenuService.cs | 250 +
.../Resource/Module/Dto/MobileModuleInput.cs | 30 +
.../Resource/Module/IMobileModuleService.cs | 52 +
.../Resource/Module/MobileModuleService.cs | 142 +
.../Resource/IMobileResourceService.cs | 89 +
.../Resource/MobileResourceService.cs | 410 +
.../UserCenter/Dto/MobileUserCenterInput.cs | 11 +
.../UserCenter/Dto/MobileUserCenterOutput.cs | 30 +
.../UserCenter/IMobileUserCenterService.cs | 29 +
.../UserCenter/MobileUserCenterService.cs | 233 +
.../SimpleAdmin.Plugin.Mobile.csproj | 25 +
.../SimpleAdmin.Plugin.Mobile.xml | 865 ++
.../SimpleAdmin.Plugin.Mobile/Startup.cs | 37 +
.../Const/CommonStatusConst.cs | 27 +
SimpleAdmin.SqlSugar/Const/EffTypeConst.cs | 67 +
SimpleAdmin.SqlSugar/Const/SqlsugarConst.cs | 56 +
SimpleAdmin.SqlSugar/Db/DbContext.cs | 216 +
SimpleAdmin.SqlSugar/Db/DbRepository.cs | 134 +
SimpleAdmin.SqlSugar/Db/SqlsugarConfig.cs | 22 +
SimpleAdmin.SqlSugar/Dto/LinqPagedList.cs | 19 +
SimpleAdmin.SqlSugar/Entity/BaseEntity.cs | 95 +
.../Extension/ISqlSugarEntitySeedData.cs | 24 +
.../Extension/SqlSugarPageExtension.cs | 190 +
.../Extension/SqlSugarUnitOfWork.cs | 79 +
SimpleAdmin.SqlSugar/Filter/IEntityFilter.cs | 29 +
SimpleAdmin.SqlSugar/GlobalUsing.cs | 31 +
.../SimpleAdmin.SqlSugar.csproj | 25 +
SimpleAdmin.SqlSugar/SimpleAdmin.SqlSugar.xml | 665 ++
.../SqlSugar.Development.json | 21 +
SimpleAdmin.SqlSugar/SqlSugar.Production.json | 20 +
SimpleAdmin.SqlSugar/Startup.cs | 53 +
SimpleAdmin.SqlSugar/Utils/CodeFirstUtils.cs | 199 +
.../Utils/Dto/SqlSugarTableInfo.cs | 42 +
.../Utils/Dto/SqlsugarColumnInfo.cs | 37 +
SimpleAdmin.SqlSugar/Utils/SeedDataUtil.cs | 154 +
SimpleAdmin.SqlSugar/Utils/SqlSugarUtils.cs | 206 +
.../Attributes/AntTableAttribute.cs | 32 +
.../Attributes/BatchEditAttribute.cs | 18 +
.../Attributes/InDictAttribute.cs | 65 +
SimpleAdmin.System/Const/CateGoryConst.cs | 266 +
SimpleAdmin.System/Const/GenConst.cs | 53 +
SimpleAdmin.System/Const/SysConfigConst.cs | 200 +
SimpleAdmin.System/Const/SysDictConst.cs | 166 +
SimpleAdmin.System/Const/SysLogConst.cs | 27 +
SimpleAdmin.System/Const/SysResourceConst.cs | 52 +
SimpleAdmin.System/Const/SysRoleConst.cs | 27 +
SimpleAdmin.System/Const/SystemConst.cs | 145 +
SimpleAdmin.System/Entity/BatchEdit.cs | 50 +
SimpleAdmin.System/Entity/BatchEditConfig.cs | 85 +
SimpleAdmin.System/Entity/ClientRelation.cs | 37 +
SimpleAdmin.System/Entity/ClientUser.cs | 289 +
SimpleAdmin.System/Entity/GenBasic.cs | 202 +
SimpleAdmin.System/Entity/GenConfig.cs | 154 +
SimpleAdmin.System/Entity/SysConfig.cs | 49 +
SimpleAdmin.System/Entity/SysDict.cs | 56 +
SimpleAdmin.System/Entity/SysFile.cs | 79 +
SimpleAdmin.System/Entity/SysLogOperate.cs | 61 +
SimpleAdmin.System/Entity/SysLogVisit.cs | 81 +
SimpleAdmin.System/Entity/SysMessage.cs | 123 +
SimpleAdmin.System/Entity/SysMessageUser.cs | 37 +
SimpleAdmin.System/Entity/SysOrg.cs | 83 +
SimpleAdmin.System/Entity/SysPosition.cs | 50 +
SimpleAdmin.System/Entity/SysRelation.cs | 37 +
SimpleAdmin.System/Entity/SysResource.cs | 191 +
SimpleAdmin.System/Entity/SysRole.cs | 83 +
SimpleAdmin.System/Entity/SysUser.cs | 393 +
.../EventSubscriber/AuthEventSubscriber.cs | 169 +
.../Const/EventSubscriberConst.cs | 64 +
.../EventSubscriber/Dto/LoginEvent.cs | 54 +
.../EventSubscriber/Dto/NoticeEvent.cs | 54 +
.../EventSubscriber/NoticeEventSubscriber.cs | 110 +
.../EventSubscriber/UserEventSubscriber.cs | 108 +
SimpleAdmin.System/ExtJson/RelationMsgUser.cs | 23 +
.../ExtJson/RelationRolePermission.cs | 33 +
.../ExtJson/RelationRoleResource.cs | 28 +
.../ExtJson/RelationUserSchedule.cs | 43 +
.../ExtJson/RelationUserWorkBench.cs | 49 +
SimpleAdmin.System/GlobalUsings.cs | 43 +
SimpleAdmin.System/Mapper.cs | 21 +
.../Options/SystemSettingsOptions.cs | 29 +
SimpleAdmin.System/Oss/MinioUtils.cs | 128 +
.../SeedData/GenBaseSeedData.cs | 12 +
.../SeedData/GenConfigSeedData.cs | 12 +
.../SeedData/Json/seed_sys_config.json | 616 ++
.../SeedData/Json/seed_sys_dict.json | 1449 +++
.../SeedData/Json/seed_sys_org.json | 764 ++
.../SeedData/Json/seed_sys_position.json | 328 +
.../SeedData/Json/seed_sys_relation.json | 3322 +++++++
.../SeedData/Json/seed_sys_resource.json | 2298 +++++
.../SeedData/Json/seed_sys_role.json | 175 +
.../SeedData/Json/seed_sys_user.json | 844 ++
.../SeedData/SysConfigSeedData.cs | 22 +
.../SeedData/SysDictSeedData.cs | 22 +
SimpleAdmin.System/SeedData/SysOrgSeedData.cs | 22 +
.../SeedData/SysPositionSeedData.cs | 22 +
.../SeedData/SysRelationSeedData.cs | 22 +
.../SeedData/SysResourceSeedData.cs | 22 +
.../SeedData/SysRoleSeedData.cs | 22 +
.../SeedData/SysUserSeedData.cs | 22 +
.../Services/Auth/Auth/AuthService.cs | 502 +
.../Services/Auth/Auth/Dto/AuthInput.cs | 103 +
.../Services/Auth/Auth/Dto/AuthOutPut.cs | 154 +
.../Services/Auth/Auth/IAuthService.cs | 61 +
.../Services/Auth/Session/Dto/SessionInput.cs | 45 +
.../Auth/Session/Dto/SessionOutput.cs | 94 +
.../Services/Auth/Session/ISessionService.cs | 49 +
.../Services/Auth/Session/SessionService.cs | 202 +
.../Services/BatchEdit/BatchEditService.cs | 214 +
.../Services/BatchEdit/Dto/BatchEditInput.cs | 138 +
.../Services/BatchEdit/Dto/BatchEditOutput.cs | 14 +
.../Services/BatchEdit/IBatchEditService.cs | 80 +
.../Services/Dev/File/Dto/FileInput.cs | 22 +
.../Services/Dev/File/FileService.cs | 273 +
.../Services/Dev/File/IFileService.cs | 63 +
.../Services/Dev/Message/Dto/MessageInput.cs | 90 +
.../Services/Dev/Message/Dto/MessageOutPut.cs | 34 +
.../Services/Dev/Message/IMessageService.cs | 97 +
.../Services/Dev/Message/MessageService.cs | 339 +
.../Services/Gen/Basic/Dto/GenBasicInput.cs | 180 +
.../Services/Gen/Basic/Dto/GenBasicOutput.cs | 67 +
.../Services/Gen/Basic/Dto/GenViewModel.cs | 254 +
.../Services/Gen/Basic/GenBasicService.cs | 808 ++
.../Services/Gen/Basic/IGenbasicService.cs | 70 +
.../Services/Gen/Config/Dto/GenConfigInput.cs | 5 +
.../Services/Gen/Config/GenConfigService.cs | 28 +
.../Services/Gen/Config/IGenConfigService.cs | 21 +
.../ImportExport/Dto/ImportPreviewInput.cs | 18 +
.../ImportExport/Dto/ImportPreviewOutput.cs | 63 +
.../ImportExport/Dto/ImportResultInput.cs | 23 +
.../ImportExport/Dto/ImportResultOutPut.cs | 44 +
.../ImportExport/Dto/ImportTemplateInput.cs | 36 +
.../ImportExport/IImportExportService.cs | 75 +
.../ImportExport/ImportExportService.cs | 204 +
.../Services/Index/Dto/IndexInput.cs | 44 +
.../Services/Index/Dto/IndexOutput.cs | 19 +
.../Services/Index/IIndexService.cs | 38 +
.../Services/Index/IndexService.cs | 60 +
.../Services/Limit/Button/ButtonService.cs | 190 +
.../Services/Limit/Button/Dto/ButtonInput.cs | 53 +
.../Services/Limit/Button/IButtonService.cs | 59 +
.../Services/Limit/Menu/Dto/MenuInput.cs | 127 +
.../Services/Limit/Menu/IMenuService.cs | 75 +
.../Services/Limit/Menu/MenuService.cs | 264 +
.../Services/Limit/Module/Dto/ModuleInput.cs | 37 +
.../Services/Limit/Module/IModuleService.cs | 58 +
.../Services/Limit/Module/ModuleService.cs | 161 +
.../Services/Limit/Role/Dto/RoleInput.cs | 130 +
.../Services/Limit/Role/Dto/RoleOutput.cs | 69 +
.../Services/Limit/Role/ISysRoleService.cs | 159 +
.../Services/Limit/Role/SysRoleService.cs | 589 ++
.../Services/Limit/Spa/Dto/SpaInput.cs | 64 +
.../Services/Limit/Spa/ISpaService.cs | 52 +
.../Services/Limit/Spa/SpaService.cs | 130 +
.../OperateLog/Dto/OperateLogInput.cs | 25 +
.../OperateLog/Dto/OperateLogOutput.cs | 39 +
.../LogAudit/OperateLog/IOperateLogService.cs | 51 +
.../LogAudit/OperateLog/OperateLogService.cs | 118 +
.../LogAudit/VisitLog/Dto/VisitLogInput.cs | 38 +
.../LogAudit/VisitLog/Dto/VisitLogOutput.cs | 48 +
.../LogAudit/VisitLog/IVisitLogService.cs | 44 +
.../LogAudit/VisitLog/VisitLogService.cs | 93 +
.../Services/Mqtt/Dto/MqttInput.cs | 27 +
.../Services/Mqtt/Dto/MqttOutput.cs | 49 +
.../Services/Mqtt/IMqttService.cs | 21 +
.../Services/Mqtt/MqttService.cs | 76 +
.../Services/Ops/Config/ConfigService.cs | 206 +
.../Services/Ops/Config/Dto/ConfigInput.cs | 69 +
.../Services/Ops/Config/IConfigService.cs | 97 +
.../Services/Ops/Dict/DictService.cs | 237 +
.../Services/Ops/Dict/Dto/DictInput.cs | 90 +
.../Services/Ops/Dict/IDictService.cs | 95 +
.../Organization/Org/Dto/SysOrgInput.cs | 140 +
.../Organization/Org/Dto/SysOrgOutput.cs | 14 +
.../Organization/Org/ISysOrgService.cs | 178 +
.../Organization/Org/SysOrgService.cs | 643 ++
.../Position/Dto/PositionInput.cs | 91 +
.../Position/Dto/PositionOutput.cs | 58 +
.../Position/ISysPositionService.cs | 114 +
.../Position/SysPositionService.cs | 307 +
.../Organization/User/Dto/UserInput.cs | 330 +
.../Organization/User/Dto/UserOutPut.cs | 254 +
.../Organization/User/ISysUserService.cs | 324 +
.../Organization/User/SysUserService.cs | 1165 +++
.../System/Relation/Dto/RelationInput.cs | 14 +
.../System/Relation/Dto/RelationOutput.cs | 15 +
.../System/Relation/IRelationService.cs | 103 +
.../System/Relation/RelationService.cs | 174 +
.../System/Resource/Dto/ResourceInput.cs | 27 +
.../System/Resource/Dto/ResourceOutPut.cs | 110 +
.../System/Resource/IResourceService.cs | 113 +
.../System/Resource/ResourceService.cs | 427 +
.../System/UserCenter/Dto/UserCenterInput.cs | 80 +
.../System/UserCenter/Dto/UserCenterOutput.cs | 58 +
.../System/UserCenter/IUserCenterService.cs | 157 +
.../System/UserCenter/UserCenterService.cs | 461 +
.../Services/Upload/IUploadService.cs | 16 +
.../Services/Upload/UploadService.cs | 15 +
SimpleAdmin.System/SimpleAdmin.System.csproj | 93 +
SimpleAdmin.System/SimpleAdmin.System.xml | 8581 +++++++++++++++++
SimpleAdmin.System/Startup.cs | 59 +
SimpleAdmin.System/System.Development.json | 28 +
SimpleAdmin.System/System.Production.json | 28 +
SimpleAdmin.System/UserManager/UserManager.cs | 83 +
.../Backend/Controllers/Controller.cs.vm | 299 +
.../CodeGen/Backend/Services/Dto/Input.cs.vm | 180 +
.../CodeGen/Backend/Services/Dto/Output.cs.vm | 53 +
.../CodeGen/Backend/Services/IService.cs.vm | 174 +
.../CodeGen/Backend/Services/Service.cs.vm | 461 +
.../Frontend/api/interface/interface.ts.vm | 85 +
.../Frontend/api/modules/modules.ts.vm | 50 +
.../ViewEngine/CodeGen/Frontend/template.vm | 14 +
.../Frontend/views/components/form.vue.vm | 191 +
.../CodeGen/Frontend/views/index.vue.vm | 192 +
.../ViewEngine/CodeGen/Sql/MySql.sql.vm | 19 +
.../ViewEngine/CodeGen/Sql/Oracle.sql.vm | 19 +
.../ViewEngine/CodeGen/Sql/SqlServer.sql.vm | 19 +
.../ViewEngine/CodeGen/Sql/Sqlite.sql.vm | 19 +
SimpleAdmin.System/ip2region.xdb | Bin 0 -> 11070130 bytes
.../Components/AuthComponent.cs | 49 +
.../Components/LoggingMonitorComponent.cs | 58 +
.../Components/WebSettingsComponent.cs | 41 +
.../Organization/BizOrgController.cs | 142 +
.../Organization/BizPositionController.cs | 118 +
.../Organization/BizRoleController.cs | 173 +
.../Organization/BizUserController.cs | 232 +
.../WeiBingJu/MedicinalController.cs | 88 +
.../WeiBingJu/PrescriptionController.cs | 77 +
.../System/Auth/AuthBController.cs | 95 +
.../System/Auth/SessionController.cs | 103 +
.../Controllers/System/BaseController.cs | 19 +
.../System/BatchEdit/BatchEditController.cs | 124 +
.../Controllers/System/CommonController.cs | 84 +
.../Controllers/System/Dev/FileController.cs | 89 +
.../System/Dev/MessageController.cs | 83 +
.../System/Gen/GenBasicController.cs | 119 +
.../System/Gen/GenConfigController.cs | 41 +
.../System/Index/IndexController.cs | 99 +
.../System/Limit/ButtonController.cs | 97 +
.../System/Limit/MenuController.cs | 125 +
.../System/Limit/ModuleController.cs | 95 +
.../System/Limit/RoleController.cs | 199 +
.../Controllers/System/Limit/SpaController.cs | 85 +
.../System/LogAudit/LogOperateController.cs | 80 +
.../System/LogAudit/LogVisitController.cs | 69 +
.../Controllers/System/Mqtt/MqttController.cs | 39 +
.../System/Ops/ConfigController.cs | 109 +
.../Controllers/System/Ops/DictController.cs | 85 +
.../System/Organization/OrgController.cs | 137 +
.../System/Organization/PositionController.cs | 117 +
.../System/Organization/UserController.cs | 287 +
.../System/Upload/UploadController.cs | 37 +
.../System/UserCenter/UserCenterController.cs | 234 +
SimpleAdmin.Web.Core/Filter/MyActionFilter.cs | 50 +
.../Filter/MyAuthorizationFilter.cs | 45 +
SimpleAdmin.Web.Core/GlobalUsing.cs | 46 +
SimpleAdmin.Web.Core/Handlers/JwtHandler.cs | 142 +
.../Handlers/LogExceptionHandler.cs | 41 +
.../Logging/DatabaseLoggingWriter.cs | 205 +
SimpleAdmin.Web.Core/Logging/LoggingConst.cs | 37 +
.../Logging/LoggingMonitorJson.cs | 225 +
.../Middleware/WebStatusMiddleware.cs | 55 +
.../Options/WebSettingsOptions.cs | 29 +
.../SimpleAdmin.Web.Core.csproj | 17 +
SimpleAdmin.Web.Core/SimpleAdmin.Web.Core.xml | 2001 ++++
SimpleAdmin.Web.Core/Startup.cs | 97 +
SimpleAdmin.Web.Core/Web.Development.json | 19 +
SimpleAdmin.Web.Core/Web.Production.json | 19 +
.../.config/dotnet-tools.json | 12 +
SimpleAdmin.Web.Entry/AntDeploy.json | 116 +
SimpleAdmin.Web.Entry/Program.cs | 19 +
.../Properties/launchSettings.json | 15 +
.../SimpleAdmin.Web.Entry.csproj | 24 +
.../SimpleAdmin.Web.Entry.xml | 8 +
SimpleAdmin.Web.Entry/SimpleAdmin.db | Bin 0 -> 1011712 bytes
SimpleAdmin.Web.Entry/appsettings.json | 37 +
SimpleAdmin.sln | 111 +
global.json | 7 +
407 files changed, 63703 insertions(+)
create mode 100644 .editorconfig
create mode 100644 .template.config/template.json
create mode 100644 Directory.Build.props
create mode 100644 SimpleAdmin.Application/Application.Development.json
create mode 100644 SimpleAdmin.Application/Application.Production.json
create mode 100644 SimpleAdmin.Application/Const/ApplicationConst.cs
create mode 100644 SimpleAdmin.Application/Entity/GenTest.cs
create mode 100644 SimpleAdmin.Application/Entity/Medicinal.cs
create mode 100644 SimpleAdmin.Application/Entity/MedicinalAddLog.cs
create mode 100644 SimpleAdmin.Application/Entity/Person.cs
create mode 100644 SimpleAdmin.Application/Entity/Prescription.cs
create mode 100644 SimpleAdmin.Application/Entity/PrescriptionHerb.cs
create mode 100644 SimpleAdmin.Application/GlobalUsings.cs
create mode 100644 SimpleAdmin.Application/Options/ApplicationSettingsOptions.cs
create mode 100644 SimpleAdmin.Application/Services/Medicinal/Dto/MedicinalDto.cs
create mode 100644 SimpleAdmin.Application/Services/Medicinal/IMedicinalService.cs
create mode 100644 SimpleAdmin.Application/Services/Medicinal/MedicinalService.cs
create mode 100644 SimpleAdmin.Application/Services/Organization/Org/IOrgService.cs
create mode 100644 SimpleAdmin.Application/Services/Organization/Org/OrgService.cs
create mode 100644 SimpleAdmin.Application/Services/Organization/Position/IPositionService.cs
create mode 100644 SimpleAdmin.Application/Services/Organization/Position/PositionService.cs
create mode 100644 SimpleAdmin.Application/Services/Organization/Role/IRoleService.cs
create mode 100644 SimpleAdmin.Application/Services/Organization/Role/RoleService.cs
create mode 100644 SimpleAdmin.Application/Services/Organization/User/Dto/UserInput.cs
create mode 100644 SimpleAdmin.Application/Services/Organization/User/Dto/UserOutput.cs
create mode 100644 SimpleAdmin.Application/Services/Organization/User/IUserService.cs
create mode 100644 SimpleAdmin.Application/Services/Organization/User/UserService.cs
create mode 100644 SimpleAdmin.Application/Services/Prescription/Dto/PrescriptionDtos.cs
create mode 100644 SimpleAdmin.Application/Services/Prescription/IPrescriptionService.cs
create mode 100644 SimpleAdmin.Application/Services/Prescription/PrescriptionService.cs
create mode 100644 SimpleAdmin.Application/SimpleAdmin.Application.csproj
create mode 100644 SimpleAdmin.Application/SimpleAdmin.Application.xml
create mode 100644 SimpleAdmin.Application/Startup.cs
create mode 100644 SimpleAdmin.Cache/Cache.Development.json
create mode 100644 SimpleAdmin.Cache/Cache.Production.json
create mode 100644 SimpleAdmin.Cache/GlobalUsing.cs
create mode 100644 SimpleAdmin.Cache/Interface/ISimpleCacheHashService.cs
create mode 100644 SimpleAdmin.Cache/Interface/ISimpleCacheQueueService.cs
create mode 100644 SimpleAdmin.Cache/Interface/ISimpleCacheService.cs
create mode 100644 SimpleAdmin.Cache/Options/CacheSettingsOptions.cs
create mode 100644 SimpleAdmin.Cache/Service/MemoryCacheHashService.cs
create mode 100644 SimpleAdmin.Cache/Service/MemoryCacheQueueService.cs
create mode 100644 SimpleAdmin.Cache/Service/MemoryCacheService.cs
create mode 100644 SimpleAdmin.Cache/Service/RedisCacheHashService.cs
create mode 100644 SimpleAdmin.Cache/Service/RedisCacheQueueService.cs
create mode 100644 SimpleAdmin.Cache/Service/RedisCacheService.cs
create mode 100644 SimpleAdmin.Cache/SimpleAdmin.Cache.csproj
create mode 100644 SimpleAdmin.Cache/SimpleAdmin.Cache.xml
create mode 100644 SimpleAdmin.Cache/Startup.cs
create mode 100644 SimpleAdmin.Core/Attributes/CodeGenAttribute.cs
create mode 100644 SimpleAdmin.Core/Attributes/IgnoreInitTableAttribute.cs
create mode 100644 SimpleAdmin.Core/Attributes/IgnoreSeedDataAttribute.cs
create mode 100644 SimpleAdmin.Core/Attributes/RolePermissionAttribute.cs
create mode 100644 SimpleAdmin.Core/Attributes/SuperAdminAttribute.cs
create mode 100644 SimpleAdmin.Core/Attributes/ValidationAttribute/IdNotNull.cs
create mode 100644 SimpleAdmin.Core/BaseInput/BaseFileInput.cs
create mode 100644 SimpleAdmin.Core/BaseInput/BaseIdInput.cs
create mode 100644 SimpleAdmin.Core/BaseInput/BasePageInput.cs
create mode 100644 SimpleAdmin.Core/BaseOutput/BaseSelectorOutput.cs
create mode 100644 SimpleAdmin.Core/Components/GzipCompressionComponent.cs
create mode 100644 SimpleAdmin.Core/Components/LoggingConsoleComponent.cs
create mode 100644 SimpleAdmin.Core/Components/LoggingFileComponent.cs
create mode 100644 SimpleAdmin.Core/Const/CacheConst.cs
create mode 100644 SimpleAdmin.Core/Const/ClaimConst.cs
create mode 100644 SimpleAdmin.Core/Const/MqttConst.cs
create mode 100644 SimpleAdmin.Core/Const/SimpleAdminConst.cs
create mode 100644 SimpleAdmin.Core/Core.Development.json
create mode 100644 SimpleAdmin.Core/Core.Production.json
create mode 100644 SimpleAdmin.Core/Dto/MqttMessage.cs
create mode 100644 SimpleAdmin.Core/Dto/TokenInfo.cs
create mode 100644 SimpleAdmin.Core/Enum/Auth/AuthDeviceTypeEnum.cs
create mode 100644 SimpleAdmin.Core/Enum/Auth/LoginClientTypeEnum.cs
create mode 100644 SimpleAdmin.Core/Enum/ErrorCodeEnum.cs
create mode 100644 SimpleAdmin.Core/Extension/LinqExtension.cs
create mode 100644 SimpleAdmin.Core/Extension/ObjectExtension.cs
create mode 100644 SimpleAdmin.Core/GlobalUsings.cs
create mode 100644 SimpleAdmin.Core/Options/BaseOptions.cs
create mode 100644 SimpleAdmin.Core/Options/LoggingSetting.cs
create mode 100644 SimpleAdmin.Core/SimpleAdmin.Core.csproj
create mode 100644 SimpleAdmin.Core/SimpleAdmin.Core.xml
create mode 100644 SimpleAdmin.Core/Startup.cs
create mode 100644 SimpleAdmin.Core/UnifyResult/SimpleAdminResult.cs
create mode 100644 SimpleAdmin.Core/UnifyResult/SimpleAdminResultProvider.cs
create mode 100644 SimpleAdmin.Core/Utils/Captcha/CaptchaInfo.cs
create mode 100644 SimpleAdmin.Core/Utils/Captcha/CaptchaType.cs
create mode 100644 SimpleAdmin.Core/Utils/Captcha/CaptchaUtil.cs
create mode 100644 SimpleAdmin.Core/Utils/CommonUtils.cs
create mode 100644 SimpleAdmin.Core/Utils/Cryptogram/CryptogramUtil.cs
create mode 100644 SimpleAdmin.Core/Utils/Cryptogram/SM2Util.cs
create mode 100644 SimpleAdmin.Core/Utils/Cryptogram/SM4Util.cs
create mode 100644 SimpleAdmin.Core/Utils/Cryptogram/Sm/SM2CryptoUtil.cs
create mode 100644 SimpleAdmin.Core/Utils/Cryptogram/Sm/SM4CryptoUtil.cs
create mode 100644 SimpleAdmin.Core/Utils/Image/AvatarUtil.cs
create mode 100644 SimpleAdmin.Core/Utils/Image/ImageUtil.cs
create mode 100644 SimpleAdmin.Core/Utils/Pwd/PwdUtil.cs
create mode 100644 SimpleAdmin.Core/Utils/Zip/ZipUtils.cs
create mode 100644 SimpleAdmin.MessageCenter/GlobalUsing.cs
create mode 100644 SimpleAdmin.MessageCenter/MessageWorker.cs
create mode 100644 SimpleAdmin.MessageCenter/Program.cs
create mode 100644 SimpleAdmin.MessageCenter/Properties/launchSettings.json
create mode 100644 SimpleAdmin.MessageCenter/SimpleAdmin.MessageCenter.csproj
create mode 100644 SimpleAdmin.MessageCenter/SimpleAdmin.MessageCenter.xml
create mode 100644 SimpleAdmin.MessageCenter/appsettings.Development.json
create mode 100644 SimpleAdmin.MessageCenter/appsettings.Production.json
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Aop/Aop/GlobalDispatchProxy.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Aop/Attributes/CacheAttribute.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Aop/GlobalUsing.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Aop/SimpleAdmin.Plugin.Aop.csproj
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Aop/SimpleAdmin.Plugin.Aop.xml
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Const/MobileConst.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Controllers/MobileButtonController.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Controllers/MobileMenuController.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Controllers/MobileModuleController.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Controllers/MobileUserCenterController.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Entity/MobileResource.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/GlobalUsing.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Mobile.Development.json
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Mobile.Production.json
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Options/MobileSettingsOptions.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/SeedData/Json/seed_mobile_resource.json
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/SeedData/Json/seed_sys_relation_mobile.json
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/SeedData/Json/seed_sys_resource_mobile.json
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/SeedData/MobileResourceSeedData.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/SeedData/SysRelationSeedData.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/SeedData/SysResourceSeedData.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/Resource/Button/Dto/ButtonInput.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/Resource/Button/IMobileButtonService.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/Resource/Button/MobileMobileButtonService.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/Resource/Menu/Dto/MobileMenuInput.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/Resource/Menu/IMobileMenuService.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/Resource/Menu/MobileMenuService.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/Resource/Module/Dto/MobileModuleInput.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/Resource/Module/IMobileModuleService.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/Resource/Module/MobileModuleService.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/Resource/Resource/IMobileResourceService.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/Resource/Resource/MobileResourceService.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/UserCenter/Dto/MobileUserCenterInput.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/UserCenter/Dto/MobileUserCenterOutput.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/UserCenter/IMobileUserCenterService.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Services/UserCenter/MobileUserCenterService.cs
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/SimpleAdmin.Plugin.Mobile.csproj
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/SimpleAdmin.Plugin.Mobile.xml
create mode 100644 SimpleAdmin.Plugin/SimpleAdmin.Plugin.Mobile/Startup.cs
create mode 100644 SimpleAdmin.SqlSugar/Const/CommonStatusConst.cs
create mode 100644 SimpleAdmin.SqlSugar/Const/EffTypeConst.cs
create mode 100644 SimpleAdmin.SqlSugar/Const/SqlsugarConst.cs
create mode 100644 SimpleAdmin.SqlSugar/Db/DbContext.cs
create mode 100644 SimpleAdmin.SqlSugar/Db/DbRepository.cs
create mode 100644 SimpleAdmin.SqlSugar/Db/SqlsugarConfig.cs
create mode 100644 SimpleAdmin.SqlSugar/Dto/LinqPagedList.cs
create mode 100644 SimpleAdmin.SqlSugar/Entity/BaseEntity.cs
create mode 100644 SimpleAdmin.SqlSugar/Extension/ISqlSugarEntitySeedData.cs
create mode 100644 SimpleAdmin.SqlSugar/Extension/SqlSugarPageExtension.cs
create mode 100644 SimpleAdmin.SqlSugar/Extension/SqlSugarUnitOfWork.cs
create mode 100644 SimpleAdmin.SqlSugar/Filter/IEntityFilter.cs
create mode 100644 SimpleAdmin.SqlSugar/GlobalUsing.cs
create mode 100644 SimpleAdmin.SqlSugar/SimpleAdmin.SqlSugar.csproj
create mode 100644 SimpleAdmin.SqlSugar/SimpleAdmin.SqlSugar.xml
create mode 100644 SimpleAdmin.SqlSugar/SqlSugar.Development.json
create mode 100644 SimpleAdmin.SqlSugar/SqlSugar.Production.json
create mode 100644 SimpleAdmin.SqlSugar/Startup.cs
create mode 100644 SimpleAdmin.SqlSugar/Utils/CodeFirstUtils.cs
create mode 100644 SimpleAdmin.SqlSugar/Utils/Dto/SqlSugarTableInfo.cs
create mode 100644 SimpleAdmin.SqlSugar/Utils/Dto/SqlsugarColumnInfo.cs
create mode 100644 SimpleAdmin.SqlSugar/Utils/SeedDataUtil.cs
create mode 100644 SimpleAdmin.SqlSugar/Utils/SqlSugarUtils.cs
create mode 100644 SimpleAdmin.System/Attributes/AntTableAttribute.cs
create mode 100644 SimpleAdmin.System/Attributes/BatchEditAttribute.cs
create mode 100644 SimpleAdmin.System/Attributes/InDictAttribute.cs
create mode 100644 SimpleAdmin.System/Const/CateGoryConst.cs
create mode 100644 SimpleAdmin.System/Const/GenConst.cs
create mode 100644 SimpleAdmin.System/Const/SysConfigConst.cs
create mode 100644 SimpleAdmin.System/Const/SysDictConst.cs
create mode 100644 SimpleAdmin.System/Const/SysLogConst.cs
create mode 100644 SimpleAdmin.System/Const/SysResourceConst.cs
create mode 100644 SimpleAdmin.System/Const/SysRoleConst.cs
create mode 100644 SimpleAdmin.System/Const/SystemConst.cs
create mode 100644 SimpleAdmin.System/Entity/BatchEdit.cs
create mode 100644 SimpleAdmin.System/Entity/BatchEditConfig.cs
create mode 100644 SimpleAdmin.System/Entity/ClientRelation.cs
create mode 100644 SimpleAdmin.System/Entity/ClientUser.cs
create mode 100644 SimpleAdmin.System/Entity/GenBasic.cs
create mode 100644 SimpleAdmin.System/Entity/GenConfig.cs
create mode 100644 SimpleAdmin.System/Entity/SysConfig.cs
create mode 100644 SimpleAdmin.System/Entity/SysDict.cs
create mode 100644 SimpleAdmin.System/Entity/SysFile.cs
create mode 100644 SimpleAdmin.System/Entity/SysLogOperate.cs
create mode 100644 SimpleAdmin.System/Entity/SysLogVisit.cs
create mode 100644 SimpleAdmin.System/Entity/SysMessage.cs
create mode 100644 SimpleAdmin.System/Entity/SysMessageUser.cs
create mode 100644 SimpleAdmin.System/Entity/SysOrg.cs
create mode 100644 SimpleAdmin.System/Entity/SysPosition.cs
create mode 100644 SimpleAdmin.System/Entity/SysRelation.cs
create mode 100644 SimpleAdmin.System/Entity/SysResource.cs
create mode 100644 SimpleAdmin.System/Entity/SysRole.cs
create mode 100644 SimpleAdmin.System/Entity/SysUser.cs
create mode 100644 SimpleAdmin.System/EventSubscriber/AuthEventSubscriber.cs
create mode 100644 SimpleAdmin.System/EventSubscriber/Const/EventSubscriberConst.cs
create mode 100644 SimpleAdmin.System/EventSubscriber/Dto/LoginEvent.cs
create mode 100644 SimpleAdmin.System/EventSubscriber/Dto/NoticeEvent.cs
create mode 100644 SimpleAdmin.System/EventSubscriber/NoticeEventSubscriber.cs
create mode 100644 SimpleAdmin.System/EventSubscriber/UserEventSubscriber.cs
create mode 100644 SimpleAdmin.System/ExtJson/RelationMsgUser.cs
create mode 100644 SimpleAdmin.System/ExtJson/RelationRolePermission.cs
create mode 100644 SimpleAdmin.System/ExtJson/RelationRoleResource.cs
create mode 100644 SimpleAdmin.System/ExtJson/RelationUserSchedule.cs
create mode 100644 SimpleAdmin.System/ExtJson/RelationUserWorkBench.cs
create mode 100644 SimpleAdmin.System/GlobalUsings.cs
create mode 100644 SimpleAdmin.System/Mapper.cs
create mode 100644 SimpleAdmin.System/Options/SystemSettingsOptions.cs
create mode 100644 SimpleAdmin.System/Oss/MinioUtils.cs
create mode 100644 SimpleAdmin.System/SeedData/GenBaseSeedData.cs
create mode 100644 SimpleAdmin.System/SeedData/GenConfigSeedData.cs
create mode 100644 SimpleAdmin.System/SeedData/Json/seed_sys_config.json
create mode 100644 SimpleAdmin.System/SeedData/Json/seed_sys_dict.json
create mode 100644 SimpleAdmin.System/SeedData/Json/seed_sys_org.json
create mode 100644 SimpleAdmin.System/SeedData/Json/seed_sys_position.json
create mode 100644 SimpleAdmin.System/SeedData/Json/seed_sys_relation.json
create mode 100644 SimpleAdmin.System/SeedData/Json/seed_sys_resource.json
create mode 100644 SimpleAdmin.System/SeedData/Json/seed_sys_role.json
create mode 100644 SimpleAdmin.System/SeedData/Json/seed_sys_user.json
create mode 100644 SimpleAdmin.System/SeedData/SysConfigSeedData.cs
create mode 100644 SimpleAdmin.System/SeedData/SysDictSeedData.cs
create mode 100644 SimpleAdmin.System/SeedData/SysOrgSeedData.cs
create mode 100644 SimpleAdmin.System/SeedData/SysPositionSeedData.cs
create mode 100644 SimpleAdmin.System/SeedData/SysRelationSeedData.cs
create mode 100644 SimpleAdmin.System/SeedData/SysResourceSeedData.cs
create mode 100644 SimpleAdmin.System/SeedData/SysRoleSeedData.cs
create mode 100644 SimpleAdmin.System/SeedData/SysUserSeedData.cs
create mode 100644 SimpleAdmin.System/Services/Auth/Auth/AuthService.cs
create mode 100644 SimpleAdmin.System/Services/Auth/Auth/Dto/AuthInput.cs
create mode 100644 SimpleAdmin.System/Services/Auth/Auth/Dto/AuthOutPut.cs
create mode 100644 SimpleAdmin.System/Services/Auth/Auth/IAuthService.cs
create mode 100644 SimpleAdmin.System/Services/Auth/Session/Dto/SessionInput.cs
create mode 100644 SimpleAdmin.System/Services/Auth/Session/Dto/SessionOutput.cs
create mode 100644 SimpleAdmin.System/Services/Auth/Session/ISessionService.cs
create mode 100644 SimpleAdmin.System/Services/Auth/Session/SessionService.cs
create mode 100644 SimpleAdmin.System/Services/BatchEdit/BatchEditService.cs
create mode 100644 SimpleAdmin.System/Services/BatchEdit/Dto/BatchEditInput.cs
create mode 100644 SimpleAdmin.System/Services/BatchEdit/Dto/BatchEditOutput.cs
create mode 100644 SimpleAdmin.System/Services/BatchEdit/IBatchEditService.cs
create mode 100644 SimpleAdmin.System/Services/Dev/File/Dto/FileInput.cs
create mode 100644 SimpleAdmin.System/Services/Dev/File/FileService.cs
create mode 100644 SimpleAdmin.System/Services/Dev/File/IFileService.cs
create mode 100644 SimpleAdmin.System/Services/Dev/Message/Dto/MessageInput.cs
create mode 100644 SimpleAdmin.System/Services/Dev/Message/Dto/MessageOutPut.cs
create mode 100644 SimpleAdmin.System/Services/Dev/Message/IMessageService.cs
create mode 100644 SimpleAdmin.System/Services/Dev/Message/MessageService.cs
create mode 100644 SimpleAdmin.System/Services/Gen/Basic/Dto/GenBasicInput.cs
create mode 100644 SimpleAdmin.System/Services/Gen/Basic/Dto/GenBasicOutput.cs
create mode 100644 SimpleAdmin.System/Services/Gen/Basic/Dto/GenViewModel.cs
create mode 100644 SimpleAdmin.System/Services/Gen/Basic/GenBasicService.cs
create mode 100644 SimpleAdmin.System/Services/Gen/Basic/IGenbasicService.cs
create mode 100644 SimpleAdmin.System/Services/Gen/Config/Dto/GenConfigInput.cs
create mode 100644 SimpleAdmin.System/Services/Gen/Config/GenConfigService.cs
create mode 100644 SimpleAdmin.System/Services/Gen/Config/IGenConfigService.cs
create mode 100644 SimpleAdmin.System/Services/ImportExport/Dto/ImportPreviewInput.cs
create mode 100644 SimpleAdmin.System/Services/ImportExport/Dto/ImportPreviewOutput.cs
create mode 100644 SimpleAdmin.System/Services/ImportExport/Dto/ImportResultInput.cs
create mode 100644 SimpleAdmin.System/Services/ImportExport/Dto/ImportResultOutPut.cs
create mode 100644 SimpleAdmin.System/Services/ImportExport/Dto/ImportTemplateInput.cs
create mode 100644 SimpleAdmin.System/Services/ImportExport/IImportExportService.cs
create mode 100644 SimpleAdmin.System/Services/ImportExport/ImportExportService.cs
create mode 100644 SimpleAdmin.System/Services/Index/Dto/IndexInput.cs
create mode 100644 SimpleAdmin.System/Services/Index/Dto/IndexOutput.cs
create mode 100644 SimpleAdmin.System/Services/Index/IIndexService.cs
create mode 100644 SimpleAdmin.System/Services/Index/IndexService.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Button/ButtonService.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Button/Dto/ButtonInput.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Button/IButtonService.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Menu/Dto/MenuInput.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Menu/IMenuService.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Menu/MenuService.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Module/Dto/ModuleInput.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Module/IModuleService.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Module/ModuleService.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Role/Dto/RoleInput.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Role/Dto/RoleOutput.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Role/ISysRoleService.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Role/SysRoleService.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Spa/Dto/SpaInput.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Spa/ISpaService.cs
create mode 100644 SimpleAdmin.System/Services/Limit/Spa/SpaService.cs
create mode 100644 SimpleAdmin.System/Services/LogAudit/OperateLog/Dto/OperateLogInput.cs
create mode 100644 SimpleAdmin.System/Services/LogAudit/OperateLog/Dto/OperateLogOutput.cs
create mode 100644 SimpleAdmin.System/Services/LogAudit/OperateLog/IOperateLogService.cs
create mode 100644 SimpleAdmin.System/Services/LogAudit/OperateLog/OperateLogService.cs
create mode 100644 SimpleAdmin.System/Services/LogAudit/VisitLog/Dto/VisitLogInput.cs
create mode 100644 SimpleAdmin.System/Services/LogAudit/VisitLog/Dto/VisitLogOutput.cs
create mode 100644 SimpleAdmin.System/Services/LogAudit/VisitLog/IVisitLogService.cs
create mode 100644 SimpleAdmin.System/Services/LogAudit/VisitLog/VisitLogService.cs
create mode 100644 SimpleAdmin.System/Services/Mqtt/Dto/MqttInput.cs
create mode 100644 SimpleAdmin.System/Services/Mqtt/Dto/MqttOutput.cs
create mode 100644 SimpleAdmin.System/Services/Mqtt/IMqttService.cs
create mode 100644 SimpleAdmin.System/Services/Mqtt/MqttService.cs
create mode 100644 SimpleAdmin.System/Services/Ops/Config/ConfigService.cs
create mode 100644 SimpleAdmin.System/Services/Ops/Config/Dto/ConfigInput.cs
create mode 100644 SimpleAdmin.System/Services/Ops/Config/IConfigService.cs
create mode 100644 SimpleAdmin.System/Services/Ops/Dict/DictService.cs
create mode 100644 SimpleAdmin.System/Services/Ops/Dict/Dto/DictInput.cs
create mode 100644 SimpleAdmin.System/Services/Ops/Dict/IDictService.cs
create mode 100644 SimpleAdmin.System/Services/Organization/Org/Dto/SysOrgInput.cs
create mode 100644 SimpleAdmin.System/Services/Organization/Org/Dto/SysOrgOutput.cs
create mode 100644 SimpleAdmin.System/Services/Organization/Org/ISysOrgService.cs
create mode 100644 SimpleAdmin.System/Services/Organization/Org/SysOrgService.cs
create mode 100644 SimpleAdmin.System/Services/Organization/Position/Dto/PositionInput.cs
create mode 100644 SimpleAdmin.System/Services/Organization/Position/Dto/PositionOutput.cs
create mode 100644 SimpleAdmin.System/Services/Organization/Position/ISysPositionService.cs
create mode 100644 SimpleAdmin.System/Services/Organization/Position/SysPositionService.cs
create mode 100644 SimpleAdmin.System/Services/Organization/User/Dto/UserInput.cs
create mode 100644 SimpleAdmin.System/Services/Organization/User/Dto/UserOutPut.cs
create mode 100644 SimpleAdmin.System/Services/Organization/User/ISysUserService.cs
create mode 100644 SimpleAdmin.System/Services/Organization/User/SysUserService.cs
create mode 100644 SimpleAdmin.System/Services/System/Relation/Dto/RelationInput.cs
create mode 100644 SimpleAdmin.System/Services/System/Relation/Dto/RelationOutput.cs
create mode 100644 SimpleAdmin.System/Services/System/Relation/IRelationService.cs
create mode 100644 SimpleAdmin.System/Services/System/Relation/RelationService.cs
create mode 100644 SimpleAdmin.System/Services/System/Resource/Dto/ResourceInput.cs
create mode 100644 SimpleAdmin.System/Services/System/Resource/Dto/ResourceOutPut.cs
create mode 100644 SimpleAdmin.System/Services/System/Resource/IResourceService.cs
create mode 100644 SimpleAdmin.System/Services/System/Resource/ResourceService.cs
create mode 100644 SimpleAdmin.System/Services/System/UserCenter/Dto/UserCenterInput.cs
create mode 100644 SimpleAdmin.System/Services/System/UserCenter/Dto/UserCenterOutput.cs
create mode 100644 SimpleAdmin.System/Services/System/UserCenter/IUserCenterService.cs
create mode 100644 SimpleAdmin.System/Services/System/UserCenter/UserCenterService.cs
create mode 100644 SimpleAdmin.System/Services/Upload/IUploadService.cs
create mode 100644 SimpleAdmin.System/Services/Upload/UploadService.cs
create mode 100644 SimpleAdmin.System/SimpleAdmin.System.csproj
create mode 100644 SimpleAdmin.System/SimpleAdmin.System.xml
create mode 100644 SimpleAdmin.System/Startup.cs
create mode 100644 SimpleAdmin.System/System.Development.json
create mode 100644 SimpleAdmin.System/System.Production.json
create mode 100644 SimpleAdmin.System/UserManager/UserManager.cs
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Backend/Controllers/Controller.cs.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Backend/Services/Dto/Input.cs.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Backend/Services/Dto/Output.cs.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Backend/Services/IService.cs.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Backend/Services/Service.cs.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Frontend/api/interface/interface.ts.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Frontend/api/modules/modules.ts.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Frontend/template.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Frontend/views/components/form.vue.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Frontend/views/index.vue.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Sql/MySql.sql.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Sql/Oracle.sql.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Sql/SqlServer.sql.vm
create mode 100644 SimpleAdmin.System/ViewEngine/CodeGen/Sql/Sqlite.sql.vm
create mode 100644 SimpleAdmin.System/ip2region.xdb
create mode 100644 SimpleAdmin.Web.Core/Components/AuthComponent.cs
create mode 100644 SimpleAdmin.Web.Core/Components/LoggingMonitorComponent.cs
create mode 100644 SimpleAdmin.Web.Core/Components/WebSettingsComponent.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/Application/Organization/BizOrgController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/Application/Organization/BizPositionController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/Application/Organization/BizRoleController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/Application/Organization/BizUserController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/Application/WeiBingJu/MedicinalController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/Application/WeiBingJu/PrescriptionController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Auth/AuthBController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Auth/SessionController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/BaseController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/BatchEdit/BatchEditController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/CommonController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Dev/FileController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Dev/MessageController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Gen/GenBasicController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Gen/GenConfigController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Index/IndexController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Limit/ButtonController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Limit/MenuController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Limit/ModuleController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Limit/RoleController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Limit/SpaController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/LogAudit/LogOperateController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/LogAudit/LogVisitController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Mqtt/MqttController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Ops/ConfigController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Ops/DictController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Organization/OrgController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Organization/PositionController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Organization/UserController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/Upload/UploadController.cs
create mode 100644 SimpleAdmin.Web.Core/Controllers/System/UserCenter/UserCenterController.cs
create mode 100644 SimpleAdmin.Web.Core/Filter/MyActionFilter.cs
create mode 100644 SimpleAdmin.Web.Core/Filter/MyAuthorizationFilter.cs
create mode 100644 SimpleAdmin.Web.Core/GlobalUsing.cs
create mode 100644 SimpleAdmin.Web.Core/Handlers/JwtHandler.cs
create mode 100644 SimpleAdmin.Web.Core/Handlers/LogExceptionHandler.cs
create mode 100644 SimpleAdmin.Web.Core/Logging/DatabaseLoggingWriter.cs
create mode 100644 SimpleAdmin.Web.Core/Logging/LoggingConst.cs
create mode 100644 SimpleAdmin.Web.Core/Logging/LoggingMonitorJson.cs
create mode 100644 SimpleAdmin.Web.Core/Middleware/WebStatusMiddleware.cs
create mode 100644 SimpleAdmin.Web.Core/Options/WebSettingsOptions.cs
create mode 100644 SimpleAdmin.Web.Core/SimpleAdmin.Web.Core.csproj
create mode 100644 SimpleAdmin.Web.Core/SimpleAdmin.Web.Core.xml
create mode 100644 SimpleAdmin.Web.Core/Startup.cs
create mode 100644 SimpleAdmin.Web.Core/Web.Development.json
create mode 100644 SimpleAdmin.Web.Core/Web.Production.json
create mode 100644 SimpleAdmin.Web.Entry/.config/dotnet-tools.json
create mode 100644 SimpleAdmin.Web.Entry/AntDeploy.json
create mode 100644 SimpleAdmin.Web.Entry/Program.cs
create mode 100644 SimpleAdmin.Web.Entry/Properties/launchSettings.json
create mode 100644 SimpleAdmin.Web.Entry/SimpleAdmin.Web.Entry.csproj
create mode 100644 SimpleAdmin.Web.Entry/SimpleAdmin.Web.Entry.xml
create mode 100644 SimpleAdmin.Web.Entry/SimpleAdmin.db
create mode 100644 SimpleAdmin.Web.Entry/appsettings.json
create mode 100644 SimpleAdmin.sln
create mode 100644 global.json
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..07608a4
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,41 @@
+[*.cs]
+#### Naming styles ####
+# Naming rules
+dotnet_naming_rule.const_should_be_all_upper.severity = suggestion
+dotnet_naming_rule.const_should_be_all_upper.symbols = const
+dotnet_naming_rule.const_should_be_all_upper.style = all_upper
+
+dotnet_naming_rule.static_readonly_field_should_be_all_upper.severity = suggestion
+dotnet_naming_rule.static_readonly_field_should_be_all_upper.symbols = static_readonly_field
+dotnet_naming_rule.static_readonly_field_should_be_all_upper.style = all_upper
+
+dotnet_naming_rule.private_or_internal_field_should_be_private_field.severity = suggestion
+dotnet_naming_rule.private_or_internal_field_should_be_private_field.symbols = private_or_internal_field
+dotnet_naming_rule.private_or_internal_field_should_be_private_field.style = private_field
+
+# Symbol specifications
+dotnet_naming_symbols.const.applicable_kinds = field
+dotnet_naming_symbols.const.applicable_accessibilities = *
+dotnet_naming_symbols.const.required_modifiers = const
+
+dotnet_naming_symbols.static_readonly_field.applicable_kinds = field
+dotnet_naming_symbols.static_readonly_field.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.static_readonly_field.required_modifiers = readonly, static
+
+dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field
+dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected
+dotnet_naming_symbols.private_or_internal_field.required_modifiers =
+
+# Naming styles
+dotnet_naming_style.private_field.required_prefix = _
+dotnet_naming_style.private_field.required_suffix =
+dotnet_naming_style.private_field.word_separator =
+dotnet_naming_style.private_field.capitalization = camel_case
+
+dotnet_naming_style.all_upper.required_prefix =
+dotnet_naming_style.all_upper.required_suffix =
+dotnet_naming_style.all_upper.word_separator = _
+dotnet_naming_style.all_upper.capitalization = all_upper
+
+# Add copyright file header
+file_header_template = Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛\n\nSimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:\n1.请不要删除和修改根目录下的LICENSE文件。\n2.请不要删除和修改SimpleAdmin源码头部的版权声明。\n3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin\n4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。\n5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。\n6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
diff --git a/.template.config/template.json b/.template.config/template.json
new file mode 100644
index 0000000..09e1d1f
--- /dev/null
+++ b/.template.config/template.json
@@ -0,0 +1,13 @@
+{
+ "author": "huguodong", //必须
+ "classifications": [ "Web/ASP.NET" ], //必须,这个对应模板的Tags
+ "name": "SimpleAdmin", //必须,这个对应模板的Templates
+ "identity": "SimpleAdmin", //可选,模板的唯一名称
+ "shortName": "simpleadmin", //必须,这个对应模板的Short Name
+ "tags": {
+ "language": "C#" ,
+ "type":"project"
+ },
+ "sourceName": "SimpleAdmin", // 可选,要替换的名字
+ "preferNameDirectory": true // 可选,添加目录
+}
\ No newline at end of file
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..527e357
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,13 @@
+
+
+ net6.0;net7.0;net8.0;
+ 1701;1702;8616;1591;8618;8619;8629;8602;8603;8604;8625;8765
+ 3.0.0
+ enable
+ en-US
+
+
+
+ $(MSBuildProjectName).xml
+
+
\ No newline at end of file
diff --git a/SimpleAdmin.Application/Application.Development.json b/SimpleAdmin.Application/Application.Development.json
new file mode 100644
index 0000000..6affcb7
--- /dev/null
+++ b/SimpleAdmin.Application/Application.Development.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "https://gitee.com/dotnetmoyu/MoYu/raw/v4/schemas/v4/MoYu-schema.json",
+ //swagger分组设置
+ "[openapi:Application]": {
+ "Order": 90, //分组排序,int 类型,数字越大排前面,默认 0
+ "Title": "业务模块" //配置分组标题,string 类型
+ },
+ //系统层设置
+ "ApplicationSettings": {
+ "InitTable": false, //是否初始化表结构
+ "InitSeedData": false //是否初始化种子数据
+ }
+}
\ No newline at end of file
diff --git a/SimpleAdmin.Application/Application.Production.json b/SimpleAdmin.Application/Application.Production.json
new file mode 100644
index 0000000..3f68a37
--- /dev/null
+++ b/SimpleAdmin.Application/Application.Production.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "https://gitee.com/dotnetmoyu/MoYu/raw/v4/schemas/v4/MoYu-schema.json",
+ //swagger分组设置
+ "[openapi:Application]": {
+ "Order": 90, //分组排序,int 类型,数字越大排前面,默认 0
+ "Title": "业务模块" //配置分组标题,string 类型
+ },
+ //系统层设置
+ "ApplicationSettings": {
+ "InitTable": false, //是否初始化表结构
+ "InitSeedData": false, //是否初始化种子数据0
+ }
+}
\ No newline at end of file
diff --git a/SimpleAdmin.Application/Const/ApplicationConst.cs b/SimpleAdmin.Application/Const/ApplicationConst.cs
new file mode 100644
index 0000000..6e31e38
--- /dev/null
+++ b/SimpleAdmin.Application/Const/ApplicationConst.cs
@@ -0,0 +1,29 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Application;
+
+public class ApplicationConst
+{
+ #region 别称
+
+ ///
+ /// 机构
+ ///
+ public const string BIZ_ORG = "机构";
+
+
+ ///
+ /// 岗位
+ ///
+ public const string BIZ_POS = "岗位";
+
+ #endregion 别称
+}
diff --git a/SimpleAdmin.Application/Entity/GenTest.cs b/SimpleAdmin.Application/Entity/GenTest.cs
new file mode 100644
index 0000000..86efa85
--- /dev/null
+++ b/SimpleAdmin.Application/Entity/GenTest.cs
@@ -0,0 +1,56 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Application;
+
+///
+/// 代码生成基础
+///
+[SugarTable("gen_test", TableDescription = "代码生成测试")]
+[Tenant(SqlSugarConst.DB_DEFAULT)]
+[CodeGen]
+public class GenTest : DataEntityBase
+{
+ ///
+ /// 姓名
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// 性别
+ ///
+ public string Sex { get; set; }
+
+ ///
+ /// 民族
+ ///
+ public string Nation { get; set; }
+
+ ///
+ /// 年龄
+ ///
+
+ public int Age { get; set; }
+
+ ///
+ /// 生日
+ ///
+ public DateTime Bir { get; set; }
+
+ ///
+ /// 存款
+ ///
+ public decimal Money { get; set; }
+
+ ///
+ /// 排序码
+ ///
+ public int SortCode { get; set; }
+}
diff --git a/SimpleAdmin.Application/Entity/Medicinal.cs b/SimpleAdmin.Application/Entity/Medicinal.cs
new file mode 100644
index 0000000..c4512e2
--- /dev/null
+++ b/SimpleAdmin.Application/Entity/Medicinal.cs
@@ -0,0 +1,36 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SimpleAdmin.Application.Entity
+{
+ [SugarTable("WeiBingJu_Medicinal", TableDescription = "药材管理")]
+ [Tenant(SqlSugarConst.DB_DEFAULT)]
+ [CodeGen]
+ public class Medicinal : DataEntityBase
+ {
+ ///
+ /// 药材
+ ///
+ [SugarColumn(ColumnDescription = "药材")]
+ public string MedicinalName { get; set; }
+ ///
+ /// 数量(g)
+ ///
+ [SugarColumn(ColumnDescription = "数量(g)")]
+ public decimal Number { get; set; }
+
+ }
+}
diff --git a/SimpleAdmin.Application/Entity/MedicinalAddLog.cs b/SimpleAdmin.Application/Entity/MedicinalAddLog.cs
new file mode 100644
index 0000000..b7d979a
--- /dev/null
+++ b/SimpleAdmin.Application/Entity/MedicinalAddLog.cs
@@ -0,0 +1,48 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SimpleAdmin.Application.Entity
+{
+ [SugarTable("WeiBingJu_MedicinalAddLog", TableDescription = "药材添加记录")]
+ [Tenant(SqlSugarConst.DB_DEFAULT)]
+ [CodeGen]
+ public class MedicinalAddLog : DataEntityBase
+ {
+ ///
+ /// 药材关联id
+ ///
+ [SugarColumn(ColumnDescription = "药材关联id")]
+ public long MedicinalId { get; set; }
+ ///
+ /// 添加重量(g)
+ ///
+ [SugarColumn(ColumnDescription = "添加重量(g)")]
+ public decimal AddWeight { get; set; }
+
+ ///
+ /// 药材单价
+ ///
+ [SugarColumn(ColumnDescription = "药材单价")]
+ public decimal UnitPrice { get; set; }
+
+ ///
+ /// 总价
+ ///
+ [SugarColumn(ColumnDescription = "总价")]
+ public decimal TotalPrice { get; set; }
+
+ }
+}
diff --git a/SimpleAdmin.Application/Entity/Person.cs b/SimpleAdmin.Application/Entity/Person.cs
new file mode 100644
index 0000000..a98c0e0
--- /dev/null
+++ b/SimpleAdmin.Application/Entity/Person.cs
@@ -0,0 +1,43 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SimpleAdmin.Application.Entity
+{
+ [SugarTable("WeiBingJu_Person", TableDescription = "人员表(员工和员工亲戚)")]
+ [Tenant(SqlSugarConst.DB_DEFAULT)]
+ [CodeGen]
+ public class Person : DataEntityBase
+ {
+ [SugarColumn(Length = 128, ColumnDescription = "姓名")]
+ public string Name { get; set; }
+
+ ///
+ /// 若非空,表示此 person 是某员工的家属
+ ///
+ [SugarColumn(ColumnDescription = "关联员工Id", IsNullable = true)]
+ public long? EmployeeId { get; set; }
+
+ [SugarColumn(ColumnDescription = "关系配置id", IsNullable = true)]
+ public long? RelationShip { get; set; }
+
+ [SugarColumn(ColumnDescription = "出生日期", IsNullable = true)]
+ public string Birthday { get; set; }
+
+ /// 单位 cm,保留两位小数
+ [SugarColumn(ColumnDescription = "身高(cm)", IsNullable = true)]
+ public decimal? Height { get; set; }
+ }
+}
diff --git a/SimpleAdmin.Application/Entity/Prescription.cs b/SimpleAdmin.Application/Entity/Prescription.cs
new file mode 100644
index 0000000..6e337a7
--- /dev/null
+++ b/SimpleAdmin.Application/Entity/Prescription.cs
@@ -0,0 +1,43 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SimpleAdmin.Application.Entity
+{
+ [SugarTable("WeiBingJu_Prescription", TableDescription = "处方管理")]
+ [Tenant(SqlSugarConst.DB_DEFAULT)]
+ [CodeGen]
+ public class Prescription : DataEntityBase
+ {
+ [SugarColumn(ColumnDescription = "处方对象 PersonId")]
+ public long PersonId { get; set; }
+
+ [SugarColumn(ColumnDescription = "诊断结果", ColumnDataType = StaticConfig.CodeFirst_BigString)]
+ public string DiagnosisResult { get; set; }
+
+ [SugarColumn(ColumnDescription = "用药建议", ColumnDataType = StaticConfig.CodeFirst_BigString)]
+ public string UserMedicinaAdvice { get; set; }
+
+ [SugarColumn(ColumnDescription = "就诊时间")]
+ public DateTime? VisitDate { get; set; }
+
+
+ /// 单位 kg,保留两位小数
+ [SugarColumn(ColumnDescription = "体重(kg)", IsNullable = true)]
+ public decimal? Weight { get; set; }
+ }
+
+}
+
diff --git a/SimpleAdmin.Application/Entity/PrescriptionHerb.cs b/SimpleAdmin.Application/Entity/PrescriptionHerb.cs
new file mode 100644
index 0000000..24ca4b7
--- /dev/null
+++ b/SimpleAdmin.Application/Entity/PrescriptionHerb.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SimpleAdmin.Application.Entity
+{
+ [SugarTable("WeiBingJu_PrescriptionHerb", TableDescription = "处方消耗药材表")]
+ [Tenant(SqlSugarConst.DB_DEFAULT)]
+ [CodeGen]
+ public class PrescriptionHerb : DataEntityBase
+ {
+ [SugarColumn(ColumnDescription = "处方Id")]
+ public long PrescriptionId { get; set; }
+
+ [SugarColumn(ColumnDescription = "药材Id")]
+ public long MedicinalId { get; set; }
+
+ /// 消耗克数,单位 g
+ [SugarColumn(ColumnDescription = "消耗(g)")]
+ public decimal AmountG { get; set; }
+
+ [SugarColumn(Length = 500, IsNullable = true, ColumnDescription = "用量说明/备注")]
+ public string Note { get; set; }
+ }
+}
diff --git a/SimpleAdmin.Application/GlobalUsings.cs b/SimpleAdmin.Application/GlobalUsings.cs
new file mode 100644
index 0000000..5f1ff20
--- /dev/null
+++ b/SimpleAdmin.Application/GlobalUsings.cs
@@ -0,0 +1,29 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+global using MoYu;
+global using MoYu.DependencyInjection;
+global using MoYu.FriendlyException;
+global using Mapster;
+global using Microsoft.AspNetCore.Builder;
+global using Microsoft.AspNetCore.Hosting;
+global using Microsoft.AspNetCore.Mvc;
+global using Microsoft.Extensions.DependencyInjection;
+global using SimpleAdmin.Cache;
+global using SimpleAdmin.Core;
+global using SimpleAdmin.Core.Extension;
+global using SimpleAdmin.SqlSugar;
+global using SimpleAdmin.System;
+global using SqlSugar;
+global using System.Reflection;
+global using SimpleAdmin.Application.Services.Medicinal;
+global using SimpleAdmin.Application.Services.Medicinal.Dto;
+global using SimpleAdmin.Application.Services.Prescription;
+global using SimpleAdmin.Application.Services.Prescription.Dto;
diff --git a/SimpleAdmin.Application/Options/ApplicationSettingsOptions.cs b/SimpleAdmin.Application/Options/ApplicationSettingsOptions.cs
new file mode 100644
index 0000000..2b64f6b
--- /dev/null
+++ b/SimpleAdmin.Application/Options/ApplicationSettingsOptions.cs
@@ -0,0 +1,20 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using MoYu.ConfigurableOptions;
+
+namespace SimpleAdmin.Application;
+
+///
+/// 系统配置
+///
+public class ApplicationSettingsOptions : BaseOptions, IConfigurableOptions
+{
+}
diff --git a/SimpleAdmin.Application/Services/Medicinal/Dto/MedicinalDto.cs b/SimpleAdmin.Application/Services/Medicinal/Dto/MedicinalDto.cs
new file mode 100644
index 0000000..b11e594
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Medicinal/Dto/MedicinalDto.cs
@@ -0,0 +1,93 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SimpleAdmin.Application.Services.Medicinal.Dto
+{
+ // 药材列表DTO
+ public class MedicinalDto
+ {
+ public long Id { get; set; }
+ public string MedicinalName { get; set; }
+ public decimal Stock { get; set; }
+ public decimal UsedCost { get; set; }
+ public decimal RemainingValue { get; set; }
+ public decimal TotalUsedWeight { get; set; }
+ }
+
+ // 药材消耗记录DTO
+ public class MedicinalConsumptionRecordDto
+ {
+ public decimal AmountG { get; set; }
+ public string PersonName { get; set; }
+ public bool IsRelative { get; set; }
+ public string EmployeeName { get; set; }
+ public DateTime? UseTime { get; set; }
+ }
+
+ // 药材添加记录DTO
+ public class MedicinalAddLogDto
+ {
+ public long Id { get; set; }
+ public decimal AddWeight { get; set; }
+ public decimal UnitPrice { get; set; }
+ public DateTime AddTime { get; set; }
+ public string AddUserName { get; set; }
+ public decimal TotalPrice { get; set; }
+
+ public bool CanEdit { get; set; }
+ }
+
+ // 添加药材输入DTO
+ public class AddMedicinalInput
+ {
+ public long? Id { get; set; }
+ public decimal AddWeight { get; set; }
+ public decimal TotalPrice { get; set; }
+ ///
+ /// 未找到下拉框的时候传这个值代表添加新的药材
+ ///
+ public string MedicinalName { get; set; }
+ }
+
+ // 修改药材添加记录输入DTO
+ public class UpdateMedicinalAddLogInput
+ {
+ public long Id { get; set; }
+ public decimal AddWeight { get; set; }
+ public decimal TotalPrice { get; set; }
+ }
+
+ // 药材类型DTO
+ public class MedicinalTypeDto
+ {
+ public long Id { get; set; }
+ public string Name { get; set; }
+ }
+
+ // 添加药材类型输入DTO
+ public class AddMedicinalTypeInput
+ {
+ [Required(ErrorMessage = "药材名称不能为空")]
+ public string Name { get; set; }
+ }
+
+ public class DeleteMedicinalLog
+ {
+ public long Id { get; set; }
+ }
+
+}
diff --git a/SimpleAdmin.Application/Services/Medicinal/IMedicinalService.cs b/SimpleAdmin.Application/Services/Medicinal/IMedicinalService.cs
new file mode 100644
index 0000000..44325fb
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Medicinal/IMedicinalService.cs
@@ -0,0 +1,72 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Dynamic.Core;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SimpleAdmin.Application.Services.Medicinal
+{
+ public interface IMedicinalService : ITransient
+ {
+ ///
+ /// 获取药材列表,带筛选
+ ///
+ /// 药材名称筛选
+ /// 页码
+ /// 页大小
+ ///
+ Task> GetMedicinalList(string medicinalName, int page, int size);
+
+ ///
+ /// 获取药材消耗记录
+ ///
+ /// 药材ID
+ ///
+ Task> GetConsumptionRecords(long medicinalId, int page, int size);
+ ///
+ /// 获取药材下拉
+ ///
+ ///
+ Task> GetMedicinalDictList();
+
+ ///
+ /// 获取药材添加记录
+ ///
+ /// 药材ID
+ ///
+ Task> GetAdditionRecords(long medicinalId, int page, int size);
+
+ ///
+ /// 添加药材
+ ///
+ /// 添加信息
+ ///
+ Task AddMedicinal(AddMedicinalInput input);
+
+ ///
+ /// 修改药材添加记录(仅当天可修改)
+ ///
+ /// 记录ID
+ /// 修改信息
+ ///
+ Task UpdateAdditionRecord(UpdateMedicinalAddLogInput input);
+
+ ///
+ /// 删除药材添加记录(仅当天可删除)
+ ///
+ /// 记录ID
+ ///
+ Task DeleteAdditionRecord(long id);
+ }
+}
diff --git a/SimpleAdmin.Application/Services/Medicinal/MedicinalService.cs b/SimpleAdmin.Application/Services/Medicinal/MedicinalService.cs
new file mode 100644
index 0000000..acfd831
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Medicinal/MedicinalService.cs
@@ -0,0 +1,412 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using System.Linq.Dynamic.Core;
+using SimpleAdmin.Application.Entity;
+using Yitter.IdGenerator;
+
+public class MedicinalService : DbRepository, IMedicinalService
+{
+ private readonly ISysUserService _sysUserService;
+ private readonly IDictService _dictService;
+ public MedicinalService(ISysUserService sysUserService, IDictService dictService)
+ {
+ _sysUserService = sysUserService;
+ _dictService = dictService;
+ }
+ public async Task> GetMedicinalList(string medicinalName, int page, int size)
+ {
+ // 1. 获取数据范围(原有逻辑不变)
+ //var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ //dataScope?.Remove(UserManager.OrgId);
+
+ // 2. 分页查询药材基本信息(1次查询,原有逻辑不变)
+ var query = this.AsQueryable()
+ //.WhereIF(dataScope.Any(), m => dataScope.Contains(m.Id))
+ .WhereIF(!string.IsNullOrEmpty(medicinalName), m => m.MedicinalName.Contains(medicinalName))
+ .OrderBy(p => p.Number)
+ .Select(m => new MedicinalDto
+ {
+ Id = m.Id,
+ MedicinalName = m.MedicinalName,
+ Stock = m.Number, // 当前库存
+ });
+
+ var pageInfo = await query.ToPagedListAsync(page, size);
+ if (!pageInfo.List.Any()) return pageInfo;
+
+ // 3. 批量计算:成本、剩余价值、总使用量(仅2次查询,无循环查询)
+ var medicinalIds = pageInfo.List.Select(dto => dto.Id).ToList();
+ var costAndUsageDict = await BatchCalculateCostAndValue(medicinalIds);
+
+ // 4. 内存中赋值所有指标(无数据库查询)
+ foreach (var item in pageInfo.List)
+ {
+ if (costAndUsageDict.TryGetValue(item.Id, out var metrics))
+ {
+ item.UsedCost = metrics.usedCost; // 使用成本
+ item.RemainingValue = metrics.remainingValue; // 剩余价值
+ item.TotalUsedWeight = metrics.totalUsedWeight; // 新增:总使用量
+ }
+ else
+ {
+ // 无数据时默认值
+ item.UsedCost = 0;
+ item.RemainingValue = 0;
+ item.TotalUsedWeight = 0;
+ }
+ }
+
+ return pageInfo;
+ }
+
+ ///
+ /// 获取药材下拉
+ ///
+ ///
+ public async Task> GetMedicinalDictList()
+ {
+ ////获取数据范围
+ //var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ //dataScope?.Remove(UserManager.OrgId);
+ //药材查询
+ return await this.AsQueryable()
+ //.WhereIF(dataScope.Any(), m => dataScope.Contains(m.Id)) //机构ID查询
+ .OrderBy(p => p.Number)
+ .Select(m => new MedicinalDto
+ {
+ Id = m.Id,
+ MedicinalName = m.MedicinalName,
+ Stock = m.Number,
+ }).ToListAsync();
+ }
+ ///
+ /// 获取药材消耗记录
+ ///
+ ///
+ ///
+ ///
+ public async Task> GetConsumptionRecords(long medicinalId, int page, int size)
+ {
+ return await Context.Queryable()
+ // 先关联处方
+ .LeftJoin((ph, p) => ph.PrescriptionId == p.Id)
+ // 再关联就诊人
+ .LeftJoin((ph, p, pe) => p.PersonId == pe.Id)
+ // 再关联员工
+ .LeftJoin((ph, p, pe, emp) => pe.EmployeeId != null && pe.EmployeeId == emp.Id)
+ // 条件也使用多参数
+ .Where((ph, p, pe, emp) => ph.MedicinalId == medicinalId)
+ .OrderByDescending((ph, p, pe, emp) => p.VisitDate)
+ // 投影使用所有表别名
+ .Select((ph, p, pe, emp) => new MedicinalConsumptionRecordDto
+ {
+ AmountG = ph.AmountG,
+ PersonName = pe.Name,
+ IsRelative = pe.EmployeeId != null,
+ EmployeeName = emp == null ? null : emp.Name,
+ UseTime = p.VisitDate
+ })
+ // 分页
+ .ToPagedListAsync(page, size);
+ }
+
+ ///
+ /// 获取药材添加记录
+ ///
+ ///
+ ///
+ public async Task> GetAdditionRecords(long medicinalId, int page, int size)
+ {
+ var returnList = await Context.Queryable()
+ .Where(log => log.MedicinalId == medicinalId)
+ .OrderByDescending(dto => dto.CreateTime)
+ .Select(log => new MedicinalAddLogDto
+ {
+ Id = log.Id,
+ AddWeight = log.AddWeight,
+ UnitPrice = log.UnitPrice,
+ AddTime = log.CreateTime.Value,
+ AddUserName = log.CreateUser,
+ TotalPrice = log.TotalPrice,
+ CanEdit = false
+ })
+ .ToPagedListAsync(page, size);
+
+ foreach (var item in returnList.List)
+ {
+ if (item.AddTime.Date == DateTime.Now.Date)
+ {
+ item.CanEdit = true;
+ }
+ }
+ return returnList;
+ }
+ ///
+ /// 添加药材
+ ///
+ ///
+ ///
+ public async Task AddMedicinal(AddMedicinalInput input)
+ {
+ if (input.TotalPrice <= 0 || input.AddWeight <= 0) throw Oops.Bah("请填写正确的金额或者重量!");
+ // 开启事务
+ await Context.Ado.BeginTranAsync();
+ try
+ {
+ // 检查药材是否已存在
+ var existing = await Context.Queryable()
+ .Where(m => m.Id == input.Id)
+ .FirstAsync();
+
+ if (existing != null)
+ {
+ // 更新库存
+ existing.Number += input.AddWeight;
+ await Context.Updateable(existing).ExecuteCommandAsync();
+ }
+ else
+ {
+ var medicinalModel = await Context.Queryable()
+ .Where(m => m.MedicinalName == input.MedicinalName)
+ .FirstAsync();
+ if (medicinalModel != null) throw Oops.Bah("已存在该药材,请在下拉框选择!");
+ input.Id = YitIdHelper.NextId();
+ // 新增药材记录
+ await Context.Insertable(new Medicinal
+ {
+ Id = input.Id.Value,
+ Number = input.AddWeight,
+ MedicinalName = input.MedicinalName,
+ }).ExecuteCommandAsync();
+ }
+ decimal unitPrice = 0m;
+ if (input.AddWeight > 0)
+ {
+ unitPrice = Decimal.Round(input.TotalPrice / input.AddWeight, 2, MidpointRounding.AwayFromZero);
+ }
+ // 添加记录
+ await Context.Insertable(new MedicinalAddLog
+ {
+ MedicinalId = input.Id.Value,
+ AddWeight = input.AddWeight,
+ UnitPrice = unitPrice,
+ TotalPrice = input.TotalPrice
+ }).ExecuteCommandAsync();
+
+ await Context.Ado.CommitTranAsync();
+ }
+ catch
+ {
+ await Context.Ado.RollbackTranAsync();
+ throw;
+ }
+ return true;
+ }
+ ///
+ /// 修改药材添加记录
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task UpdateAdditionRecord(UpdateMedicinalAddLogInput input)
+ {
+ if(input.TotalPrice<=0 || input.AddWeight<=0) throw Oops.Bah("请填写正确的金额或者重量!");
+ var log = await Context.Queryable().Where(l => l.Id == input.Id).FirstAsync();
+ if (log == null)
+ {
+ throw Oops.Bah("记录不存在!");
+ }
+
+ // 检查是否是当天记录
+ if (log.CreateTime.Value.Date != DateTime.Now.Date)
+ {
+ throw Oops.Bah("只能修改当天的记录!");
+ }
+
+ // 计算重量变化
+ var weightDiff = input.AddWeight - log.AddWeight;
+
+ // 开启事务
+ await Context.Ado.BeginTranAsync();
+
+ try
+ {
+ // 更新记录
+ log.AddWeight = input.AddWeight;
+ log.TotalPrice = input.TotalPrice;
+ log.UnitPrice = Decimal.Round(input.TotalPrice / input.AddWeight, 2, MidpointRounding.AwayFromZero);
+ await Context.Updateable(log).ExecuteCommandAsync();
+
+ // 更新药材库存
+ var medicinal = await Context.Queryable()
+ .Where(m => m.Id == log.MedicinalId)
+ .FirstAsync();
+
+ if (medicinal != null)
+ {
+ medicinal.Number += weightDiff;
+ if(medicinal.Number<0) throw Oops.Bah("无法修改,库存不足!");
+ await Context.Updateable(medicinal).ExecuteCommandAsync();
+ }
+
+ await Context.Ado.CommitTranAsync();
+ }
+ catch
+ {
+ await Context.Ado.RollbackTranAsync();
+ throw;
+ }
+
+ return true;
+ }
+ ///
+ /// 删除药材添加记录
+ ///
+ ///
+ ///
+ ///
+ public async Task DeleteAdditionRecord(long id)
+ {
+ var log = await Context.Queryable().Where(l => l.Id == id).FirstAsync();
+ if (log == null)
+ {
+ throw Oops.Bah("记录不存在!");
+ }
+
+ // 检查是否是当天记录
+ if (log.CreateTime.Value.Date != DateTime.Now.Date)
+ {
+ throw Oops.Bah("只能删除当天的记录!");
+ }
+
+ // 开启事务
+ await Context.Ado.BeginTranAsync();
+
+ try
+ {
+ // 删除记录
+ log.IsDelete = true;
+ await Context.Updateable(log).ExecuteCommandAsync();
+
+
+ // 更新药材库存
+ var medicinal = await Context.Queryable()
+ .Where(m => m.Id == log.MedicinalId)
+ .FirstAsync();
+
+ if (medicinal != null)
+ {
+ medicinal.Number -= log.AddWeight;
+ if(medicinal.Number<0) throw Oops.Bah("无法删除,库存不足!");
+ await Context.Updateable(medicinal).ExecuteCommandAsync();
+ }
+
+ await Context.Ado.CommitTranAsync();
+ }
+ catch
+ {
+ await Context.Ado.RollbackTranAsync();
+ throw;
+ }
+
+ return true;
+ }
+
+ ///
+ /// 批量计算:使用成本、剩余价值、总使用量(先进先出法)
+ ///
+ /// 需要计算的药材ID列表
+ private async Task> BatchCalculateCostAndValue(List medicinalIds)
+ {
+ var result = new Dictionary();
+ if (!medicinalIds.Any()) return result;
+
+ // 1. 批量查询所有药材的【当前库存】(1次查询)
+ var medicinals = await Context.Queryable()
+ .Where(m => medicinalIds.Contains(m.Id))
+ .Select(m => new { m.Id, m.Number }) // Number = 当前库存
+ .ToListAsync();
+
+ // 2. 批量查询所有药材的【入库记录】(1次查询,仅查需要的字段)
+ var allAddLogs = await Context.Queryable()
+ .Where(l => medicinalIds.Contains(l.MedicinalId))
+ .OrderBy(l => l.CreateTime) // 先进先出:按入库时间排序
+ .Select(l => new {
+ l.MedicinalId,
+ l.AddWeight, // 入库量
+ l.UnitPrice, // 单价(用于计算成本)
+ l.TotalPrice // 总成本(用于计算成本)
+ })
+ .ToListAsync();
+
+ // 3. 按【药材ID】分组入库记录(内存处理,无数据库查询)
+ var groupedLogs = allAddLogs
+ .GroupBy(l => l.MedicinalId)
+ .ToDictionary(g => g.Key, g => g.ToList());
+
+ // 4. 遍历每个药材,内存中计算所有指标
+ foreach (var med in medicinals)
+ {
+ // 初始化默认值(无入库记录时)
+ decimal totalIn = 0; // 总入库量(AddWeight 总和)
+ decimal totalCost = 0; // 总入库成本
+ decimal totalUsedWeight = 0; // 总使用量
+ decimal usedCost = 0; // 使用成本
+ decimal remainingValue = 0;// 剩余价值
+
+ // 若有入库记录,计算总入库量、总成本
+ if (groupedLogs.TryGetValue(med.Id, out var addLogs) && addLogs.Any())
+ {
+ totalIn = addLogs.Sum(l => l.AddWeight); // 总入库量 = 所有 AddWeight 求和
+ totalCost = addLogs.Sum(l => l.TotalPrice); // 总入库成本
+ }
+
+ // 计算总使用量:总入库量 - 当前库存(若结果为负,说明数据异常,按0处理)
+ totalUsedWeight = Math.Max(0, totalIn - med.Number);
+
+ // 若有使用量,继续用先进先出法计算使用成本
+ if (totalUsedWeight > 0 && groupedLogs.TryGetValue(med.Id, out var validLogs))
+ {
+ decimal remainingToCalculate = totalUsedWeight;
+ foreach (var log in validLogs)
+ {
+ if (remainingToCalculate <= 0) break;
+
+ // 当前入库记录的量 <= 剩余未计算的使用量:全部计入成本
+ if (log.AddWeight <= remainingToCalculate)
+ {
+ usedCost += log.AddWeight * log.UnitPrice;
+ remainingToCalculate -= log.AddWeight;
+ }
+ // 当前入库记录的量 > 剩余未计算的使用量:仅计算剩余部分
+ else
+ {
+ usedCost += remainingToCalculate * log.UnitPrice;
+ remainingToCalculate = 0;
+ }
+ }
+ }
+
+ // 剩余价值 = 总入库成本 - 使用成本(若为负,按0处理)
+ remainingValue = Math.Max(0, totalCost - usedCost);
+
+ // 存入结果字典
+ result[med.Id] = (usedCost, remainingValue, totalUsedWeight);
+ }
+
+ return result;
+ }
+}
diff --git a/SimpleAdmin.Application/Services/Organization/Org/IOrgService.cs b/SimpleAdmin.Application/Services/Organization/Org/IOrgService.cs
new file mode 100644
index 0000000..0415f9a
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Organization/Org/IOrgService.cs
@@ -0,0 +1,66 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Application;
+
+///
+/// 机构服务
+///
+public interface IOrgService : ITransient
+{
+ ///
+ /// 添加机构
+ ///
+ /// 添加参数
+ ///
+ Task Add(SysOrgAddInput input);
+
+ ///
+ /// 复制机构
+ ///
+ /// 机构复制参数
+ ///
+ Task Copy(SysOrgCopyInput input);
+
+ ///
+ /// 删除机构
+ ///
+ /// 删除参数
+ ///
+ Task Delete(BaseIdListInput input);
+
+ ///
+ /// 编辑机构
+ ///
+ /// 编辑参数
+ ///
+ Task Edit(SysOrgEditInput input);
+
+ ///
+ /// 机构分页查询
+ ///
+ /// 查询参数
+ /// 分页信息
+ Task> Page(SysOrgPageInput input);
+
+ ///
+ /// 机构树结构
+ ///
+ /// 机构选择器
+ ///
+ Task> Tree(SysOrgTreeInput input = null);
+
+ ///
+ /// 机构详情
+ ///
+ ///
+ ///
+ Task Detail(BaseIdInput input);
+}
diff --git a/SimpleAdmin.Application/Services/Organization/Org/OrgService.cs b/SimpleAdmin.Application/Services/Organization/Org/OrgService.cs
new file mode 100644
index 0000000..3425542
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Organization/Org/OrgService.cs
@@ -0,0 +1,149 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Application;
+
+///
+public class OrgService : DbRepository, IOrgService
+{
+ private readonly ISysOrgService _sysOrgService;
+ private readonly ISysUserService _sysUserService;
+
+ public OrgService(ISysOrgService sysOrgService, ISysUserService sysUserService)
+ {
+ _sysOrgService = sysOrgService;
+ _sysUserService = sysUserService;
+ }
+
+ ///
+ public async Task> Page(SysOrgPageInput input)
+ {
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ dataScope?.Remove(UserManager.OrgId);
+ //构建查询
+ var query = Context.Queryable()
+ .WhereIF(dataScope != null, it => dataScope.Contains(it.Id))//机构ID查询
+ .WhereIF(input.ParentId > 0,
+ it => it.ParentId == input.ParentId || SqlFunc.JsonLike(it.ParentIdList, input.ParentId.ToString()))//父级
+ .WhereIF(!string.IsNullOrEmpty(input.Name), it => it.Name.Contains(input.Name))//根据名称查询
+ .WhereIF(!string.IsNullOrEmpty(input.Code), it => it.Code.Contains(input.Code))//根据编码查询
+ .WhereIF(!string.IsNullOrEmpty(input.Status), it => it.Status == input.Status)//根据状态查询
+ .OrderByIF(!string.IsNullOrEmpty(input.SortField), $"{input.SortField} {input.SortOrder}").OrderBy(it => it.SortCode)
+ .OrderBy(it => it.CreateTime);//排序
+ var pageInfo = await query.ToPagedListAsync(input.PageNum, input.PageSize);//分页
+ return pageInfo;
+ }
+
+ ///
+ public async Task> Tree(SysOrgTreeInput input = null)
+ {
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ //构建机构树
+ var result = await _sysOrgService.Tree(dataScope, input);
+ return result;
+ }
+
+ ///
+ public async Task Add(SysOrgAddInput input)
+ {
+ await CheckInput(input, SystemConst.ADD);//检查参数
+ await _sysOrgService.Add(input, ApplicationConst.BIZ_ORG);
+ }
+
+ ///
+ public async Task Edit(SysOrgEditInput input)
+ {
+ await CheckInput(input, SystemConst.EDIT);//检查参数
+ await _sysOrgService.Edit(input, ApplicationConst.BIZ_ORG);
+ }
+
+ ///
+ public async Task Copy(SysOrgCopyInput input)
+ {
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ if (dataScope == null || dataScope.Count > 0)//如果有机构
+ {
+ if (dataScope is { Count: > 0 } && (!dataScope.ContainsAll(input.Ids) || !dataScope.Contains(input.TargetId)))//判断目标机构和需要复制的机构是否都在数据范围里面
+ throw Oops.Bah("您没有权限复制这些机构");
+ await _sysOrgService.Copy(input);//复制操作
+ }
+ }
+
+ ///
+ public async Task Delete(BaseIdListInput input)
+ {
+ //获取所有ID
+ var ids = input.Ids;
+ //获取要删除的机构列表
+ var orgList = (await _sysOrgService.GetListAsync()).Where(it => ids.Contains(it.Id)).ToList();
+ if (orgList.Any(it => it.Category == CateGoryConst.ORG_COMPANY))//如果有公司{
+ throw Oops.Bah("不能删除根机构");
+ //检查数据范围
+ var orgIds = orgList.Select(it => it.Id).ToList();
+ var createUserIds = orgList.Select(it => it.CreateUserId.GetValueOrDefault()).ToList();
+ await _sysUserService.CheckApiDataScope(orgIds, createUserIds, "您没有权限删除这些机构");
+ await _sysOrgService.Delete(input, ApplicationConst.BIZ_ORG);//删除操作
+ }
+
+ ///
+ public async Task Detail(BaseIdInput input)
+ {
+ var org = await _sysOrgService.GetSysOrgById(input.Id);//获取机构
+ var errorMessage = "您没有权限查看该机构";
+ //判断数据范围
+ await _sysUserService.CheckApiDataScope(org.Id, org.CreateUserId.GetValueOrDefault(), errorMessage);
+ return org;
+ }
+
+ #region 方法
+
+ ///
+ /// 检查输入参数
+ ///
+ /// 参数
+ /// 操作名称
+ private async Task CheckInput(SysOrg sysOrg, string operate)
+ {
+ sysOrg.Category = CateGoryConst.ORG_DEPT;//设置分类为部门,业务只能操作部门
+ if (sysOrg.ParentId == SimpleAdminConst.ZERO)
+ {
+ throw Oops.Bah($"不能{operate}根机构");
+ }
+ var errorMessage = $"您没有权限{operate}该机构";
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ if (dataScope is { Count: > 0 })//如果有机构
+ {
+ if (sysOrg.Id > 0 && !dataScope.Contains(sysOrg.Id))//如果id不为0判断是否在数据范围
+ throw Oops.Bah(errorMessage);
+ if (!dataScope.Contains(sysOrg.ParentId))//判断父ID是否在数据范围
+ throw Oops.Bah($"{errorMessage}下的机构");
+ }
+ else if (dataScope is { Count: 0 })
+ {
+ //如果id大于0表示编辑
+ if (sysOrg.Id > 0)
+ {
+ var org = await _sysOrgService.GetSysOrgById(sysOrg.Id);//获取机构
+ if (org.CreateUserId != UserManager.UserId)
+ throw Oops.Bah(errorMessage);//机构的创建人不是自己则报错
+ }
+ else
+ {
+ throw Oops.Bah(errorMessage);
+ }
+ }
+ }
+
+ #endregion 方法
+}
diff --git a/SimpleAdmin.Application/Services/Organization/Position/IPositionService.cs b/SimpleAdmin.Application/Services/Organization/Position/IPositionService.cs
new file mode 100644
index 0000000..4ffa68d
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Organization/Position/IPositionService.cs
@@ -0,0 +1,66 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Application;
+
+///
+/// 岗位管理
+///
+public interface IPositionService : ITransient
+{
+ ///
+ /// 添加岗位
+ ///
+ /// 添加参数
+ ///
+ Task Add(PositionAddInput input);
+
+ ///
+ /// 删除岗位
+ ///
+ /// id列表
+ ///
+ Task Delete(BaseIdListInput input);
+
+ ///
+ /// 编辑岗位
+ ///
+ /// 编辑参数
+ ///
+ Task Edit(PositionEditInput input);
+
+ ///
+ /// 岗位分页查询
+ ///
+ /// 查询参数
+ /// 分页列表
+ Task> Page(PositionPageInput input);
+
+ ///
+ /// 岗位选择器
+ ///
+ ///
+ ///
+ Task> Selector(PositionSelectorInput input);
+
+ ///
+ /// 岗位详情
+ ///
+ ///
+ ///
+ Task Detail(BaseIdInput input);
+
+ ///
+ /// 岗位树形结构
+ ///
+ ///
+ ///
+ Task> Tree(PositionTreeInput input);
+}
diff --git a/SimpleAdmin.Application/Services/Organization/Position/PositionService.cs b/SimpleAdmin.Application/Services/Organization/Position/PositionService.cs
new file mode 100644
index 0000000..a619a98
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Organization/Position/PositionService.cs
@@ -0,0 +1,131 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Application;
+
+///
+///
+///
+public class PositionService : DbRepository, IPositionService
+{
+ private readonly ISysUserService _sysUserService;
+ private readonly ISysPositionService _sysPositionService;
+
+ public PositionService(ISysUserService sysUserService, ISysPositionService sysPositionService)
+ {
+ _sysUserService = sysUserService;
+ _sysPositionService = sysPositionService;
+ }
+
+ #region 查询
+
+ ///
+ public async Task> Page(PositionPageInput input)
+ {
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ input.OrgIds = dataScope;
+ //分页查询
+ var pageInfo = await _sysPositionService.Page(input);
+ return pageInfo;
+ }
+
+ ///
+ public async Task> Tree(PositionTreeInput input)
+ {
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ input.OrgIds = dataScope;
+ var result = await _sysPositionService.Tree(input);
+ return result;
+ }
+
+ #endregion
+
+ #region 新增
+
+ ///
+ public async Task Add(PositionAddInput input)
+ {
+ await CheckInput(input, SystemConst.ADD);//检查参数
+ await _sysPositionService.Add(input, ApplicationConst.BIZ_POS);//添加岗位
+ }
+
+ ///
+ public async Task> Selector(PositionSelectorInput input)
+ {
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ input.OrgIds = dataScope;//赋值机构列表
+ var result = await _sysPositionService.Selector(input);//查询
+ return result;
+ }
+
+ ///
+ public async Task Detail(BaseIdInput input)
+ {
+ var position = await _sysPositionService.GetSysPositionById(input.Id);
+ //判断数据范围
+ await _sysUserService.CheckApiDataScope(position.OrgId, position.CreateUserId.GetValueOrDefault(), "您没有权限查看该机构");
+ return position;
+ }
+
+ #endregion
+
+ #region 编辑
+
+ ///
+ public async Task Edit(PositionEditInput input)
+ {
+ await CheckInput(input, SystemConst.EDIT);//检查参数
+ await _sysPositionService.Edit(input, ApplicationConst.BIZ_POS);//编辑
+ }
+
+ #endregion
+
+
+ #region 删除
+
+ ///
+ public async Task Delete(BaseIdListInput input)
+ {
+ //获取所有ID
+ var ids = input.Ids;
+ //获取要删除的岗位列表
+ var positions = (await _sysPositionService.GetListAsync()).Where(it => ids.Contains(it.Id)).ToList();
+ //检查数据范围
+ var orgIds = positions.Select(it => it.OrgId).ToList();
+ var createUserIds = positions.Select(it => it.CreateUserId.GetValueOrDefault()).ToList();
+ await _sysUserService.CheckApiDataScope(orgIds, createUserIds, "您没有权限删除该机构");
+ await _sysPositionService.Delete(input, ApplicationConst.BIZ_ORG);//删除岗位
+ }
+
+ #endregion
+
+ #region 方法
+
+ ///
+ /// 检查输入参数
+ ///
+ /// 参数
+ /// 操作名称
+ private async Task CheckInput(SysPosition sysPosition, string operate)
+ {
+ var errorMessage = $"您没有权限在该机构下{operate}岗位";
+ //如果id大于0表示编辑
+ if (sysPosition.Id > 0)
+ {
+ var position = await _sysPositionService.GetSysPositionById(sysPosition.Id);//获取机构
+ sysPosition.CreateUserId = position.CreateUserId;
+ }
+ await _sysUserService.CheckApiDataScope(sysPosition.OrgId, sysPosition.CreateUserId.GetValueOrDefault(), errorMessage);
+ }
+
+ #endregion 方法
+}
diff --git a/SimpleAdmin.Application/Services/Organization/Role/IRoleService.cs b/SimpleAdmin.Application/Services/Organization/Role/IRoleService.cs
new file mode 100644
index 0000000..39bd737
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Organization/Role/IRoleService.cs
@@ -0,0 +1,115 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Application;
+
+public interface IRoleService : ITransient
+{
+ #region 查询
+
+ ///
+ /// 角色拥有资源
+ ///
+ /// 角色id
+ /// 资源类型
+ /// 角色拥有资源信息
+ Task OwnResource(BaseIdInput input, string category);
+
+ ///
+ /// 获取角色下的用户
+ ///
+ /// 角色ID
+ ///
+ Task> OwnUser(BaseIdInput input);
+
+ ///
+ /// 分页查询角色
+ ///
+ /// 查询参数
+ ///
+ Task> Page(RolePageInput input);
+
+ ///
+ /// 角色选择器
+ ///
+ ///
+ ///
+ Task> RoleSelector(RoleSelectorInput input);
+
+ ///
+ /// 获取角色树
+ ///
+ /// 角色树
+ ///
+ Task> Tree(RoleTreeInput input);
+
+ ///
+ /// 角色详情
+ ///
+ /// 角色Id
+ ///
+ Task Detail(BaseIdInput input);
+
+ ///
+ /// 资源树选择器
+ ///
+ ///
+ Task> ResourceTreeSelector();
+
+ #endregion
+
+ #region 新增
+
+ ///
+ /// 添加角色
+ ///
+ /// 添加参数
+ ///
+ Task Add(RoleAddInput input);
+
+ #endregion
+
+ #region 编辑
+
+ ///
+ /// 编辑角色
+ ///
+ /// 编辑参数
+ ///
+ Task Edit(RoleEditInput input);
+
+
+ ///
+ /// 给角色授权
+ ///
+ /// 授权参数
+ ///
+ Task GrantResource(GrantResourceInput input);
+
+ ///
+ /// 给角色授权用户
+ ///
+ /// 授权信息
+ ///
+ Task GrantUser(GrantUserInput input);
+
+ #endregion
+
+ #region 删除
+
+ ///
+ /// 删除角色
+ ///
+ /// 删除参数
+ ///
+ Task Delete(BaseIdListInput input);
+
+ #endregion
+}
diff --git a/SimpleAdmin.Application/Services/Organization/Role/RoleService.cs b/SimpleAdmin.Application/Services/Organization/Role/RoleService.cs
new file mode 100644
index 0000000..9ddeb97
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Organization/Role/RoleService.cs
@@ -0,0 +1,286 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using Microsoft.Extensions.Logging;
+using NewLife.Serialization;
+
+namespace SimpleAdmin.Application;
+
+///
+public class RoleService : IRoleService
+{
+ private readonly ILogger _logger;
+ private readonly ISysUserService _sysUserService;
+ private readonly ISysRoleService _sysRoleService;
+ private readonly IResourceService _resourceService;
+ private readonly IRelationService _relationService;
+
+ public RoleService(ILogger logger, ISysUserService sysUserService, ISysRoleService sysRoleService,
+ IResourceService resourceService, IRelationService relationService)
+ {
+ _logger = logger;
+ _sysUserService = sysUserService;
+ _sysRoleService = sysRoleService;
+ _resourceService = resourceService;
+ _relationService = relationService;
+ }
+
+ #region 查询
+
+ ///
+ public async Task OwnResource(BaseIdInput input, string category)
+ {
+ return await _sysRoleService.OwnResource(input, category);
+ }
+
+ ///
+ public async Task> OwnUser(BaseIdInput input)
+ {
+ return await _sysRoleService.OwnUser(input);
+ }
+
+ ///
+ public async Task> Page(RolePageInput input)
+ {
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ input.OrgIds = dataScope;
+ input.Category = CateGoryConst.ROLE_ORG;//只查询机构角色
+ //分页查询
+ var pageInfo = await _sysRoleService.Page(input);
+ return pageInfo;
+ }
+
+
+ ///
+ public async Task> RoleSelector(RoleSelectorInput input)
+ {
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ input.OrgIds = dataScope;
+ return await _sysRoleService.RoleSelector(input);
+ }
+
+ ///
+ public async Task> Tree(RoleTreeInput input)
+ {
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ input.OrgIds = dataScope;
+ return await _sysRoleService.Tree(input);
+ }
+
+ ///
+ public async Task Detail(BaseIdInput input)
+ {
+ var role = await _sysRoleService.Detail(input);
+ var errorMessage = "您没有权限查看该角色";
+ await _sysUserService.CheckApiDataScope(role.OrgId, role.CreateUserId, errorMessage);
+ return role;
+ }
+
+ ///
+ public async Task> ResourceTreeSelector()
+ {
+ var resourceTreeSelectors = new List();//定义结果
+ var user = await _sysUserService.GetUserById(UserManager.UserId);//获取用户
+ //获取角色资源关系
+ var relations =
+ await _relationService.GetRelationListByObjectIdListAndCategory(user.RoleIdList, CateGoryConst.RELATION_SYS_ROLE_HAS_RESOURCE);
+ var menuIds = new HashSet();//菜单ID集合
+ var buttonIds = new HashSet();//按钮ID集合
+ relations.ForEach(it =>
+ {
+ var resources = it.ExtJson.ToJsonEntity();//转换为对象获取资源
+ menuIds.Add(resources.MenuId);//添加菜单ID
+ resources.ButtonInfo.ForEach(b => buttonIds.Add(b));//添加按钮ID
+ });
+ var menuList = await _resourceService.GetListByCategory(CateGoryConst.RESOURCE_MENU);//获取所有菜单
+ var buttonList = await _resourceService.GetListByCategory(CateGoryConst.RESOURCE_BUTTON);//获取所有按钮
+ var moduleList = await _resourceService.GetListByCategory(CateGoryConst.RESOURCE_MODULE);//获取所有模块
+ var ownMenuList = menuList.Where(it => menuIds.Contains(it.Id)).ToList();//已拥有的菜单
+ var parentMenuList = menuList.Where(it => ownMenuList.Select(m => m.ParentId).Contains(it.Id)).ToList();//获取所有父级菜单
+ ownMenuList.AddRange(parentMenuList);//将父级菜单加入到拥有菜单列表
+ var ownButtonList = buttonList.Where(it => buttonIds.Contains(it.Id)).ToList();//已拥有的按钮
+ var moduleIds = ownMenuList.Select(it => it.Module.GetValueOrDefault()).Distinct().ToList();//模块ID集合
+ var ownModuleList = moduleList.Where(it => moduleIds.Contains(it.Id)).ToList();//已拥有的模块
+ //遍历模块
+ foreach (var module in ownModuleList)
+ {
+ //将实体转换为ResourceTreeSelectorOutPut获取基本信息
+ var resourceTreeSelector = module.Adapt();
+ resourceTreeSelector.Menu = await GetRoleGrantResourceMenus(module.Id, ownMenuList, ownButtonList);//获取授权菜单
+ resourceTreeSelectors.Add(resourceTreeSelector);
+ }
+ return resourceTreeSelectors;
+ }
+
+ #endregion
+
+ #region 增加
+
+ ///
+ public async Task Add(RoleAddInput input)
+ {
+ await CheckInput(input);//检查参数
+ await _sysRoleService.Add(input);
+ }
+
+ #endregion
+
+ #region 编辑
+
+ ///
+ public async Task Edit(RoleEditInput input)
+ {
+ await CheckInput(input);//检查参数
+ await _sysRoleService.Edit(input);
+ }
+
+ ///
+ public async Task GrantResource(GrantResourceInput input)
+ {
+ await _sysRoleService.GrantResource(input);
+ }
+
+ ///
+ public async Task GrantUser(GrantUserInput input)
+ {
+ await _sysRoleService.GrantUser(input);
+ }
+
+ #endregion
+
+ #region 删除
+
+ ///
+ public async Task Delete(BaseIdListInput input)
+ {
+ //获取所有ID
+ var ids = input.Ids;
+ //获取要删除的机构列表
+ var roleList = (await _sysRoleService.GetListAsync()).Where(it => ids.Contains(it.Id)).ToList();
+ if (roleList.Any(it => it.Category == CateGoryConst.ROLE_GLOBAL))//如果有全局角色
+ throw Oops.Bah("不能删除全局角色");
+ //检查数据范围
+ var orgIds = roleList.Select(it => it.OrgId.GetValueOrDefault()).ToList();
+ var createUserIds = roleList.Select(it => it.CreateUserId.GetValueOrDefault()).ToList();
+ await _sysUserService.CheckApiDataScope(orgIds, createUserIds, "您没有权限删除这些角色");
+ await _sysRoleService.Delete(input);
+ }
+
+ #endregion
+
+ #region 方法
+
+ ///
+ /// 检查输入参数
+ ///
+ ///
+ private async Task CheckInput(SysRole sysRole)
+ {
+ sysRole.Category = CateGoryConst.ROLE_ORG;
+ if (sysRole.DefaultDataScope.ScopeCategory == CateGoryConst.SCOPE_ALL)
+ throw Oops.Bah("不能添加全局数据范围的角色");
+ await _sysUserService.CheckApiDataScope(sysRole.OrgId, sysRole.CreateUserId.GetValueOrDefault(), "您没有权限添加该角色");
+ }
+
+ ///
+ /// 获取授权菜单
+ ///
+ /// 模块Id
+ /// 拥有菜单列表
+ /// 拥有权限按钮列表
+ ///
+ public async Task> GetRoleGrantResourceMenus(long moduleId, List ownMenuList,
+ List ownButtonList)
+ {
+ var roleGrantResourceMenus = new List();//定义结果
+ var parentMenuList = ownMenuList.Where(it => it.ParentId == SimpleAdminConst.ZERO).ToList();//获取一级目录
+ //遍历一级目录
+ foreach (var parent in parentMenuList)
+ {
+ //如果是目录则去遍历下级
+ if (parent.MenuType == SysResourceConst.CATALOG)
+ {
+ //获取所有下级菜单
+ var menuList = _resourceService.GetChildListById(ownMenuList, parent.Id, false);
+ if (menuList.Count > 0)//如果有菜单
+ {
+ //遍历下级菜单
+ foreach (var menu in menuList)
+ {
+ //如果菜单类型是菜单
+ if (menu.MenuType is SysResourceConst.MENU or SysResourceConst.SUBSET)
+ {
+ //获取菜单下按钮集合并转换成对应实体
+ var buttonList = ownButtonList.Where(it => it.ParentId == menu.Id).ToList();
+ var buttons = buttonList.Adapt>();
+ roleGrantResourceMenus.Add(new ResTreeSelector.RoleGrantResourceMenu
+ {
+ Id = menu.Id,
+ ParentId = parent.Id,
+ ParentName = parent.Title,
+ Module = moduleId,
+ Title = _resourceService.GetRoleGrantResourceMenuTitle(menuList, menu),//菜单名称需要特殊处理因为有二级菜单
+ Button = buttons
+ });
+ }
+ else if (menu.MenuType == SysResourceConst.LINK || menu.MenuType == SysResourceConst.IFRAME)//如果是内链或者外链
+ {
+ //直接加到资源列表
+ roleGrantResourceMenus.Add(new ResTreeSelector.RoleGrantResourceMenu
+ {
+ Id = menu.Id,
+ ParentId = parent.Id,
+ ParentName = parent.Title,
+ Module = moduleId,
+ Title = menu.Title
+ });
+ }
+ }
+ }
+ else
+ {
+ //否则就将自己加到一级目录里面
+ roleGrantResourceMenus.Add(new ResTreeSelector.RoleGrantResourceMenu
+ {
+ Id = parent.Id,
+ ParentId = parent.Id,
+ ParentName = parent.Title,
+ Module = moduleId
+ });
+ }
+ }
+ else
+ {
+ //就将自己加到一级目录里面
+ var roleGrantResourcesButtons = new ResTreeSelector.RoleGrantResourceMenu
+ {
+ Id = parent.Id,
+ ParentId = parent.Id,
+ ParentName = parent.Title,
+ Module = moduleId,
+ Title = parent.Title
+ };
+ //如果菜单类型是菜单
+ if (parent.MenuType == SysResourceConst.MENU)
+ {
+ //获取菜单下按钮集合并转换成对应实体
+ var buttonList = ownButtonList.Where(it => it.ParentId == parent.Id).ToList();
+ roleGrantResourcesButtons.Button = buttonList.Adapt>();
+ }
+ roleGrantResourceMenus.Add(roleGrantResourcesButtons);
+ }
+ }
+ return roleGrantResourceMenus;
+ }
+
+ #endregion
+}
diff --git a/SimpleAdmin.Application/Services/Organization/User/Dto/UserInput.cs b/SimpleAdmin.Application/Services/Organization/User/Dto/UserInput.cs
new file mode 100644
index 0000000..d3dd86e
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Organization/User/Dto/UserInput.cs
@@ -0,0 +1,18 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Application;
+
+///
+/// 业务用户导入
+///
+public class BizUserImportInput : SysUserImportInput
+{
+}
diff --git a/SimpleAdmin.Application/Services/Organization/User/Dto/UserOutput.cs b/SimpleAdmin.Application/Services/Organization/User/Dto/UserOutput.cs
new file mode 100644
index 0000000..81562dd
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Organization/User/Dto/UserOutput.cs
@@ -0,0 +1,18 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Application;
+
+///
+/// 业务用户导出
+///
+public class BizUserExportOutput : SysUserExportOutput
+{
+}
diff --git a/SimpleAdmin.Application/Services/Organization/User/IUserService.cs b/SimpleAdmin.Application/Services/Organization/User/IUserService.cs
new file mode 100644
index 0000000..57b11e6
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Organization/User/IUserService.cs
@@ -0,0 +1,155 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Application;
+
+///
+/// 人员管理服务
+///
+public interface IUserService : ITransient
+{
+ #region 查询
+
+ ///
+ /// 人员选择器
+ ///
+ /// 查询参数
+ /// 人员列表
+ Task> Selector(UserSelectorInput input);
+
+ ///
+ /// 用户分页查询
+ ///
+ /// 查询参数
+ /// 用户分页列表
+ Task> Page(UserPageInput input);
+
+ ///
+ /// 获取用户拥有角色
+ ///
+ /// 用户ID
+ ///
+ Task> OwnRole(BaseIdInput input);
+
+ ///
+ /// 角色选择器
+ ///
+ ///
+ ///
+ Task> RoleSelector(RoleSelectorInput input);
+
+ ///
+ /// 人员详情
+ ///
+ ///
+ ///
+ Task Detail(BaseIdInput input);
+
+ #endregion 查询
+
+ #region 添加
+
+ ///
+ /// 添加用户
+ ///
+ /// 添加参数
+ ///
+ Task Add(UserAddInput input);
+
+ #endregion 添加
+
+ #region 编辑
+
+ ///
+ /// 编辑
+ ///
+ /// 编辑参数
+ ///
+ Task Edit(UserEditInput input);
+
+ ///
+ /// 禁用用户
+ ///
+ /// 用户Id
+ ///
+ Task DisableUser(BaseIdInput input);
+
+ ///
+ /// 启用用户
+ ///
+ /// 用户Id
+ ///
+ Task EnableUser(BaseIdInput input);
+
+ ///
+ /// 重置密码
+ ///
+ /// 用户Id
+ ///
+ Task ResetPassword(BaseIdInput input);
+
+ ///
+ /// 给用户授权角色
+ ///
+ /// 授权参数
+ ///
+ Task GrantRole(UserGrantRoleInput input);
+
+ #endregion 编辑
+
+ #region 删除
+
+ ///
+ /// 删除用户
+ ///
+ /// Id列表
+ ///
+ Task Delete(BaseIdListInput input);
+
+ #endregion 删除
+
+ #region 导入导出
+
+ ///
+ /// 导入预览
+ ///
+ /// 导入参数
+ ///
+ Task Preview(ImportPreviewInput input);
+
+ ///
+ /// 获取导入模板
+ ///
+ ///
+ Task Template();
+
+ ///
+ /// 导出
+ ///
+ /// 查询参数
+ ///
+ Task Export(UserPageInput input);
+
+ ///
+ /// 导入数据
+ ///
+ /// 数据
+ /// 导入结果
+ Task> Import(ImportResultInput input);
+
+ ///
+ /// 批量编辑
+ ///
+ /// 编辑字段信息
+ ///
+ Task Edits(BatchEditInput input);
+
+ #endregion 导入导出
+}
diff --git a/SimpleAdmin.Application/Services/Organization/User/UserService.cs b/SimpleAdmin.Application/Services/Organization/User/UserService.cs
new file mode 100644
index 0000000..7ca05da
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Organization/User/UserService.cs
@@ -0,0 +1,332 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Application;
+
+///
+///
+///
+public class UserService : DbRepository, IUserService
+{
+ private readonly ISysUserService _sysUserService;
+ private readonly ISysRoleService _sysRoleService;
+ private readonly IImportExportService _importExportService;
+
+ public UserService(ISysUserService sysUserService, ISysRoleService sysRoleService, IImportExportService importExportService)
+ {
+ _sysUserService = sysUserService;
+ _sysRoleService = sysRoleService;
+ _importExportService = importExportService;
+ }
+
+ #region 查询
+
+ ///
+ public async Task> Page(UserPageInput input)
+ {
+ var query = await GetQuery(input);
+ //分页查询
+ var pageInfo = await _sysUserService.Page(query);
+ return pageInfo;
+ }
+
+ ///
+ public async Task> OwnRole(BaseIdInput input)
+ {
+ return await _sysUserService.OwnRole(input);//获取角色
+ }
+
+ ///
+ public async Task> Selector(UserSelectorInput input)
+ {
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ if (dataScope == null)
+ return await _sysUserService.Selector(input);//查询
+ if (dataScope.Count > 0)
+ {
+ input.OrgIds = dataScope;//赋值机构列表
+ return await _sysUserService.Selector(input);//查询
+ }
+ //返回自己
+ return new SqlSugarPagedList
+ {
+ Total = 1,
+ Pages = 1,
+ HasPrevPages = false,
+ HasNextPages = false,
+ List = new[]
+ {
+ new UserSelectorOutPut
+ {
+ Account = UserManager.UserAccount, Id = UserManager.UserId,
+ Name = UserManager.Name, OrgId = UserManager.OrgId
+ }
+ }
+ };
+ }
+
+ ///
+ public async Task> RoleSelector(RoleSelectorInput input)
+ {
+ var sysRoles = new SqlSugarPagedList
+ {
+ Total = 1,
+ Pages = 1,
+ HasPrevPages = false,
+ HasNextPages = false,
+ List = new List()
+ };
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ if (dataScope == null)
+ sysRoles = await _sysRoleService.RoleSelector(input);//获取角色选择器列表
+ else if (dataScope.Count > 0)//如果有机构
+ {
+ input.OrgIds = dataScope;//将数据范传进去
+ sysRoles = await _sysRoleService.RoleSelector(input);//获取角色选择器列表
+ }
+ return sysRoles;
+ }
+
+ ///
+ public async Task Detail(BaseIdInput input)
+ {
+ var user = await _sysUserService.Detail(input);
+ var errorMessage = "您没有权限查看该人员";
+ //判断数据范围
+ await _sysUserService.CheckApiDataScope(user.OrgId, user.CreateUserId, errorMessage);
+ return user;
+ }
+
+ #endregion 查询
+
+ #region 新增
+
+ ///
+ public async Task Add(UserAddInput input)
+ {
+ await CheckInput(input, SystemConst.ADD);//检查参数
+ await _sysUserService.Add(input);//添加
+ }
+
+ #endregion 新增
+
+ #region 编辑
+
+ ///
+ public async Task Edit(UserEditInput input)
+ {
+ await CheckInput(input, SystemConst.EDIT);//检查参数
+ await _sysUserService.Edit(input);//编辑
+ }
+
+ ///
+ public async Task Edits(BatchEditInput input)
+ {
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ var ids = input.Ids;
+ var sysUsers = await GetListAsync(it => ids.Contains(it.Id),
+ it => new SysUser { OrgId = it.OrgId, CreateUserId = it.CreateUserId });//根据用户ID获取机构id、
+ sysUsers.ForEach(it =>
+ {
+ if (dataScope != null && !dataScope.Contains(it.OrgId) && it.CreateUserId != UserManager.UserId)
+ throw Oops.Bah(ErrorCodeEnum.A0004);//如果不包含机构id并且不是自己创建的
+ });
+ await _sysUserService.Edits(input);
+ }
+
+ ///
+ public async Task DisableUser(BaseIdInput input)
+ {
+ await CheckInput(input.Id, SystemConst.DISABLE);//检查权限
+ await _sysUserService.DisableUser(input);//禁用
+ }
+
+ ///
+ public async Task EnableUser(BaseIdInput input)
+ {
+ await CheckInput(input.Id, SystemConst.ENABLE);//检查权限
+ await _sysUserService.EnableUser(input);//启用
+ }
+
+ ///
+ public async Task GrantRole(UserGrantRoleInput input)
+ {
+ await CheckInput(input.Id, SystemConst.DISABLE);//检查权限
+ await _sysUserService.GrantRole(input);//授权
+ }
+
+ ///
+ public async Task ResetPassword(BaseIdInput input)
+ {
+ await CheckInput(input.Id, SystemConst.RESET_PWD);//检查权限
+ await _sysUserService.ResetPassword(input);//重置密码
+ }
+
+ #endregion 编辑
+
+ #region 删除
+
+ ///
+ public async Task Delete(BaseIdListInput input)
+ {
+ //获取所有ID
+ var ids = input.Ids;
+
+ //获取用户下信息
+ var users = await GetListAsync(it => ids.Contains(it.Id), it => new SysUser { OrgId = it.OrgId, Id = it.Id });
+ //检查数据范围
+ var orgIds = users.Select(it => it.OrgId).ToList();
+ var createUserIds = users.Select(it => it.CreateUserId.GetValueOrDefault()).ToList();
+ await _sysUserService.CheckApiDataScope(orgIds, createUserIds, "您没有权限删除这些人员");
+ await _sysUserService.Delete(input);//删除
+ }
+
+ #endregion 删除
+
+ #region 导入导出
+
+ ///
+ public async Task Template()
+ {
+ var templateName = "人员信息.xlsx";
+ //var result = _importExportService.GenerateLocalTemplate(templateName);
+ var result = await _importExportService.GenerateTemplate(templateName);
+ return result;
+ }
+
+ ///
+ public async Task Preview(ImportPreviewInput input)
+ {
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ if (dataScope == null || dataScope.Count > 0)
+ {
+ var importPreview = await _importExportService.GetImportPreview(input.File);
+ importPreview.Data = await CheckImport(importPreview.Data, dataScope);//检查导入数据
+ return importPreview;
+ }
+ throw Oops.Bah("您无权导入用户");
+ }
+
+ ///
+ public async Task Export(UserPageInput input)
+ {
+ var query = await GetQuery(input);
+ var users = await _sysUserService.List(query);
+ var data = users.Adapt>();//转为Dto
+ var result = await _importExportService.Export(data, "人员信息");
+ return result;
+ }
+
+ ///
+ public async Task> Import(ImportResultInput input)
+ {
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ if (dataScope.Count > 0)
+ {
+ var data = await CheckImport(input.Data, dataScope, true);//检查数据格式
+ var result = _importExportService.GetImportResultPreview(data, out var importData);
+ var sysUsers = importData.Adapt>();//转实体
+ await _sysUserService.SetUserDefault(sysUsers);//设置用户默认值
+ await InsertOrBulkCopy(sysUsers);// 数据导入
+ return result;
+ }
+ throw Oops.Bah("您无权导入用户");
+ }
+
+ #endregion 导入导出
+
+ #region 方法
+
+ ///
+ /// 检查输入参数
+ ///
+ ///
+ /// 操作类型
+ private async Task CheckInput(SysUser sysUser, string operate)
+ {
+ var errorMessage = $"您没有权限{operate}该机构下的人员";
+ if (sysUser.Id != SimpleAdminConst.ZERO)
+ {
+ var user = await _sysUserService.GetUserById(sysUser.Id);
+ sysUser.CreateUserId = user.CreateUserId;
+ }
+ //检查数据范围
+ await _sysUserService.CheckApiDataScope(sysUser.OrgId, sysUser.CreateUserId.GetValueOrDefault(), errorMessage);
+ }
+
+ ///
+ /// 检查输入参数
+ ///
+ /// 用户ID
+ /// 操作
+ private async Task CheckInput(long userId, string operate)
+ {
+ var errorMessage = $"您没有权限{operate}该机构下的人员";
+ var sysUser = await _sysUserService.GetUserById(userId);
+ //检查数据范围
+ await _sysUserService.CheckApiDataScope(sysUser.OrgId, sysUser.CreateUserId.GetValueOrDefault(), errorMessage);
+ }
+
+ ///
+ /// 检查导入数据
+ ///
+ /// 数据
+ /// 数据范围ID数组
+ /// 是否初始化错误
+ ///
+ public async Task> CheckImport(List data, List dataScope, bool clearError = false)
+ {
+ var errorMessage = "没有权限";
+ //先经过系统用户检查
+ var bizUsers = await _sysUserService.CheckImport(data, clearError);
+ bizUsers.ForEach(it =>
+ {
+ //如果机构没有错误
+ if (!it.ErrorInfo.ContainsKey(nameof(it.OrgName)))
+ {
+ //判断是否包含数据范围,如果不包含
+ if (dataScope != null && !dataScope.Contains(it.OrgId))
+ {
+ it.ErrorInfo.Add(nameof(it.OrgName), errorMessage);
+ if (!it.ErrorInfo.ContainsKey(nameof(it.PositionName)))//如果机构没错
+ it.ErrorInfo.Add(nameof(it.PositionName), errorMessage);
+ }
+ }
+ if (it.ErrorInfo.Count > 0) it.HasError = true;//如果错误信息数量大于0则表示有错误
+ });
+ bizUsers = bizUsers.OrderByDescending(it => it.HasError).ToList();//排序
+ return bizUsers;
+ }
+
+ ///
+ /// 获取查询条件
+ ///
+ ///
+ ///
+ public async Task GetQuery(UserPageInput input)
+ {
+ //获取数据范围
+ var dataScope = await _sysUserService.GetLoginUserApiDataScope();
+ //动态查询条件
+ var exp = Expressionable.Create();
+ exp.And(u => u.Account != SysRoleConst.SUPER_ADMIN);
+ exp.AndIF(dataScope is { Count: > 0 }, u => dataScope.Contains(u.OrgId));//用户机构在数据范围内
+ exp.AndIF(dataScope is { Count: 0 }, u => u.Id == UserManager.UserId);//用户ID等于自己
+ input.Expression = exp;
+ return input;
+ }
+
+ #endregion 方法
+}
diff --git a/SimpleAdmin.Application/Services/Prescription/Dto/PrescriptionDtos.cs b/SimpleAdmin.Application/Services/Prescription/Dto/PrescriptionDtos.cs
new file mode 100644
index 0000000..fee9868
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Prescription/Dto/PrescriptionDtos.cs
@@ -0,0 +1,162 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SimpleAdmin.Application.Services.Prescription.Dto
+{
+ // 人员类型枚举
+ public enum PersonType
+ {
+ [Description("员工")]
+ Employee = 1,
+ [Description("家属")]
+ Relative = 2
+ }
+
+ // 处方列表DTO
+ public class PrescriptionDto
+ {
+ public long Id { get; set; }
+ public long PersonId { get; set; }
+ public string PersonName { get; set; }
+ public PersonType PersonType { get; set; }
+ ///
+ /// 关联的员工名称
+ ///
+ public string EmployeeName { get; set; }
+ public DateTime? VisitDate { get; set; }
+ public bool CanEdit { get; set; }
+
+ public DateTime CreateTime { get; set; }
+
+ public decimal TotalMedicineCost { get; set; }
+
+ }
+ // 辅助类:存储FIFO计算所需的入库记录信息
+ public class MedicinalFifoRecord
+ {
+ public long MedicinalId { get; set; }
+ public decimal AddWeight { get; set; }
+ public decimal UnitPrice { get; set; }
+ }
+ // 处方查询输入DTO
+ public class PrescriptionQueryInput: BasePageInput
+ {
+ public DateTime? VisitDate { get; set; }
+ public long? MedicinalId { get; set; }
+ public PersonType? PersonType { get; set; }
+ public long? EmployeeId { get; set; }
+
+ public string PersonName { get; set; }
+ }
+
+ // 处方详情DTO
+ public class PrescriptionDetailDto
+ {
+ public long Id { get; set; }
+ public PersonDetailDto Person { get; set; }
+ public string DiagnosisResult { get; set; }
+ public string UserMedicinaAdvice { get; set; }
+ public DateTime? VisitDate { get; set; }
+ public List Herbs { get; set; }
+ public bool CanEdit { get; set; }
+ }
+
+ // 人员详情DTO
+ public class PersonDetailDto
+ {
+ public long? Id { get; set; }
+ public string Name { get; set; }
+ public string Birthday { get; set; }
+ public decimal? Weight { get; set; }
+ public decimal? Height { get; set; }
+ public bool IsEmployee { get; set; }
+ public long? EmployeeId { get; set; }
+ public string EmployeeName { get; set; }
+ public long? RelationShip { get; set; }
+ public string RelationShipName { get; set; }
+ }
+
+ // 处方药材DTO
+ public class PrescriptionHerbDto
+ {
+ public long MedicinalId { get; set; }
+ public string MedicinalName { get; set; }
+ public decimal AmountG { get; set; }
+ public string Note { get; set; }
+ }
+
+ // DTOs(替换/合并到你的 DTO 定义处)
+ public class SavePrescriptionInput
+ {
+ public long? Id { get; set; }
+ public PersonInputDto Person { get; set; }
+ public string DiagnosisResult { get; set; }
+ public string UserMedicinaAdvice { get; set; }
+ public DateTime? VisitDate { get; set; }
+ public List Herbs { get; set; }
+ }
+
+ // 人员输入 DTO(新增字段以支持前端发送临时员工信息)
+ public class PersonInputDto
+ {
+ public long? Id { get; set; } // 可能的已存在人员ID
+ public string TempId { get; set; } // 可选:前端临时 id(兼容旧流程)
+ public string Name { get; set; }
+ public string Birthday { get; set; }
+ public decimal? Weight { get; set; }
+ public decimal? Height { get; set; }
+ public bool IsEmployee { get; set; }
+ public long? RelationShip { get; set; } // 亲属关系 id(若为家属)
+ public long? EmployeeId { get; set; } // 关联员工 id(如果是家属)
+ ///
+ /// 当前关联的员工是否是前端临时新增(需要后端创建)
+ ///
+ public bool EmployeeIsTemp { get; set; }
+ ///
+ /// 当 EmployeeIsTemp 为 true 或者前端直接传了员工名字时,后端可用此字段创建员工
+ ///
+ public string EmployeeName { get; set; }
+ }
+ // 处方药材输入DTO
+ public class PrescriptionHerbInputDto
+ {
+ public long Id { get; set; }
+ public decimal AmountG { get; set; }
+ public string Note { get; set; }
+ }
+
+ // 人员DTO
+ public class PersonDto
+ {
+ public long Id { get; set; }
+ public string Name { get; set; }
+ public string Birthday { get; set; }
+
+ public decimal? Height { get; set; }
+
+ public long? RelationShip { get; set; }
+ }
+
+ // 关系类型DTO
+ public class RelationTypeDto
+ {
+ public long Id { get; set; }
+ public string Name { get; set; }
+ }
+
+}
diff --git a/SimpleAdmin.Application/Services/Prescription/IPrescriptionService.cs b/SimpleAdmin.Application/Services/Prescription/IPrescriptionService.cs
new file mode 100644
index 0000000..2191722
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Prescription/IPrescriptionService.cs
@@ -0,0 +1,58 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Dynamic.Core;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SimpleAdmin.Application.Services.Prescription
+{
+ public interface IPrescriptionService : ITransient
+ {
+ ///
+ /// 获取处方列表,带筛选
+ ///
+ /// 筛选条件
+ ///
+ Task> GetPrescriptionList(PrescriptionQueryInput input);
+
+ ///
+ /// 获取处方详情
+ ///
+ /// 处方ID
+ ///
+ Task GetPrescriptionDetail(long id);
+
+ ///
+ /// 保存处方(新增或编辑)
+ ///
+ /// 处方信息
+ ///
+ Task SavePrescription(SavePrescriptionInput input);
+
+ ///
+ /// 获取人员列表(员工和家属)
+ ///
+ /// 人员类型
+ /// 员工ID(用于获取家属)
+ ///
+ Task> GetPersonList(PersonType? type, long? employeeId);
+
+
+ ///
+ /// 获取所有关系类型(写死在代码中)
+ ///
+ ///
+ Task> GetRelationTypes();
+ }
+}
diff --git a/SimpleAdmin.Application/Services/Prescription/PrescriptionService.cs b/SimpleAdmin.Application/Services/Prescription/PrescriptionService.cs
new file mode 100644
index 0000000..310771a
--- /dev/null
+++ b/SimpleAdmin.Application/Services/Prescription/PrescriptionService.cs
@@ -0,0 +1,551 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Dynamic.Core;
+using SimpleAdmin.Application.Entity;
+using SimpleAdmin.Application.Services.Prescription;
+using Yitter.IdGenerator;
+
+public class PrescriptionService : DbRepository, IPrescriptionService
+{
+ public async Task> GetPrescriptionList(PrescriptionQueryInput input)
+ {
+ // 原有查询逻辑保持不变
+ var query = Context.Queryable()
+ .LeftJoin((p, pe) => p.PersonId == pe.Id)
+ .LeftJoin((p, pe, emp) => pe.EmployeeId != null && pe.EmployeeId == emp.Id)
+ .WhereIF(!string.IsNullOrEmpty(input.PersonName), (p, pe, emp) =>
+ input.PersonName.Contains(pe.Name) || pe.Name.Contains(input.PersonName) ||
+ input.PersonName.Contains(emp.Name) || emp.Name.Contains(input.PersonName))
+ .WhereIF(input.PersonType.HasValue && input.PersonType == PersonType.Employee, (p, pe) =>
+ pe.EmployeeId == null)
+ .WhereIF(input.PersonType.HasValue && input.PersonType != PersonType.Employee, (p, pe) =>
+ pe.EmployeeId != null);
+
+ try
+ {
+ // 获取处方基础信息(添加总成本属性)
+ var prescriptionPage = await query.OrderByDescending((p, pe, emp) => p.CreateTime)
+ .Select((p, pe, emp) => new PrescriptionDto
+ {
+ Id = p.Id,
+ PersonId = p.PersonId,
+ PersonName = pe.Name,
+ PersonType = pe.EmployeeId != null ? PersonType.Relative : PersonType.Employee,
+ VisitDate = p.VisitDate,
+ CreateTime = p.CreateTime.Value,
+ EmployeeName = emp.Name,
+ CanEdit = false,
+ TotalMedicineCost = 0 // 初始化总成本
+ }).ToPagedListAsync(input.PageNum, input.PageSize);
+
+ // 设置可编辑状态
+ foreach (var item in prescriptionPage.List)
+ {
+ item.CanEdit = item.CreateTime.Date == DateTime.Now.Date;
+ }
+
+ // 获取当前页所有处方的药材明细
+ var pidList = prescriptionPage.List.Select(a => a.Id).ToList();
+ var prescriptionHerbList = await Context.Queryable()
+ .Where(a => pidList.Contains(a.PrescriptionId))
+ .ToListAsync();
+
+ if (prescriptionHerbList.Any())
+ {
+ // 1. 按【处方ID+药材ID】分组,统计每个处方中每种药材的总使用量
+ var prescriptionMedicinalUsage = prescriptionHerbList
+ .GroupBy(h => new { h.PrescriptionId, h.MedicinalId })
+ .Select(g => new
+ {
+ PrescriptionId = g.Key.PrescriptionId,
+ MedicinalId = g.Key.MedicinalId,
+ TotalUsedWeight = g.Sum(h => h.AmountG) // 同一处方中同一药材的总用量
+ })
+ .ToList();
+
+ // 2. 收集所有涉及的药材ID,批量获取FIFO计算所需数据
+ var medicinalIds = prescriptionMedicinalUsage.Select(u => u.MedicinalId).Distinct().ToList();
+ var fifoData = await GetMedicinalFifoData(medicinalIds);
+
+ // 3. 按处方ID分组,计算每个处方的总成本
+ var groupedByPrescription = prescriptionMedicinalUsage
+ .GroupBy(u => u.PrescriptionId)
+ .ToDictionary(g => g.Key, g => g.ToList());
+
+ // 4. 遍历处方,计算总成本
+ foreach (var prescription in prescriptionPage.List)
+ {
+ if (groupedByPrescription.TryGetValue(prescription.Id, out var usages))
+ {
+ foreach (var usage in usages)
+ {
+ // 基于FIFO计算当前药材的使用成本
+ var herbCost = CalculateHerbCostByFifo(
+ fifoData,
+ usage.MedicinalId,
+ usage.TotalUsedWeight
+ );
+
+ // 累加到处方总成本
+ prescription.TotalMedicineCost += herbCost;
+ }
+ }
+ }
+ }
+
+ return prescriptionPage;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"错误: {ex.Message}");
+ throw;
+ }
+ }
+
+ ///
+ /// 获取药材FIFO计算所需的基础数据(入库记录)
+ ///
+ private async Task>> GetMedicinalFifoData(List medicinalIds)
+ {
+ if (!medicinalIds.Any())
+ return new Dictionary>();
+
+ // 批量查询所有涉及药材的入库记录(按时间排序)
+ var addLogs = await Context.Queryable()
+ .Where(l => medicinalIds.Contains(l.MedicinalId))
+ .OrderBy(l => l.CreateTime) // FIFO核心:按入库时间排序
+ .Select(l => new MedicinalFifoRecord
+ {
+ MedicinalId = l.MedicinalId,
+ AddWeight = l.AddWeight,
+ UnitPrice = l.UnitPrice
+ })
+ .ToListAsync();
+
+ // 按药材ID分组
+ return addLogs.GroupBy(l => l.MedicinalId)
+ .ToDictionary(g => g.Key, g => g.ToList());
+ }
+
+ ///
+ /// 按FIFO规则计算单种药材的使用成本
+ ///
+ private decimal CalculateHerbCostByFifo(
+ Dictionary> fifoData,
+ long medicinalId,
+ decimal usedWeight)
+ {
+ if (usedWeight <= 0 || !fifoData.TryGetValue(medicinalId, out var records) || !records.Any())
+ return 0;
+
+ decimal remainingToCalculate = usedWeight;
+ decimal totalCost = 0;
+
+ // 按入库顺序依次消耗
+ foreach (var record in records)
+ {
+ if (remainingToCalculate <= 0)
+ break;
+
+ if (record.AddWeight <= remainingToCalculate)
+ {
+ // 当前批次全部消耗
+ totalCost += record.AddWeight * record.UnitPrice;
+ remainingToCalculate -= record.AddWeight;
+ }
+ else
+ {
+ // 消耗当前批次的部分量
+ totalCost += remainingToCalculate * record.UnitPrice;
+ remainingToCalculate = 0;
+ }
+ }
+
+ return totalCost;
+ }
+
+
+ ///
+ /// 获取处方详情
+ ///
+ ///
+ ///
+ ///
+ public async Task GetPrescriptionDetail(long id)
+ {
+ var prescription = await Context.Queryable()
+ .Where(p => p.Id == id)
+ .FirstAsync();
+
+ if (prescription == null)
+ {
+ throw Oops.Bah("处方不存在");
+ }
+
+ var person = await Context.Queryable()
+ .Where(pe => pe.Id == prescription.PersonId)
+ .FirstAsync();
+
+ var herbs = await Context.Queryable((ph, mt) => ph.MedicinalId == mt.Id)
+ .Where(ph => ph.PrescriptionId == id)
+ .Select((ph, mt) => new PrescriptionHerbDto
+ {
+ MedicinalId = mt.Id,
+ MedicinalName = mt.MedicinalName,
+ AmountG = ph.AmountG,
+ Note = ph.Note
+ })
+ .ToListAsync();
+
+ // 判断是否是员工还是家属
+ PersonDto employee = null;
+ if (person.EmployeeId.HasValue)
+ {
+ var empPerson = await Context.Queryable()
+ .Where(pe => pe.Id == person.EmployeeId)
+ .Select(pe => new PersonDto
+ {
+ Id = pe.Id,
+ Name = pe.Name
+ })
+ .FirstAsync();
+
+ employee = empPerson;
+ }
+ var RelationShipName = await GetRelationTypes();
+ return new PrescriptionDetailDto
+ {
+ Id = prescription.Id,
+ Person = new PersonDetailDto
+ {
+ Id = person.Id,
+ Name = person.Name,
+ Birthday = person.Birthday,
+ Weight = prescription.Weight,
+ Height = person.Height,
+ IsEmployee = !person.EmployeeId.HasValue,
+ EmployeeId = person.EmployeeId,
+ EmployeeName = employee?.Name,
+ RelationShip = person.RelationShip,
+ RelationShipName = RelationShipName.FirstOrDefault(t => t.Id == person.RelationShip)?.Name
+ },
+ DiagnosisResult = prescription.DiagnosisResult,
+ UserMedicinaAdvice = prescription.UserMedicinaAdvice,
+ VisitDate = prescription.VisitDate,
+ Herbs = herbs,
+ CanEdit = prescription.CreateTime.Value.Date == DateTime.Now.Date
+ };
+ }
+ ///
+ /// 添加编辑处方记录
+ ///
+ ///
+ ///
+ public async Task SavePrescription(SavePrescriptionInput input)
+ {
+ // 基础参数验证
+ if (input == null)
+ throw Oops.Bah("输入参数不能为空");
+
+ if (input.Herbs == null || !input.Herbs.Any())
+ throw Oops.Bah("处方药材不能为空");
+
+ await Context.Ado.BeginTranAsync();
+ try
+ {
+ // 用于在方法内记录新创建的员工 id(如果需要)
+ long? createdEmployeeId = null;
+
+ // ---------- 1. 处理前端在 person 中携带的“临时员工”(如果存在) ----------
+ if (input.Person == null)
+ throw Oops.Bah("人员信息不能为空");
+
+ // 场景 A: 病人是家属(IsEmployee == false),但关联的员工是前端临时新增
+ if (!input.Person.IsEmployee)
+ {
+ // 如果前端明确标记关联员工为临时新增(EmployeeIsTemp),需要先创建员工
+ if (input.Person.EmployeeIsTemp)
+ {
+ if (string.IsNullOrWhiteSpace(input.Person.EmployeeName))
+ throw Oops.Bah("标记了临时关联员工,但未提供员工姓名");
+
+ // 创建新员工记录(作为 Person 表的一条记录,RelationShip=null, EmployeeId=null)
+ var newEmp = new Person
+ {
+ Id = YitIdHelper.NextId(),
+ Name = input.Person.EmployeeName?.Trim(),
+ };
+ await Context.Insertable(newEmp).ExecuteCommandAsync();
+ createdEmployeeId = newEmp.Id;
+ }
+ else if (input.Person.EmployeeId.HasValue && input.Person.EmployeeId.Value > 0)
+ {
+ // 如果前端传的是已有员工 ID,校验该员工是否存在
+ var exists = await Context.Queryable()
+ .AnyAsync(p => p.Id == input.Person.EmployeeId.Value);
+ if (!exists)
+ throw Oops.Bah($"关联的员工 ID={input.Person.EmployeeId.Value} 不存在");
+ }
+ else if (!string.IsNullOrWhiteSpace(input.Person.EmployeeName))
+ {
+ // 兼容:即便没有显式 EmployeeIsTemp,前端传了 EmployeeName,我们也可以选择创建员工
+ var newEmp = new Person
+ {
+ Id = YitIdHelper.NextId(),
+ Name = input.Person.EmployeeName.Trim(),
+ };
+ await Context.Insertable(newEmp).ExecuteCommandAsync();
+ createdEmployeeId = newEmp.Id;
+ }
+ else
+ {
+ // 没有绑定员工信息(既不是 temp,也没有 employeeId),则无法继续
+ if (input.Person.Id == null || input.Person.Id <= 0)
+ throw Oops.Bah("家属未关联员工,请选择或新增关联员工");
+ }
+ }
+ else
+ {
+ // 病人是公司员工(IsEmployee == true)
+ // 如果没有 Id,但前端同时将该员工标记为临时新增,或者传了 Name 而无 Id,则创建员工
+ if ((!input.Person.Id.HasValue || input.Person.Id.Value <= 0) &&
+ (!string.IsNullOrWhiteSpace(input.Person.Name) || input.Person.EmployeeIsTemp))
+ {
+ // 如果前端对员工也标记了 EmployeeIsTemp 且提供了 EmployeeName,则优先使用 EmployeeName(兼容性)
+ string empNameForCreate = !string.IsNullOrWhiteSpace(input.Person.Name) ? input.Person.Name.Trim() : input.Person.EmployeeName?.Trim();
+ if (string.IsNullOrWhiteSpace(empNameForCreate))
+ throw Oops.Bah("新增员工时姓名不能为空");
+
+ var newEmp = new Person
+ {
+ Id = YitIdHelper.NextId(),
+ Name = empNameForCreate,
+ Birthday = input.Person.Birthday,
+ Height = input.Person.Height,
+ };
+ await Context.Insertable(newEmp).ExecuteCommandAsync();
+ // 将新创建的员工 id 作为主 person id(病人本身)
+ input.Person.Id = newEmp.Id;
+ }
+ else if (input.Person.Id.HasValue && input.Person.Id.Value > 0)
+ {
+ // 校验存在性
+ var exists = await Context.Queryable().AnyAsync(p => p.Id == input.Person.Id.Value);
+ if (!exists)
+ throw Oops.Bah($"指定的人员 ID={input.Person.Id.Value} 不存在");
+ }
+ }
+
+ // ---------- 2. 确定主 personId(如果是临时创建的员工, input.Person.Id 已在上一步设置) ----------
+ long personId;
+ if (input.Person.Id.HasValue && input.Person.Id.Value > 0)
+ {
+ personId = input.Person.Id.Value;
+ // 已存在的人员(或上一步创建的员工),我们仍然可以继续使用 Storageable 更新信息
+ }
+ else
+ {
+ // 没有 Id,需新建主人员(可能是家属或员工)
+ if (string.IsNullOrWhiteSpace(input.Person.Name))
+ throw Oops.Bah("新增人员信息不完整,姓名为必填项");
+
+ personId = YitIdHelper.NextId();
+ }
+
+ // ---------- 3. 保存/更新主人员信息(使用 Storageable,兼容插入或更新) ----------
+ var mappedEmployeeId = input.Person.EmployeeId;
+
+ // 如果之前创建了员工(createdEmployeeId),优先使用该 id 作为家属的 EmployeeId
+ if (createdEmployeeId.HasValue)
+ mappedEmployeeId = createdEmployeeId.Value;
+
+ // 如果 person.IsEmployee == true,则 person.EmployeeId 应为 null(员工不需要关联员工)
+ if (input.Person.IsEmployee)
+ mappedEmployeeId = null;
+
+ var person = new Person
+ {
+ Id = personId,
+ Name = input.Person?.Name,
+ Birthday = input.Person?.Birthday,
+ Height = input.Person?.Height,
+ RelationShip = input.Person?.RelationShip,
+ EmployeeId = mappedEmployeeId
+ };
+ await Context.Storageable(person).ExecuteCommandAsync();
+
+ // ---------- 4. 处方保存/编辑逻辑(沿用原逻辑) ----------
+ Prescription prescription;
+ if (input.Id.HasValue) // 编辑
+ {
+ prescription = await Context.Queryable()
+ .FirstAsync(p => p.Id == input.Id.Value);
+
+ if (prescription == null)
+ throw Oops.Bah("处方不存在");
+
+ if (prescription.CreateTime.Value.Date != DateTime.Now.Date)
+ throw Oops.Bah("只能编辑当天的处方");
+
+ // 查询原有消耗记录并恢复库存
+ var oldHerbs = await Context.Queryable()
+ .Where(ph => ph.PrescriptionId == input.Id.Value)
+ .ToListAsync();
+
+ if (oldHerbs.Count > 0)
+ {
+ foreach (var g in oldHerbs.GroupBy(x => x.MedicinalId))
+ {
+ // 恢复库存(加回已消耗)
+ // 注意:使用 Updateable 批量操作替换为 SetColumns 表达式累加数值
+ await Context.Updateable()
+ .SetColumns(m => new Medicinal { Number = m.Number + g.Sum(x => x.AmountG) })
+ .Where(m => m.Id == g.Key)
+ .ExecuteCommandAsync();
+ }
+ }
+
+ // 删除原有处方药材(物理删除或软删按你系统策略)
+ await Context.Deleteable()
+ .Where(ph => ph.PrescriptionId == input.Id.Value)
+ .ExecuteCommandAsync();
+
+ // 更新处方
+ prescription.PersonId = personId;
+ prescription.Weight = input.Person.Weight;
+ prescription.DiagnosisResult = input.DiagnosisResult;
+ prescription.UserMedicinaAdvice = input.UserMedicinaAdvice;
+ prescription.VisitDate = input.VisitDate ?? DateTime.Now;
+ await Context.Updateable(prescription).ExecuteCommandAsync();
+ }
+ else // 新增
+ {
+ var prescripId = YitIdHelper.NextId();
+ prescription = new Prescription
+ {
+ Id = prescripId,
+ Weight = input.Person.Weight,
+ PersonId = personId,
+ DiagnosisResult = input.DiagnosisResult,
+ UserMedicinaAdvice = input.UserMedicinaAdvice,
+ VisitDate = input.VisitDate ?? DateTime.Now,
+ CreateTime = DateTime.Now // 新增时设置创建时间
+ };
+ await Context.Insertable(prescription).ExecuteCommandAsync();
+ input.Id = prescripId;
+ }
+
+ // ---------- 5. 校验库存 & 扣减 & 插入消耗记录 ----------
+ var herbIds = input.Herbs.Select(h => h.Id).ToList();
+ var medicinalList = await Context.Queryable()
+ .Where(m => herbIds.Contains(m.Id))
+ .ToListAsync();
+ List HerbsId = new List();
+ foreach (var herb in input.Herbs)
+ {
+ var medicinal = medicinalList.FirstOrDefault(m => m.Id == herb.Id);
+ if (medicinal == null)
+ throw Oops.Bah($"药材[{herb.Id}]不存在");
+ if (herb.AmountG<=0)
+ throw Oops.Bah($"请填写正确的消耗量,药材[{medicinal.MedicinalName}]");
+ if (medicinal.Number < herb.AmountG)
+ throw Oops.Bah($"药材[{medicinal.MedicinalName}]库存不足,当前库存: {medicinal.Number}g,需要: {herb.AmountG}g");
+ if(HerbsId.Contains(herb.Id)) throw Oops.Bah($"请勿重复添加同一个药材【{medicinal.MedicinalName}】");
+ HerbsId.Add(herb.Id);
+ medicinal.Number -= herb.AmountG;
+ }
+
+ // 批量更新药材库存
+ await Context.Updateable(medicinalList).ExecuteCommandAsync();
+
+ // 批量插入处方药材
+ var prescriptionHerbs = input.Herbs.Select(h => new PrescriptionHerb
+ {
+ PrescriptionId = input.Id.Value,
+ MedicinalId = h.Id,
+ AmountG = h.AmountG,
+ Note = h.Note
+ }).ToList();
+ await Context.Insertable(prescriptionHerbs).ExecuteCommandAsync();
+
+ await Context.Ado.CommitTranAsync();
+ return input.Id.Value;
+ }
+ catch
+ {
+ await Context.Ado.RollbackTranAsync();
+ throw;
+ }
+ }
+
+ ///
+ /// 获取 人员下拉
+ ///
+ ///
+ ///
+ ///
+ public async Task> GetPersonList(PersonType? type, long? employeeId)
+ {
+ var query = Context.Queryable();
+
+ // 筛选员工或家属
+ if (type.HasValue)
+ {
+ if (type == PersonType.Employee)
+ {
+ query = query.Where(pe => pe.EmployeeId == null);
+ }
+ else if (type == PersonType.Relative && employeeId.HasValue)
+ {
+ query = query.Where(pe => pe.EmployeeId == employeeId);
+ }
+ }
+
+ return await query.Select(pe => new PersonDto
+ {
+ Id = pe.Id,
+ Name = pe.Name,
+ Birthday = pe.Birthday,
+ Height = pe.Height,
+ RelationShip = pe.RelationShip
+ }).ToListAsync();
+ }
+ ///
+ /// 获取关系下拉
+ ///
+ ///
+ public async Task> GetRelationTypes()
+ {
+ var sysmodel = await Context.Queryable().FirstAsync(a => a.DictValue == "Relation");
+ if (sysmodel != null)
+ {
+ return await Context.Queryable().Where(a => a.ParentId == sysmodel.Id).Select(pe => new RelationTypeDto
+ {
+ Id = int.Parse(pe.DictValue),
+ Name = pe.DictLabel,
+ }).ToListAsync();
+ }
+ else
+ {
+ return new List
+ {
+ new RelationTypeDto { Id = 1, Name = "配偶" },
+ new RelationTypeDto { Id = 2, Name = "子女" },
+ new RelationTypeDto { Id = 3, Name = "父母" },
+ new RelationTypeDto { Id = 4, Name = "兄弟姐妹" },
+ new RelationTypeDto { Id = 5, Name = "其他" }
+ };
+ }
+ }
+}
diff --git a/SimpleAdmin.Application/SimpleAdmin.Application.csproj b/SimpleAdmin.Application/SimpleAdmin.Application.csproj
new file mode 100644
index 0000000..d7bd53a
--- /dev/null
+++ b/SimpleAdmin.Application/SimpleAdmin.Application.csproj
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
+
diff --git a/SimpleAdmin.Application/SimpleAdmin.Application.xml b/SimpleAdmin.Application/SimpleAdmin.Application.xml
new file mode 100644
index 0000000..7a5bfee
--- /dev/null
+++ b/SimpleAdmin.Application/SimpleAdmin.Application.xml
@@ -0,0 +1,838 @@
+
+
+
+ SimpleAdmin.Application
+
+
+
+
+ 机构
+
+
+
+
+ 岗位
+
+
+
+
+ 代码生成基础
+
+
+
+
+ 姓名
+
+
+
+
+ 性别
+
+
+
+
+ 民族
+
+
+
+
+ 年龄
+
+
+
+
+ 生日
+
+
+
+
+ 存款
+
+
+
+
+ 排序码
+
+
+
+
+ 药材
+
+
+
+
+ 数量(g)
+
+
+
+
+ 药材关联id
+
+
+
+
+ 添加重量(g)
+
+
+
+
+ 药材单价
+
+
+
+
+ 总价
+
+
+
+
+ 若非空,表示此 person 是某员工的家属
+
+
+
+ 单位 cm,保留两位小数
+
+
+ 单位 kg,保留两位小数
+
+
+ 消耗克数,单位 g
+
+
+
+ 系统配置
+
+
+
+
+ 未找到下拉框的时候传这个值代表添加新的药材
+
+
+
+
+ 获取药材列表,带筛选
+
+ 药材名称筛选
+ 页码
+ 页大小
+
+
+
+
+ 获取药材消耗记录
+
+ 药材ID
+
+
+
+
+ 获取药材下拉
+
+
+
+
+
+ 获取药材添加记录
+
+ 药材ID
+
+
+
+
+ 添加药材
+
+ 添加信息
+
+
+
+
+ 修改药材添加记录(仅当天可修改)
+
+ 记录ID
+ 修改信息
+
+
+
+
+ 删除药材添加记录(仅当天可删除)
+
+ 记录ID
+
+
+
+
+ 关联的员工名称
+
+
+
+
+ 当前关联的员工是否是前端临时新增(需要后端创建)
+
+
+
+
+ 当 EmployeeIsTemp 为 true 或者前端直接传了员工名字时,后端可用此字段创建员工
+
+
+
+
+ 获取处方列表,带筛选
+
+ 筛选条件
+
+
+
+
+ 获取处方详情
+
+ 处方ID
+
+
+
+
+ 保存处方(新增或编辑)
+
+ 处方信息
+
+
+
+
+ 获取人员列表(员工和家属)
+
+ 人员类型
+ 员工ID(用于获取家属)
+
+
+
+
+ 获取所有关系类型(写死在代码中)
+
+
+
+
+
+ 机构服务
+
+
+
+
+ 添加机构
+
+ 添加参数
+
+
+
+
+ 复制机构
+
+ 机构复制参数
+
+
+
+
+ 删除机构
+
+ 删除参数
+
+
+
+
+ 编辑机构
+
+ 编辑参数
+
+
+
+
+ 机构分页查询
+
+ 查询参数
+ 分页信息
+
+
+
+ 机构树结构
+
+ 机构选择器
+
+
+
+
+ 机构详情
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 检查输入参数
+
+ 参数
+ 操作名称
+
+
+
+ 岗位管理
+
+
+
+
+ 添加岗位
+
+ 添加参数
+
+
+
+
+ 删除岗位
+
+ id列表
+
+
+
+
+ 编辑岗位
+
+ 编辑参数
+
+
+
+
+ 岗位分页查询
+
+ 查询参数
+ 分页列表
+
+
+
+ 岗位选择器
+
+
+
+
+
+
+ 岗位详情
+
+
+
+
+
+
+ 岗位树形结构
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 检查输入参数
+
+ 参数
+ 操作名称
+
+
+
+ 角色拥有资源
+
+ 角色id
+ 资源类型
+ 角色拥有资源信息
+
+
+
+ 获取角色下的用户
+
+ 角色ID
+
+
+
+
+ 分页查询角色
+
+ 查询参数
+
+
+
+
+ 角色选择器
+
+
+
+
+
+
+ 获取角色树
+
+ 角色树
+
+
+
+
+ 角色详情
+
+ 角色Id
+
+
+
+
+ 资源树选择器
+
+
+
+
+
+ 添加角色
+
+ 添加参数
+
+
+
+
+ 编辑角色
+
+ 编辑参数
+
+
+
+
+ 给角色授权
+
+ 授权参数
+
+
+
+
+ 给角色授权用户
+
+ 授权信息
+
+
+
+
+ 删除角色
+
+ 删除参数
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 检查输入参数
+
+
+
+
+
+ 获取授权菜单
+
+ 模块Id
+ 拥有菜单列表
+ 拥有权限按钮列表
+
+
+
+
+ 业务用户导入
+
+
+
+
+ 业务用户导出
+
+
+
+
+ 人员管理服务
+
+
+
+
+ 人员选择器
+
+ 查询参数
+ 人员列表
+
+
+
+ 用户分页查询
+
+ 查询参数
+ 用户分页列表
+
+
+
+ 获取用户拥有角色
+
+ 用户ID
+
+
+
+
+ 角色选择器
+
+
+
+
+
+
+ 人员详情
+
+
+
+
+
+
+ 添加用户
+
+ 添加参数
+
+
+
+
+ 编辑
+
+ 编辑参数
+
+
+
+
+ 禁用用户
+
+ 用户Id
+
+
+
+
+ 启用用户
+
+ 用户Id
+
+
+
+
+ 重置密码
+
+ 用户Id
+
+
+
+
+ 给用户授权角色
+
+ 授权参数
+
+
+
+
+ 删除用户
+
+ Id列表
+
+
+
+
+ 导入预览
+
+ 导入参数
+
+
+
+
+ 获取导入模板
+
+
+
+
+
+ 导出
+
+ 查询参数
+
+
+
+
+ 导入数据
+
+ 数据
+ 导入结果
+
+
+
+ 批量编辑
+
+ 编辑字段信息
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 检查输入参数
+
+
+ 操作类型
+
+
+
+ 检查输入参数
+
+ 用户ID
+ 操作
+
+
+
+ 检查导入数据
+
+ 数据
+ 数据范围ID数组
+ 是否初始化错误
+
+
+
+
+ 获取查询条件
+
+
+
+
+
+
+ AppStartup启动类
+
+
+
+
+ ConfigureServices中不能解析服务,比如App.GetService(),尤其是不能在ConfigureServices中获取诸如缓存等数据进行初始化,应该在Configure中进行
+ 服务都还没初始化完成,会导致内存中存在多份 IOC 容器!!
+ 正确应该在 Configure 中,这个时候服务(IServiceCollection 已经完成 BuildServiceProvider() 操作了
+
+
+
+
+
+ 获取药材下拉
+
+
+
+
+
+
+ 获取药材添加记录
+
+
+
+
+
+
+ 添加药材
+
+
+
+
+
+
+ 修改药材添加记录
+
+
+
+
+
+
+
+
+ 删除药材添加记录
+
+
+
+
+
+
+
+ 批量计算:使用成本、剩余价值、总使用量(先进先出法)
+
+ 需要计算的药材ID列表
+
+
+
+ 获取药材FIFO计算所需的基础数据(入库记录)
+
+
+
+
+ 按FIFO规则计算单种药材的使用成本
+
+
+
+
+ 获取处方详情
+
+
+
+
+
+
+
+ 添加编辑处方记录
+
+
+
+
+
+
+ 获取 人员下拉
+
+
+
+
+
+
+
+ 获取关系下拉
+
+
+
+
+
diff --git a/SimpleAdmin.Application/Startup.cs b/SimpleAdmin.Application/Startup.cs
new file mode 100644
index 0000000..f20b884
--- /dev/null
+++ b/SimpleAdmin.Application/Startup.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Application;
+
+///
+/// AppStartup启动类
+///
+public class Startup : AppStartup
+{
+ ///
+ /// ConfigureServices中不能解析服务,比如App.GetService(),尤其是不能在ConfigureServices中获取诸如缓存等数据进行初始化,应该在Configure中进行
+ /// 服务都还没初始化完成,会导致内存中存在多份 IOC 容器!!
+ /// 正确应该在 Configure 中,这个时候服务(IServiceCollection 已经完成 BuildServiceProvider() 操作了
+ ///
+ ///
+ public void ConfigureServices(IServiceCollection services)
+ {
+ //业务配置转实体
+ services.AddConfigurableOptions();
+ }
+
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+ {
+ var fullName = Assembly.GetExecutingAssembly().FullName;//获取程序集全名
+ //通过 App.GetOptions 获取选项
+ var settings = App.GetOptions();
+ CodeFirstUtils.CodeFirst(settings, fullName);//CodeFirst
+ }
+}
diff --git a/SimpleAdmin.Cache/Cache.Development.json b/SimpleAdmin.Cache/Cache.Development.json
new file mode 100644
index 0000000..a136f90
--- /dev/null
+++ b/SimpleAdmin.Cache/Cache.Development.json
@@ -0,0 +1,12 @@
+{
+ //缓存设置
+ "CacheSettings": {
+ "UseRedis": false, //启用redis
+ "RedisSettings": {
+ "Address": "127.0.0.1:6379", //地址
+ "Password": "123456", //Redis服务密码
+ "Db": 9, //默认库
+ "ClearRedis": true //是否每次启动都清除Redis缓存
+ }
+ }
+}
\ No newline at end of file
diff --git a/SimpleAdmin.Cache/Cache.Production.json b/SimpleAdmin.Cache/Cache.Production.json
new file mode 100644
index 0000000..a136f90
--- /dev/null
+++ b/SimpleAdmin.Cache/Cache.Production.json
@@ -0,0 +1,12 @@
+{
+ //缓存设置
+ "CacheSettings": {
+ "UseRedis": false, //启用redis
+ "RedisSettings": {
+ "Address": "127.0.0.1:6379", //地址
+ "Password": "123456", //Redis服务密码
+ "Db": 9, //默认库
+ "ClearRedis": true //是否每次启动都清除Redis缓存
+ }
+ }
+}
\ No newline at end of file
diff --git a/SimpleAdmin.Cache/GlobalUsing.cs b/SimpleAdmin.Cache/GlobalUsing.cs
new file mode 100644
index 0000000..0b4bbe1
--- /dev/null
+++ b/SimpleAdmin.Cache/GlobalUsing.cs
@@ -0,0 +1,19 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+global using MoYu;
+global using Masuit.Tools;
+global using Microsoft.AspNetCore.Builder;
+global using Microsoft.AspNetCore.Hosting;
+global using Microsoft.Extensions.DependencyInjection;
+global using NewLife.Caching;
+global using NewLife.Serialization;
+global using SimpleAdmin.Core;
+global using SimpleRedis;
diff --git a/SimpleAdmin.Cache/Interface/ISimpleCacheHashService.cs b/SimpleAdmin.Cache/Interface/ISimpleCacheHashService.cs
new file mode 100644
index 0000000..5b3452c
--- /dev/null
+++ b/SimpleAdmin.Cache/Interface/ISimpleCacheHashService.cs
@@ -0,0 +1,70 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Cache;
+
+///
+/// 缓存服务
+///
+public partial interface ISimpleCacheService
+{
+ ///
+ /// 添加一条数据到HashMap
+ ///
+ ///
+ /// 键
+ /// hash列表里的Key
+ /// 值
+ void HashAdd(string key, string hashKey, T value);
+
+ ///
+ /// 添加多条数据到HashMap
+ ///
+ ///
+ /// 键
+ /// 键值对字典
+ ///
+ bool HashSet(string key, Dictionary dic);
+
+ ///
+ /// 从HashMap中删除数据
+ ///
+ ///
+ /// 键
+ /// hash键列表
+ /// 执行结果
+ int HashDel(string key, params string[] fields);
+
+ ///
+ /// 根据键获取hash列表中的值
+ ///
+ ///
+ /// 键
+ /// hash键列表
+ /// 数据列表
+ List HashGet(string key, params string[] fields);
+
+ ///
+ /// 根据键获取hash列表中的值
+ ///
+ ///
+ /// 键
+ /// hash键
+ ///
+ T HashGetOne(string key, string field);
+
+ ///
+ /// 获取所有键值对
+ ///
+ ///
+ /// 键
+ /// 数据字典
+ IDictionary HashGetAll(string key);
+}
diff --git a/SimpleAdmin.Cache/Interface/ISimpleCacheQueueService.cs b/SimpleAdmin.Cache/Interface/ISimpleCacheQueueService.cs
new file mode 100644
index 0000000..de157c7
--- /dev/null
+++ b/SimpleAdmin.Cache/Interface/ISimpleCacheQueueService.cs
@@ -0,0 +1,108 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using NewLife.Caching.Queues;
+
+namespace SimpleAdmin.Cache;
+
+///
+/// 缓存服务
+///
+public partial interface ISimpleCacheService
+{
+ #region 普通队列
+
+ ///
+ /// 添加到队列
+ ///
+ ///
+ /// 键
+ /// 值数组
+ /// 添加数量
+ int AddQueue(string key, T[] value);
+
+ ///
+ /// 添加到队列
+ ///
+ ///
+ /// 键
+ /// 值
+ /// 添加数量
+ int AddQueue(string key, T value);
+
+ ///
+ /// 获取队列实例
+ ///
+ ///
+ /// 键
+ /// 队列实例
+ RedisQueue GetRedisQueue(string key);
+
+ ///
+ /// 从队列中获取数据
+ ///
+ ///
+ /// 键
+ /// 数量
+ /// 数据列表
+ List GetQueue(string key, int Count = 1);
+
+ ///
+ /// 取一条数据
+ ///
+ ///
+ /// 键
+ /// 阻塞时间
+ /// 数据
+ T GetQueueOne(string key, int timeout = 1);
+
+ ///
+ /// 异步取一条数据
+ ///
+ ///
+ /// 键
+ /// 阻塞时间
+ /// 数据
+ Task GetQueueOneAsync(string key, int timeout = 1);
+
+ #endregion
+
+ #region 延迟队列
+
+ ///
+ /// 添加一条数据到延迟队列
+ ///
+ ///
+ /// 键
+ /// 值
+ /// 延迟时间
+ /// 添加成功数量
+ int AddDelayQueue(string key, T value, int delay);
+
+ ///
+ /// 批量添加数据到延迟队列
+ ///
+ ///
+ /// 键
+ /// 值
+ /// 延迟时间
+ /// 添加成功数量
+ int AddDelayQueue(string key, List value, int delay);
+
+ ///
+ /// 获取延迟队列实例
+ ///
+ ///
+ /// 键
+ ///
+ RedisDelayQueue GetDelayQueue(string key);
+
+ #endregion
+}
diff --git a/SimpleAdmin.Cache/Interface/ISimpleCacheService.cs b/SimpleAdmin.Cache/Interface/ISimpleCacheService.cs
new file mode 100644
index 0000000..7299aed
--- /dev/null
+++ b/SimpleAdmin.Cache/Interface/ISimpleCacheService.cs
@@ -0,0 +1,191 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Cache;
+
+///
+/// 缓存服务
+///
+public partial interface ISimpleCacheService
+{
+ #region 基础操作
+
+ /// 是否包含缓存项
+ ///
+ ///
+ bool ContainsKey(string key);
+
+ /// 设置缓存项
+ /// 键
+ /// 值
+ /// 过期时间,秒。小于0时采用默认缓存时间
+ ///
+ bool Set(string key, T value, int expire = -1);
+
+ /// 设置缓存项
+ /// 键
+ /// 值
+ /// 过期时间
+ ///
+ bool Set(string key, T value, TimeSpan expire);
+
+ /// 获取缓存项
+ /// 键
+ ///
+ T Get(string key);
+
+ /// 批量移除缓存项
+ /// 键集合
+ ///
+ int Remove(params string[] keys);
+
+ /// 清空所有缓存项
+ void Clear();
+
+ /// 设置缓存项有效期
+ /// 键
+ /// 过期时间
+ bool SetExpire(string key, TimeSpan expire);
+
+ /// 获取缓存项有效期
+ /// 键
+ ///
+ TimeSpan GetExpire(string key);
+
+ ///
+ /// 模糊删除
+ ///
+ /// 匹配关键字
+ void DelByPattern(string pattern);
+
+ #endregion 基础操作
+
+ #region 集合操作
+
+ /// 批量获取缓存项
+ ///
+ ///
+ ///
+ IDictionary GetAll(IEnumerable keys);
+
+ /// 批量设置缓存项
+ ///
+ ///
+ /// 过期时间,秒。小于0时采用默认缓存时间
+ void SetAll(IDictionary values, int expire = -1);
+
+ /// 获取列表
+ /// 元素类型
+ /// 键
+ ///
+ IList GetList(string key);
+
+ /// 获取哈希
+ /// 元素类型
+ /// 键
+ ///
+ IDictionary GetDictionary(string key);
+
+ /// 获取队列
+ /// 元素类型
+ /// 键
+ ///
+ IProducerConsumer GetQueue(string key);
+
+ /// 获取栈
+ /// 元素类型
+ /// 键
+ ///
+ IProducerConsumer GetStack(string key);
+
+ /// 获取Set
+ ///
+ ///
+ ///
+ ICollection GetSet(string key);
+
+ #endregion 集合操作
+
+ #region 高级操作
+
+ /// 添加,已存在时不更新
+ /// 值类型
+ /// 键
+ /// 值
+ /// 过期时间,秒。小于0时采用默认缓存时间
+ ///
+ bool Add(string key, T value, int expire = -1);
+
+ /// 设置新值并获取旧值,原子操作
+ ///
+ /// 常常配合Increment使用,用于累加到一定数后重置归零,又避免多线程冲突。
+ ///
+ /// 值类型
+ /// 键
+ /// 值
+ ///
+ T Replace(string key, T value);
+
+ /// 尝试获取指定键,返回是否包含值。有可能缓存项刚好是默认值,或者只是反序列化失败,解决缓存穿透问题
+ /// 值类型
+ /// 键
+ /// 值。即使有值也不一定能够返回,可能缓存项刚好是默认值,或者只是反序列化失败
+ /// 返回是否包含值,即使反序列化失败
+ bool TryGetValue(string key, out T value);
+
+ /// 累加,原子操作
+ /// 键
+ /// 变化量
+ ///
+ long Increment(string key, long value);
+
+ /// 累加,原子操作
+ /// 键
+ /// 变化量
+ ///
+ double Increment(string key, double value);
+
+ /// 递减,原子操作
+ /// 键
+ /// 变化量
+ ///
+ long Decrement(string key, long value);
+
+ /// 递减,原子操作
+ /// 键
+ /// 变化量
+ ///
+ double Decrement(string key, double value);
+
+ #endregion 高级操作
+
+ #region 事务
+
+ /// 提交变更。部分提供者需要刷盘
+ ///
+ int Commit();
+
+ /// 申请分布式锁
+ /// 要锁定的key
+ /// 锁等待时间,单位毫秒
+ ///
+ IDisposable AcquireLock(string key, int msTimeout);
+
+ /// 申请分布式锁
+ /// 要锁定的key
+ /// 锁等待时间,申请加锁时如果遇到冲突则等待的最大时间,单位毫秒
+ /// 锁过期时间,超过该时间如果没有主动释放则自动释放锁,必须整数秒,单位毫秒
+ /// 失败时是否抛出异常,如果不抛出异常,可通过返回null得知申请锁失败
+ ///
+ IDisposable AcquireLock(string key, int msTimeout, int msExpire,
+ bool throwOnFailure);
+
+ #endregion 事务
+}
diff --git a/SimpleAdmin.Cache/Options/CacheSettingsOptions.cs b/SimpleAdmin.Cache/Options/CacheSettingsOptions.cs
new file mode 100644
index 0000000..380d26c
--- /dev/null
+++ b/SimpleAdmin.Cache/Options/CacheSettingsOptions.cs
@@ -0,0 +1,55 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using MoYu.ConfigurableOptions;
+
+namespace SimpleAdmin.Cache;
+
+///
+/// 缓存设置
+///
+public class CacheSettingsOptions : IConfigurableOptions
+{
+ ///
+ /// 使用Redis
+ ///
+ public bool UseRedis { get; set; }
+
+ ///
+ /// Redis设置
+ ///
+ public RedisSettings RedisSettings { get; set; }
+}
+
+///
+/// Redis设置
+///
+public class RedisSettings
+{
+ ///
+ /// 连接地址
+ ///
+ public string Address { get; set; }
+
+ ///
+ /// 密码
+ ///
+ public string Password { get; set; }
+
+ ///
+ /// 数据库
+ ///
+ public int Db { get; set; } = 0;
+
+ ///
+ /// 是否每次启动都清空
+ ///
+ public bool ClearRedis { get; set; } = false;
+}
diff --git a/SimpleAdmin.Cache/Service/MemoryCacheHashService.cs b/SimpleAdmin.Cache/Service/MemoryCacheHashService.cs
new file mode 100644
index 0000000..0b2f8fe
--- /dev/null
+++ b/SimpleAdmin.Cache/Service/MemoryCacheHashService.cs
@@ -0,0 +1,98 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Cache;
+
+///
+///
+/// 内存缓存
+///
+public partial class MemoryCacheService
+{
+ ///
+ public void HashAdd(string key, string hashKey, T value)
+ {
+ //获取字典
+ var exist = _memoryCache.GetDictionary(key);
+ if (exist.ContainsKey(hashKey))//如果包含Key
+ exist[hashKey] = value;//重新赋值
+ else exist.TryAdd(hashKey, value);//加上新的值
+ _memoryCache.Set(key, exist);
+ }
+
+ //private IDictionary GetDictionary(string key,string)
+
+ ///
+ public bool HashSet(string key, Dictionary dic)
+ {
+ //获取字典
+ var exist = _memoryCache.GetDictionary(key);
+ dic.ForEach(it =>
+ {
+ if (exist.ContainsKey(it.Key))//如果包含Key
+ exist[it.Key] = it.Value;//重新赋值
+ else exist.Add(it.Key, it.Value);//加上新的值
+ });
+
+ return true;
+ }
+
+ ///
+ public int HashDel(string key, params string[] fields)
+ {
+ var result = 0;
+ //获取字典
+ var exist = _memoryCache.GetDictionary(key);
+ foreach (var field in fields)
+ {
+ if (field != null && exist.ContainsKey(field))//如果包含Key
+ {
+ exist.Remove(field);//删除
+ result++;
+ }
+ }
+ return result;
+ }
+
+ ///
+ public List HashGet(string key, params string[] fields)
+ {
+ var list = new List();
+ //获取字典
+ var exist = _memoryCache.GetDictionary(key);
+ foreach (var field in fields)
+ {
+ if (exist.TryGetValue(field, out var value))//如果包含Key
+ {
+ list.Add(value);
+ }
+ else { list.Add(default); }
+ }
+ return list;
+ }
+
+ ///
+ public T HashGetOne(string key, string field)
+ {
+ //获取字典
+ var exist = _memoryCache.GetDictionary(key);
+
+ exist.TryGetValue(field, out var result);
+ var data = result.DeepClone();
+ return data;
+ }
+
+ ///
+ public IDictionary HashGetAll(string key)
+ {
+ var data = _memoryCache.GetDictionary(key);
+ return data;
+ }
+}
diff --git a/SimpleAdmin.Cache/Service/MemoryCacheQueueService.cs b/SimpleAdmin.Cache/Service/MemoryCacheQueueService.cs
new file mode 100644
index 0000000..a1eff51
--- /dev/null
+++ b/SimpleAdmin.Cache/Service/MemoryCacheQueueService.cs
@@ -0,0 +1,74 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+using NewLife.Caching.Queues;
+
+namespace SimpleAdmin.Cache;
+
+///
+///
+/// 内存缓存
+///
+public partial class MemoryCacheService
+{
+ ///
+ public int AddQueue(string key, T[] value)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ public int AddQueue(string key, T value)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ public RedisQueue GetRedisQueue(string key)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ public List GetQueue(string key, int Count = 1)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ public T GetQueueOne(string key, int timeout = 1)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ public async Task GetQueueOneAsync(string key, int timeout = 1)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ public int AddDelayQueue(string key, T value, int delay)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ public int AddDelayQueue(string key, List value, int delay)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ public RedisDelayQueue GetDelayQueue(string key)
+ {
+ throw new NotImplementedException();
+ }
+}
diff --git a/SimpleAdmin.Cache/Service/MemoryCacheService.cs b/SimpleAdmin.Cache/Service/MemoryCacheService.cs
new file mode 100644
index 0000000..40d9074
--- /dev/null
+++ b/SimpleAdmin.Cache/Service/MemoryCacheService.cs
@@ -0,0 +1,229 @@
+// Copyright (c) 2022-Now 少林寺驻北固山办事处大神父王喇嘛
+//
+// SimpleAdmin 基于 Apache License Version 2.0 协议发布,可用于商业项目,但必须遵守以下补充条款:
+// 1.请不要删除和修改根目录下的LICENSE文件。
+// 2.请不要删除和修改SimpleAdmin源码头部的版权声明。
+// 3.分发源码时候,请注明软件出处 https://gitee.com/dotnetmoyu/SimpleAdmin
+// 4.基于本软件的作品,只能使用 SimpleAdmin 作为后台服务,除外情况不可商用且不允许二次分发或开源。
+// 5.请不得将本软件应用于危害国家安全、荣誉和利益的行为,不能以任何形式用于非法为目的的行为。
+// 6.任何基于本软件而产生的一切法律纠纷和责任,均于我司无关。
+
+namespace SimpleAdmin.Cache;
+
+///
+///
+/// 内存缓存
+///
+public partial class MemoryCacheService : ISimpleCacheService
+{
+ private readonly MemoryCache _memoryCache;
+
+ public MemoryCacheService()
+ {
+ _memoryCache = new MemoryCache();
+ }
+
+ #region 普通操作
+
+ ///
+ public T Get(string key)
+ {
+ var data = _memoryCache.Get(key);
+ return data.ToObject();
+ }
+
+ ///
+ public int Remove(params string[] keys)
+ {
+ return _memoryCache.Remove(keys);
+ }
+
+ ///
+ public bool Set(string key, T value, int expire = -1)
+ {
+ return _memoryCache.Set(key, value.ToJson(), expire);
+ }
+
+ ///
+ public bool Set(string key, T value, TimeSpan expire)
+ {
+ return _memoryCache.Set(key, value.ToJson(), expire);
+ }
+
+ ///
+ public bool SetExpire(string key, TimeSpan expire)
+ {
+ return _memoryCache.SetExpire(key, expire);
+ }
+
+ ///
+ public TimeSpan GetExpire(string key)
+ {
+ return _memoryCache.GetExpire(key);
+ }
+
+ ///
+ public bool ContainsKey(string key)
+ {
+ return _memoryCache.ContainsKey(key);
+ }
+
+ ///
+ public void Clear()
+ {
+ _memoryCache.Clear();
+ }
+
+ ///
+ public void DelByPattern(string pattern)
+ {
+ var keys = _memoryCache.Keys.ToList();//获取所有key
+ keys.ForEach(it =>
+ {
+ if (it.Contains(pattern))//如果匹配
+ _memoryCache.Remove(pattern);
+ });
+ }
+
+ #endregion 普通操作
+
+ #region 集合操作
+
+ ///
+ public IDictionary GetAll(IEnumerable keys)
+ {
+ IDictionary? result = default;//定义集合
+ var data = _memoryCache.GetAll(keys);//获取数据
+ data.ForEach(it =>
+ {
+ result.Add(it.Key, it.Value.ToObject());//遍历数据,格式化并加到新的数据集合
+ });
+ return result;
+ }
+
+ ///
+ public void SetAll(IDictionary values, int expire = -1)
+ {
+ IDictionary? result = default;//定义集合
+ values.ForEach(it =>
+ {
+ result.Add(it.Key, it.Value.ToJson());//遍历数据,格式化并加到新的数据集合
+ });
+ _memoryCache.SetAll(values, expire);
+ }
+
+ ///
+ public IDictionary GetDictionary(string key)
+ {
+ IDictionary? result = default;//定义集合
+ var data = _memoryCache.GetDictionary(key);
+ data.ForEach(it =>
+ {
+ result.Add(it.Key, it.Value.ToObject());//遍历数据,格式化并加到新的数据集合
+ });
+ return result;
+ }
+
+ ///
+ public IProducerConsumer GetQueue(string key)
+ {
+ return _memoryCache.GetQueue(key);
+ }
+
+ ///
+ public IProducerConsumer GetStack(string key)
+ {
+ return _memoryCache.GetStack(key);
+ }
+
+ ///
+ public ICollection GetSet(string key)
+ {
+ return _memoryCache.GetSet(key);
+ }
+
+ #endregion 集合操作
+
+ #region 高级操作
+
+ ///