diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/FileController.cs b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/FileController.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/FileController.cs rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/FileController.cs diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/JobController.cs b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/JobController.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/JobController.cs rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/JobController.cs diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MouldController.cs b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/MouldController.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MouldController.cs rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/MouldController.cs diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/SettingController.cs b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/SettingController.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/SettingController.cs rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/SettingController.cs diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/UserController.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Controllers/UserController.cs diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Log4net.config b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Log4net.config similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/Log4net.config rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Log4net.config diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Program.cs b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Program.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/Program.cs rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Program.cs diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Startup.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Startup.cs diff --git a/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/SwaggerDoc.xml b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/SwaggerDoc.xml new file mode 100644 index 00000000..3173de6a --- /dev/null +++ b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/SwaggerDoc.xml @@ -0,0 +1,278 @@ + + + + Yi.Framework.ApiMicroservice + + + + + 登录方法,要返回data:{user,token} token + + + + + + + 不用写,单纯制作日志 + + + + + + code为验证码,从redis中判断一下code是否正确 + + + + + + + + 发送短信,需要将生成的sms+code存入redis + + + + + + + 发送邮箱,需要先到数据库判断该邮箱是否被人注册过,到userservice写mail_exist方法,还有接口别忘了。 + + + + + + + 修改密码 + + + + + + + 该方法不对外暴露 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 这个是要递归的,但是要过滤掉删除的,所以,可以写一个通用过滤掉删除的方法 + + + + + + 更 + + + + + + + 删 + + + + + + + 增 + 现在,top菜单只允许为一个 + + + + + + + 给一个菜单设置一个接口,Id1为菜单id,Id2为接口id + 用于给菜单设置接口 + + + + + + + 给一个菜单添加子节点(注意:添加,不是覆盖) + + + + + + + 获取用户的目录菜单,不包含接口 + 用于账户信息页面,显示这个用户有哪些菜单,需要并列 + + + + + + 更 + + + + + + + 删 + + + + + + + 增 + + + + + + + 更 + + + + + + + 删 + + + + + + + 增 + + + + + + + 根据用户id得到该用户有哪些角色 + 用于显示用户详情中的角色说明 + + + + + + 给角色设置菜单,多个角色与多个菜单,让每一个角色都设置,ids1为角色,ids2为菜单 + 用于设置角色 + + + + + + + 用于给角色设置菜单的时候,点击一个角色,显示这个角色拥有的并列的菜单 + + + + + + + 查 + + + + + + 更 + + + + + + + 查 + + + + + + 更 + + + + + + + 删 + + + + + + + 增 + + + + + + + SetRoleByUser + 给多个用户设置多个角色,ids有用户id与 角色列表ids,多对多,ids1用户,ids2为角色 + 用户设置给用户设置角色 + + + + + + + 根据http上下文的用户得到该用户信息,关联角色 + 用于显示账号信息页中的用户信息和角色信息 + + + + + + 得到登录用户的递归菜单,放到导航栏 + 用户放到导航栏中 + + + + + + 得到请求模型 + + + + + + diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102231510.xlsx b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102231510.xlsx similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102231510.xlsx rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102231510.xlsx diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102232113.xlsx b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102232113.xlsx similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102232113.xlsx rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102232113.xlsx diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/0a5221e4-dca6-4d4e-8486-acf86822f2e4.jpg b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/0a5221e4-dca6-4d4e-8486-acf86822f2e4.jpg similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/0a5221e4-dca6-4d4e-8486-acf86822f2e4.jpg rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/0a5221e4-dca6-4d4e-8486-acf86822f2e4.jpg diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/1b0a926d-ddce-4048-9b09-e2b8ec37c161.jpg b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/1b0a926d-ddce-4048-9b09-e2b8ec37c161.jpg similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/1b0a926d-ddce-4048-9b09-e2b8ec37c161.jpg rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/1b0a926d-ddce-4048-9b09-e2b8ec37c161.jpg diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/3d6ed457-0c20-4ce6-b91c-8c424f2f03bb.jpeg b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/3d6ed457-0c20-4ce6-b91c-8c424f2f03bb.jpeg similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/3d6ed457-0c20-4ce6-b91c-8c424f2f03bb.jpeg rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/3d6ed457-0c20-4ce6-b91c-8c424f2f03bb.jpeg diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/6312706b-7013-4aa5-af3c-0bbb6b3f4804.jpg b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/6312706b-7013-4aa5-af3c-0bbb6b3f4804.jpg similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/6312706b-7013-4aa5-af3c-0bbb6b3f4804.jpg rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/6312706b-7013-4aa5-af3c-0bbb6b3f4804.jpg diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/7ca98a58-8822-40f5-a766-2a2dd21d2431.jpg b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/7ca98a58-8822-40f5-a766-2a2dd21d2431.jpg similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/7ca98a58-8822-40f5-a766-2a2dd21d2431.jpg rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/7ca98a58-8822-40f5-a766-2a2dd21d2431.jpg diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/966200f6-265c-4470-ad20-c91c3d84a1cc.jpg b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/966200f6-265c-4470-ad20-c91c3d84a1cc.jpg similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/966200f6-265c-4470-ad20-c91c3d84a1cc.jpg rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/966200f6-265c-4470-ad20-c91c3d84a1cc.jpg diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/feae1964-04ce-464b-848b-86f2245f3f63.jpeg b/Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/feae1964-04ce-464b-848b-86f2245f3f63.jpeg similarity index 100% rename from Yi.Framework/Yi.Framework.ApiMicroservice/wwwroot/image/feae1964-04ce-464b-848b-86f2245f3f63.jpeg rename to Yi.Framework.Net5/Yi.Framework.ApiMicroservice/wwwroot/image/feae1964-04ce-464b-848b-86f2245f3f63.jpeg diff --git a/Yi.Framework/Yi.Framework.AuthenticationCenter/Controllers/WeatherForecastController.cs b/Yi.Framework.Net5/Yi.Framework.AuthenticationCenter/Controllers/WeatherForecastController.cs similarity index 100% rename from Yi.Framework/Yi.Framework.AuthenticationCenter/Controllers/WeatherForecastController.cs rename to Yi.Framework.Net5/Yi.Framework.AuthenticationCenter/Controllers/WeatherForecastController.cs diff --git a/Yi.Framework/Yi.Framework.AuthenticationCenter/Program.cs b/Yi.Framework.Net5/Yi.Framework.AuthenticationCenter/Program.cs similarity index 100% rename from Yi.Framework/Yi.Framework.AuthenticationCenter/Program.cs rename to Yi.Framework.Net5/Yi.Framework.AuthenticationCenter/Program.cs diff --git a/Yi.Framework/Yi.Framework.AuthenticationCenter/Startup.cs b/Yi.Framework.Net5/Yi.Framework.AuthenticationCenter/Startup.cs similarity index 100% rename from Yi.Framework/Yi.Framework.AuthenticationCenter/Startup.cs rename to Yi.Framework.Net5/Yi.Framework.AuthenticationCenter/Startup.cs diff --git a/Yi.Framework/Yi.Framework.AuthenticationCenter/Yi.Framework.AuthenticationCenter.csproj b/Yi.Framework.Net5/Yi.Framework.AuthenticationCenter/Yi.Framework.AuthenticationCenter.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.AuthenticationCenter/Yi.Framework.AuthenticationCenter.csproj rename to Yi.Framework.Net5/Yi.Framework.AuthenticationCenter/Yi.Framework.AuthenticationCenter.csproj diff --git a/Yi.Framework/Yi.Framework.Common/Const/DbConst.cs b/Yi.Framework.Net5/Yi.Framework.Common/Const/DbConst.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Const/DbConst.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Const/DbConst.cs diff --git a/Yi.Framework/Yi.Framework.Common/Const/FileConst.cs b/Yi.Framework.Net5/Yi.Framework.Common/Const/FileConst.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Const/FileConst.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Const/FileConst.cs diff --git a/Yi.Framework/Yi.Framework.Common/Const/JobConst.cs b/Yi.Framework.Net5/Yi.Framework.Common/Const/JobConst.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Const/JobConst.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Const/JobConst.cs diff --git a/Yi.Framework/Yi.Framework.Common/Const/JwtConst.cs b/Yi.Framework.Net5/Yi.Framework.Common/Const/JwtConst.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Const/JwtConst.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Const/JwtConst.cs diff --git a/Yi.Framework/Yi.Framework.Common/Const/RabbitConst.cs b/Yi.Framework.Net5/Yi.Framework.Common/Const/RabbitConst.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Const/RabbitConst.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Const/RabbitConst.cs diff --git a/Yi.Framework/Yi.Framework.Common/Const/RedisConst.cs b/Yi.Framework.Net5/Yi.Framework.Common/Const/RedisConst.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Const/RedisConst.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Const/RedisConst.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/AssemblyHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/AssemblyHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/AssemblyHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/AssemblyHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/Base32Helper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/Base32Helper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/Base32Helper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/Base32Helper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/ConsoleHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/ConsoleHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/ConsoleHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/ConsoleHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/DateHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/DateHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/DateHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/DateHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/EmailHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/EmailHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/EmailHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/EmailHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/ExcelHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/ExcelHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/ExcelHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/ExcelHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/FileHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/FileHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/FileHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/FileHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/HtmlHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/HtmlHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/HtmlHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/HtmlHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/HttpHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/HttpHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/HttpHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/HttpHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/IpHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/IpHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/IpHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/IpHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/JsonHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/JsonHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/JsonHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/JsonHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/MD5Hepler.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/MD5Hepler.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/MD5Hepler.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/MD5Hepler.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/MimeHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/MimeHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/MimeHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/MimeHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/RSAHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/RSAHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/RSAHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/RSAHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/RandomHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/RandomHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/RandomHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/RandomHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/SerializeHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/SerializeHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/SerializeHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/SerializeHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/SnowflakeHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/SnowflakeHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/SnowflakeHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/SnowflakeHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/StringHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/StringHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/StringHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/StringHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/UnicodeHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/UnicodeHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/UnicodeHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/UnicodeHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/UrlHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/UrlHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/UrlHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/UrlHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/Helper/XmlHelper.cs b/Yi.Framework.Net5/Yi.Framework.Common/Helper/XmlHelper.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Helper/XmlHelper.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Helper/XmlHelper.cs diff --git a/Yi.Framework/Yi.Framework.Common/IOCOptions/ConsulClientOption.cs b/Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/ConsulClientOption.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/IOCOptions/ConsulClientOption.cs rename to Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/ConsulClientOption.cs diff --git a/Yi.Framework/Yi.Framework.Common/IOCOptions/ConsulRegisterOption.cs b/Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/ConsulRegisterOption.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/IOCOptions/ConsulRegisterOption.cs rename to Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/ConsulRegisterOption.cs diff --git a/Yi.Framework/Yi.Framework.Common/IOCOptions/ElasticSearchOptions.cs b/Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/ElasticSearchOptions.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/IOCOptions/ElasticSearchOptions.cs rename to Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/ElasticSearchOptions.cs diff --git a/Yi.Framework/Yi.Framework.Common/IOCOptions/JWTTokenOptions.cs b/Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/JWTTokenOptions.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/IOCOptions/JWTTokenOptions.cs rename to Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/JWTTokenOptions.cs diff --git a/Yi.Framework/Yi.Framework.Common/IOCOptions/KafkaOptions.cs b/Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/KafkaOptions.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/IOCOptions/KafkaOptions.cs rename to Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/KafkaOptions.cs diff --git a/Yi.Framework/Yi.Framework.Common/IOCOptions/MySqlConnOptions.cs b/Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/MySqlConnOptions.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/IOCOptions/MySqlConnOptions.cs rename to Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/MySqlConnOptions.cs diff --git a/Yi.Framework/Yi.Framework.Common/IOCOptions/RabbitMQOptions.cs b/Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/RabbitMQOptions.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/IOCOptions/RabbitMQOptions.cs rename to Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/RabbitMQOptions.cs diff --git a/Yi.Framework/Yi.Framework.Common/IOCOptions/RedisConnOptions.cs b/Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/RedisConnOptions.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/IOCOptions/RedisConnOptions.cs rename to Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/RedisConnOptions.cs diff --git a/Yi.Framework/Yi.Framework.Common/IOCOptions/SMSOptions.cs b/Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/SMSOptions.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/IOCOptions/SMSOptions.cs rename to Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/SMSOptions.cs diff --git a/Yi.Framework/Yi.Framework.Common/IOCOptions/SqliteOptions.cs b/Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/SqliteOptions.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/IOCOptions/SqliteOptions.cs rename to Yi.Framework.Net5/Yi.Framework.Common/IOCOptions/SqliteOptions.cs diff --git a/Yi.Framework/Yi.Framework.Common/Models/AxiosUrlsModel.cs b/Yi.Framework.Net5/Yi.Framework.Common/Models/AxiosUrlsModel.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Models/AxiosUrlsModel.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Models/AxiosUrlsModel.cs diff --git a/Yi.Framework/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs b/Yi.Framework.Net5/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs diff --git a/Yi.Framework/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs b/Yi.Framework.Net5/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs diff --git a/Yi.Framework/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs b/Yi.Framework.Net5/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs diff --git a/Yi.Framework/Yi.Framework.Common/Models/Enum/TopFlagEnum.cs b/Yi.Framework.Net5/Yi.Framework.Common/Models/Enum/TopFlagEnum.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Models/Enum/TopFlagEnum.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Models/Enum/TopFlagEnum.cs diff --git a/Yi.Framework/Yi.Framework.Common/Models/Enum/WriteAndReadEnum.cs b/Yi.Framework.Net5/Yi.Framework.Common/Models/Enum/WriteAndReadEnum.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Models/Enum/WriteAndReadEnum.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Models/Enum/WriteAndReadEnum.cs diff --git a/Yi.Framework/Yi.Framework.Common/Models/JobModel.cs b/Yi.Framework.Net5/Yi.Framework.Common/Models/JobModel.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Models/JobModel.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Models/JobModel.cs diff --git a/Yi.Framework/Yi.Framework.Common/Models/LogModel.cs b/Yi.Framework.Net5/Yi.Framework.Common/Models/LogModel.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Models/LogModel.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Models/LogModel.cs diff --git a/Yi.Framework/Yi.Framework.Common/Models/PageModel.cs b/Yi.Framework.Net5/Yi.Framework.Common/Models/PageModel.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Models/PageModel.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Models/PageModel.cs diff --git a/Yi.Framework/Yi.Framework.Common/Models/Result.cs b/Yi.Framework.Net5/Yi.Framework.Common/Models/Result.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Models/Result.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Models/Result.cs diff --git a/Yi.Framework/Yi.Framework.Common/Models/SwaggerModel.cs b/Yi.Framework.Net5/Yi.Framework.Common/Models/SwaggerModel.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Models/SwaggerModel.cs rename to Yi.Framework.Net5/Yi.Framework.Common/Models/SwaggerModel.cs diff --git a/Yi.Framework/Yi.Framework.Common/QueueModel/OrderCreateQueueModel.cs b/Yi.Framework.Net5/Yi.Framework.Common/QueueModel/OrderCreateQueueModel.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/QueueModel/OrderCreateQueueModel.cs rename to Yi.Framework.Net5/Yi.Framework.Common/QueueModel/OrderCreateQueueModel.cs diff --git a/Yi.Framework/Yi.Framework.Common/QueueModel/SKUWarmupQueueModel.cs b/Yi.Framework.Net5/Yi.Framework.Common/QueueModel/SKUWarmupQueueModel.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/QueueModel/SKUWarmupQueueModel.cs rename to Yi.Framework.Net5/Yi.Framework.Common/QueueModel/SKUWarmupQueueModel.cs diff --git a/Yi.Framework/Yi.Framework.Common/QueueModel/SMSQueueModel.cs b/Yi.Framework.Net5/Yi.Framework.Common/QueueModel/SMSQueueModel.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/QueueModel/SMSQueueModel.cs rename to Yi.Framework.Net5/Yi.Framework.Common/QueueModel/SMSQueueModel.cs diff --git a/Yi.Framework/Yi.Framework.Common/QueueModel/SPUCQRSQueueModel.cs b/Yi.Framework.Net5/Yi.Framework.Common/QueueModel/SPUCQRSQueueModel.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Common/QueueModel/SPUCQRSQueueModel.cs rename to Yi.Framework.Net5/Yi.Framework.Common/QueueModel/SPUCQRSQueueModel.cs diff --git a/Yi.Framework/Yi.Framework.Common/Yi.Framework.Common.csproj b/Yi.Framework.Net5/Yi.Framework.Common/Yi.Framework.Common.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.Common/Yi.Framework.Common.csproj rename to Yi.Framework.Net5/Yi.Framework.Common/Yi.Framework.Common.csproj diff --git a/Yi.Framework/Yi.Framework.Core/CacheClientDB.cs b/Yi.Framework.Net5/Yi.Framework.Core/CacheClientDB.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Core/CacheClientDB.cs rename to Yi.Framework.Net5/Yi.Framework.Core/CacheClientDB.cs diff --git a/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/AbstractConsulDispatcher.cs b/Yi.Framework.Net5/Yi.Framework.Core/ConsulExtend/ClienExtend/AbstractConsulDispatcher.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/AbstractConsulDispatcher.cs rename to Yi.Framework.Net5/Yi.Framework.Core/ConsulExtend/ClienExtend/AbstractConsulDispatcher.cs diff --git a/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/AverageDispatcher.cs b/Yi.Framework.Net5/Yi.Framework.Core/ConsulExtend/ClienExtend/AverageDispatcher.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/AverageDispatcher.cs rename to Yi.Framework.Net5/Yi.Framework.Core/ConsulExtend/ClienExtend/AverageDispatcher.cs diff --git a/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/PollingDispatcher.cs b/Yi.Framework.Net5/Yi.Framework.Core/ConsulExtend/ClienExtend/PollingDispatcher.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/PollingDispatcher.cs rename to Yi.Framework.Net5/Yi.Framework.Core/ConsulExtend/ClienExtend/PollingDispatcher.cs diff --git a/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/WeightDispatcher.cs b/Yi.Framework.Net5/Yi.Framework.Core/ConsulExtend/ClienExtend/WeightDispatcher.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/WeightDispatcher.cs rename to Yi.Framework.Net5/Yi.Framework.Core/ConsulExtend/ClienExtend/WeightDispatcher.cs diff --git a/Yi.Framework/Yi.Framework.Core/ElasticSearchInvoker.cs b/Yi.Framework.Net5/Yi.Framework.Core/ElasticSearchInvoker.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Core/ElasticSearchInvoker.cs rename to Yi.Framework.Net5/Yi.Framework.Core/ElasticSearchInvoker.cs diff --git a/Yi.Framework/Yi.Framework.Core/Library/Microsoft.Bcl.AsyncInterfaces.dll b/Yi.Framework.Net5/Yi.Framework.Core/Library/Microsoft.Bcl.AsyncInterfaces.dll similarity index 100% rename from Yi.Framework/Yi.Framework.Core/Library/Microsoft.Bcl.AsyncInterfaces.dll rename to Yi.Framework.Net5/Yi.Framework.Core/Library/Microsoft.Bcl.AsyncInterfaces.dll diff --git a/Yi.Framework/Yi.Framework.Core/Library/ServiceStack.Common.dll b/Yi.Framework.Net5/Yi.Framework.Core/Library/ServiceStack.Common.dll similarity index 100% rename from Yi.Framework/Yi.Framework.Core/Library/ServiceStack.Common.dll rename to Yi.Framework.Net5/Yi.Framework.Core/Library/ServiceStack.Common.dll diff --git a/Yi.Framework/Yi.Framework.Core/Library/ServiceStack.Interfaces.dll b/Yi.Framework.Net5/Yi.Framework.Core/Library/ServiceStack.Interfaces.dll similarity index 100% rename from Yi.Framework/Yi.Framework.Core/Library/ServiceStack.Interfaces.dll rename to Yi.Framework.Net5/Yi.Framework.Core/Library/ServiceStack.Interfaces.dll diff --git a/Yi.Framework/Yi.Framework.Core/Library/ServiceStack.Redis.dll b/Yi.Framework.Net5/Yi.Framework.Core/Library/ServiceStack.Redis.dll similarity index 100% rename from Yi.Framework/Yi.Framework.Core/Library/ServiceStack.Redis.dll rename to Yi.Framework.Net5/Yi.Framework.Core/Library/ServiceStack.Redis.dll diff --git a/Yi.Framework/Yi.Framework.Core/Library/ServiceStack.Text.dll b/Yi.Framework.Net5/Yi.Framework.Core/Library/ServiceStack.Text.dll similarity index 100% rename from Yi.Framework/Yi.Framework.Core/Library/ServiceStack.Text.dll rename to Yi.Framework.Net5/Yi.Framework.Core/Library/ServiceStack.Text.dll diff --git a/Yi.Framework/Yi.Framework.Core/MakeJwt.cs b/Yi.Framework.Net5/Yi.Framework.Core/MakeJwt.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Core/MakeJwt.cs rename to Yi.Framework.Net5/Yi.Framework.Core/MakeJwt.cs diff --git a/Yi.Framework/Yi.Framework.Core/Quartz/MyQuartzFactory.cs b/Yi.Framework.Net5/Yi.Framework.Core/Quartz/MyQuartzFactory.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Core/Quartz/MyQuartzFactory.cs rename to Yi.Framework.Net5/Yi.Framework.Core/Quartz/MyQuartzFactory.cs diff --git a/Yi.Framework/Yi.Framework.Core/Quartz/QuartzInvoker.cs b/Yi.Framework.Net5/Yi.Framework.Core/Quartz/QuartzInvoker.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Core/Quartz/QuartzInvoker.cs rename to Yi.Framework.Net5/Yi.Framework.Core/Quartz/QuartzInvoker.cs diff --git a/Yi.Framework/Yi.Framework.Core/RabbitMQInvoker.cs b/Yi.Framework.Net5/Yi.Framework.Core/RabbitMQInvoker.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Core/RabbitMQInvoker.cs rename to Yi.Framework.Net5/Yi.Framework.Core/RabbitMQInvoker.cs diff --git a/Yi.Framework/Yi.Framework.Core/SMS/AliyunSMSInvoker.cs b/Yi.Framework.Net5/Yi.Framework.Core/SMS/AliyunSMSInvoker.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Core/SMS/AliyunSMSInvoker.cs rename to Yi.Framework.Net5/Yi.Framework.Core/SMS/AliyunSMSInvoker.cs diff --git a/Yi.Framework/Yi.Framework.Core/TreeMenuBuild.cs b/Yi.Framework.Net5/Yi.Framework.Core/TreeMenuBuild.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Core/TreeMenuBuild.cs rename to Yi.Framework.Net5/Yi.Framework.Core/TreeMenuBuild.cs diff --git a/Yi.Framework/Yi.Framework.Core/Yi.Framework.Core.csproj b/Yi.Framework.Net5/Yi.Framework.Core/Yi.Framework.Core.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.Core/Yi.Framework.Core.csproj rename to Yi.Framework.Net5/Yi.Framework.Core/Yi.Framework.Core.csproj diff --git a/Yi.Framework/Yi.Framework.DTOModel/ChangePwdDto.cs b/Yi.Framework.Net5/Yi.Framework.DTOModel/ChangePwdDto.cs similarity index 100% rename from Yi.Framework/Yi.Framework.DTOModel/ChangePwdDto.cs rename to Yi.Framework.Net5/Yi.Framework.DTOModel/ChangePwdDto.cs diff --git a/Yi.Framework/Yi.Framework.DTOModel/ChildrenDto.cs b/Yi.Framework.Net5/Yi.Framework.DTOModel/ChildrenDto.cs similarity index 100% rename from Yi.Framework/Yi.Framework.DTOModel/ChildrenDto.cs rename to Yi.Framework.Net5/Yi.Framework.DTOModel/ChildrenDto.cs diff --git a/Yi.Framework/Yi.Framework.DTOModel/IdsDto.cs b/Yi.Framework.Net5/Yi.Framework.DTOModel/IdsDto.cs similarity index 100% rename from Yi.Framework/Yi.Framework.DTOModel/IdsDto.cs rename to Yi.Framework.Net5/Yi.Framework.DTOModel/IdsDto.cs diff --git a/Yi.Framework/Yi.Framework.DTOModel/SettingDto.cs b/Yi.Framework.Net5/Yi.Framework.DTOModel/SettingDto.cs similarity index 100% rename from Yi.Framework/Yi.Framework.DTOModel/SettingDto.cs rename to Yi.Framework.Net5/Yi.Framework.DTOModel/SettingDto.cs diff --git a/Yi.Framework/Yi.Framework.DTOModel/Yi.Framework.DTOModel.csproj b/Yi.Framework.Net5/Yi.Framework.DTOModel/Yi.Framework.DTOModel.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.DTOModel/Yi.Framework.DTOModel.csproj rename to Yi.Framework.Net5/Yi.Framework.DTOModel/Yi.Framework.DTOModel.csproj diff --git a/Yi.Framework/Yi.Framework.ElasticSearchProcessor/InitESIndexWorker.cs b/Yi.Framework.Net5/Yi.Framework.ElasticSearchProcessor/InitESIndexWorker.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ElasticSearchProcessor/InitESIndexWorker.cs rename to Yi.Framework.Net5/Yi.Framework.ElasticSearchProcessor/InitESIndexWorker.cs diff --git a/Yi.Framework/Yi.Framework.ElasticSearchProcessor/Log4net.config b/Yi.Framework.Net5/Yi.Framework.ElasticSearchProcessor/Log4net.config similarity index 100% rename from Yi.Framework/Yi.Framework.ElasticSearchProcessor/Log4net.config rename to Yi.Framework.Net5/Yi.Framework.ElasticSearchProcessor/Log4net.config diff --git a/Yi.Framework/Yi.Framework.ElasticSearchProcessor/Program.cs b/Yi.Framework.Net5/Yi.Framework.ElasticSearchProcessor/Program.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ElasticSearchProcessor/Program.cs rename to Yi.Framework.Net5/Yi.Framework.ElasticSearchProcessor/Program.cs diff --git a/Yi.Framework/Yi.Framework.ElasticSearchProcessor/WarmupESIndexWorker.cs b/Yi.Framework.Net5/Yi.Framework.ElasticSearchProcessor/WarmupESIndexWorker.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ElasticSearchProcessor/WarmupESIndexWorker.cs rename to Yi.Framework.Net5/Yi.Framework.ElasticSearchProcessor/WarmupESIndexWorker.cs diff --git a/Yi.Framework/Yi.Framework.ElasticSearchProcessor/Worker.cs b/Yi.Framework.Net5/Yi.Framework.ElasticSearchProcessor/Worker.cs similarity index 100% rename from Yi.Framework/Yi.Framework.ElasticSearchProcessor/Worker.cs rename to Yi.Framework.Net5/Yi.Framework.ElasticSearchProcessor/Worker.cs diff --git a/Yi.Framework/Yi.Framework.ElasticSearchProcessor/Yi.Framework.ElasticSearchProcessor.csproj b/Yi.Framework.Net5/Yi.Framework.ElasticSearchProcessor/Yi.Framework.ElasticSearchProcessor.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.ElasticSearchProcessor/Yi.Framework.ElasticSearchProcessor.csproj rename to Yi.Framework.Net5/Yi.Framework.ElasticSearchProcessor/Yi.Framework.ElasticSearchProcessor.csproj diff --git a/Yi.Framework/Yi.Framework.Interface/IBaseService.cs b/Yi.Framework.Net5/Yi.Framework.Interface/IBaseService.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Interface/IBaseService.cs rename to Yi.Framework.Net5/Yi.Framework.Interface/IBaseService.cs diff --git a/Yi.Framework/Yi.Framework.Interface/IMenuService.cs b/Yi.Framework.Net5/Yi.Framework.Interface/IMenuService.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Interface/IMenuService.cs rename to Yi.Framework.Net5/Yi.Framework.Interface/IMenuService.cs diff --git a/Yi.Framework/Yi.Framework.Interface/IMouldService.cs b/Yi.Framework.Net5/Yi.Framework.Interface/IMouldService.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Interface/IMouldService.cs rename to Yi.Framework.Net5/Yi.Framework.Interface/IMouldService.cs diff --git a/Yi.Framework/Yi.Framework.Interface/IRoleService.cs b/Yi.Framework.Net5/Yi.Framework.Interface/IRoleService.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Interface/IRoleService.cs rename to Yi.Framework.Net5/Yi.Framework.Interface/IRoleService.cs diff --git a/Yi.Framework/Yi.Framework.Interface/IUserService.cs b/Yi.Framework.Net5/Yi.Framework.Interface/IUserService.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Interface/IUserService.cs rename to Yi.Framework.Net5/Yi.Framework.Interface/IUserService.cs diff --git a/Yi.Framework/Yi.Framework.Interface/T4Iservice.cs b/Yi.Framework.Net5/Yi.Framework.Interface/T4Iservice.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Interface/T4Iservice.cs rename to Yi.Framework.Net5/Yi.Framework.Interface/T4Iservice.cs diff --git a/Yi.Framework/Yi.Framework.Interface/T4Iservice.tt b/Yi.Framework.Net5/Yi.Framework.Interface/T4Iservice.tt similarity index 100% rename from Yi.Framework/Yi.Framework.Interface/T4Iservice.tt rename to Yi.Framework.Net5/Yi.Framework.Interface/T4Iservice.tt diff --git a/Yi.Framework/Yi.Framework.Interface/Yi - Backup.Framework.Interface.csproj b/Yi.Framework.Net5/Yi.Framework.Interface/Yi - Backup.Framework.Interface.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.Interface/Yi - Backup.Framework.Interface.csproj rename to Yi.Framework.Net5/Yi.Framework.Interface/Yi - Backup.Framework.Interface.csproj diff --git a/Yi.Framework/Yi.Framework.Interface/Yi.Framework.Interface.csproj b/Yi.Framework.Net5/Yi.Framework.Interface/Yi.Framework.Interface.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.Interface/Yi.Framework.Interface.csproj rename to Yi.Framework.Net5/Yi.Framework.Interface/Yi.Framework.Interface.csproj diff --git a/Yi.Framework/Yi.Framework.MSUnitTest/UnitTest1.cs b/Yi.Framework.Net5/Yi.Framework.MSUnitTest/UnitTest1.cs similarity index 100% rename from Yi.Framework/Yi.Framework.MSUnitTest/UnitTest1.cs rename to Yi.Framework.Net5/Yi.Framework.MSUnitTest/UnitTest1.cs diff --git a/Yi.Framework/Yi.Framework.MSUnitTest/Yi.Framework.MSUnitTest.csproj b/Yi.Framework.Net5/Yi.Framework.MSUnitTest/Yi.Framework.MSUnitTest.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.MSUnitTest/Yi.Framework.MSUnitTest.csproj rename to Yi.Framework.Net5/Yi.Framework.MSUnitTest/Yi.Framework.MSUnitTest.csproj diff --git a/Yi.Framework/Yi.Framework.Model/BaseModels/baseModel.cs b/Yi.Framework.Net5/Yi.Framework.Model/BaseModels/baseModel.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/BaseModels/baseModel.cs rename to Yi.Framework.Net5/Yi.Framework.Model/BaseModels/baseModel.cs diff --git a/Yi.Framework/Yi.Framework.Model/BaseModels/loopModel.cs b/Yi.Framework.Net5/Yi.Framework.Model/BaseModels/loopModel.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/BaseModels/loopModel.cs rename to Yi.Framework.Net5/Yi.Framework.Model/BaseModels/loopModel.cs diff --git a/Yi.Framework/Yi.Framework.Model/DataContext.cs b/Yi.Framework.Net5/Yi.Framework.Model/DataContext.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/DataContext.cs rename to Yi.Framework.Net5/Yi.Framework.Model/DataContext.cs diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211106080544_ec1.Designer.cs b/Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106080544_ec1.Designer.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Migrations/20211106080544_ec1.Designer.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106080544_ec1.Designer.cs diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211106080544_ec1.cs b/Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106080544_ec1.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Migrations/20211106080544_ec1.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106080544_ec1.cs diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211106080646_ec2.Designer.cs b/Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106080646_ec2.Designer.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Migrations/20211106080646_ec2.Designer.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106080646_ec2.Designer.cs diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211106080646_ec2.cs b/Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106080646_ec2.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Migrations/20211106080646_ec2.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106080646_ec2.cs diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211106082100_yi-1.Designer.cs b/Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106082100_yi-1.Designer.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Migrations/20211106082100_yi-1.Designer.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106082100_yi-1.Designer.cs diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211106082100_yi-1.cs b/Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106082100_yi-1.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Migrations/20211106082100_yi-1.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106082100_yi-1.cs diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211106084427_ec3.Designer.cs b/Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106084427_ec3.Designer.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Migrations/20211106084427_ec3.Designer.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106084427_ec3.Designer.cs diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211106084427_ec3.cs b/Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106084427_ec3.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Migrations/20211106084427_ec3.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106084427_ec3.cs diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211106110713_ec4.Designer.cs b/Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106110713_ec4.Designer.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Migrations/20211106110713_ec4.Designer.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106110713_ec4.Designer.cs diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211106110713_ec4.cs b/Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106110713_ec4.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Migrations/20211106110713_ec4.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Migrations/20211106110713_ec4.cs diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs b/Yi.Framework.Net5/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs diff --git a/Yi.Framework/Yi.Framework.Model/ModelFactory/DbContextExtend.cs b/Yi.Framework.Net5/Yi.Framework.Model/ModelFactory/DbContextExtend.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/ModelFactory/DbContextExtend.cs rename to Yi.Framework.Net5/Yi.Framework.Model/ModelFactory/DbContextExtend.cs diff --git a/Yi.Framework/Yi.Framework.Model/ModelFactory/DbContextFactory.cs b/Yi.Framework.Net5/Yi.Framework.Model/ModelFactory/DbContextFactory.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/ModelFactory/DbContextFactory.cs rename to Yi.Framework.Net5/Yi.Framework.Model/ModelFactory/DbContextFactory.cs diff --git a/Yi.Framework/Yi.Framework.Model/ModelFactory/IDbContextFactory.cs b/Yi.Framework.Net5/Yi.Framework.Model/ModelFactory/IDbContextFactory.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/ModelFactory/IDbContextFactory.cs rename to Yi.Framework.Net5/Yi.Framework.Model/ModelFactory/IDbContextFactory.cs diff --git a/Yi.Framework/Yi.Framework.Model/Models/menu.cs b/Yi.Framework.Net5/Yi.Framework.Model/Models/menu.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Models/menu.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Models/menu.cs diff --git a/Yi.Framework/Yi.Framework.Model/Models/mould.cs b/Yi.Framework.Net5/Yi.Framework.Model/Models/mould.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Models/mould.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Models/mould.cs diff --git a/Yi.Framework/Yi.Framework.Model/Models/role.cs b/Yi.Framework.Net5/Yi.Framework.Model/Models/role.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Models/role.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Models/role.cs diff --git a/Yi.Framework/Yi.Framework.Model/Models/user.cs b/Yi.Framework.Net5/Yi.Framework.Model/Models/user.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Models/user.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Models/user.cs diff --git a/Yi.Framework/Yi.Framework.Model/Models/visit.cs b/Yi.Framework.Net5/Yi.Framework.Model/Models/visit.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Models/visit.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Models/visit.cs diff --git a/Yi.Framework/Yi.Framework.Model/Search/PageResult.cs b/Yi.Framework.Net5/Yi.Framework.Model/Search/PageResult.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Search/PageResult.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Search/PageResult.cs diff --git a/Yi.Framework/Yi.Framework.Model/Search/SearchRequest.cs b/Yi.Framework.Net5/Yi.Framework.Model/Search/SearchRequest.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Search/SearchRequest.cs rename to Yi.Framework.Net5/Yi.Framework.Model/Search/SearchRequest.cs diff --git a/Yi.Framework/Yi.Framework.Model/T4DataContext.cs b/Yi.Framework.Net5/Yi.Framework.Model/T4DataContext.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Model/T4DataContext.cs rename to Yi.Framework.Net5/Yi.Framework.Model/T4DataContext.cs diff --git a/Yi.Framework/Yi.Framework.Model/T4DataContext.tt b/Yi.Framework.Net5/Yi.Framework.Model/T4DataContext.tt similarity index 100% rename from Yi.Framework/Yi.Framework.Model/T4DataContext.tt rename to Yi.Framework.Net5/Yi.Framework.Model/T4DataContext.tt diff --git a/Yi.Framework/Yi.Framework.Model/Yi - Backup (1).Framework.Model.csproj b/Yi.Framework.Net5/Yi.Framework.Model/Yi - Backup (1).Framework.Model.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Yi - Backup (1).Framework.Model.csproj rename to Yi.Framework.Net5/Yi.Framework.Model/Yi - Backup (1).Framework.Model.csproj diff --git a/Yi.Framework/Yi.Framework.Model/Yi - Backup.Framework.Model.csproj b/Yi.Framework.Net5/Yi.Framework.Model/Yi - Backup.Framework.Model.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Yi - Backup.Framework.Model.csproj rename to Yi.Framework.Net5/Yi.Framework.Model/Yi - Backup.Framework.Model.csproj diff --git a/Yi.Framework/Yi.Framework.Model/Yi.Framework.Model.csproj b/Yi.Framework.Net5/Yi.Framework.Model/Yi.Framework.Model.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.Model/Yi.Framework.Model.csproj rename to Yi.Framework.Net5/Yi.Framework.Model/Yi.Framework.Model.csproj diff --git a/Yi.Framework/Yi.Framework.OcelotGateway/Log4net.config b/Yi.Framework.Net5/Yi.Framework.OcelotGateway/Log4net.config similarity index 100% rename from Yi.Framework/Yi.Framework.OcelotGateway/Log4net.config rename to Yi.Framework.Net5/Yi.Framework.OcelotGateway/Log4net.config diff --git a/Yi.Framework/Yi.Framework.OcelotGateway/Program.cs b/Yi.Framework.Net5/Yi.Framework.OcelotGateway/Program.cs similarity index 100% rename from Yi.Framework/Yi.Framework.OcelotGateway/Program.cs rename to Yi.Framework.Net5/Yi.Framework.OcelotGateway/Program.cs diff --git a/Yi.Framework/Yi.Framework.OcelotGateway/Startup.cs b/Yi.Framework.Net5/Yi.Framework.OcelotGateway/Startup.cs similarity index 100% rename from Yi.Framework/Yi.Framework.OcelotGateway/Startup.cs rename to Yi.Framework.Net5/Yi.Framework.OcelotGateway/Startup.cs diff --git a/Yi.Framework.Net5/Yi.Framework.OcelotGateway/SwaggerDoc.xml b/Yi.Framework.Net5/Yi.Framework.OcelotGateway/SwaggerDoc.xml new file mode 100644 index 00000000..16f3de1b --- /dev/null +++ b/Yi.Framework.Net5/Yi.Framework.OcelotGateway/SwaggerDoc.xml @@ -0,0 +1,8 @@ + + + + Yi.Framework.OcelotGateway + + + + diff --git a/Yi.Framework/Yi.Framework.OcelotGateway/Yi.Framework.OcelotGateway.csproj b/Yi.Framework.Net5/Yi.Framework.OcelotGateway/Yi.Framework.OcelotGateway.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.OcelotGateway/Yi.Framework.OcelotGateway.csproj rename to Yi.Framework.Net5/Yi.Framework.OcelotGateway/Yi.Framework.OcelotGateway.csproj diff --git a/Yi.Framework/Yi.Framework.PageDetail/Controllers/PageDetaiController.cs b/Yi.Framework.Net5/Yi.Framework.PageDetail/Controllers/PageDetaiController.cs similarity index 100% rename from Yi.Framework/Yi.Framework.PageDetail/Controllers/PageDetaiController.cs rename to Yi.Framework.Net5/Yi.Framework.PageDetail/Controllers/PageDetaiController.cs diff --git a/Yi.Framework/Yi.Framework.PageDetail/Log4net.config b/Yi.Framework.Net5/Yi.Framework.PageDetail/Log4net.config similarity index 100% rename from Yi.Framework/Yi.Framework.PageDetail/Log4net.config rename to Yi.Framework.Net5/Yi.Framework.PageDetail/Log4net.config diff --git a/Yi.Framework/Yi.Framework.PageDetail/Program.cs b/Yi.Framework.Net5/Yi.Framework.PageDetail/Program.cs similarity index 100% rename from Yi.Framework/Yi.Framework.PageDetail/Program.cs rename to Yi.Framework.Net5/Yi.Framework.PageDetail/Program.cs diff --git a/Yi.Framework/Yi.Framework.PageDetail/Startup.cs b/Yi.Framework.Net5/Yi.Framework.PageDetail/Startup.cs similarity index 100% rename from Yi.Framework/Yi.Framework.PageDetail/Startup.cs rename to Yi.Framework.Net5/Yi.Framework.PageDetail/Startup.cs diff --git a/Yi.Framework.Net5/Yi.Framework.PageDetail/SwaggerDoc.xml b/Yi.Framework.Net5/Yi.Framework.PageDetail/SwaggerDoc.xml new file mode 100644 index 00000000..f7714016 --- /dev/null +++ b/Yi.Framework.Net5/Yi.Framework.PageDetail/SwaggerDoc.xml @@ -0,0 +1,8 @@ + + + + Yi.Framework.PageDetail + + + + diff --git a/Yi.Framework/Yi.Framework.PageDetail/Views/PageDetai/Index.cshtml b/Yi.Framework.Net5/Yi.Framework.PageDetail/Views/PageDetai/Index.cshtml similarity index 100% rename from Yi.Framework/Yi.Framework.PageDetail/Views/PageDetai/Index.cshtml rename to Yi.Framework.Net5/Yi.Framework.PageDetail/Views/PageDetai/Index.cshtml diff --git a/Yi.Framework/Yi.Framework.PageDetail/Views/Shared/_ValidationScriptsPartial.cshtml b/Yi.Framework.Net5/Yi.Framework.PageDetail/Views/Shared/_ValidationScriptsPartial.cshtml similarity index 100% rename from Yi.Framework/Yi.Framework.PageDetail/Views/Shared/_ValidationScriptsPartial.cshtml rename to Yi.Framework.Net5/Yi.Framework.PageDetail/Views/Shared/_ValidationScriptsPartial.cshtml diff --git a/Yi.Framework/Yi.Framework.PageDetail/Yi.Framework.PageDetail.csproj b/Yi.Framework.Net5/Yi.Framework.PageDetail/Yi.Framework.PageDetail.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.PageDetail/Yi.Framework.PageDetail.csproj rename to Yi.Framework.Net5/Yi.Framework.PageDetail/Yi.Framework.PageDetail.csproj diff --git a/Yi.Framework/Yi.Framework.SMSProcessor/Log4net.config b/Yi.Framework.Net5/Yi.Framework.SMSProcessor/Log4net.config similarity index 100% rename from Yi.Framework/Yi.Framework.SMSProcessor/Log4net.config rename to Yi.Framework.Net5/Yi.Framework.SMSProcessor/Log4net.config diff --git a/Yi.Framework/Yi.Framework.SMSProcessor/Program.cs b/Yi.Framework.Net5/Yi.Framework.SMSProcessor/Program.cs similarity index 100% rename from Yi.Framework/Yi.Framework.SMSProcessor/Program.cs rename to Yi.Framework.Net5/Yi.Framework.SMSProcessor/Program.cs diff --git a/Yi.Framework/Yi.Framework.SMSProcessor/SendWorker.cs b/Yi.Framework.Net5/Yi.Framework.SMSProcessor/SendWorker.cs similarity index 100% rename from Yi.Framework/Yi.Framework.SMSProcessor/SendWorker.cs rename to Yi.Framework.Net5/Yi.Framework.SMSProcessor/SendWorker.cs diff --git a/Yi.Framework/Yi.Framework.SMSProcessor/Worker.cs b/Yi.Framework.Net5/Yi.Framework.SMSProcessor/Worker.cs similarity index 100% rename from Yi.Framework/Yi.Framework.SMSProcessor/Worker.cs rename to Yi.Framework.Net5/Yi.Framework.SMSProcessor/Worker.cs diff --git a/Yi.Framework/Yi.Framework.SMSProcessor/Yi.Framework.SMSProcessor.csproj b/Yi.Framework.Net5/Yi.Framework.SMSProcessor/Yi.Framework.SMSProcessor.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.SMSProcessor/Yi.Framework.SMSProcessor.csproj rename to Yi.Framework.Net5/Yi.Framework.SMSProcessor/Yi.Framework.SMSProcessor.csproj diff --git a/Yi.Framework/Yi.Framework.Service/BaseService.cs b/Yi.Framework.Net5/Yi.Framework.Service/BaseService.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Service/BaseService.cs rename to Yi.Framework.Net5/Yi.Framework.Service/BaseService.cs diff --git a/Yi.Framework/Yi.Framework.Service/MenuService.cs b/Yi.Framework.Net5/Yi.Framework.Service/MenuService.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Service/MenuService.cs rename to Yi.Framework.Net5/Yi.Framework.Service/MenuService.cs diff --git a/Yi.Framework/Yi.Framework.Service/MouldService.cs b/Yi.Framework.Net5/Yi.Framework.Service/MouldService.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Service/MouldService.cs rename to Yi.Framework.Net5/Yi.Framework.Service/MouldService.cs diff --git a/Yi.Framework/Yi.Framework.Service/RoleService.cs b/Yi.Framework.Net5/Yi.Framework.Service/RoleService.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Service/RoleService.cs rename to Yi.Framework.Net5/Yi.Framework.Service/RoleService.cs diff --git a/Yi.Framework/Yi.Framework.Service/T4Service.cs b/Yi.Framework.Net5/Yi.Framework.Service/T4Service.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Service/T4Service.cs rename to Yi.Framework.Net5/Yi.Framework.Service/T4Service.cs diff --git a/Yi.Framework/Yi.Framework.Service/T4Service.tt b/Yi.Framework.Net5/Yi.Framework.Service/T4Service.tt similarity index 100% rename from Yi.Framework/Yi.Framework.Service/T4Service.tt rename to Yi.Framework.Net5/Yi.Framework.Service/T4Service.tt diff --git a/Yi.Framework/Yi.Framework.Service/UserService.cs b/Yi.Framework.Net5/Yi.Framework.Service/UserService.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Service/UserService.cs rename to Yi.Framework.Net5/Yi.Framework.Service/UserService.cs diff --git a/Yi.Framework/Yi.Framework.Service/Yi - Backup.Framework.Service.csproj b/Yi.Framework.Net5/Yi.Framework.Service/Yi - Backup.Framework.Service.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.Service/Yi - Backup.Framework.Service.csproj rename to Yi.Framework.Net5/Yi.Framework.Service/Yi - Backup.Framework.Service.csproj diff --git a/Yi.Framework/Yi.Framework.Service/Yi.Framework.Service.csproj b/Yi.Framework.Net5/Yi.Framework.Service/Yi.Framework.Service.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.Service/Yi.Framework.Service.csproj rename to Yi.Framework.Net5/Yi.Framework.Service/Yi.Framework.Service.csproj diff --git a/Yi.Framework/Yi.Framework.StaticPageProcessor/InitPageWorker.cs b/Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/InitPageWorker.cs similarity index 100% rename from Yi.Framework/Yi.Framework.StaticPageProcessor/InitPageWorker.cs rename to Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/InitPageWorker.cs diff --git a/Yi.Framework/Yi.Framework.StaticPageProcessor/Log4net.config b/Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/Log4net.config similarity index 100% rename from Yi.Framework/Yi.Framework.StaticPageProcessor/Log4net.config rename to Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/Log4net.config diff --git a/Yi.Framework/Yi.Framework.StaticPageProcessor/Program.cs b/Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/Program.cs similarity index 100% rename from Yi.Framework/Yi.Framework.StaticPageProcessor/Program.cs rename to Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/Program.cs diff --git a/Yi.Framework/Yi.Framework.StaticPageProcessor/WarmupPageWorker.cs b/Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/WarmupPageWorker.cs similarity index 100% rename from Yi.Framework/Yi.Framework.StaticPageProcessor/WarmupPageWorker.cs rename to Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/WarmupPageWorker.cs diff --git a/Yi.Framework/Yi.Framework.StaticPageProcessor/Worker.cs b/Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/Worker.cs similarity index 100% rename from Yi.Framework/Yi.Framework.StaticPageProcessor/Worker.cs rename to Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/Worker.cs diff --git a/Yi.Framework/Yi.Framework.StaticPageProcessor/Yi.Framework.StaticPageProcessor.csproj b/Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/Yi.Framework.StaticPageProcessor.csproj similarity index 94% rename from Yi.Framework/Yi.Framework.StaticPageProcessor/Yi.Framework.StaticPageProcessor.csproj rename to Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/Yi.Framework.StaticPageProcessor.csproj index b42904f3..8cb7cd48 100644 --- a/Yi.Framework/Yi.Framework.StaticPageProcessor/Yi.Framework.StaticPageProcessor.csproj +++ b/Yi.Framework.Net5/Yi.Framework.StaticPageProcessor/Yi.Framework.StaticPageProcessor.csproj @@ -2,6 +2,7 @@ net5.0 + Exe diff --git a/Yi.Framework/Yi.Framework.Task/HttpJob.cs b/Yi.Framework.Net5/Yi.Framework.Task/HttpJob.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Task/HttpJob.cs rename to Yi.Framework.Net5/Yi.Framework.Task/HttpJob.cs diff --git a/Yi.Framework/Yi.Framework.Task/VisitJob.cs b/Yi.Framework.Net5/Yi.Framework.Task/VisitJob.cs similarity index 100% rename from Yi.Framework/Yi.Framework.Task/VisitJob.cs rename to Yi.Framework.Net5/Yi.Framework.Task/VisitJob.cs diff --git a/Yi.Framework/Yi.Framework.Task/Yi.Framework.Job.csproj b/Yi.Framework.Net5/Yi.Framework.Task/Yi.Framework.Job.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.Task/Yi.Framework.Job.csproj rename to Yi.Framework.Net5/Yi.Framework.Task/Yi.Framework.Job.csproj diff --git a/Yi.Framework/Yi.Framework.WebCore/Appsettings.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/Appsettings.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/Appsettings.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/Appsettings.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/BuilderExtend/ApolloExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/BuilderExtend/ApolloExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/BuilderExtend/ApolloExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/BuilderExtend/ApolloExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/BuilderExtend/JsonExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/BuilderExtend/JsonExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/BuilderExtend/JsonExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/BuilderExtend/JsonExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/BuilderExtend/JsonFileExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/BuilderExtend/JsonFileExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/BuilderExtend/JsonFileExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/BuilderExtend/JsonFileExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/CommonExtend.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/CommonExtend.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/CommonExtend.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/CommonExtend.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/FilterExtend/CORSFilter.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CORSFilter.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/FilterExtend/CORSFilter.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CORSFilter.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomAction2CommitFilterAttribute.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CustomAction2CommitFilterAttribute.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomAction2CommitFilterAttribute.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CustomAction2CommitFilterAttribute.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomActionCacheFilterAttribute.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CustomActionCacheFilterAttribute.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomActionCacheFilterAttribute.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CustomActionCacheFilterAttribute.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomActionCheckFilterAttribute.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CustomActionCheckFilterAttribute.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomActionCheckFilterAttribute.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CustomActionCheckFilterAttribute.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomExceptionFilterAttribute.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CustomExceptionFilterAttribute.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomExceptionFilterAttribute.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CustomExceptionFilterAttribute.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomIOCFilterFactoryAttribute.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CustomIOCFilterFactoryAttribute.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomIOCFilterFactoryAttribute.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CustomIOCFilterFactoryAttribute.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomResourceFilterAttribute.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CustomResourceFilterAttribute.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomResourceFilterAttribute.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/CustomResourceFilterAttribute.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/FilterExtend/LogActionFilterAttribute.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/LogActionFilterAttribute.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/FilterExtend/LogActionFilterAttribute.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/FilterExtend/LogActionFilterAttribute.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/Init/DataSeed.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/Init/DataSeed.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/Init/DataSeed.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/Init/DataSeed.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/Init/RedisInit.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/Init/RedisInit.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/Init/RedisInit.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/Init/RedisInit.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/CAPExtend.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/CAPExtend.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/CAPExtend.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/CAPExtend.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/ConsulRegiterExtend.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/ConsulRegiterExtend.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/ConsulRegiterExtend.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/ConsulRegiterExtend.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/CorsExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/CorsExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/CorsExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/CorsExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/DbExtend.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/DbExtend.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/DbExtend.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/DbExtend.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/DbSeedInitExtend.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/DbSeedInitExtend.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/DbSeedInitExtend.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/DbSeedInitExtend.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/ElasticSeachExtend.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/ElasticSeachExtend.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/ElasticSeachExtend.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/ElasticSeachExtend.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/HealthCheckExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/HealthCheckExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/HealthCheckExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/HealthCheckExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/IocExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/IocExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/IocExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/IocExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/PreOptionRequestExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/PreOptionRequestExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/PreOptionRequestExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/PreOptionRequestExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/QuartzExtensions.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/QuartzExtensions.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/QuartzExtensions.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/QuartzExtensions.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RabbitMQExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/RabbitMQExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RabbitMQExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/RabbitMQExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RedisExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/RedisExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RedisExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/RedisExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RedisInitExtend.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/RedisInitExtend.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RedisInitExtend.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/RedisInitExtend.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/SMSExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/SMSExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/SMSExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/SMSExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/StaticPageExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/StaticPageExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/StaticPageExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/StaticPageExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/Utility/CustomAutofacAop.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/Utility/CustomAutofacAop.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/Utility/CustomAutofacAop.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/Utility/CustomAutofacAop.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/Utility/CustomHostingStartup.cs b/Yi.Framework.Net5/Yi.Framework.WebCore/Utility/CustomHostingStartup.cs similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/Utility/CustomHostingStartup.cs rename to Yi.Framework.Net5/Yi.Framework.WebCore/Utility/CustomHostingStartup.cs diff --git a/Yi.Framework/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj b/Yi.Framework.Net5/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj similarity index 100% rename from Yi.Framework/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj rename to Yi.Framework.Net5/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj diff --git a/Yi.Framework/Yi.Framework.sln b/Yi.Framework.Net5/Yi.Framework.sln similarity index 100% rename from Yi.Framework/Yi.Framework.sln rename to Yi.Framework.Net5/Yi.Framework.sln diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs new file mode 100644 index 00000000..32d475a2 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -0,0 +1,222 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common; +using Yi.Framework.Common.Const; +using Yi.Framework.Common.Helper; +using Yi.Framework.Common.Models; +using Yi.Framework.Common.QueueModel; +using Yi.Framework.Core; +using Yi.Framework.DTOModel; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.WebCore; + +namespace Yi.Framework.ApiMicroservice.Controllers +{ + [ApiController] + [Route("api/[controller]/[action]")] + public class AccountController : Controller + { + private readonly ILogger _logger; + + private IUserService _userService; + private IMenuService _menuService; + private RabbitMQInvoker _rabbitMQInvoker; + private CacheClientDB _cacheClientDB; + private IRoleService _roleService; + private IHttpContextAccessor _httpContext; + public AccountController(ILogger logger, IUserService userService, IMenuService menuService,RabbitMQInvoker rabbitMQInvoker,CacheClientDB cacheClientDB, IRoleService roleService, IHttpContextAccessor httpContext) + { + _logger = logger; + _userService = userService; + _menuService = menuService; + _rabbitMQInvoker = rabbitMQInvoker; + _cacheClientDB = cacheClientDB; + _roleService = roleService; + _httpContext = httpContext; + } + + + /// + /// 登录方法,要返回data:{user,token} token + /// + /// + /// + [HttpPost] + public async Task Login(user _user) + { + var user_data = await _userService.Login(_user); + if (user_data == null) + { + return Result.Error("该用户不存在"); + } + var menuList = await _menuService.GetTopMenuByUserId(user_data.id); + if ( user_data!=null) + { + var token = MakeJwt.app(new jwtUser() {user=user_data,menuIds= menuList}); + + JobModel.visitNum += 1; + return Result.Success().SetData(new { user = new { user_data.id, user_data.username, user_data.introduction, user_data.icon, user_data.nick }, token }); + } + return Result.Error(); + } + + /// + /// 不用写,单纯制作日志 + /// + /// + [HttpPost] + public Result Logout() + { + return Result.Success(); + } + + /// + /// code为验证码,从redis中判断一下code是否正确 + /// + /// + /// + /// + [HttpPost] + public async Task Register(user _user, string code) + { + _user.username=_user.username.Trim(); + if(string.IsNullOrEmpty(_user.username)) + code = code.Trim(); + + string trueCode= _cacheClientDB.Get(RedisConst.keyCode + _user.phone); + if (code == trueCode) + { + //设置默认头像 + var setting = JsonHelper.StrToObj(_cacheClientDB.Get(RedisConst.key)); + _user.icon = setting.InitIcon; + _user.ip = _httpContext.HttpContext.Request.Headers["X-Real-IP"].FirstOrDefault();//通过上下文获取ip + //设置默认角色 + if (string.IsNullOrEmpty(setting.InitRole)) + { + return Result.Error("无默认角色,请初始化数据库"); + } + _user.roles = new List(); + _user.roles.Add(await _roleService.GetEntity(u => u.role_name == setting.InitRole)); + await _userService.Register(_user); + + return Result.Success("恭喜,你已加入我们!"); + } + return Result.Error("验证码有误,请重新输入!"); + } + + + /// + /// 发送短信,需要将生成的sms+code存入redis + /// + /// + /// + [HttpPost] + public async Task SendSMS(string SMSAddress) + { + if (string.IsNullOrEmpty(SMSAddress)) + { + return Result.Error("请输入电话号码"); + } + SMSAddress = SMSAddress.Trim(); + if (!await _userService.PhoneIsExsit(SMSAddress)) + { + SMSQueueModel sMSQueueModel = new SMSQueueModel(); + sMSQueueModel.phone = SMSAddress; + sMSQueueModel.code =RandomHelper.GenerateCheckCodeNum(6); + + //10分钟过期 + _cacheClientDB.Set(RedisConst.keyCode+sMSQueueModel.phone, sMSQueueModel.code, TimeSpan.FromMinutes(10)); + + _rabbitMQInvoker.Send(new Common.IOCOptions.RabbitMQConsumerModel() { ExchangeName = RabbitConst.SMS_Exchange, QueueName = RabbitConst.SMS_Queue_Send }, JsonHelper.ObjToStr(sMSQueueModel)); + return Result.Success("发送短信成功,10分钟后过期,请留意短信接收"); + } + return Result.Error("该号码已被注册"); + } + + /// + /// 发送邮箱,需要先到数据库判断该邮箱是否被人注册过,到userservice写mail_exist方法,还有接口别忘了。 + /// + /// + /// + [HttpPost]//邮箱验证 + public async Task Email(string emailAddress) + { + emailAddress = emailAddress.Trim().ToLower(); + //先判断邮箱是否被注册使用过,如果被使用过,便不让操作 + if (!await _userService.EmailIsExsit(emailAddress)) + { + string code = RandomHelper.GenerateRandomLetter(6); + code = code.ToUpper();//全部转为大写 + EmailHelper.sendMail(code, emailAddress); + + //我要把邮箱和对应的code加进到数据库,还有申请时间 + //设置10分钟过期 + //set不存在便添加,如果存在便替换 + //CacheHelper.SetCache(emailAddress, code, TimeSpan.FromSeconds(10)); + + return Result.Success("发送邮件成功,请查看邮箱(可能在垃圾箱)"); + } + else + { + return Result.Error("该邮箱已被注册"); + } + // 邮箱和验证码都要被记住,然后注册时候比对邮箱和验证码是不是都和现在生成的一样 + } + /// + /// 修改密码 + /// + /// + /// + [HttpPut] + [Authorize] + public async Task ChangePassword(ChangePwdDto pwdDto) + { + var user_data = await _userService.GetUserById(pwdDto.user.id); + string msg = "修改成功"; + if (! string.IsNullOrEmpty( pwdDto.newPassword)) + { + if (user_data.password == pwdDto.user.password) + { + + user_data.password = pwdDto.newPassword; + user_data.phone = pwdDto.user.phone; + user_data.introduction = pwdDto.user.introduction; + user_data.email = pwdDto.user.email; + user_data.age = pwdDto.user.age; + user_data.address = pwdDto.user.address; + user_data.nick = pwdDto.user.nick; + + + await _userService.UpdateAsync(user_data); + user_data.password = null; + return Result.Success(msg); + } + else + { + msg = "密码错误"; + return Result.Error(msg); + } + } + + user_data.phone = pwdDto.user.phone; + user_data.introduction = pwdDto.user.introduction; + user_data.email = pwdDto.user.email; + user_data.age = pwdDto.user.age; + user_data.address = pwdDto.user.address; + user_data.nick = pwdDto.user.nick; + + await _userService.UpdateAsync(user_data); + + + return Result.Success(msg); + } + + } +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/FileController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/FileController.cs new file mode 100644 index 00000000..8dcae4c7 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/FileController.cs @@ -0,0 +1,92 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Hosting; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.Interface; +using Yi.Framework.WebCore; + +namespace Yi.Framework.ApiMicroservice.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class FileController : ControllerBase + { + private IUserService _userService; + private readonly IHostEnvironment _env; + public FileController(IUserService userService, IHostEnvironment env) + { + _userService = userService; + _env = env; + } + [HttpPost] + [Authorize] + public async Task EditIcon(IFormFile file) + { + try + { + var _user = HttpContext.GetCurrentUserInfo(); + var user_data = await _userService.GetUserById(_user.id); + var type = "image"; + var filename = await Upload(type, file); + user_data.icon = filename; + await _userService.UpdateAsync(user_data); + return Result.Success(); + } + catch + { + return Result.Error(); + } + } + + [Route("/api/{type}/{fileName}")] + [HttpGet] + public IActionResult Get(string type, string fileName) + { + try + { + var path = Path.Combine($"wwwroot/{type}", fileName); + var stream = System.IO.File.OpenRead(path); + var MimeType = Common.Helper.MimeHelper.GetMimeMapping(fileName); + return new FileStreamResult(stream, MimeType); + } + catch + { + return new NotFoundResult(); + } + } + + /// + /// 该方法不对外暴露 + /// + /// + /// + /// + private async Task Upload(string type, IFormFile file) + { + string filename = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); + using (var stream = new FileStream(Path.Combine($"wwwroot/{type}", filename), FileMode.CreateNew, FileAccess.Write)) + { + await file.CopyToAsync(stream); + } + + return filename; + } + + [HttpGet] + public async Task ExportFile() + { + var userdata = await _userService.GetAllEntitiesTrueAsync(); + var userList = userdata.ToList(); + List header = new() { "用户", "密码", "头像", "昵称", "邮箱", "ip", "年龄", "个人介绍", "地址", "手机", "角色" }; + var filename = Common.Helper.ExcelHelper.CreateExcelFromList(userList, header, _env.ContentRootPath.ToString()); + var MimeType = Common.Helper.MimeHelper.GetMimeMapping(filename); + return new FileStreamResult(new FileStream(Path.Combine(_env.ContentRootPath+@"/wwwroot/Excel", filename), FileMode.Open),MimeType); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/JobController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/JobController.cs new file mode 100644 index 00000000..84566713 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/JobController.cs @@ -0,0 +1,104 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common; +using Yi.Framework.Common.Const; +using Yi.Framework.Common.Helper; +using Yi.Framework.Common.Models; +using Yi.Framework.Core; +using Yi.Framework.DTOModel; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.ApiMicroservice.Controllers +{ + [ApiController] + [Route("api/[controller]/[action]")] + public class JobController : Controller + { + private readonly ILogger _logger; + private QuartzInvoker _quartzInvoker; + public JobController(ILogger logger,QuartzInvoker quartzInvoker) + { + _logger = logger; + _quartzInvoker = quartzInvoker; + } + + /// + /// + /// + /// + [HttpPost] + public async Task startJob() + { + //任务1 + //await _quartzInvoker.start("*/1 * * * * ? ", new Quartz.JobKey("test", "my"), "VisitJob"); + + //任务2 + Dictionary data = new Dictionary() + { + {JobConst.method,"get" }, + {JobConst.url,"https://www.baidu.com" } + }; + await _quartzInvoker.start("*/1 * * * * ? ", new Quartz.JobKey("test", "my"), "HttpJob",data: data); + return Result.Success(); + } + + /// + /// + /// + /// + [HttpGet] + public async Task getRunJobList() + { + return Result.Success().SetData(await _quartzInvoker.getRunJobList()); + } + + /// + /// + /// + /// + [HttpGet] + public Result getJobClass() + { + return Result.Success().SetData(_quartzInvoker.getJobClassList()); + } + + /// + /// + /// + /// + [HttpPut] + public async Task stopJob() + { + await _quartzInvoker.Stop(new Quartz.JobKey("test", "my")); + return Result.Success(); + } + + /// + /// + /// + /// + [HttpDelete] + public async Task DeleteJob() + { + await _quartzInvoker.Delete(new Quartz.JobKey("test", "my")); + return Result.Success(); + } + + /// + /// + /// + /// + [HttpPut] + public async Task ResumeJob() + { + await _quartzInvoker.Resume(new Quartz.JobKey("test", "my")); + return Result.Success(); + } + } +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs new file mode 100644 index 00000000..ce14e68b --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs @@ -0,0 +1,113 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.DTOModel; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.WebCore; + +namespace Yi.Framework.ApiMicroservice.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize] + public class MenuController : ControllerBase + { + private IMenuService _menuService; + public MenuController(IMenuService menuService) + { + _menuService = menuService; + } + /// + /// 这个是要递归的,但是要过滤掉删除的,所以,可以写一个通用过滤掉删除的方法 + /// + /// + [HttpGet] + public async Task GetMenuInMould() + { + return Result.Success().SetData(await _menuService.GetMenuInMould()); + } + + /// + /// 更 + /// + /// + /// + [HttpPut] + public async Task UpdateMenu(menu _menu) + { + await _menuService.UpdateAsync(_menu); + return Result.Success(); + + } + + /// + /// 删 + /// + /// + /// + [HttpDelete] + public async Task DelListMenu(List _ids) + { + await _menuService.DelListByUpdateAsync(_ids); + return Result.Success(); + } + + /// + /// 增 + /// 现在,top菜单只允许为一个 + /// + /// + /// + [HttpPost] + public async Task AddTopMenu(menu _menu) + { + await _menuService.AddTopMenu(_menu); + return Result.Success(); + } + + /// + /// 给一个菜单设置一个接口,Id1为菜单id,Id2为接口id + /// 用于给菜单设置接口 + /// + /// + /// + [HttpPost] + public async Task SetMouldByMenu(IdDto idDto) + { + await _menuService.SetMouldByMenu(idDto.id1, idDto.id2); + return Result.Success(); + } + + + /// + /// 给一个菜单添加子节点(注意:添加,不是覆盖) + /// + /// + /// + [HttpPost] + public async Task AddChildrenMenu(ChildrenDto childrenDto) + { + await _menuService.AddChildrenMenu(childrenDto.parentId, childrenDto.data); + return Result.Success(); + } + + /// + /// 获取用户的目录菜单,不包含接口 + /// 用于账户信息页面,显示这个用户有哪些菜单,需要并列 + /// + /// + [HttpGet] + public async Task GetTopMenusByHttpUser() + { + HttpContext.GetCurrentUserInfo(out List menuIds); + + return Result.Success().SetData(await _menuService.GetTopMenusByTopMenuIds(menuIds)); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MouldController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MouldController.cs new file mode 100644 index 00000000..7c0ee94a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MouldController.cs @@ -0,0 +1,69 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.ApiMicroservice.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize] + public class MouldController : ControllerBase + { + private IMouldService _mouldService; + public MouldController(IMouldService mouldService) + { + _mouldService = mouldService; + } + [HttpGet] + public async Task GetMould() + { + return Result.Success().SetData(await _mouldService.GetAllEntitiesTrueAsync()); + } + + /// + /// 更 + /// + /// + /// + [HttpPut] + public async Task UpdateMould(mould _mould) + { + await _mouldService.UpdateAsync(_mould); + return Result.Success(); + + } + + /// + /// 删 + /// + /// + /// + [HttpDelete] + public async Task DelListMould(List _ids) + { + await _mouldService.DelListByUpdateAsync(_ids); + return Result.Success(); + } + + /// + /// 增 + /// + /// + /// + [HttpPost] + public async Task AddMould(mould _mould) + { + await _mouldService.AddAsync(_mould); + return Result.Success(); + } + + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs new file mode 100644 index 00000000..46fe2cc3 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs @@ -0,0 +1,106 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.DTOModel; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.WebCore; + +namespace Yi.Framework.ApiMicroservice.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize] + public class RoleController : ControllerBase + { + private IRoleService _roleService; + public RoleController(IRoleService roleService) + { + _roleService = roleService; + } + [HttpGet] + public async Task GetRole() + { + return Result.Success().SetData(await _roleService.GetAllEntitiesTrueAsync()); + } + + + /// + /// 更 + /// + /// + /// + [HttpPut] + public async Task UpdateRole(role _role) + { + await _roleService.UpdateAsync(_role); + return Result.Success(); + + } + + /// + /// 删 + /// + /// + /// + [HttpDelete] + public async Task DelListRole(List _ids) + { + await _roleService.DelListByUpdateAsync(_ids); + return Result.Success(); + } + + /// + /// 增 + /// + /// + /// + [HttpPost] + public async Task AddRole(role _role) + { + await _roleService.AddAsync(_role); + return Result.Success(); + } + + /// + /// 根据用户id得到该用户有哪些角色 + /// 用于显示用户详情中的角色说明 + /// + /// + [HttpGet] + public async Task GetRolesByUserId(int userId) + { + + return Result.Success().SetData(await _roleService.GetRolesByUserId(userId)); + } + /// + /// 给角色设置菜单,多个角色与多个菜单,让每一个角色都设置,ids1为角色,ids2为菜单 + /// 用于设置角色 + /// + /// + /// + [HttpPost] + public async Task SetMenuByRole(IdsListDto idsListDto) + { + await _roleService.SetMenusByRolesId(idsListDto.ids2, idsListDto.ids1); + return Result.Success(); + } + /// + /// 用于给角色设置菜单的时候,点击一个角色,显示这个角色拥有的并列的菜单 + /// + /// + /// + [HttpGet] + public async Task GetTopMenusByRoleId(int roleId) + { + + return Result.Success().SetData(await _roleService.GetTopMenusByRoleId(roleId) ); ; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/SettingController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/SettingController.cs new file mode 100644 index 00000000..d101bc9d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/SettingController.cs @@ -0,0 +1,60 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common.Const; +using Yi.Framework.Common.Models; +using Yi.Framework.Core; +using Yi.Framework.DTOModel; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.WebCore; + +namespace Yi.Framework.ApiMicroservice.Controllers +{ + [ApiController] + [Route("api/[controller]/[action]")] + [Authorize] + public class SettingController : ControllerBase + { + private readonly ILogger _logger; + private readonly CacheClientDB _cacheClientDB; + + public SettingController(ILogger logger, CacheClientDB cacheClientDB) + { + _logger = logger; + _cacheClientDB = cacheClientDB; + } + + + + /// + /// 查 + /// + /// + [HttpGet] + public Result GetSetting() + { + var setDto = Common.Helper.JsonHelper.StrToObj(_cacheClientDB.Get(RedisConst.key)); + return Result.Success().SetData( setDto); + } + + /// + /// 更 + /// + /// + /// + [HttpPut] + public Result UpdateSetting(SettingDto settingDto) + { + var setDto = Common.Helper.JsonHelper.ObjToStr(settingDto); + + _cacheClientDB.Set(RedisConst.key, setDto); + return Result.Success(); + + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs new file mode 100644 index 00000000..c552a081 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs @@ -0,0 +1,147 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.DTOModel; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; +using Yi.Framework.WebCore; + +namespace Yi.Framework.ApiMicroservice.Controllers +{ + [ApiController] + [Route("api/[controller]/[action]")] + [Authorize] + public class UserController : ControllerBase + { + private readonly ILogger _logger; + + private IUserService _userService; + public UserController(ILogger logger, IUserService userService) + { + _logger = logger; + _userService = userService; + } + + /// + /// 查 + /// + /// + [HttpGet] + public async Task GetUser() + { + return Result.Success().SetData(await _userService.GetAllEntitiesTrueAsync()); + } + + /// + /// 更 + /// + /// + /// + [HttpPut] + public async Task UpdateUser(user _user) + { + await _userService.UpdateAsync(_user); + return Result.Success(); + + } + + /// + /// 删 + /// + /// + /// + [HttpDelete] + public async Task DelListUser(List _ids) + { + await _userService.DelListByUpdateAsync(_ids); + return Result.Success(); + } + + /// + /// 增 + /// + /// + /// + [HttpPost] + public async Task AddUser(user _user) + { + await _userService.AddAsync(_user); + return Result.Success(); + } + + + /// + /// SetRoleByUser + /// 给多个用户设置多个角色,ids有用户id与 角色列表ids,多对多,ids1用户,ids2为角色 + /// 用户设置给用户设置角色 + /// + /// + /// + [HttpPost] + public async Task SetRoleByUser(IdsListDto idsListDto) + { + await _userService.SetRoleByUser(idsListDto.ids2, idsListDto.ids1); + return Result.Success(); + } + + /// + /// 根据http上下文的用户得到该用户信息,关联角色 + /// 用于显示账号信息页中的用户信息和角色信息 + /// + /// + [HttpGet] + public async Task GetUserInRolesByHttpUser() + { + var _user = HttpContext.GetCurrentUserInfo(); + return Result.Success().SetData( await _userService.GetUserInRolesByHttpUser(_user.id)); + } + + /// + /// 得到登录用户的递归菜单,放到导航栏 + /// 用户放到导航栏中 + /// + /// + [HttpGet] + public async Task GetMenuByHttpUser() + { + HttpContext.GetCurrentUserInfo(out var allMenuIds); + return Result.Success().SetData(await _userService.GetMenuByHttpUser(allMenuIds)); + } + + /// + /// 得到请求模型 + /// + /// + /// + [HttpGet] + public async Task GetAxiosByRouter(string router) + { + + var _user = HttpContext.GetCurrentUserInfo(out List menuIds); + if (menuIds == null) + { + return Result.Error(); + } + var menuList= await _userService.GetAxiosByRouter(router, _user.id, menuIds); + AxiosUrlsModel urlsModel = new(); + menuList.ForEach(u => + { + switch (u.menu_name) + { + case "get":urlsModel.get = u.mould.url;break; + case "del": urlsModel.del = u.mould.url; break; + case "add": urlsModel.add = u.mould.url; break; + case "update": urlsModel.update = u.mould.url; break; + } + }); + + return Result.Success().SetData(urlsModel); + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Log4net.config b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Log4net.config new file mode 100644 index 00000000..958c7e78 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Log4net.config @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs new file mode 100644 index 00000000..6a1ce8a9 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs @@ -0,0 +1,157 @@ +using Autofac.Extensions.DependencyInjection; +using Yi.Framework.WebCore.BuilderExtend; +using Yi.Framework.Core; +using Yi.Framework.Model.ModelFactory; +using Yi.Framework.WebCore.MiddlewareExtend; +using Yi.Framework.WebCore.Utility; +using Autofac; + +var builder = WebApplication.CreateBuilder(args); + +builder.Host.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) => + { + configurationBuilder.AddCommandLine(args); + configurationBuilder.AddJsonFileService(); + #region + //Apollo + #endregion + configurationBuilder.AddApolloService("Yi"); + }); +builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()); +builder.Host.ConfigureContainer(containerBuilder => +{ + #region + //Moduleע + #endregion + containerBuilder.RegisterModule(); +}); +builder.Host.ConfigureLogging(loggingBuilder => + { + loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning); + loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning); + loggingBuilder.AddLog4Net(); + }); +#region +// +//builder.Host.ConfigureWebHostDefaults(webBuilder => +// { +// //webBuilder.UseStartup(); +// }); +#endregion +//----------------------------------------------------------------------------------------------------------- +#region +//Ioc +#endregion +builder.Services.AddIocService(builder.Configuration); + +#region +//Quartz +#endregion +builder.Services.AddQuartzService(); +#region +//+ +#endregion +builder.Services.AddControllers(optios => { + //optios.Filters.Add(typeof(CustomExceptionFilterAttribute)); +}).AddJsonFileService(); +#region +//Swagger +#endregion +builder.Services.AddSwaggerService(); +#region +// +#endregion +builder.Services.AddCorsService(); +#region +//JwtȨ +#endregion +builder.Services.AddJwtService(); +#region +//ݿ +#endregion +builder.Services.AddDbService(); +#region +//Redis +#endregion +builder.Services.AddRedisService(); +#region +//RabbitMQ +#endregion +builder.Services.AddRabbitMQService(); +#region +//ElasticSeach +#endregion +builder.Services.AddElasticSeachService(); +#region +//ŷ +#endregion +builder.Services.AddSMSService(); +#region +//CAP +#endregion +builder.Services.AddCAPService(); +//----------------------------------------------------------------------------------------------------------- +var app = builder.Build(); +//if (app.Environment.IsDevelopment()) +{ + #region + //ҳע + #endregion + app.UseDeveloperExceptionPage(); + #region + //Swaggerע + #endregion + app.UseSwaggerService(); +} +#region +//ץȡע +#endregion +app.UseErrorHandlingService(); +#region +//̬ļע +#endregion +//app.UseStaticFiles(); +#region +//HttpsRedirectionע +#endregion +app.UseHttpsRedirection(); +#region +//·ע +#endregion +app.UseRouting(); +#region +//ע +#endregion +app.UseCorsService(); +#region +//ע +#endregion +app.UseHealthCheckMiddleware(); +#region +//Ȩע +#endregion +app.UseAuthentication(); +#region +//Ȩע +#endregion +app.UseAuthorization(); +#region +//Consulע +#endregion +app.UseConsulService(); +#region +//ݿע +#endregion +app.UseDbSeedInitService(app.Services.GetService()); +#region +//redisע +#endregion +app.UseRedisSeedInitService(app.Services.GetService()); +#region +//Endpointsע +#endregion +app.UseEndpoints(endpoints => +{ + endpoints.MapControllers(); +}); +app.Run(); \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/SwaggerDoc.xml new file mode 100644 index 00000000..3173de6a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/SwaggerDoc.xml @@ -0,0 +1,278 @@ + + + + Yi.Framework.ApiMicroservice + + + + + 登录方法,要返回data:{user,token} token + + + + + + + 不用写,单纯制作日志 + + + + + + code为验证码,从redis中判断一下code是否正确 + + + + + + + + 发送短信,需要将生成的sms+code存入redis + + + + + + + 发送邮箱,需要先到数据库判断该邮箱是否被人注册过,到userservice写mail_exist方法,还有接口别忘了。 + + + + + + + 修改密码 + + + + + + + 该方法不对外暴露 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 这个是要递归的,但是要过滤掉删除的,所以,可以写一个通用过滤掉删除的方法 + + + + + + 更 + + + + + + + 删 + + + + + + + 增 + 现在,top菜单只允许为一个 + + + + + + + 给一个菜单设置一个接口,Id1为菜单id,Id2为接口id + 用于给菜单设置接口 + + + + + + + 给一个菜单添加子节点(注意:添加,不是覆盖) + + + + + + + 获取用户的目录菜单,不包含接口 + 用于账户信息页面,显示这个用户有哪些菜单,需要并列 + + + + + + 更 + + + + + + + 删 + + + + + + + 增 + + + + + + + 更 + + + + + + + 删 + + + + + + + 增 + + + + + + + 根据用户id得到该用户有哪些角色 + 用于显示用户详情中的角色说明 + + + + + + 给角色设置菜单,多个角色与多个菜单,让每一个角色都设置,ids1为角色,ids2为菜单 + 用于设置角色 + + + + + + + 用于给角色设置菜单的时候,点击一个角色,显示这个角色拥有的并列的菜单 + + + + + + + 查 + + + + + + 更 + + + + + + + 查 + + + + + + 更 + + + + + + + 删 + + + + + + + 增 + + + + + + + SetRoleByUser + 给多个用户设置多个角色,ids有用户id与 角色列表ids,多对多,ids1用户,ids2为角色 + 用户设置给用户设置角色 + + + + + + + 根据http上下文的用户得到该用户信息,关联角色 + 用于显示账号信息页中的用户信息和角色信息 + + + + + + 得到登录用户的递归菜单,放到导航栏 + 用户放到导航栏中 + + + + + + 得到请求模型 + + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj new file mode 100644 index 00000000..91146868 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj @@ -0,0 +1,40 @@ + + + + net6.0 + enable + + + + D:\CC.Yi\CC.Yi\Yi.Framework\Yi.Framework.ApiMicroservice\SwaggerDoc.xml + 1701;1702;CS1591 + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102231510.xlsx b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102231510.xlsx new file mode 100644 index 00000000..f1634a6f Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102231510.xlsx differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102232113.xlsx b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102232113.xlsx new file mode 100644 index 00000000..428fa119 Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/Excel/Excel_20211102232113.xlsx differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/0a5221e4-dca6-4d4e-8486-acf86822f2e4.jpg b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/0a5221e4-dca6-4d4e-8486-acf86822f2e4.jpg new file mode 100644 index 00000000..0e7512ee Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/0a5221e4-dca6-4d4e-8486-acf86822f2e4.jpg differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/1b0a926d-ddce-4048-9b09-e2b8ec37c161.jpg b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/1b0a926d-ddce-4048-9b09-e2b8ec37c161.jpg new file mode 100644 index 00000000..aa4daf73 Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/1b0a926d-ddce-4048-9b09-e2b8ec37c161.jpg differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/3d6ed457-0c20-4ce6-b91c-8c424f2f03bb.jpeg b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/3d6ed457-0c20-4ce6-b91c-8c424f2f03bb.jpeg new file mode 100644 index 00000000..a1070258 Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/3d6ed457-0c20-4ce6-b91c-8c424f2f03bb.jpeg differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/6312706b-7013-4aa5-af3c-0bbb6b3f4804.jpg b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/6312706b-7013-4aa5-af3c-0bbb6b3f4804.jpg new file mode 100644 index 00000000..b1bdce5b Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/6312706b-7013-4aa5-af3c-0bbb6b3f4804.jpg differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/7ca98a58-8822-40f5-a766-2a2dd21d2431.jpg b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/7ca98a58-8822-40f5-a766-2a2dd21d2431.jpg new file mode 100644 index 00000000..aa4daf73 Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/7ca98a58-8822-40f5-a766-2a2dd21d2431.jpg differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/966200f6-265c-4470-ad20-c91c3d84a1cc.jpg b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/966200f6-265c-4470-ad20-c91c3d84a1cc.jpg new file mode 100644 index 00000000..0e7512ee Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/966200f6-265c-4470-ad20-c91c3d84a1cc.jpg differ diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/feae1964-04ce-464b-848b-86f2245f3f63.jpeg b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/feae1964-04ce-464b-848b-86f2245f3f63.jpeg new file mode 100644 index 00000000..76a391b4 Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/wwwroot/image/feae1964-04ce-464b-848b-86f2245f3f63.jpeg differ diff --git a/Yi.Framework.Net6/Yi.Framework.AuthenticationCenter/Controllers/WeatherForecastController.cs b/Yi.Framework.Net6/Yi.Framework.AuthenticationCenter/Controllers/WeatherForecastController.cs new file mode 100644 index 00000000..3eeeea74 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.AuthenticationCenter/Controllers/WeatherForecastController.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Yi.Framework.AuthenticationCenter.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.AuthenticationCenter/Program.cs b/Yi.Framework.Net6/Yi.Framework.AuthenticationCenter/Program.cs new file mode 100644 index 00000000..e75b3a47 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.AuthenticationCenter/Program.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Yi.Framework.AuthenticationCenter +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.AuthenticationCenter/Startup.cs b/Yi.Framework.Net6/Yi.Framework.AuthenticationCenter/Startup.cs new file mode 100644 index 00000000..6c28a88d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.AuthenticationCenter/Startup.cs @@ -0,0 +1,59 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Yi.Framework.AuthenticationCenter +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + + services.AddControllers(); + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "Yi.Framework.AuthenticationCenter", Version = "v1" }); + }); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + app.UseSwagger(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Yi.Framework.AuthenticationCenter v1")); + } + + app.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.AuthenticationCenter/Yi.Framework.AuthenticationCenter.csproj b/Yi.Framework.Net6/Yi.Framework.AuthenticationCenter/Yi.Framework.AuthenticationCenter.csproj new file mode 100644 index 00000000..9da1712b --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.AuthenticationCenter/Yi.Framework.AuthenticationCenter.csproj @@ -0,0 +1,11 @@ + + + + net6.0 + + + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Const/DbConst.cs b/Yi.Framework.Net6/Yi.Framework.Common/Const/DbConst.cs new file mode 100644 index 00000000..99950713 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Const/DbConst.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Const +{ + public class DbConst + { + public const string Mysql = "Mysql"; + public const string Sqlite = "Sqlite"; + public const string Sqlserver = "Sqlserver"; + public const string Oracle = "Oracle"; + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Const/FileConst.cs b/Yi.Framework.Net6/Yi.Framework.Common/Const/FileConst.cs new file mode 100644 index 00000000..a7ae7119 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Const/FileConst.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Const +{ + public class FileConst + { + public const string Image = "Image"; + public const string File = "File"; + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Const/JobConst.cs b/Yi.Framework.Net6/Yi.Framework.Common/Const/JobConst.cs new file mode 100644 index 00000000..ce81cb0a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Const/JobConst.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Const +{ + public class JobConst + { + + public const string url = nameof(url); + + public const string method = nameof(method); + } + +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Const/JwtConst.cs b/Yi.Framework.Net6/Yi.Framework.Common/Const/JwtConst.cs new file mode 100644 index 00000000..7ea25ea2 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Const/JwtConst.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Yi.Framework.Common.Const +{ + public class JwtConst + { + public const string SecurityKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"; + public const string Domain = "https://localhost:44329"; + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Const/RabbitConst.cs b/Yi.Framework.Net6/Yi.Framework.Common/Const/RabbitConst.cs new file mode 100644 index 00000000..cb7f294e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Const/RabbitConst.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Const +{ + public class RabbitConst + { + private const string prefix = "Yi.Framework."; + public const string SMS_Exchange = prefix+"SMS.Exchange"; + public const string SMS_Queue_Send = prefix+ "SMS.Queue.Send"; + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Const/RedisConst.cs b/Yi.Framework.Net6/Yi.Framework.Common/Const/RedisConst.cs new file mode 100644 index 00000000..1c59a4db --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Const/RedisConst.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Const +{ + public class RedisConst + { + /// + /// 前缀 + /// + public const string key = "YiFramework:data"; + + public const string keyCode = "YiFramework:code"; + ///// + ///// 初始化角色名 + ///// + //public const string InitRole_key = nameof(InitRole_key); + + ///// + ///// 标题名 + ///// + //public const string Title_key = nameof(Title_key); + + ///// + ///// 图片列表名 + ///// + //public const string ImageList_key = nameof(ImageList_key); + + //public static Dictionary stringData = new Dictionary() + //{ + // {prefix+nameof(InitRole_key), "普通用户"}, + // {prefix+nameof(Title_key), "YiFramework"}, + //}; + + //public static Dictionary> listData = new Dictionary>() + //{ + // {prefix+nameof(ImageList_key), new List(){"图片地址1", "图片地址2", "图片地址3", "图片地址4" } } + //}; + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/AssemblyHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/AssemblyHelper.cs new file mode 100644 index 00000000..ac95e268 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/AssemblyHelper.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Helper +{ + public class AssemblyHelper + { + public static List GetClass(string assemblyFile, string className = null, string spaceName=null) + { + Assembly assembly = Assembly.Load(assemblyFile); + return assembly.GetTypes().Where(m => m.IsClass + && className == null?true:m.Name==className + && spaceName == null ? true :m.Namespace == spaceName + ).ToList(); + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/Base32Helper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/Base32Helper.cs new file mode 100644 index 00000000..3d422caa --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/Base32Helper.cs @@ -0,0 +1,101 @@ +using System; +using System.Text; + +namespace Yi.Framework.Common.Helper +{ + public sealed class Base32Helper + { + + // the valid chars for the encoding + private static string ValidChars = "QAZ2WSX3" + "EDC4RFV5" + "TGB6YHN7" + "UJM8K9LP"; + + /// + /// Converts an array of bytes to a Base32-k string. + /// + public static string ToString(byte[] bytes) + { + StringBuilder sb = new StringBuilder(); // holds the base32 chars + byte index; + int hi = 5; + int currentByte = 0; + + while (currentByte < bytes.Length) + { + // do we need to use the next byte? + if (hi > 8) + { + // get the last piece from the current byte, shift it to the right + // and increment the byte counter + index = (byte)(bytes[currentByte++] >> (hi - 5)); + if (currentByte != bytes.Length) + { + // if we are not at the end, get the first piece from + // the next byte, clear it and shift it to the left + index = (byte)(((byte)(bytes[currentByte] << (16 - hi)) >> 3) | index); + } + + hi -= 3; + } + else if (hi == 8) + { + index = (byte)(bytes[currentByte++] >> 3); + hi -= 3; + } + else + { + + // simply get the stuff from the current byte + index = (byte)((byte)(bytes[currentByte] << (8 - hi)) >> 3); + hi += 5; + } + + sb.Append(ValidChars[index]); + } + + return sb.ToString(); + } + + + /// + /// Converts a Base32-k string into an array of bytes. + /// + /// + /// Input string s contains invalid Base32-k characters. + /// + public static byte[] FromBase32String(string str) + { + int numBytes = str.Length * 5 / 8; + byte[] bytes = new Byte[numBytes]; + + // all UPPERCASE chars + str = str.ToUpper(); + + int bit_buffer; + int currentCharIndex; + int bits_in_buffer; + + if (str.Length < 3) + { + bytes[0] = (byte)(ValidChars.IndexOf(str[0]) | ValidChars.IndexOf(str[1]) << 5); + return bytes; + } + + bit_buffer = (ValidChars.IndexOf(str[0]) | ValidChars.IndexOf(str[1]) << 5); + bits_in_buffer = 10; + currentCharIndex = 2; + for (int i = 0; i < bytes.Length; i++) + { + bytes[i] = (byte)bit_buffer; + bit_buffer >>= 8; + bits_in_buffer -= 8; + while (bits_in_buffer < 8 && currentCharIndex < str.Length) + { + bit_buffer |= ValidChars.IndexOf(str[currentCharIndex++]) << bits_in_buffer; + bits_in_buffer += 5; + } + } + + return bytes; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/ConsoleHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/ConsoleHelper.cs new file mode 100644 index 00000000..50a9688f --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/ConsoleHelper.cs @@ -0,0 +1,54 @@ +using System; + +namespace Yi.Framework.Common.Helper +{ + public static class ConsoleHelper + { + public static void WriteColorLine(string str, ConsoleColor color) + { + ConsoleColor currentForeColor = Console.ForegroundColor; + Console.ForegroundColor = color; + Console.WriteLine(str); + Console.ForegroundColor = currentForeColor; + } + + /// + /// 打印错误信息 + /// + /// 待打印的字符串 + /// 想要打印的颜色 + public static void WriteErrorLine(this string str, ConsoleColor color = ConsoleColor.Red) + { + WriteColorLine(str, color); + } + + /// + /// 打印警告信息 + /// + /// 待打印的字符串 + /// 想要打印的颜色 + public static void WriteWarningLine(this string str, ConsoleColor color = ConsoleColor.Yellow) + { + WriteColorLine(str, color); + } + /// + /// 打印正常信息 + /// + /// 待打印的字符串 + /// 想要打印的颜色 + public static void WriteInfoLine(this string str, ConsoleColor color = ConsoleColor.White) + { + WriteColorLine(str, color); + } + /// + /// 打印成功的信息 + /// + /// 待打印的字符串 + /// 想要打印的颜色 + public static void WriteSuccessLine(this string str, ConsoleColor color = ConsoleColor.Green) + { + WriteColorLine(str, color); + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/DateHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/DateHelper.cs new file mode 100644 index 00000000..0e31e4c7 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/DateHelper.cs @@ -0,0 +1,58 @@ +using System; + +namespace Yi.Framework.Common.Helper +{ + public class DateHelper + { + public static DateTime StampToDateTime(string time) + { + time = time.Substring(0, 10); + double timestamp = Convert.ToInt64(time); + System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0); + dateTime = dateTime.AddSeconds(timestamp).ToLocalTime(); + return dateTime; + } + + public static string TimeSubTract(DateTime time1,DateTime time2) + { + TimeSpan subTract = time1.Subtract(time2); + return $"{subTract.Days} 天 {subTract.Hours} 时 {subTract.Minutes} 分 "; + } + /// + /// 时间戳转本地时间-时间戳精确到秒 + /// + public static DateTime ToLocalTimeDateBySeconds(long unix) + { + var dto = DateTimeOffset.FromUnixTimeSeconds(unix); + return dto.ToLocalTime().DateTime; + } + + /// + /// 时间转时间戳Unix-时间戳精确到秒 + /// + public static long ToUnixTimestampBySeconds(DateTime dt) + { + DateTimeOffset dto = new DateTimeOffset(dt); + return dto.ToUnixTimeSeconds(); + } + + + /// + /// 时间戳转本地时间-时间戳精确到毫秒 + /// + public static DateTime ToLocalTimeDateByMilliseconds(long unix) + { + var dto = DateTimeOffset.FromUnixTimeMilliseconds(unix); + return dto.ToLocalTime().DateTime; + } + + /// + /// 时间转时间戳Unix-时间戳精确到毫秒 + /// + public static long ToUnixTimestampByMilliseconds(DateTime dt) + { + DateTimeOffset dto = new DateTimeOffset(dt); + return dto.ToUnixTimeMilliseconds(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/EmailHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/EmailHelper.cs new file mode 100644 index 00000000..5629592d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/EmailHelper.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Net.Mail; +using System.Net.Sockets; +using System.Text; + +namespace Yi.Framework.Common.Helper +{ + public class EmailHelper + { + public static string fromMail { get; set; } + public static string pwdMail { get; set; } + public static string senderMail { get; set; } + public static string subjectMail { get; set; } + public static void Init(string fromMail,string pwdMail,string senderMail, string subjectMail) + { + EmailHelper.fromMail = fromMail; + EmailHelper.pwdMail = pwdMail; + EmailHelper.senderMail = senderMail; + EmailHelper.subjectMail = subjectMail; + } + + public static bool sendMail(string body, string toMail) + { + try + { + + //string fromMail = "454313500@qq.com"; + //string pwdMail = "yvjioburildgbhdf"; + MailMessage message = new MailMessage(); + //设置发件人,发件人需要与设置的邮件发送服务器的邮箱一致 + System.Net.Mail.MailAddress fromAddr = new System.Net.Mail.MailAddress(fromMail, EmailHelper.senderMail); + message.From = fromAddr; + + //设置收件人,可添加多个,添加方法与下面的一样 + message.To.Add(toMail); + + + //设置邮件标题 + message.Subject = EmailHelper.subjectMail; + + //设置邮件内容 + message.Body = body; + + //设置邮件发送服务器,服务器根据你使用的邮箱而不同,可以到相应的 邮箱管理后台查看,下面是QQ的 + System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.qq.com", 25) + ; + //设置发送人的邮箱账号和密码,POP3/SMTP服务要开启, 密码要是POP3/SMTP等服务的授权码 + client.Credentials = new System.Net.NetworkCredential(fromMail, pwdMail);//vtirsfsthwuadjfe fhszmpegwoqnecja + + //启用ssl,也就是安全发送 + client.EnableSsl = true; + + //发送邮件 + client.Send(message); + + return true; + } + catch + { + return false; + } + + } + + public static void 接受邮件() + { + using (TcpClient client = new TcpClient("pop.qq.com", 110)) + using (NetworkStream n = client.GetStream()) + { + GetEmail.ReadLine(n); // Read the welcome message. + GetEmail.SendCommand(n, "USER 1040079213@qq.com"); + GetEmail.SendCommand(n, "PASS odfaizoqdiupbfgi"); + GetEmail.SendCommand(n, "LIST"); // Retrieve message IDs + List messageIDs = new List(); + while (true) + { + string line = GetEmail.ReadLine(n); // e.g., "11876" + if (line == ".") break; + messageIDs.Add(int.Parse(line.Split(' ')[0])); // Message ID + } + foreach (int id in messageIDs) // Retrieve each message. + { + GetEmail.SendCommand(n, "RETR " + id); + string randomFile = Guid.NewGuid().ToString() + ".eml"; + using (StreamWriter writer = File.CreateText(randomFile)) + while (true) + { + string line = GetEmail.ReadLine(n); // Read next line of message. + if (line == ".") break; // Single dot = end of message. + if (line == "..") line = "."; // "Escape out" double dot. + writer.WriteLine(line); // Write to output file. + } + GetEmail.SendCommand(n, "DELE " + id); // Delete message off server. + } + GetEmail.SendCommand(n, "QUIT"); + } + } + } + //接受邮件pop + public class GetEmail + { + public static void SendCommand(Stream stream, string line) + { + byte[] data = Encoding.UTF8.GetBytes(line + "\r\n"); + stream.Write(data, 0, data.Length); + string response = ReadLine(stream); + if (!response.StartsWith("+OK")) + throw new Exception("POP Error: " + response); + } + public static string ReadLine(Stream s) + { + List lineBuffer = new List(); + while (true) + { + int b = s.ReadByte(); + if (b == 10 || b < 0) break; + if (b != 13) lineBuffer.Add((byte)b); + } + return Encoding.UTF8.GetString(lineBuffer.ToArray()); + } + } +} + diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/ExcelHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/ExcelHelper.cs new file mode 100644 index 00000000..8d0f808d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/ExcelHelper.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using OfficeOpenXml; + +namespace Yi.Framework.Common.Helper +{ + public class ExcelHelper + { + /// + /// + /// + /// + /// 数据 + /// 表头 + /// + public static string CreateExcelFromList(List dataList, List headers,string evn) + { + ExcelPackage.LicenseContext = LicenseContext.NonCommercial; + string sWebRootFolder = Path.Combine($"{evn}", "wwwroot/Excel");//如果用浏览器url下载的方式 存放excel的文件夹一定要建在网站首页的同级目录下!!! + if (!Directory.Exists(sWebRootFolder)) + { + Directory.CreateDirectory(sWebRootFolder); + } + string sFileName = $@"Excel_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"; + var path = Path.Combine(sWebRootFolder, sFileName); + FileInfo file = new FileInfo(path); + if (file.Exists) + { + file.Delete(); + file = new FileInfo(path); + } + using (ExcelPackage package = new(file)) + { + //创建sheet + ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("sheet1"); + worksheet.Cells.LoadFromCollection(dataList, true); + //表头字段 + for (int i = 0; i < headers.Count; i++) + { + worksheet.Cells[1, i + 1].Value = headers[i]; + } + for (int i = 0; i < headers.Count + 1; i++) + {//删除不需要的列 + string aa = worksheet.Cells[1, i + 1].Value.ToString(); + if (aa == "总行数") + { + worksheet.DeleteColumn(i + 1); + } + } + package.Save(); + } + //return path;//这是返回文件的方式 + return sFileName; //如果用浏览器url下载的方式 这里直接返回生成的文件名就可以了 + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/FileHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/FileHelper.cs new file mode 100644 index 00000000..2ffc9ba2 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/FileHelper.cs @@ -0,0 +1,395 @@ +using System; +using System.IO; +using System.Linq; +using System.Text; + +namespace Yi.Framework.Common.Helper +{ + public class FileHelper : IDisposable + { + + private bool _alreadyDispose = false; + + #region 构造函数 + public FileHelper() + { + // + // TODO: 在此处添加构造函数逻辑 + // + } + ~FileHelper() + { + Dispose(); ; + } + + protected virtual void Dispose(bool isDisposing) + { + if (_alreadyDispose) return; + _alreadyDispose = true; + } + #endregion + + #region IDisposable 成员 + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + #endregion + + #region 取得文件后缀名 + /**************************************** + * 函数名称:GetPostfixStr + * 功能说明:取得文件后缀名 + * 参 数:filename:文件名称 + * 调用示列: + * string filename = "aaa.aspx"; + * string s = EC.FileObj.GetPostfixStr(filename); + *****************************************/ + /// + /// 取后缀名 + /// + /// 文件名 + /// .gif|.html格式 + public static string GetPostfixStr(string filename) + { + int start = filename.LastIndexOf("."); + int length = filename.Length; + string postfix = filename.Substring(start, length - start); + return postfix; + } + #endregion + + #region 根据文件大小获取指定前缀的可用文件名 + /// + /// 根据文件大小获取指定前缀的可用文件名 + /// + /// 文件夹 + /// 文件前缀 + /// 文件大小(1m) + /// 文件后缀(.log) + /// 可用文件名 + //public static string GetAvailableFileWithPrefixOrderSize(string folderPath, string prefix, int size = 1 * 1024 * 1024, string ext = ".log") + //{ + // var allFiles = new DirectoryInfo(folderPath); + // var selectFiles = allFiles.GetFiles().Where(fi => fi.Name.ToLower().Contains(prefix.ToLower()) && fi.Extension.ToLower() == ext.ToLower() && fi.Length < size).OrderByDescending(d=>d.Name).ToList(); + + // if (selectFiles.Count > 0) + // { + // return selectFiles.FirstOrDefault().FullName; + // } + + // return Path.Combine(folderPath, $@"{prefix}_{DateTime.Now.DateToTimeStamp()}.log"); + //} + //public static string GetAvailableFileNameWithPrefixOrderSize(string _contentRoot, string prefix, int size = 1 * 1024 * 1024, string ext = ".log") + //{ + // var folderPath = Path.Combine(_contentRoot, "Log"); + // if (!Directory.Exists(folderPath)) + // { + // Directory.CreateDirectory(folderPath); + // } + + // var allFiles = new DirectoryInfo(folderPath); + // var selectFiles = allFiles.GetFiles().Where(fi => fi.Name.ToLower().Contains(prefix.ToLower()) && fi.Extension.ToLower() == ext.ToLower() && fi.Length < size).OrderByDescending(d => d.Name).ToList(); + + // if (selectFiles.Count > 0) + // { + // return selectFiles.FirstOrDefault().Name.Replace(".log",""); + // } + + // return $@"{prefix}_{DateTime.Now.DateToTimeStamp()}"; + //} + #endregion + + #region 写文件 + /**************************************** + * 函数名称:WriteFile + * 功能说明:写文件,会覆盖掉以前的内容 + * 参 数:Path:文件路径,Strings:文本内容 + * 调用示列: + * string Path = Server.MapPath("Default2.aspx"); + * string Strings = "这是我写的内容啊"; + * EC.FileObj.WriteFile(Path,Strings); + *****************************************/ + /// + /// 写文件 + /// + /// 文件路径 + /// 文件内容 + public static void WriteFile(string Path, string Strings) + { + if (!File.Exists(Path)) + { + FileStream f = File.Create(Path); + f.Close(); + } + StreamWriter f2 = new StreamWriter(Path, false, System.Text.Encoding.GetEncoding("gb2312")); + f2.Write(Strings); + f2.Close(); + f2.Dispose(); + } + + /// + /// 写文件 + /// + /// 文件路径 + /// 文件内容 + /// 编码格式 + public static void WriteFile(string Path, string Strings, Encoding encode) + { + if (!File.Exists(Path)) + { + FileStream f = File.Create(Path); + f.Close(); + } + StreamWriter f2 = new StreamWriter(Path, false, encode); + f2.Write(Strings); + f2.Close(); + f2.Dispose(); + } + #endregion + + #region 读文件 + /**************************************** + * 函数名称:ReadFile + * 功能说明:读取文本内容 + * 参 数:Path:文件路径 + * 调用示列: + * string Path = Server.MapPath("Default2.aspx"); + * string s = EC.FileObj.ReadFile(Path); + *****************************************/ + /// + /// 读文件 + /// + /// 文件路径 + /// + public static string ReadFile(string Path) + { + string s = ""; + if (!File.Exists(Path)) + s = "不存在相应的目录"; + else + { + StreamReader f2 = new StreamReader(Path, System.Text.Encoding.GetEncoding("gb2312")); + s = f2.ReadToEnd(); + f2.Close(); + f2.Dispose(); + } + + return s; + } + + /// + /// 读文件 + /// + /// 文件路径 + /// 编码格式 + /// + public static string ReadFile(string Path, Encoding encode) + { + string s = ""; + if (!File.Exists(Path)) + s = "不存在相应的目录"; + else + { + StreamReader f2 = new StreamReader(Path, encode); + s = f2.ReadToEnd(); + f2.Close(); + f2.Dispose(); + } + + return s; + } + #endregion + + #region 追加文件 + /**************************************** + * 函数名称:FileAdd + * 功能说明:追加文件内容 + * 参 数:Path:文件路径,strings:内容 + * 调用示列: + * string Path = Server.MapPath("Default2.aspx"); + * string Strings = "新追加内容"; + * EC.FileObj.FileAdd(Path, Strings); + *****************************************/ + /// + /// 追加文件 + /// + /// 文件路径 + /// 内容 + public static void FileAdd(string Path, string strings) + { + StreamWriter sw = File.AppendText(Path); + sw.Write(strings); + sw.Flush(); + sw.Close(); + } + #endregion + + #region 拷贝文件 + /**************************************** + * 函数名称:FileCoppy + * 功能说明:拷贝文件 + * 参 数:OrignFile:原始文件,NewFile:新文件路径 + * 调用示列: + * string orignFile = Server.MapPath("Default2.aspx"); + * string NewFile = Server.MapPath("Default3.aspx"); + * EC.FileObj.FileCoppy(OrignFile, NewFile); + *****************************************/ + /// + /// 拷贝文件 + /// + /// 原始文件 + /// 新文件路径 + public static void FileCoppy(string orignFile, string NewFile) + { + File.Copy(orignFile, NewFile, true); + } + + #endregion + + #region 删除文件 + /**************************************** + * 函数名称:FileDel + * 功能说明:删除文件 + * 参 数:Path:文件路径 + * 调用示列: + * string Path = Server.MapPath("Default3.aspx"); + * EC.FileObj.FileDel(Path); + *****************************************/ + /// + /// 删除文件 + /// + /// 路径 + public static void FileDel(string Path) + { + File.Delete(Path); + } + #endregion + + #region 移动文件 + /**************************************** + * 函数名称:FileMove + * 功能说明:移动文件 + * 参 数:OrignFile:原始路径,NewFile:新文件路径 + * 调用示列: + * string orignFile = Server.MapPath("../说明.txt"); + * string NewFile = Server.MapPath("http://www.cnblogs.com/说明.txt"); + * EC.FileObj.FileMove(OrignFile, NewFile); + *****************************************/ + /// + /// 移动文件 + /// + /// 原始路径 + /// 新路径 + public static void FileMove(string orignFile, string NewFile) + { + File.Move(orignFile, NewFile); + } + #endregion + + #region 在当前目录下创建目录 + /**************************************** + * 函数名称:FolderCreate + * 功能说明:在当前目录下创建目录 + * 参 数:OrignFolder:当前目录,NewFloder:新目录 + * 调用示列: + * string orignFolder = Server.MapPath("test/"); + * string NewFloder = "new"; + * EC.FileObj.FolderCreate(OrignFolder, NewFloder); + *****************************************/ + /// + /// 在当前目录下创建目录 + /// + /// 当前目录 + /// 新目录 + public static void FolderCreate(string orignFolder, string NewFloder) + { + Directory.SetCurrentDirectory(orignFolder); + Directory.CreateDirectory(NewFloder); + } + #endregion + + #region 递归删除文件夹目录及文件 + /**************************************** + * 函数名称:DeleteFolder + * 功能说明:递归删除文件夹目录及文件 + * 参 数:dir:文件夹路径 + * 调用示列: + * string dir = Server.MapPath("test/"); + * EC.FileObj.DeleteFolder(dir); + *****************************************/ + /// + /// 递归删除文件夹目录及文件 + /// + /// + /// + public static void DeleteFolder(string dir) + { + if (Directory.Exists(dir)) //如果存在这个文件夹删除之 + { + foreach (string d in Directory.GetFileSystemEntries(dir)) + { + if (File.Exists(d)) + File.Delete(d); //直接删除其中的文件 + else + DeleteFolder(d); //递归删除子文件夹 + } + Directory.Delete(dir); //删除已空文件夹 + } + + } + #endregion + + #region 将指定文件夹下面的所有内容copy到目标文件夹下面 果目标文件夹为只读属性就会报错。 + /**************************************** + * 函数名称:CopyDir + * 功能说明:将指定文件夹下面的所有内容copy到目标文件夹下面 果目标文件夹为只读属性就会报错。 + * 参 数:srcPath:原始路径,aimPath:目标文件夹 + * 调用示列: + * string srcPath = Server.MapPath("test/"); + * string aimPath = Server.MapPath("test1/"); + * EC.FileObj.CopyDir(srcPath,aimPath); + *****************************************/ + /// + /// 指定文件夹下面的所有内容copy到目标文件夹下面 + /// + /// 原始路径 + /// 目标文件夹 + public static void CopyDir(string srcPath, string aimPath) + { + try + { + // 检查目标目录是否以目录分割字符结束如果不是则添加之 + if (aimPath[aimPath.Length - 1] != Path.DirectorySeparatorChar) + aimPath += Path.DirectorySeparatorChar; + // 判断目标目录是否存在如果不存在则新建之 + if (!Directory.Exists(aimPath)) + Directory.CreateDirectory(aimPath); + // 得到源目录的文件列表,该里面是包含文件以及目录路径的一个数组 + //如果你指向copy目标文件下面的文件而不包含目录请使用下面的方法 + //string[] fileList = Directory.GetFiles(srcPath); + string[] fileList = Directory.GetFileSystemEntries(srcPath); + //遍历所有的文件和目录 + foreach (string file in fileList) + { + //先当作目录处理如果存在这个目录就递归Copy该目录下面的文件 + + if (Directory.Exists(file)) + CopyDir(file, aimPath + Path.GetFileName(file)); + //否则直接Copy文件 + else + File.Copy(file, aimPath + Path.GetFileName(file), true); + } + + } + catch (Exception ee) + { + throw new Exception(ee.ToString()); + } + } + #endregion + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/HtmlHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/HtmlHelper.cs new file mode 100644 index 00000000..1e1e0086 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/HtmlHelper.cs @@ -0,0 +1,24 @@ +namespace Yi.Framework.Common.Helper +{ + public static class HtmlHelper + { + #region 去除富文本中的HTML标签 + /// + /// 去除富文本中的HTML标签 + /// + /// + /// + /// + public static string ReplaceHtmlTag(string html, int length = 0) + { + string strText = System.Text.RegularExpressions.Regex.Replace(html, "<[^>]+>", ""); + strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", ""); + + if (length > 0 && strText.Length > length) + return strText.Substring(0, length); + + return strText; + } + #endregion + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/HttpHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/HttpHelper.cs new file mode 100644 index 00000000..96b7c4c0 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/HttpHelper.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Helper +{ + public static class HttpHelper + { + public static string HttpGet(string Url, string postDataStr="") + { + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr); + request.Method = "GET"; + request.ContentType = "text/html;charset=UTF-8"; + + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + Stream myResponseStream = response.GetResponseStream(); + StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8")); + string retString = myStreamReader.ReadToEnd(); + myStreamReader.Close(); + myResponseStream.Close(); + + return retString; + } + + public static bool HttpIOGet(string Url, string file, string postDataStr="") + { + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr); + request.Method = "GET"; + request.ContentType = "text/html;charset=UTF-8"; + + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + Stream myResponseStream = response.GetResponseStream(); + FileStream writer = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Write); + byte[] buffer = new byte[1024]; + int c; + while ((c = myResponseStream.Read(buffer, 0, buffer.Length)) > 0) + { + writer.Write(buffer, 0, c); + } + writer.Close(); + myResponseStream.Close(); + + return true; + } + + public static string HttpPost(string Url, string postDataStr="") + { + CookieContainer cookie = new CookieContainer(); + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); + request.Method = "POST"; + request.ContentType = "application/x-www-form-urlencoded"; + request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr); + request.CookieContainer = cookie; + Stream myRequestStream = request.GetRequestStream(); + StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("gb2312")); + myStreamWriter.Write(postDataStr); + myStreamWriter.Close(); + + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + + response.Cookies = cookie.GetCookies(response.ResponseUri); + Stream myResponseStream = response.GetResponseStream(); + StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8")); + string retString = myStreamReader.ReadToEnd(); + myStreamReader.Close(); + myResponseStream.Close(); + + return retString; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/IpHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/IpHelper.cs new file mode 100644 index 00000000..b39d112a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/IpHelper.cs @@ -0,0 +1,51 @@ +using System.Linq; +using System.Net; +using System.Net.NetworkInformation; +using System.Net.Sockets; + +namespace Yi.Framework.Common.Helper +{ + public class IpHelper + { + /// + /// 获取当前IP地址 + /// + /// + /// + public static string GetCurrentIp(string preferredNetworks) + { + var instanceIp = "127.0.0.1"; + + try + { + // 获取可用网卡 + var nics = NetworkInterface.GetAllNetworkInterfaces()?.Where(network => network.OperationalStatus == OperationalStatus.Up); + + // 获取所有可用网卡IP信息 + var ipCollection = nics?.Select(x => x.GetIPProperties())?.SelectMany(x => x.UnicastAddresses); + + foreach (var ipadd in ipCollection) + { + if (!IPAddress.IsLoopback(ipadd.Address) && ipadd.Address.AddressFamily == AddressFamily.InterNetwork) + { + if (string.IsNullOrEmpty(preferredNetworks)) + { + instanceIp = ipadd.Address.ToString(); + break; + } + + if (!ipadd.Address.ToString().StartsWith(preferredNetworks)) continue; + instanceIp = ipadd.Address.ToString(); + break; + } + } + } + catch + { + // ignored + } + + return instanceIp; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/JsonHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/JsonHelper.cs new file mode 100644 index 00000000..9b983cbe --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/JsonHelper.cs @@ -0,0 +1,509 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Yi.Framework.Common.Helper +{ + public class JsonHelper + { + + + public static string ObjToStr(T obj) + { + return Newtonsoft.Json.JsonConvert.SerializeObject(obj); + } + + public static T StrToObj(string str) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject(str); + } + /// + /// 转换对象为JSON格式数据 + /// + /// + /// 对象 + /// 字符格式的JSON数据 + public static string GetJSON(object obj) + { + string result = String.Empty; + try + { + JsonSerializer.Serialize(""); + System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = + new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(T)); + using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) + { + serializer.WriteObject(ms, obj); + result = System.Text.Encoding.UTF8.GetString(ms.ToArray()); + } + } + catch (Exception) + { + throw; + } + return result; + } + /// + /// 转换List的数据为JSON格式 + /// + /// + /// 列表值 + /// JSON格式数据 + public string JSON(List vals) + { + System.Text.StringBuilder st = new System.Text.StringBuilder(); + try + { + System.Runtime.Serialization.Json.DataContractJsonSerializer s = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(T)); + + foreach (T city in vals) + { + using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) + { + s.WriteObject(ms, city); + st.Append(System.Text.Encoding.UTF8.GetString(ms.ToArray())); + } + } + } + catch (Exception) + { + } + + return st.ToString(); + } + /// + /// JSON格式字符转换为T类型的对象 + /// + /// + /// + /// + public static T ParseFormByJson(string jsonStr) + { + T obj = Activator.CreateInstance(); + using (System.IO.MemoryStream ms = + new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(jsonStr))) + { + System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = + new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(T)); + return (T)serializer.ReadObject(ms); + } + } + + public string JSON1(List vals) + { + System.Text.StringBuilder st = new System.Text.StringBuilder(); + try + { + System.Runtime.Serialization.Json.DataContractJsonSerializer s = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(SendData)); + + foreach (SendData city in vals) + { + using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) + { + s.WriteObject(ms, city); + st.Append(System.Text.Encoding.UTF8.GetString(ms.ToArray())); + } + } + } + catch (Exception) + { + } + + return st.ToString(); + } + + private static bool IsJsonStart(ref string json) + { + if (!string.IsNullOrEmpty(json)) + { + json = json.Trim('\r', '\n', ' '); + if (json.Length > 1) + { + char s = json[0]; + char e = json[json.Length - 1]; + return (s == '{' && e == '}') || (s == '[' && e == ']'); + } + } + return false; + } + public static bool IsJson(string json) + { + int errIndex; + return IsJson(json, out errIndex); + } + public static bool IsJson(string json, out int errIndex) + { + errIndex = 0; + if (IsJsonStart(ref json)) + { + CharState cs = new CharState(); + char c; + for (int i = 0; i < json.Length; i++) + { + c = json[i]; + if (SetCharState(c, ref cs) && cs.childrenStart)//设置关键符号状态。 + { + string item = json.Substring(i); + int err; + int length = GetValueLength(item, true, out err); + cs.childrenStart = false; + if (err > 0) + { + errIndex = i + err; + return false; + } + i = i + length - 1; + } + if (cs.isError) + { + errIndex = i; + return false; + } + } + + return !cs.arrayStart && !cs.jsonStart; + } + return false; + } + + /// + /// 获取值的长度(当Json值嵌套以"{"或"["开头时) + /// + private static int GetValueLength(string json, bool breakOnErr, out int errIndex) + { + errIndex = 0; + int len = 0; + if (!string.IsNullOrEmpty(json)) + { + CharState cs = new CharState(); + char c; + for (int i = 0; i < json.Length; i++) + { + c = json[i]; + if (!SetCharState(c, ref cs))//设置关键符号状态。 + { + if (!cs.jsonStart && !cs.arrayStart)//json结束,又不是数组,则退出。 + { + break; + } + } + else if (cs.childrenStart)//正常字符,值状态下。 + { + int length = GetValueLength(json.Substring(i), breakOnErr, out errIndex);//递归子值,返回一个长度。。。 + cs.childrenStart = false; + cs.valueStart = 0; + //cs.state = 0; + i = i + length - 1; + } + if (breakOnErr && cs.isError) + { + errIndex = i; + return i; + } + if (!cs.jsonStart && !cs.arrayStart)//记录当前结束位置。 + { + len = i + 1;//长度比索引+1 + break; + } + } + } + return len; + } + + /// + /// 设置字符状态(返回true则为关键词,返回false则当为普通字符处理) + /// + private static bool SetCharState(char c, ref CharState cs) + { + cs.CheckIsError(c); + switch (c) + { + case '{'://[{ "[{A}]":[{"[{B}]":3,"m":"C"}]}] + #region 大括号 + if (cs.keyStart <= 0 && cs.valueStart <= 0) + { + cs.keyStart = 0; + cs.valueStart = 0; + if (cs.jsonStart && cs.state == 1) + { + cs.childrenStart = true; + } + else + { + cs.state = 0; + } + cs.jsonStart = true;//开始。 + return true; + } + #endregion + break; + case '}': + #region 大括号结束 + if (cs.keyStart <= 0 && cs.valueStart < 2 && cs.jsonStart) + { + cs.jsonStart = false;//正常结束。 + cs.state = 0; + cs.keyStart = 0; + cs.valueStart = 0; + cs.setDicValue = true; + return true; + } + // cs.isError = !cs.jsonStart && cs.state == 0; + #endregion + break; + case '[': + #region 中括号开始 + if (!cs.jsonStart) + { + cs.arrayStart = true; + return true; + } + else if (cs.jsonStart && cs.state == 1) + { + cs.childrenStart = true; + return true; + } + #endregion + break; + case ']': + #region 中括号结束 + if (cs.arrayStart && !cs.jsonStart && cs.keyStart <= 2 && cs.valueStart <= 0)//[{},333]//这样结束。 + { + cs.keyStart = 0; + cs.valueStart = 0; + cs.arrayStart = false; + return true; + } + #endregion + break; + case '"': + case '\'': + #region 引号 + if (cs.jsonStart || cs.arrayStart) + { + if (cs.state == 0)//key阶段,有可能是数组["aa",{}] + { + if (cs.keyStart <= 0) + { + cs.keyStart = (c == '"' ? 3 : 2); + return true; + } + else if ((cs.keyStart == 2 && c == '\'') || (cs.keyStart == 3 && c == '"')) + { + if (!cs.escapeChar) + { + cs.keyStart = -1; + return true; + } + else + { + cs.escapeChar = false; + } + } + } + else if (cs.state == 1 && cs.jsonStart)//值阶段必须是Json开始了。 + { + if (cs.valueStart <= 0) + { + cs.valueStart = (c == '"' ? 3 : 2); + return true; + } + else if ((cs.valueStart == 2 && c == '\'') || (cs.valueStart == 3 && c == '"')) + { + if (!cs.escapeChar) + { + cs.valueStart = -1; + return true; + } + else + { + cs.escapeChar = false; + } + } + + } + } + #endregion + break; + case ':': + #region 冒号 + if (cs.jsonStart && cs.keyStart < 2 && cs.valueStart < 2 && cs.state == 0) + { + if (cs.keyStart == 1) + { + cs.keyStart = -1; + } + cs.state = 1; + return true; + } + // cs.isError = !cs.jsonStart || (cs.keyStart < 2 && cs.valueStart < 2 && cs.state == 1); + #endregion + break; + case ',': + #region 逗号 //["aa",{aa:12,}] + + if (cs.jsonStart) + { + if (cs.keyStart < 2 && cs.valueStart < 2 && cs.state == 1) + { + cs.state = 0; + cs.keyStart = 0; + cs.valueStart = 0; + //if (cs.valueStart == 1) + //{ + // cs.valueStart = 0; + //} + cs.setDicValue = true; + return true; + } + } + else if (cs.arrayStart && cs.keyStart <= 2) + { + cs.keyStart = 0; + //if (cs.keyStart == 1) + //{ + // cs.keyStart = -1; + //} + return true; + } + #endregion + break; + case ' ': + case '\r': + case '\n'://[ "a",\r\n{} ] + case '\0': + case '\t': + if (cs.keyStart <= 0 && cs.valueStart <= 0) //cs.jsonStart && + { + return true;//跳过空格。 + } + break; + default: //值开头。。 + if (c == '\\') //转义符号 + { + if (cs.escapeChar) + { + cs.escapeChar = false; + } + else + { + cs.escapeChar = true; + return true; + } + } + else + { + cs.escapeChar = false; + } + if (cs.jsonStart || cs.arrayStart) // Json 或数组开始了。 + { + if (cs.keyStart <= 0 && cs.state == 0) + { + cs.keyStart = 1;//无引号的 + } + else if (cs.valueStart <= 0 && cs.state == 1 && cs.jsonStart)//只有Json开始才有值。 + { + cs.valueStart = 1;//无引号的 + } + } + break; + } + return false; + } + } + /// + /// 字符状态 + /// + public class CharState + { + internal bool jsonStart = false;//以 "{"开始了... + internal bool setDicValue = false;// 可以设置字典值了。 + internal bool escapeChar = false;//以"\"转义符号开始了 + /// + /// 数组开始【仅第一开头才算】,值嵌套的以【childrenStart】来标识。 + /// + internal bool arrayStart = false;//以"[" 符号开始了 + internal bool childrenStart = false;//子级嵌套开始了。 + /// + /// 【0 初始状态,或 遇到“,”逗号】;【1 遇到“:”冒号】 + /// + internal int state = 0; + + /// + /// 【-1 取值结束】【0 未开始】【1 无引号开始】【2 单引号开始】【3 双引号开始】 + /// + internal int keyStart = 0; + /// + /// 【-1 取值结束】【0 未开始】【1 无引号开始】【2 单引号开始】【3 双引号开始】 + /// + internal int valueStart = 0; + internal bool isError = false;//是否语法错误。 + + internal void CheckIsError(char c)//只当成一级处理(因为GetLength会递归到每一个子项处理) + { + if (keyStart > 1 || valueStart > 1) + { + return; + } + //示例 ["aa",{"bbbb":123,"fff","ddd"}] + switch (c) + { + case '{'://[{ "[{A}]":[{"[{B}]":3,"m":"C"}]}] + isError = jsonStart && state == 0;//重复开始错误 同时不是值处理。 + break; + case '}': + isError = !jsonStart || (keyStart != 0 && state == 0);//重复结束错误 或者 提前结束{"aa"}。正常的有{} + break; + case '[': + isError = arrayStart && state == 0;//重复开始错误 + break; + case ']': + isError = !arrayStart || jsonStart;//重复开始错误 或者 Json 未结束 + break; + case '"': + case '\'': + isError = !(jsonStart || arrayStart); //json 或数组开始。 + if (!isError) + { + //重复开始 [""",{"" "}] + isError = (state == 0 && keyStart == -1) || (state == 1 && valueStart == -1); + } + if (!isError && arrayStart && !jsonStart && c == '\'')//['aa',{}] + { + isError = true; + } + break; + case ':': + isError = !jsonStart || state == 1;//重复出现。 + break; + case ',': + isError = !(jsonStart || arrayStart); //json 或数组开始。 + if (!isError) + { + if (jsonStart) + { + isError = state == 0 || (state == 1 && valueStart > 1);//重复出现。 + } + else if (arrayStart)//["aa,] [,] [{},{}] + { + isError = keyStart == 0 && !setDicValue; + } + } + break; + case ' ': + case '\r': + case '\n'://[ "a",\r\n{} ] + case '\0': + case '\t': + break; + default: //值开头。。 + isError = (!jsonStart && !arrayStart) || (state == 0 && keyStart == -1) || (valueStart == -1 && state == 1);// + break; + } + //if (isError) + //{ + + //} + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/MD5Hepler.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/MD5Hepler.cs new file mode 100644 index 00000000..6eb53422 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/MD5Hepler.cs @@ -0,0 +1,67 @@ +using System; +using System.Security.Cryptography; +using System.Text; + +namespace Yi.Framework.Common.Helper +{ + public class MD5Helper + { + /// + /// 16位MD5加密 + /// + /// + /// + public static string MD5Encrypt16(string password) + { + var md5 = new MD5CryptoServiceProvider(); + string t2 = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(password)), 4, 8); + t2 = t2.Replace("-", string.Empty); + return t2; + } + + /// + /// 32位MD5加密 + /// + /// + /// + public static string MD5Encrypt32(string password = "") + { + string pwd = string.Empty; + try + { + if (!string.IsNullOrEmpty(password) && !string.IsNullOrWhiteSpace(password)) + { + MD5 md5 = MD5.Create(); //实例化一个md5对像 + // 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择  + byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(password)); + // 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得 + foreach (var item in s) + { + // 将得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符 + pwd = string.Concat(pwd, item.ToString("X2")); + } + } + } + catch + { + throw new Exception($"错误的 password 字符串:【{password}】"); + } + return pwd; + } + + /// + /// 64位MD5加密 + /// + /// + /// + public static string MD5Encrypt64(string password) + { + // 实例化一个md5对像 + // 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择  + MD5 md5 = MD5.Create(); + byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(password)); + return Convert.ToBase64String(s); + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/MimeHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/MimeHelper.cs new file mode 100644 index 00000000..bd783d48 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/MimeHelper.cs @@ -0,0 +1,244 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Helper +{ + public static class MimeHelper + { + // 通过自己定义一个静态类 + // 将所有的Content Type都扔进去吧 + // 调用的时候直接调用静态方法即可。 + + private static Hashtable _mimeMappingTable; + + private static void AddMimeMapping(string extension, string MimeType) + { + MimeHelper._mimeMappingTable.Add(extension, MimeType); + } + + public static string GetMimeMapping(string FileName) + { + string text = null; + int num = FileName.LastIndexOf('.'); + if (0 < num && num > FileName.LastIndexOf('\\')) + { + text = (string)MimeHelper._mimeMappingTable[FileName.Substring(num)]; + } + if (text == null) + { + text = (string)MimeHelper._mimeMappingTable[".*"]; + } + return text; + } + + static MimeHelper() + { + MimeHelper._mimeMappingTable = new Hashtable(190, StringComparer.CurrentCultureIgnoreCase); + MimeHelper.AddMimeMapping(".323", "text/h323"); + MimeHelper.AddMimeMapping(".asx", "video/x-ms-asf"); + MimeHelper.AddMimeMapping(".acx", "application/internet-property-stream"); + MimeHelper.AddMimeMapping(".ai", "application/postscript"); + MimeHelper.AddMimeMapping(".aif", "audio/x-aiff"); + MimeHelper.AddMimeMapping(".aiff", "audio/aiff"); + MimeHelper.AddMimeMapping(".axs", "application/olescript"); + MimeHelper.AddMimeMapping(".aifc", "audio/aiff"); + MimeHelper.AddMimeMapping(".asr", "video/x-ms-asf"); + MimeHelper.AddMimeMapping(".avi", "video/x-msvideo"); + MimeHelper.AddMimeMapping(".asf", "video/x-ms-asf"); + MimeHelper.AddMimeMapping(".au", "audio/basic"); + MimeHelper.AddMimeMapping(".application", "application/x-ms-application"); + MimeHelper.AddMimeMapping(".bin", "application/octet-stream"); + MimeHelper.AddMimeMapping(".bas", "text/plain"); + MimeHelper.AddMimeMapping(".bcpio", "application/x-bcpio"); + MimeHelper.AddMimeMapping(".bmp", "image/bmp"); + MimeHelper.AddMimeMapping(".cdf", "application/x-cdf"); + MimeHelper.AddMimeMapping(".cat", "application/vndms-pkiseccat"); + MimeHelper.AddMimeMapping(".crt", "application/x-x509-ca-cert"); + MimeHelper.AddMimeMapping(".c", "text/plain"); + MimeHelper.AddMimeMapping(".css", "text/css"); + MimeHelper.AddMimeMapping(".cer", "application/x-x509-ca-cert"); + MimeHelper.AddMimeMapping(".crl", "application/pkix-crl"); + MimeHelper.AddMimeMapping(".cmx", "image/x-cmx"); + MimeHelper.AddMimeMapping(".csh", "application/x-csh"); + MimeHelper.AddMimeMapping(".cod", "image/cis-cod"); + MimeHelper.AddMimeMapping(".cpio", "application/x-cpio"); + MimeHelper.AddMimeMapping(".clp", "application/x-msclip"); + MimeHelper.AddMimeMapping(".crd", "application/x-mscardfile"); + MimeHelper.AddMimeMapping(".deploy", "application/octet-stream"); + MimeHelper.AddMimeMapping(".dll", "application/x-msdownload"); + MimeHelper.AddMimeMapping(".dot", "application/msword"); + MimeHelper.AddMimeMapping(".doc", "application/msword"); + MimeHelper.AddMimeMapping(".dvi", "application/x-dvi"); + MimeHelper.AddMimeMapping(".dir", "application/x-director"); + MimeHelper.AddMimeMapping(".dxr", "application/x-director"); + MimeHelper.AddMimeMapping(".der", "application/x-x509-ca-cert"); + MimeHelper.AddMimeMapping(".dib", "image/bmp"); + MimeHelper.AddMimeMapping(".dcr", "application/x-director"); + MimeHelper.AddMimeMapping(".disco", "text/xml"); + MimeHelper.AddMimeMapping(".exe", "application/octet-stream"); + MimeHelper.AddMimeMapping(".etx", "text/x-setext"); + MimeHelper.AddMimeMapping(".evy", "application/envoy"); + MimeHelper.AddMimeMapping(".eml", "message/rfc822"); + MimeHelper.AddMimeMapping(".eps", "application/postscript"); + MimeHelper.AddMimeMapping(".flr", "x-world/x-vrml"); + MimeHelper.AddMimeMapping(".fif", "application/fractals"); + MimeHelper.AddMimeMapping(".gtar", "application/x-gtar"); + MimeHelper.AddMimeMapping(".gif", "image/gif"); + MimeHelper.AddMimeMapping(".gz", "application/x-gzip"); + MimeHelper.AddMimeMapping(".hta", "application/hta"); + MimeHelper.AddMimeMapping(".htc", "text/x-component"); + MimeHelper.AddMimeMapping(".htt", "text/webviewhtml"); + MimeHelper.AddMimeMapping(".h", "text/plain"); + MimeHelper.AddMimeMapping(".hdf", "application/x-hdf"); + MimeHelper.AddMimeMapping(".hlp", "application/winhlp"); + MimeHelper.AddMimeMapping(".html", "text/html"); + MimeHelper.AddMimeMapping(".htm", "text/html"); + MimeHelper.AddMimeMapping(".hqx", "application/mac-binhex40"); + MimeHelper.AddMimeMapping(".isp", "application/x-internet-signup"); + MimeHelper.AddMimeMapping(".iii", "application/x-iphone"); + MimeHelper.AddMimeMapping(".ief", "image/ief"); + MimeHelper.AddMimeMapping(".ivf", "video/x-ivf"); + MimeHelper.AddMimeMapping(".ins", "application/x-internet-signup"); + MimeHelper.AddMimeMapping(".ico", "image/x-icon"); + MimeHelper.AddMimeMapping(".jpg", "image/jpeg"); + MimeHelper.AddMimeMapping(".jfif", "image/pjpeg"); + MimeHelper.AddMimeMapping(".jpe", "image/jpeg"); + MimeHelper.AddMimeMapping(".jpeg", "image/jpeg"); + MimeHelper.AddMimeMapping(".js", "application/x-javascript"); + MimeHelper.AddMimeMapping(".lsx", "video/x-la-asf"); + MimeHelper.AddMimeMapping(".latex", "application/x-latex"); + MimeHelper.AddMimeMapping(".lsf", "video/x-la-asf"); + MimeHelper.AddMimeMapping(".manifest", "application/x-ms-manifest"); + MimeHelper.AddMimeMapping(".mhtml", "message/rfc822"); + MimeHelper.AddMimeMapping(".mny", "application/x-msmoney"); + MimeHelper.AddMimeMapping(".mht", "message/rfc822"); + MimeHelper.AddMimeMapping(".mid", "audio/mid"); + MimeHelper.AddMimeMapping(".mpv2", "video/mpeg"); + MimeHelper.AddMimeMapping(".man", "application/x-troff-man"); + MimeHelper.AddMimeMapping(".mvb", "application/x-msmediaview"); + MimeHelper.AddMimeMapping(".mpeg", "video/mpeg"); + MimeHelper.AddMimeMapping(".m3u", "audio/x-mpegurl"); + MimeHelper.AddMimeMapping(".mdb", "application/x-msaccess"); + MimeHelper.AddMimeMapping(".mpp", "application/vnd.ms-project"); + MimeHelper.AddMimeMapping(".m1v", "video/mpeg"); + MimeHelper.AddMimeMapping(".mpa", "video/mpeg"); + MimeHelper.AddMimeMapping(".me", "application/x-troff-me"); + MimeHelper.AddMimeMapping(".m13", "application/x-msmediaview"); + MimeHelper.AddMimeMapping(".movie", "video/x-sgi-movie"); + MimeHelper.AddMimeMapping(".m14", "application/x-msmediaview"); + MimeHelper.AddMimeMapping(".mpe", "video/mpeg"); + MimeHelper.AddMimeMapping(".mp2", "video/mpeg"); + MimeHelper.AddMimeMapping(".mov", "video/quicktime"); + MimeHelper.AddMimeMapping(".mp3", "audio/mpeg"); + MimeHelper.AddMimeMapping(".mpg", "video/mpeg"); + MimeHelper.AddMimeMapping(".ms", "application/x-troff-ms"); + MimeHelper.AddMimeMapping(".nc", "application/x-netcdf"); + MimeHelper.AddMimeMapping(".nws", "message/rfc822"); + MimeHelper.AddMimeMapping(".oda", "application/oda"); + MimeHelper.AddMimeMapping(".ods", "application/oleobject"); + MimeHelper.AddMimeMapping(".pmc", "application/x-perfmon"); + MimeHelper.AddMimeMapping(".p7r", "application/x-pkcs7-certreqresp"); + MimeHelper.AddMimeMapping(".p7b", "application/x-pkcs7-certificates"); + MimeHelper.AddMimeMapping(".p7s", "application/pkcs7-signature"); + MimeHelper.AddMimeMapping(".pmw", "application/x-perfmon"); + MimeHelper.AddMimeMapping(".ps", "application/postscript"); + MimeHelper.AddMimeMapping(".p7c", "application/pkcs7-mime"); + MimeHelper.AddMimeMapping(".pbm", "image/x-portable-bitmap"); + MimeHelper.AddMimeMapping(".ppm", "image/x-portable-pixmap"); + MimeHelper.AddMimeMapping(".pub", "application/x-mspublisher"); + MimeHelper.AddMimeMapping(".pnm", "image/x-portable-anymap"); + MimeHelper.AddMimeMapping(".png", "image/png"); + MimeHelper.AddMimeMapping(".pml", "application/x-perfmon"); + MimeHelper.AddMimeMapping(".p10", "application/pkcs10"); + MimeHelper.AddMimeMapping(".pfx", "application/x-pkcs12"); + MimeHelper.AddMimeMapping(".p12", "application/x-pkcs12"); + MimeHelper.AddMimeMapping(".pdf", "application/pdf"); + MimeHelper.AddMimeMapping(".pps", "application/vnd.ms-powerpoint"); + MimeHelper.AddMimeMapping(".p7m", "application/pkcs7-mime"); + MimeHelper.AddMimeMapping(".pko", "application/vndms-pkipko"); + MimeHelper.AddMimeMapping(".ppt", "application/vnd.ms-powerpoint"); + MimeHelper.AddMimeMapping(".pmr", "application/x-perfmon"); + MimeHelper.AddMimeMapping(".pma", "application/x-perfmon"); + MimeHelper.AddMimeMapping(".pot", "application/vnd.ms-powerpoint"); + MimeHelper.AddMimeMapping(".prf", "application/pics-rules"); + MimeHelper.AddMimeMapping(".pgm", "image/x-portable-graymap"); + MimeHelper.AddMimeMapping(".qt", "video/quicktime"); + MimeHelper.AddMimeMapping(".ra", "audio/x-pn-realaudio"); + MimeHelper.AddMimeMapping(".rgb", "image/x-rgb"); + MimeHelper.AddMimeMapping(".ram", "audio/x-pn-realaudio"); + MimeHelper.AddMimeMapping(".rmi", "audio/mid"); + MimeHelper.AddMimeMapping(".ras", "image/x-cmu-raster"); + MimeHelper.AddMimeMapping(".roff", "application/x-troff"); + MimeHelper.AddMimeMapping(".rtf", "application/rtf"); + MimeHelper.AddMimeMapping(".rtx", "text/richtext"); + MimeHelper.AddMimeMapping(".sv4crc", "application/x-sv4crc"); + MimeHelper.AddMimeMapping(".spc", "application/x-pkcs7-certificates"); + MimeHelper.AddMimeMapping(".setreg", "application/set-registration-initiation"); + MimeHelper.AddMimeMapping(".snd", "audio/basic"); + MimeHelper.AddMimeMapping(".stl", "application/vndms-pkistl"); + MimeHelper.AddMimeMapping(".setpay", "application/set-payment-initiation"); + MimeHelper.AddMimeMapping(".stm", "text/html"); + MimeHelper.AddMimeMapping(".shar", "application/x-shar"); + MimeHelper.AddMimeMapping(".sh", "application/x-sh"); + MimeHelper.AddMimeMapping(".sit", "application/x-stuffit"); + MimeHelper.AddMimeMapping(".spl", "application/futuresplash"); + MimeHelper.AddMimeMapping(".sct", "text/scriptlet"); + MimeHelper.AddMimeMapping(".scd", "application/x-msschedule"); + MimeHelper.AddMimeMapping(".sst", "application/vndms-pkicertstore"); + MimeHelper.AddMimeMapping(".src", "application/x-wais-source"); + MimeHelper.AddMimeMapping(".sv4cpio", "application/x-sv4cpio"); + MimeHelper.AddMimeMapping(".tex", "application/x-tex"); + MimeHelper.AddMimeMapping(".tgz", "application/x-compressed"); + MimeHelper.AddMimeMapping(".t", "application/x-troff"); + MimeHelper.AddMimeMapping(".tar", "application/x-tar"); + MimeHelper.AddMimeMapping(".tr", "application/x-troff"); + MimeHelper.AddMimeMapping(".tif", "image/tiff"); + MimeHelper.AddMimeMapping(".txt", "text/plain"); + MimeHelper.AddMimeMapping(".texinfo", "application/x-texinfo"); + MimeHelper.AddMimeMapping(".trm", "application/x-msterminal"); + MimeHelper.AddMimeMapping(".tiff", "image/tiff"); + MimeHelper.AddMimeMapping(".tcl", "application/x-tcl"); + MimeHelper.AddMimeMapping(".texi", "application/x-texinfo"); + MimeHelper.AddMimeMapping(".tsv", "text/tab-separated-values"); + MimeHelper.AddMimeMapping(".ustar", "application/x-ustar"); + MimeHelper.AddMimeMapping(".uls", "text/iuls"); + MimeHelper.AddMimeMapping(".vcf", "text/x-vcard"); + MimeHelper.AddMimeMapping(".wps", "application/vnd.ms-works"); + MimeHelper.AddMimeMapping(".wav", "audio/wav"); + MimeHelper.AddMimeMapping(".wrz", "x-world/x-vrml"); + MimeHelper.AddMimeMapping(".wri", "application/x-mswrite"); + MimeHelper.AddMimeMapping(".wks", "application/vnd.ms-works"); + MimeHelper.AddMimeMapping(".wmf", "application/x-msmetafile"); + MimeHelper.AddMimeMapping(".wcm", "application/vnd.ms-works"); + MimeHelper.AddMimeMapping(".wrl", "x-world/x-vrml"); + MimeHelper.AddMimeMapping(".wdb", "application/vnd.ms-works"); + MimeHelper.AddMimeMapping(".wsdl", "text/xml"); + MimeHelper.AddMimeMapping(".xap", "application/x-silverlight-app"); + MimeHelper.AddMimeMapping(".xml", "text/xml"); + MimeHelper.AddMimeMapping(".xlm", "application/vnd.ms-excel"); + MimeHelper.AddMimeMapping(".xaf", "x-world/x-vrml"); + MimeHelper.AddMimeMapping(".xla", "application/vnd.ms-excel"); + MimeHelper.AddMimeMapping(".xls", "application/vnd.ms-excel"); + MimeHelper.AddMimeMapping(".xlsx", "application/vnd.ms-excel"); + MimeHelper.AddMimeMapping(".xof", "x-world/x-vrml"); + MimeHelper.AddMimeMapping(".xlt", "application/vnd.ms-excel"); + MimeHelper.AddMimeMapping(".xlc", "application/vnd.ms-excel"); + MimeHelper.AddMimeMapping(".xsl", "text/xml"); + MimeHelper.AddMimeMapping(".xbm", "image/x-xbitmap"); + MimeHelper.AddMimeMapping(".xlw", "application/vnd.ms-excel"); + MimeHelper.AddMimeMapping(".xpm", "image/x-xpixmap"); + MimeHelper.AddMimeMapping(".xwd", "image/x-xwindowdump"); + MimeHelper.AddMimeMapping(".xsd", "text/xml"); + MimeHelper.AddMimeMapping(".z", "application/x-compress"); + MimeHelper.AddMimeMapping(".zip", "application/x-zip-compressed"); + MimeHelper.AddMimeMapping(".*", "application/octet-stream"); + } + } + + + +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/RSAHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/RSAHelper.cs new file mode 100644 index 00000000..f439b544 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/RSAHelper.cs @@ -0,0 +1,390 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace Yi.Framework.Common.Helper +{ + /// + /// RSA加解密 使用OpenSSL的公钥加密/私钥解密 + /// 公私钥请使用openssl生成 + /// + public class RSAHelper + { + public readonly RSA _privateKeyRsaProvider; + public readonly RSA _publicKeyRsaProvider; + private readonly HashAlgorithmName _hashAlgorithmName; + private readonly Encoding _encoding; + + /// + /// 实例化RSAHelper + /// + /// 加密算法类型 RSA SHA1;RSA2 SHA256 密钥长度至少为2048 + /// 编码类型 + /// 私钥 + /// 公钥 + public RSAHelper(RSAType rsaType, Encoding encoding, string privateKey, string publicKey = null) + { + _encoding = encoding; + if (!string.IsNullOrEmpty(privateKey)) + { + _privateKeyRsaProvider = CreateRsaProviderFromPrivateKey(privateKey); + } + + if (!string.IsNullOrEmpty(publicKey)) + { + _publicKeyRsaProvider = CreateRsaProviderFromPublicKey(publicKey); + } + + _hashAlgorithmName = rsaType == RSAType.RSA ? HashAlgorithmName.SHA1 : HashAlgorithmName.SHA256; + } + + #region 使用私钥签名 + + /// + /// 使用私钥签名 + /// + /// 原始数据 + /// + public string Sign(string data) + { + byte[] dataBytes = _encoding.GetBytes(data); + + var signatureBytes = _privateKeyRsaProvider.SignData(dataBytes, _hashAlgorithmName, RSASignaturePadding.Pkcs1); + + return Convert.ToBase64String(signatureBytes); + } + + #endregion + + #region 使用公钥验签 + + /// + /// 使用公钥验签 + /// + /// 原始数据 + /// 签名 + /// + public bool Verify(string data, string sign) + { + byte[] dataBytes = _encoding.GetBytes(data); + byte[] signBytes = Convert.FromBase64String(sign); + + var verify = _publicKeyRsaProvider.VerifyData(dataBytes, signBytes, _hashAlgorithmName, RSASignaturePadding.Pkcs1); + + return verify; + } + + #endregion + + #region 解密 + /// + /// 私钥解密(原) + /// + /// 解密字符串(base64) + /// + + //public string Decrypt(string cipherText) + //{ + // if (_privateKeyRsaProvider == null) + // { + // throw new Exception("_privateKeyRsaProvider is null"); + // } + // return _encoding.GetString(_privateKeyRsaProvider.Decrypt(Convert.FromBase64String(cipherText), RSAEncryptionPadding.Pkcs1)); + //} + /// + /// 私钥解密(支持大量数据) + /// + /// + /// + public string Decrypt(string cipherText) + { + if (_privateKeyRsaProvider == null) + { + throw new Exception("_privateKeyRsaProvider is null"); + } + var bufferSize = (_privateKeyRsaProvider.KeySize / 8); + byte[] buffer = new byte[bufferSize];//待解密块 + using (MemoryStream msInput = new MemoryStream(Convert.FromBase64String(cipherText))) + { + using (MemoryStream msOutput = new MemoryStream()) + { + int readLen; while ((readLen = msInput.Read(buffer, 0, bufferSize)) > 0) + { + byte[] dataToEnc = new byte[readLen]; + Array.Copy(buffer, 0, dataToEnc, 0, readLen); byte[] encData = _privateKeyRsaProvider.Decrypt(dataToEnc, RSAEncryptionPadding.Pkcs1); + msOutput.Write(encData, 0, encData.Length); + } + byte[] result = msOutput.ToArray(); + return _encoding.GetString(result); + } + } + } + + #endregion + + #region 加密 + + /// + /// 公钥加密(原) + /// + /// + /// + //public string Encrypt(string text) + //{ + // if (_publicKeyRsaProvider == null) + // { + // throw new Exception("_publicKeyRsaProvider is null"); + // } + // return Convert.ToBase64String(_publicKeyRsaProvider.Encrypt(Encoding.UTF8.GetBytes(text), RSAEncryptionPadding.Pkcs1)); + //} + /// + /// 公钥加密(支持大量数据) + /// + /// + /// + public string Encrypt(string text) + { + if (_publicKeyRsaProvider == null) + { + throw new Exception("_publicKeyRsaProvider is null"); + } + var bufferSize = (_publicKeyRsaProvider.KeySize / 8 - 11); + byte[] buffer = new byte[bufferSize];//待加密块 + + using (MemoryStream msInput = new MemoryStream(_encoding.GetBytes(text))) + { + using (MemoryStream msOutput = new MemoryStream()) + { + int readLen; while ((readLen = msInput.Read(buffer, 0, bufferSize)) > 0) + { + byte[] dataToEnc = new byte[readLen]; + Array.Copy(buffer, 0, dataToEnc, 0, readLen); byte[] encData = _publicKeyRsaProvider.Encrypt(dataToEnc, RSAEncryptionPadding.Pkcs1); + msOutput.Write(encData, 0, encData.Length); + } + byte[] result = msOutput.ToArray(); + return Convert.ToBase64String(result); + } + } + } + + #endregion + + #region 使用私钥创建RSA实例 + /// + /// 使用私钥创建RSA实例 + /// + /// + /// + private RSA CreateRsaProviderFromPrivateKey(string privateKey) + { + var privateKeyBits = Convert.FromBase64String(privateKey); + + var rsa = RSA.Create(); + var rsaParameters = new RSAParameters(); + + using (BinaryReader binr = new BinaryReader(new MemoryStream(privateKeyBits))) + { + byte bt = 0; + ushort twobytes = 0; + twobytes = binr.ReadUInt16(); + if (twobytes == 0x8130) + binr.ReadByte(); + else if (twobytes == 0x8230) + binr.ReadInt16(); + else + throw new Exception("Unexpected value read binr.ReadUInt16()"); + + twobytes = binr.ReadUInt16(); + if (twobytes != 0x0102) + throw new Exception("Unexpected version"); + + bt = binr.ReadByte(); + if (bt != 0x00) + throw new Exception("Unexpected value read binr.ReadByte()"); + + rsaParameters.Modulus = binr.ReadBytes(GetIntegerSize(binr)); + rsaParameters.Exponent = binr.ReadBytes(GetIntegerSize(binr)); + rsaParameters.D = binr.ReadBytes(GetIntegerSize(binr)); + rsaParameters.P = binr.ReadBytes(GetIntegerSize(binr)); + rsaParameters.Q = binr.ReadBytes(GetIntegerSize(binr)); + rsaParameters.DP = binr.ReadBytes(GetIntegerSize(binr)); + rsaParameters.DQ = binr.ReadBytes(GetIntegerSize(binr)); + rsaParameters.InverseQ = binr.ReadBytes(GetIntegerSize(binr)); + } + + rsa.ImportParameters(rsaParameters); + return rsa; + } + + #endregion + + #region 使用公钥创建RSA实例 + /// + /// 使用公钥创建RSA实例 + /// + /// + /// + public RSA CreateRsaProviderFromPublicKey(string publicKeyString) + { + // encoded OID sequence for PKCS #1 rsaEncryption szOID_RSA_RSA = "1.2.840.113549.1.1.1" + byte[] seqOid = { 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00 }; + byte[] seq = new byte[15]; + + var x509Key = Convert.FromBase64String(publicKeyString); + + // --------- Set up stream to read the asn.1 encoded SubjectPublicKeyInfo blob ------ + using (MemoryStream mem = new MemoryStream(x509Key)) + { + using (BinaryReader binr = new BinaryReader(mem)) //wrap Memory Stream with BinaryReader for easy reading + { + byte bt = 0; + ushort twobytes = 0; + + twobytes = binr.ReadUInt16(); + if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81) + binr.ReadByte(); //advance 1 byte + else if (twobytes == 0x8230) + binr.ReadInt16(); //advance 2 bytes + else + return null; + + seq = binr.ReadBytes(15); //read the Sequence OID + if (!CompareBytearrays(seq, seqOid)) //make sure Sequence for OID is correct + return null; + + twobytes = binr.ReadUInt16(); + if (twobytes == 0x8103) //data read as little endian order (actual data order for Bit String is 03 81) + binr.ReadByte(); //advance 1 byte + else if (twobytes == 0x8203) + binr.ReadInt16(); //advance 2 bytes + else + return null; + + bt = binr.ReadByte(); + if (bt != 0x00) //expect null byte next + return null; + + twobytes = binr.ReadUInt16(); + if (twobytes == 0x8130) //data read as little endian order (actual data order for Sequence is 30 81) + binr.ReadByte(); //advance 1 byte + else if (twobytes == 0x8230) + binr.ReadInt16(); //advance 2 bytes + else + return null; + + twobytes = binr.ReadUInt16(); + byte lowbyte = 0x00; + byte highbyte = 0x00; + + if (twobytes == 0x8102) //data read as little endian order (actual data order for Integer is 02 81) + lowbyte = binr.ReadByte(); // read next bytes which is bytes in modulus + else if (twobytes == 0x8202) + { + highbyte = binr.ReadByte(); //advance 2 bytes + lowbyte = binr.ReadByte(); + } + else + return null; + byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; //reverse byte order since asn.1 key uses big endian order + int modsize = BitConverter.ToInt32(modint, 0); + + int firstbyte = binr.PeekChar(); + if (firstbyte == 0x00) + { //if first byte (highest order) of modulus is zero, don't include it + binr.ReadByte(); //skip this null byte + modsize -= 1; //reduce modulus buffer size by 1 + } + + byte[] modulus = binr.ReadBytes(modsize); //read the modulus bytes + + if (binr.ReadByte() != 0x02) //expect an Integer for the exponent data + return null; + int expbytes = (int)binr.ReadByte(); // should only need one byte for actual exponent data (for all useful values) + byte[] exponent = binr.ReadBytes(expbytes); + + // ------- create RSACryptoServiceProvider instance and initialize with public key ----- + var rsa = RSA.Create(); + RSAParameters rsaKeyInfo = new RSAParameters + { + Modulus = modulus, + Exponent = exponent + }; + rsa.ImportParameters(rsaKeyInfo); + + return rsa; + } + + } + } + + #endregion + + #region 导入密钥算法 + + private int GetIntegerSize(BinaryReader binr) + { + byte bt = 0; + int count = 0; + bt = binr.ReadByte(); + if (bt != 0x02) + return 0; + bt = binr.ReadByte(); + + if (bt == 0x81) + count = binr.ReadByte(); + else + if (bt == 0x82) + { + var highbyte = binr.ReadByte(); + var lowbyte = binr.ReadByte(); + byte[] modint = { lowbyte, highbyte, 0x00, 0x00 }; + count = BitConverter.ToInt32(modint, 0); + } + else + { + count = bt; + } + + while (binr.ReadByte() == 0x00) + { + count -= 1; + } + binr.BaseStream.Seek(-1, SeekOrigin.Current); + return count; + } + + private bool CompareBytearrays(byte[] a, byte[] b) + { + if (a.Length != b.Length) + return false; + int i = 0; + foreach (byte c in a) + { + if (c != b[i]) + return false; + i++; + } + return true; + } + + #endregion + + } + + /// + /// RSA算法类型 + /// + public enum RSAType + { + /// + /// SHA1 + /// + RSA = 0, + /// + /// RSA2 密钥长度至少为2048 + /// SHA256 + /// + RSA2 + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/RandomHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/RandomHelper.cs new file mode 100644 index 00000000..8c5cd40f --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/RandomHelper.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; + +namespace Yi.Framework.Common.Helper +{ + public class RandomHelper + { + public static string replaceBianLiang(string content) + { + content = content.Replace("{当前时间}", DateTime.Now.TimeOfDay.ToString()); + string[] bianliang = new string[] { "{随机字母}", "{随机数字}", "{随机汉字}" }; + Regex r; + int count; + string readstr = ""; + foreach (string str in bianliang) + { + count = (content.Length - content.Replace(str, "").Length) / str.Length; + if (str == "{随机汉字}") readstr = RandChina(count); + if (str == "{随机数字}") readstr = GenerateCheckCodeNum(count); + if (str == "{随机字母}") readstr = GenerateRandomLetter(count); + if (count > readstr.Length) count = readstr.Length; + r = new Regex(str.Replace("{", "\\{").Replace("}", "\\}")); + for (int i = 0; i < count; i++) + { + content = r.Replace(content, readstr.Substring(i, 1), 1); + } + } + return content; + } + + + /// + /// 随机生成字母 + /// + /// + /// + public static string GenerateRandomLetter(int Length) + { + char[] Pattern = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; + string result = ""; + int n = Pattern.Length; + Random random = new Random(~unchecked((int)DateTime.Now.Ticks)); + for (int i = 0; i < Length; i++) + { + int rnd = random.Next(0, n); + result += Pattern[rnd]; + } + return result; + } + + /// + /// 随机生成数字 + /// + /// + /// + public static string GenerateCheckCodeNum(int codeCount) + { + int rep = 0; + string str = string.Empty; + long num2 = DateTime.Now.Ticks + rep; + rep++; + Random random = new Random(((int)(((ulong)num2) & 0xffffffffL)) | ((int)(num2 >> rep))); + for (int i = 0; i < codeCount; i++) + { + int num = random.Next(); + str = str + ((char)(0x30 + ((ushort)(num % 10)))).ToString(); + } + return str; + } + + /// + /// 此函数为生成指定数目的汉字 + /// + /// 汉字数目 + /// 所有汉字 + public static string RandChina(int charLen) + { + int area, code;//汉字由区位和码位组成(都为0-94,其中区位16-55为一级汉字区,56-87为二级汉字区,1-9为特殊字符区) + StringBuilder strtem = new StringBuilder(); + Random rand = new Random(); + for (int i = 0; i < charLen; i++) + { + area = rand.Next(16, 88); + if (area == 55)//第55区只有89个字符 + { + code = rand.Next(1, 90); + } + else + { + code = rand.Next(1, 94); + } + strtem.Append(Encoding.GetEncoding("GB2312").GetString(new byte[] { Convert.ToByte(area + 160), Convert.ToByte(code + 160) })); + } + return strtem.ToString(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/SerializeHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/SerializeHelper.cs new file mode 100644 index 00000000..9a5aee9b --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/SerializeHelper.cs @@ -0,0 +1,35 @@ +using Newtonsoft.Json; +using System.Text; + +namespace Yi.Framework.Common.Helper +{ + public class SerializeHelper + { + /// + /// 序列化 + /// + /// + /// + public static byte[] Serialize(object item) + { + var jsonString = JsonConvert.SerializeObject(item); + + return Encoding.UTF8.GetBytes(jsonString); + } + /// + /// 反序列化 + /// + /// + /// + /// + public static TEntity Deserialize(byte[] value) + { + if (value == null) + { + return default(TEntity); + } + var jsonString = Encoding.UTF8.GetString(value); + return JsonConvert.DeserializeObject(jsonString); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/SnowflakeHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/SnowflakeHelper.cs new file mode 100644 index 00000000..603acb75 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/SnowflakeHelper.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Helper +{ + public static class SnowflakeHelper + { + public static long Next() + { + SnowflakeTool snowflakeTool = new SnowflakeTool(1); + return snowflakeTool.NextId(); + } + + private class SnowflakeTool + { + //机器ID + private static long nodeId; + private static long twepoch = 687888001020L; //唯一时间,这是一个避免重复的随机量,自行设定不要大于当前时间戳 + private static long sequence = 0L; + private static int workerIdBits = 4; //机器码字节数。4个字节用来保存机器码(定义为Long类型会出现,最大偏移64位,所以左移64位没有意义) + public static long maxWorkerId = -1L ^ -1L << workerIdBits; //最大机器ID + private static int sequenceBits = 10; //计数器字节数,10个字节用来保存计数码 + private static int workerIdShift = sequenceBits; //机器码数据左移位数,就是后面计数器占用的位数 + private static int timestampLeftShift = sequenceBits + workerIdBits; //时间戳左移动位数就是机器码和计数器总字节数 + public static long sequenceMask = -1L ^ -1L << sequenceBits; //一微秒内可以产生计数,如果达到该值则等到下一微妙在进行生成 + private long lastTimestamp = -1L; + + /// + /// 机器码 + /// + /// + public SnowflakeTool(long workerId) + { + if (workerId > maxWorkerId || workerId < 0) + throw new Exception(string.Format("节点id 不能大于 {0} 或者 小于 0 ", workerId)); + SnowflakeTool.nodeId = workerId; + + } + + public long NextId() + { + lock (this) + { + long timestamp = TimeGen(); + if (this.lastTimestamp == timestamp) + { //同一微妙中生成ID + SnowflakeTool.sequence = (SnowflakeTool.sequence + 1) & SnowflakeTool.sequenceMask; //用&运算计算该微秒内产生的计数是否已经到达上限 + if (SnowflakeTool.sequence == 0) + { + //一微妙内产生的ID计数已达上限,等待下一微妙 + timestamp = TillNextMillis(this.lastTimestamp); + } + } + else + { //不同微秒生成ID + SnowflakeTool.sequence = 0; //计数清0 + } + if (timestamp < lastTimestamp) + { //如果当前时间戳比上一次生成ID时时间戳还小,抛出异常,因为不能保证现在生成的ID之前没有生成过 + throw new Exception(string.Format("Clock moved backwards. Refusing to generate id for {0} milliseconds", + this.lastTimestamp - timestamp)); + } + this.lastTimestamp = timestamp; //把当前时间戳保存为最后生成ID的时间戳 + long nextId = (timestamp - twepoch << timestampLeftShift) | SnowflakeTool.nodeId << SnowflakeTool.workerIdShift | SnowflakeTool.sequence; + return nextId; + } + } + + /// + /// 获取下一微秒时间戳 + /// + /// + /// + private long TillNextMillis(long lastTimestamp) + { + long timestamp = TimeGen(); + while (timestamp <= lastTimestamp) + { + timestamp = TimeGen(); + } + return timestamp; + } + + /// + /// 生成当前时间戳 + /// + /// + private long TimeGen() + { + return (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; + } + } + } + + +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/StringHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/StringHelper.cs new file mode 100644 index 00000000..b4287ed5 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/StringHelper.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace Yi.Framework.Common.Helper +{ + public class StringHelper + { + /// + /// 根据分隔符返回前n条数据 + /// + /// 数据内容 + /// 分隔符 + /// 前n条 + /// 是否倒序(默认false) + /// + public static List GetTopDataBySeparator(string content, string separator, int top, bool isDesc = false) + { + if (string.IsNullOrEmpty(content)) + { + return new List() { }; + } + + if (string.IsNullOrEmpty(separator)) + { + throw new ArgumentException("message", nameof(separator)); + } + + var dataArray = content.Split(separator).Where(d => !string.IsNullOrEmpty(d)).ToArray(); + if (isDesc) + { + Array.Reverse(dataArray); + } + + if (top > 0) + { + dataArray = dataArray.Take(top).ToArray(); + } + + return dataArray.ToList(); + } + /// + /// 根据字段拼接get参数 + /// + /// + /// + public static string GetPars(Dictionary dic) + { + + StringBuilder sb = new StringBuilder(); + string urlPars = null; + bool isEnter = false; + foreach (var item in dic) + { + sb.Append($"{(isEnter ? "&" : "")}{item.Key}={item.Value}"); + isEnter = true; + } + urlPars = sb.ToString(); + return urlPars; + } + /// + /// 根据字段拼接get参数 + /// + /// + /// + public static string GetPars(Dictionary dic) + { + + StringBuilder sb = new StringBuilder(); + string urlPars = null; + bool isEnter = false; + foreach (var item in dic) + { + sb.Append($"{(isEnter ? "&" : "")}{item.Key}={item.Value}"); + isEnter = true; + } + urlPars = sb.ToString(); + return urlPars; + } + /// + /// 获取一个GUID + /// + /// 格式-默认为N + /// + public static string GetGUID(string format="N") { + return Guid.NewGuid().ToString(format); + } + /// + /// 根据GUID获取19位的唯一数字序列 + /// + /// + public static long GetGuidToLongID() + { + byte[] buffer = Guid.NewGuid().ToByteArray(); + return BitConverter.ToInt64(buffer, 0); + } + /// + /// 获取字符串最后X行 + /// + /// + /// + /// + public static string GetCusLine(string resourceStr, int length) { + string[] arrStr = resourceStr.Split("\r\n"); + return string.Join("", (from q in arrStr select q).Skip(arrStr.Length - length + 1).Take(length).ToArray()); + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/UnicodeHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/UnicodeHelper.cs new file mode 100644 index 00000000..d6d96f75 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/UnicodeHelper.cs @@ -0,0 +1,47 @@ +using System; +using System.Text; +using System.Text.RegularExpressions; + +namespace Yi.Framework.Common.Helper +{ + public static class UnicodeHelper + { + /// + /// 字符串转Unicode码 + /// + /// The to unicode. + /// Value. + public static string StringToUnicode(string value) + { + byte[] bytes = Encoding.Unicode.GetBytes(value); + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < bytes.Length; i += 2) + { + // 取两个字符,每个字符都是右对齐。 + stringBuilder.AppendFormat("u{0}{1}", bytes[i + 1].ToString("x").PadLeft(2, '0'), bytes[i].ToString("x").PadLeft(2, '0')); + } + return stringBuilder.ToString(); + } + + /// + /// Unicode转字符串 + /// + /// The to string. + /// Unicode. + public static string UnicodeToString(string unicode) + { + unicode = unicode.Replace("%", "\\"); + + return new Regex(@"\\u([0-9A-F]{4})", RegexOptions.IgnoreCase | RegexOptions.Compiled).Replace( + unicode, x => string.Empty + Convert.ToChar(Convert.ToUInt16(x.Result("$1"), 16))); + + //string resultStr = ""; + //string[] strList = unicode.Split('u'); + //for (int i = 1; i < strList.Length; i++) + //{ + // resultStr += (char)int.Parse(strList[i], System.Globalization.NumberStyles.HexNumber); + //} + //return resultStr; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/UrlHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/UrlHelper.cs new file mode 100644 index 00000000..6ebd30c0 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/UrlHelper.cs @@ -0,0 +1,23 @@ +namespace Yi.Framework.Common.Helper +{ + public class UrlHelper + { + /// + /// UrlEncode编码 + /// + /// url + /// + public static string UrlEncode(string url) { + return System.Web.HttpUtility.UrlEncode(url, System.Text.Encoding.UTF8); + } + /// + /// UrlEncode解码 + /// + /// 数据 + /// + public static string UrlDecode(string data) + { + return System.Web.HttpUtility.UrlDecode(data, System.Text.Encoding.UTF8); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/XmlHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/XmlHelper.cs new file mode 100644 index 00000000..44133350 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/XmlHelper.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Serialization; + +namespace Yi.Framework.Common.Helper +{ + public class XmlHelper + { + /// + /// 转换对象为JSON格式数据 + /// + /// + /// 对象 + /// 字符格式的JSON数据 + public static string GetXML(object obj) + { + try + { + XmlSerializer xs = new XmlSerializer(typeof(T)); + + using (TextWriter tw = new StringWriter()) + { + xs.Serialize(tw, obj); + return tw.ToString(); + } + } + catch (Exception) + { + return string.Empty; + } + } + + /// + /// Xml格式字符转换为T类型的对象 + /// + /// + /// + /// + public static T ParseFormByXml(string xml,string rootName="root") + { + XmlSerializer serializer = new XmlSerializer(typeof(T), new XmlRootAttribute(rootName)); + StringReader reader = new StringReader(xml); + + T res = (T)serializer.Deserialize(reader); + reader.Close(); + reader.Dispose(); + return res; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/ConsulClientOption.cs b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/ConsulClientOption.cs new file mode 100644 index 00000000..a9cc27a3 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/ConsulClientOption.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Yi.Framework.Common.IOCOptions +{ + /// + /// 使用Consul时需要配置 + /// + public class ConsulClientOption + { + public string IP { get; set; } + public int Port { get; set; } + public string Datacenter { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/ConsulRegisterOption.cs b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/ConsulRegisterOption.cs new file mode 100644 index 00000000..a5c4fa6a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/ConsulRegisterOption.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.IOCOptions +{ + public class ConsulRegisterOption + { + /// + /// 服务自身IP + /// + public string IP { get; set; } + /// + /// 服务自身Port + /// + public int Port { get; set; } + /// + /// 组名称 + /// + public string GroupName { get; set; } + /// + /// 心跳检查地址 + /// + public string HealthCheckUrl { get; set; } + /// + /// 心跳频率 + /// + public int Interval { get; set; } + /// + /// 心跳超时 + /// + public int Timeout { get; set; } + /// + /// 移除延迟时间 + /// + public int DeregisterCriticalServiceAfter { get; set; } + /// + /// 标签,额外信息,用于权重 + /// + public string Tag { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/ElasticSearchOptions.cs b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/ElasticSearchOptions.cs new file mode 100644 index 00000000..1080aaa6 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/ElasticSearchOptions.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.IOCOptions +{ + public class ElasticSearchOptions + { + public string Url { get; set; } + public string IndexName { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/JWTTokenOptions.cs b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/JWTTokenOptions.cs new file mode 100644 index 00000000..89fd0993 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/JWTTokenOptions.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.IOCOptions +{ + public class JWTTokenOptions + { + public string Audience + { + get; + set; + } + public string SecurityKey + { + get; + set; + } + //public SigningCredentials Credentials + //{ + // get; + // set; + //} + public string Issuer + { + get; + set; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/KafkaOptions.cs b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/KafkaOptions.cs new file mode 100644 index 00000000..cfc6955e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/KafkaOptions.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.IOCOptions +{ + public class KafkaOptions + { + public string BrokerList { get; set; } + public string TopicName { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/MySqlConnOptions.cs b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/MySqlConnOptions.cs new file mode 100644 index 00000000..c5ae46b1 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/MySqlConnOptions.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace Yi.Framework.Common.IOCOptions +{ + public class DbConnOptions + { + public string WriteUrl { get; set; } + public List ReadUrl { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/RabbitMQOptions.cs b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/RabbitMQOptions.cs new file mode 100644 index 00000000..bdcb0f13 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/RabbitMQOptions.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.IOCOptions +{ + public class RabbitMQOptions + { + ///// + ///// exchange---queue + ///// + //private static Dictionary RabbitMQ_Mapping = new Dictionary(); + //private static readonly object RabbitMQOptions_Lock = new object(); + //public void Init(string exchangeName, string queueName) + //{ + // lock (RabbitMQOptions_Lock) + // { + // RabbitMQ_Mapping[exchangeName] = queueName; + // } + //} + + public string HostName { get; set; } + public string UserName { get; set; } + public string Password { get; set; } + + public int Port { get; set; } + + } + + public class RabbitMQConsumerModel + { + /// + /// 生产者指定,交换机 + /// + public string ExchangeName { get; set; } + /// + /// 自己起的名字 + /// + public string QueueName { get; set; } + } + + public class RabbitMQExchangeQueueName + { + public static readonly string SKUCQRS_Exchange = "Zhaoxi.MSACormmerce.SKUCQRS.Exchange"; + public static readonly string SKUCQRS_Queue_StaticPage = "Zhaoxi.MSACormmerce.SKUCQRS.Queue.StaticPage"; + public static readonly string SKUCQRS_Queue_ESIndex = "Zhaoxi.MSACormmerce.SKUCQRS.Queue.ESIndex"; + + + public static readonly string SKUWarmup_Exchange = "Zhaoxi.MSACormmerce.Warmup.Exchange"; + public static readonly string SKUWarmup_Queue_StaticPage = "Zhaoxi.MSACormmerce.Warmup.Queue.StaticPage"; + public static readonly string SKUWarmup_Queue_ESIndex = "Zhaoxi.MSACormmerce.Warmup.Queue.ESIndex"; + + /// + /// 订单创建后的交换机 + /// + public static readonly string OrderCreate_Exchange = "Zhaoxi.MSACormmerce.OrderCreate.Exchange"; + public static readonly string OrderCreate_Queue_CleanCart = "Zhaoxi.MSACormmerce.OrderCreate.Queue.CleanCart"; + + /// + /// 订单创建后的交换机,支付状态的 + /// + public static readonly string OrderPay_Exchange = "Zhaoxi.MSACormmerce.OrderPay.Exchange"; + public static readonly string OrderPay_Queue_RefreshPay = "Zhaoxi.MSACormmerce.OrderPay.Queue.RefreshPay"; + + /// + /// 创建订单后的延时队列配置 + /// + public static readonly string OrderCreate_Delay_Exchange = "Zhaoxi.MSACormmerce.OrderCreate.DelayExchange"; + public static readonly string OrderCreate_Delay_Queue_CancelOrder = "Zhaoxi.MSACormmerce.OrderCreate.DelayQueue.CancelOrder"; + + /// + /// 秒杀异步的 + /// + public static readonly string Seckill_Exchange = "Zhaoxi.MSACormmerce.Seckill.Exchange"; + public static readonly string Seckill_Order_Queue = "Zhaoxi.MSACormmerce.Seckill.Order.Queue"; + + + /// + /// CAP队列名称 + /// + public const string Order_Stock_Decrease = "RabbitMQ.MySQL.Order-Stock.Decrease"; + public const string Order_Stock_Resume = "RabbitMQ.MySQL.Order-Stock.Resume"; + public const string Stock_Logistics = "RabbitMQ.MySQL.Stock-Logistics"; + + public const string Pay_Order_UpdateStatus = "RabbitMQ.MySQL.Pay_Order.UpdateStatus"; + } + +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/RedisConnOptions.cs b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/RedisConnOptions.cs new file mode 100644 index 00000000..031509a3 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/RedisConnOptions.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.IOCOptions +{ + public class RedisConnOptions + { + public string Host { get; set; } + public int DB { get; set; } = 0; + public int Prot { get; set; } + public string Password { get; set; } + } + + +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/SMSOptions.cs b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/SMSOptions.cs new file mode 100644 index 00000000..c9f36347 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/SMSOptions.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.IOCOptions +{ + public class SMSOptions + { + + public string ID { get; set; } + public string Secret { get; set; } + public string Sign { get; set; } + public string Template { get; set; } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/SqliteOptions.cs b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/SqliteOptions.cs new file mode 100644 index 00000000..bd2caf1e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/IOCOptions/SqliteOptions.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.IOCOptions +{ + public class SqliteOptions + { + public string WriteUrl { get; set; } + public List ReadUrl { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/AxiosUrlsModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/AxiosUrlsModel.cs new file mode 100644 index 00000000..f5cdacb8 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/AxiosUrlsModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Models +{ + public class AxiosUrlsModel + { + public string get { get; set; } + public string update { get; set; } + public string del { get; set; } + public string add { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs new file mode 100644 index 00000000..1a22bf81 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/AgrFlagEnum.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Yi.Framework.Common.Enum +{ + public enum AgrFlagEnum + { + wait = 0, + Agree = 1 + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs new file mode 100644 index 00000000..7433fec5 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/DelFlagEnum.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Yi.Framework.Common.Enum +{ + public enum DelFlagEnum + { + Normal=0, + Deleted=1 + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs new file mode 100644 index 00000000..cbd8ea1b --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Enum +{ + public enum ShowFlagEnum + { + NoShow=0, + Show=1 + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/TopFlagEnum.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/TopFlagEnum.cs new file mode 100644 index 00000000..a9e05013 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/TopFlagEnum.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Enum +{ + public enum TopFlagEnum + { + Children=0, + Top=1 + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/WriteAndReadEnum.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/WriteAndReadEnum.cs new file mode 100644 index 00000000..c67de196 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/Enum/WriteAndReadEnum.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Yi.Framework.Common.Enum +{ + public enum WriteAndReadEnum + { + Write, //主库操作 + Read //从库操作 + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/JobModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/JobModel.cs new file mode 100644 index 00000000..f831ee46 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/JobModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Models +{ + public class JobModel + { + public static int visitNum { get; set; } = 0; + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/LogModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/LogModel.cs new file mode 100644 index 00000000..1c7b779f --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/LogModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Models +{ + /// + /// 写入分布式日志需要的字段 + /// + public class LogModel + { + public string OriginalClassName { get; set; } + public string OriginalMethodName { get; set; } + public string Remark { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/PageModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/PageModel.cs new file mode 100644 index 00000000..491f1c7e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/PageModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Models +{ + public class PageModel + { + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/Result.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/Result.cs new file mode 100644 index 00000000..890b01f7 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/Result.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Yi.Framework.Common.Models +{ + /// + /// 结果数据 + /// + public class Result + { + public bool status { get; set; } + public int code { get; set; } + public string msg { get; set; } + public object data { get; set; } + public static Result Instance(bool status, string msg) + { + return new Result() { status = status, code = 500, msg = msg }; + } + public static Result Error(string msg = "fail") + { + return new Result() { status = false, code = 500, msg = msg }; + } + public static Result Success(string msg = "succeed") + { + return new Result() { status = true, code = 200, msg = msg }; + } + public static Result UnAuthorize(string msg = "unAuthorize") + { + return new Result() { status = false, code = 401, msg = msg }; + } + + public Result SetData(object obj) + { + this.data = obj; + return this; + } + public Result SetCode(int Code) + { + this.code = Code; + return this; + } + } + public class Result + { + public bool status { get; set; } + public int code { get; set; } + public string msg { get; set; } + public T data { get; set; } + + public static Result Instance(bool status, string msg) + { + return new Result() { status = status, code = 500, msg = msg }; + } + public static Result Error(string msg = "fail") + { + return new Result { status = false, code = 500, msg = msg }; + } + public static Result Success(string msg = "succeed") + { + return new Result { status = true, code = 200, msg = msg }; + } + + public static Result UnAuthorize(string msg = "unAuthorize") + { + return new Result{ status = false, code = 401, msg = msg }; + } + + public Result SetData(T TValue) + { + this.data = TValue; + return this; + } + } + +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/SwaggerModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/SwaggerModel.cs new file mode 100644 index 00000000..43d8f300 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/SwaggerModel.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Models +{ + public class SwaggerModel + { + public SwaggerModel(string url, string name) + { + this.url = url; + this.name = name; + } + public string url { get; set; } + public string name { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/OrderCreateQueueModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/OrderCreateQueueModel.cs new file mode 100644 index 00000000..fd20b344 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/OrderCreateQueueModel.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.QueueModel +{ + /// + /// 下单成功后的实体 + /// + public class OrderCreateQueueModel + { + /// + /// 用户Id + /// + public long UserId { get; set; } + /// + /// 订单Id + /// + public long OrderId { get; set; } + /// + /// sku ID 集合 + /// + public List SkuIdList { get; set; } + + /// + /// 尝试次数 + /// + public int TryTime { get; set; } + + public OrderTypeEnum OrderType { get; set; } + + public enum OrderTypeEnum + { + Normal, + Seckill + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/SKUWarmupQueueModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/SKUWarmupQueueModel.cs new file mode 100644 index 00000000..80c926cf --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/SKUWarmupQueueModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.QueueModel +{ + public class SKUWarmupQueueModel + { + public bool Warmup { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/SMSQueueModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/SMSQueueModel.cs new file mode 100644 index 00000000..242a75c9 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/SMSQueueModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.QueueModel +{ + public class SMSQueueModel + { + public string code { get; set; } + public string phone { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/SPUCQRSQueueModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/SPUCQRSQueueModel.cs new file mode 100644 index 00000000..a9a2efba --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/SPUCQRSQueueModel.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.QueueModel +{ + /// + /// 以SPU为单位 + /// + public class SPUCQRSQueueModel + { + public long SpuId { get; set; } + + /// + /// enum SPUCQRSQueueModelType + /// + public int CQRSType { get; set; } + } + + /// + /// 操作类型 + /// + public enum SPUCQRSQueueModelType + { + Insert = 0, + Update = 1, + Delete = 2, + Search = 3 + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Yi.Framework.Common.csproj b/Yi.Framework.Net6/Yi.Framework.Common/Yi.Framework.Common.csproj new file mode 100644 index 00000000..bea37057 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Yi.Framework.Common.csproj @@ -0,0 +1,12 @@ + + + + net6.0 + + + + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.Core/CacheClientDB.cs b/Yi.Framework.Net6/Yi.Framework.Core/CacheClientDB.cs new file mode 100644 index 00000000..32187406 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/CacheClientDB.cs @@ -0,0 +1,1074 @@ +using Microsoft.Extensions.Options; +using ServiceStack; +using ServiceStack.Redis; +using ServiceStack.Redis.Pipeline; +using ServiceStack.Text; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; +using Yi.Framework.Common.IOCOptions; + +namespace Yi.Framework.Core +{ + public class CacheClientDB : IDisposable + { + private readonly RedisConnOptions _RedisOptions; + + #region TestRedisCrack + //static CacheClientDB() + //{ + // try + // { + // Parallel.For(0, 10000, (i) => + // { + // using (RedisClient client = new RedisClient("192.168.3.254")) + // { + // client.Set("name" + i, i); + // client.Incr("name" + i); + // Console.WriteLine(i); + // } + + // }); + // Console.WriteLine("ok"); + + // Console.WriteLine("Hello World!"); + // } + // catch (Exception ex) + // { + // Console.WriteLine(ex.Message); + // } + //} + #endregion + public CacheClientDB(IOptionsMonitor redisConnOptions) + { + this._RedisOptions = redisConnOptions.CurrentValue; + client = new RedisClient(_RedisOptions.Host, _RedisOptions.Prot, _RedisOptions.Password, _RedisOptions.DB); + } + // 管道模式 三种模式 + public IRedisClient GetClient() + { + return client; + } + private IRedisClient client; + + public void Dispose() + { + + this.TryCatchException(delegate + { + this.client.Dispose(); + }, string.Empty); + } + // 为了以后全链路做准备 + private void TryCatchException(Action action, string key) + { + try + { + action(); + } + catch (Exception e) + { + + Console.WriteLine(e.Message); + } + } + + private T TryCatch(Func action, string key) + { + Stopwatch sw = Stopwatch.StartNew(); + //Exception ex = null; + //bool isError = false; + T result; + try + { + result = action(); + } + catch (Exception exinfo) + { + object p=null; + result =(T)p; + //isError = true; + Console.WriteLine(exinfo); + + } + finally + { + + sw.Stop(); + + } + + return result; + } + + private void TryCatch(Action action, string key) + { + + Stopwatch sw = Stopwatch.StartNew(); + //bool isError = false; + //Exception ex = null; + try + { + action(); + } + catch (Exception exinfo) + { + + //isError = true; + Console.WriteLine(exinfo); + } + finally + { + sw.Stop(); + + } + } + public bool Add(string key, T value) + { + + return this.TryCatch(() => this.client.Add(key, value), key); + } + /// + /// 简单模式 事务模式 + /// + /// + /// + /// + /// + /// + public bool Add(string key, T value, DateTime expiresAt) + { + + return this.TryCatch(() => this.client.Add(key, value, expiresAt), key); + } + + public bool Add(string key, T value, TimeSpan expiresIn) + { + return this.TryCatch(() => this.client.Add(key, value, expiresIn), key); + } + + public long Decrement(string key, uint amount) + { + return this.TryCatch(() => this.client.Decrement(key, amount), key); + } + + public void FlushAll() + { + this.TryCatch(delegate + { + this.client.FlushAll(); + }, string.Empty); + } + + public T Get(string key) + { + return this.TryCatch(() => this.client.Get(key), key); + } + + public IDictionary GetAll(IEnumerable keys) + { + return this.TryCatch>(() => this.client.GetAll(keys), keys.FirstOrDefault()); + } + + public long Increment(string key, uint amount) + { + return this.TryCatch(() => this.client.Increment(key, amount), key); + } + + public bool Remove(string key) + { + return this.TryCatch(() => this.client.Remove(key), key); + } + + public void RemoveAll(IEnumerable keys) + { + this.TryCatch(delegate + { + this.client.RemoveAll(keys); + }, keys.FirstOrDefault()); + } + + public bool Replace(string key, T value) + { + return this.TryCatch(() => this.client.Replace(key, value), key); + } + + public bool Replace(string key, T value, DateTime expiresAt) + { + return this.TryCatch(() => this.client.Replace(key, value, expiresAt), key); + } + + public bool Replace(string key, T value, TimeSpan expiresIn) + { + return this.TryCatch(() => this.client.Replace(key, value, expiresIn), key); + } + + public bool Set(string key, T value) + { + return this.TryCatch(() => this.client.Set(key, value), key); + } + + public bool Set(string key, T value, DateTime expiresAt) + { + return this.TryCatch(() => this.client.Set(key, value, expiresAt), key); + } + + public bool Set(string key, T value, TimeSpan expiresIn) + { + return this.TryCatch(() => this.client.Set(key, value, expiresIn), key); + } + + public void SetAll(IDictionary values) + { + this.TryCatch(delegate + { + this.client.SetAll(values); + }, values.Keys.FirstOrDefault()); + } + + + public void Delete(T entity) where T : class, new() + { + this.TryCatch(delegate + { + this.client.Delete(entity); + }, string.Empty); + } + + public void DeleteAll() where TEntity : class, new() + { + this.TryCatch(delegate + { + this.client.DeleteAll(); + }, string.Empty); + } + + public void DeleteById(object id) where T : class, new() + { + this.TryCatch(delegate + { + this.client.DeleteById(id); + }, string.Empty); + } + + public void DeleteByIds(ICollection ids) where T : class, new() + { + this.TryCatch(delegate + { + this.client.DeleteById(ids); + }, string.Empty); + } + + public T GetById(object id) where T : class, new() + { + return this.TryCatch(() => this.client.GetById(id), string.Empty); + } + + public IList GetByIds(ICollection ids) where T : class, new() + { + return this.TryCatch>(() => this.client.GetByIds(ids), string.Empty); + } + + public T Store(T entity) where T : class, new() + { + return this.TryCatch(() => this.client.Store(entity), string.Empty); + } + + public void StoreAll(IEnumerable entities) where TEntity : class, new() + { + this.TryCatch(delegate + { + this.client.StoreAll(entities); + }, string.Empty); + } + + public void AddItemToList(string listId, string value) + { + this.TryCatch(delegate + { + this.client.AddItemToList(listId, value); + }, listId); + } + + public void AddItemToSet(string setId, string item) + { + this.TryCatch(delegate + { + this.client.AddItemToSet(setId, item); + }, setId); + } + + public bool AddItemToSortedSet(string setId, string value) + { + return this.TryCatch(() => this.client.AddItemToSortedSet(setId, value), setId); + } + + public bool AddItemToSortedSet(string setId, string value, double score) + { + return this.TryCatch(() => this.client.AddItemToSortedSet(setId, value, score), setId); + } + + public void AddRangeToList(string listId, List values) + { + this.TryCatch(delegate + { + this.client.AddRangeToList(listId, values); + }, listId); + } + + public void AddRangeToSet(string setId, List items) + { + this.TryCatch(delegate + { + this.client.AddRangeToSet(setId, items); + }, setId); + } + + public bool AddRangeToSortedSet(string setId, List values, double score) + { + return this.TryCatch(() => this.client.AddRangeToSortedSet(setId, values, score), setId); + } + + public bool AddRangeToSortedSet(string setId, List values, long score) + { + return this.TryCatch(() => this.client.AddRangeToSortedSet(setId, values, score), setId); + } + + public long AppendToValue(string key, string value) + { + return this.TryCatch(() => this.client.AppendToValue(key, value), key); + } + + public string BlockingDequeueItemFromList(string listId, TimeSpan? timeOut) + { + return this.TryCatch(() => this.client.BlockingDequeueItemFromList(listId, timeOut), listId); + } + + public KeyValuePair BlockingDequeueItemFromLists(string[] listIds, TimeSpan? timeOut) + { + return this.TryCatch>(delegate + { + ItemRef item = this.client.BlockingDequeueItemFromLists(listIds, timeOut); + return new KeyValuePair(item.Id, item.Item); + }, listIds[0]); + } + + public string BlockingPopAndPushItemBetweenLists(string fromListId, string toListId, TimeSpan? timeOut) + { + return this.TryCatch(() => this.client.BlockingPopAndPushItemBetweenLists(fromListId, toListId, timeOut), fromListId); + } + + public string BlockingPopItemFromList(string listId, TimeSpan? timeOut) + { + return this.TryCatch(() => this.client.BlockingPopItemFromList(listId, timeOut), listId); + } + + public KeyValuePair BlockingPopItemFromLists(string[] listIds, TimeSpan? timeOut) + { + return this.TryCatch>(delegate + { + ItemRef item = this.client.BlockingPopItemFromLists(listIds, timeOut); + return new KeyValuePair(item.Id, item.Item); + }, listIds[0]); + } + + public string BlockingRemoveStartFromList(string listId, TimeSpan? timeOut) + { + return this.TryCatch(() => this.client.BlockingRemoveStartFromList(listId, timeOut), listId); + } + + public KeyValuePair BlockingRemoveStartFromLists(string[] listIds, TimeSpan? timeOut) + { + return this.TryCatch>(delegate + { + ItemRef item = this.client.BlockingRemoveStartFromLists(listIds, timeOut); + return new KeyValuePair(item.Id, item.Item); + }, listIds[0]); + } + + public bool ContainsKey(string key) + { + return this.TryCatch(() => this.client.ContainsKey(key), key); + } + + public long DecrementValue(string key) + { + return this.TryCatch(() => this.client.DecrementValue(key), key); + } + + public long DecrementValueBy(string key, int count) + { + return this.TryCatch(() => this.client.DecrementValueBy(key, count), key); + } + + public string DequeueItemFromList(string listId) + { + return this.TryCatch(() => this.client.DequeueItemFromList(listId), listId); + } + + public void EnqueueItemOnList(string listId, string value) + { + this.TryCatch(delegate + { + this.client.EnqueueItemOnList(listId, value); + }, listId); + } + + public bool ExpireEntryAt(string key, DateTime expireAt) + { + return this.TryCatch(() => this.client.ExpireEntryAt(key, expireAt), key); + } + + public bool ExpireEntryIn(string key, TimeSpan expireIn) + { + return this.TryCatch(() => this.client.ExpireEntryIn(key, expireIn), key); + } + + public Dictionary GetAllEntriesFromHash(string hashId) + { + return this.TryCatch>(() => this.client.GetAllEntriesFromHash(hashId), hashId); + } + + public List GetAllItemsFromList(string listId) + { + return this.TryCatch>(() => this.client.GetAllItemsFromList(listId), listId); + } + + public HashSet GetAllItemsFromSet(string setId) + { + return this.TryCatch>(() => this.client.GetAllItemsFromSet(setId), setId); + } + + public List GetAllItemsFromSortedSet(string setId) + { + return this.TryCatch>(() => this.client.GetAllItemsFromSortedSet(setId), setId); + } + + public List GetAllItemsFromSortedSetDesc(string setId) + { + return this.TryCatch>(() => this.client.GetAllItemsFromSortedSetDesc(setId), setId); + } + + public List GetAllKeys() + { + return this.TryCatch>(() => this.client.GetAllKeys(), string.Empty); + } + + public IDictionary GetAllWithScoresFromSortedSet(string setId) + { + return this.TryCatch>(() => this.client.GetAllWithScoresFromSortedSet(setId), setId); + } + + public string GetAndSetEntry(string key, string value) + { + return this.TryCatch(() => this.client.GetAndSetValue(key, value), key); + } + + public HashSet GetDifferencesFromSet(string fromSetId, params string[] withSetIds) + { + return this.TryCatch>(() => this.client.GetDifferencesFromSet(fromSetId, withSetIds), fromSetId); + } + + public T GetFromHash(object id) + { + return this.TryCatch(() => this.client.GetFromHash(id), string.Empty); + } + + public long GetHashCount(string hashId) + { + return this.TryCatch(() => this.client.GetHashCount(hashId), hashId); + } + + public List GetHashKeys(string hashId) + { + return this.TryCatch>(() => this.client.GetHashKeys(hashId), hashId); + } + + public List GetHashValues(string hashId) + { + return this.TryCatch>(() => this.client.GetHashValues(hashId), hashId); + } + + public HashSet GetIntersectFromSets(params string[] setIds) + { + return this.TryCatch>(() => this.client.GetIntersectFromSets(setIds), setIds[0]); + } + + public string GetItemFromList(string listId, int listIndex) + { + return this.TryCatch(() => this.client.GetItemFromList(listId, listIndex), listId); + } + + public long GetItemIndexInSortedSet(string setId, string value) + { + return this.TryCatch(() => this.client.GetItemIndexInSortedSet(setId, value), setId); + } + + public long GetItemIndexInSortedSetDesc(string setId, string value) + { + return this.TryCatch(() => this.client.GetItemIndexInSortedSetDesc(setId, value), setId); + } + + public double GetItemScoreInSortedSet(string setId, string value) + { + return this.TryCatch(() => this.client.GetItemScoreInSortedSet(setId, value), setId); + } + + public long GetListCount(string listId) + { + return this.TryCatch(() => this.client.GetListCount(listId), listId); + } + + public string GetRandomItemFromSet(string setId) + { + return this.TryCatch(() => this.client.GetRandomItemFromSet(setId), setId); + } + + public List GetRangeFromList(string listId, int startingFrom, int endingAt) + { + return this.TryCatch>(() => this.client.GetRangeFromList(listId, startingFrom, endingAt), listId); + } + + public List GetRangeFromSortedList(string listId, int startingFrom, int endingAt) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedList(listId, startingFrom, endingAt), listId); + } + + public List GetRangeFromSortedSet(string setId, int fromRank, int toRank) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSet(setId, fromRank, toRank), setId); + } + + public List GetRangeFromSortedSetByHighestScore(string setId, double fromScore, double toScore) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetByHighestScore(setId, fromScore, toScore), setId); + } + + public List GetRangeFromSortedSetByHighestScore(string setId, long fromScore, long toScore) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetByHighestScore(setId, fromScore, toScore), setId); + } + + public List GetRangeFromSortedSetByHighestScore(string setId, string fromStringScore, string toStringScore) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetByHighestScore(setId, fromStringScore, toStringScore), setId); + } + + public List GetRangeFromSortedSetByHighestScore(string setId, double fromScore, double toScore, int? skip, int? take) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetByHighestScore(setId, fromScore, toScore, skip, take), setId); + } + + public List GetRangeFromSortedSetByHighestScore(string setId, long fromScore, long toScore, int? skip, int? take) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetByHighestScore(setId, fromScore, toScore, skip, take), setId); + } + + public List GetRangeFromSortedSetByHighestScore(string setId, string fromStringScore, string toStringScore, int? skip, int? take) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetByHighestScore(setId, fromStringScore, toStringScore, skip, take), setId); + } + + public List GetRangeFromSortedSetByLowestScore(string setId, double fromScore, double toScore) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetByLowestScore(setId, fromScore, toScore), setId); + } + + public List GetRangeFromSortedSetByLowestScore(string setId, long fromScore, long toScore) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetByLowestScore(setId, fromScore, toScore), setId); + } + + public List GetRangeFromSortedSetByLowestScore(string setId, string fromStringScore, string toStringScore) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetByLowestScore(setId, fromStringScore, toStringScore), setId); + } + + public List GetRangeFromSortedSetByLowestScore(string setId, double fromScore, double toScore, int? skip, int? take) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetByLowestScore(setId, fromScore, toScore, skip, take), setId); + } + + public List GetRangeFromSortedSetByLowestScore(string setId, long fromScore, long toScore, int? skip, int? take) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetByLowestScore(setId, fromScore, toScore, skip, take), setId); + } + + public List GetRangeFromSortedSetByLowestScore(string setId, string fromStringScore, string toStringScore, int? skip, int? take) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetByLowestScore(setId, fromStringScore, toStringScore, skip, take), setId); + } + + public List GetRangeFromSortedSetDesc(string setId, int fromRank, int toRank) + { + return this.TryCatch>(() => this.client.GetRangeFromSortedSetDesc(setId, fromRank, toRank), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSet(string setId, int fromRank, int toRank) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSet(setId, fromRank, toRank), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetByHighestScore(string setId, double fromScore, double toScore) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetByHighestScore(setId, fromScore, toScore), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetByHighestScore(string setId, long fromScore, long toScore) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetByHighestScore(setId, fromScore, toScore), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetByHighestScore(string setId, string fromStringScore, string toStringScore) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetByHighestScore(setId, fromStringScore, toStringScore), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetByHighestScore(string setId, double fromScore, double toScore, int? skip, int? take) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetByHighestScore(setId, fromScore, toScore, skip, take), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetByHighestScore(string setId, long fromScore, long toScore, int? skip, int? take) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetByHighestScore(setId, fromScore, toScore, skip, take), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetByHighestScore(string setId, string fromStringScore, string toStringScore, int? skip, int? take) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetByHighestScore(setId, fromStringScore, toStringScore, skip, take), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetByLowestScore(string setId, double fromScore, double toScore) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetByHighestScore(setId, fromScore, toScore), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetByLowestScore(string setId, long fromScore, long toScore) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetByLowestScore(setId, fromScore, toScore), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetByLowestScore(string setId, string fromStringScore, string toStringScore) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetByLowestScore(setId, fromStringScore, toStringScore), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetByLowestScore(string setId, double fromScore, double toScore, int? skip, int? take) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetByLowestScore(setId, fromScore, toScore, skip, take), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetByLowestScore(string setId, long fromScore, long toScore, int? skip, int? take) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetByLowestScore(setId, fromScore, toScore, skip, take), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetByLowestScore(string setId, string fromStringScore, string toStringScore, int? skip, int? take) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetByLowestScore(setId, fromStringScore, toStringScore, skip, take), setId); + } + + public IDictionary GetRangeWithScoresFromSortedSetDesc(string setId, int fromRank, int toRank) + { + return this.TryCatch>(() => this.client.GetRangeWithScoresFromSortedSetDesc(setId, fromRank, toRank), setId); + } + + public long GetSetCount(string setId) + { + return this.TryCatch(() => this.client.GetSetCount(setId), setId); + } + + public List GetSortedEntryValues(string key, int startingFrom, int endingAt) + { + return this.TryCatch>(() => this.client.GetSortedEntryValues(key, startingFrom, endingAt), key); + } + + public long GetSortedSetCount(string setId) + { + return this.TryCatch(() => this.client.GetSortedSetCount(setId), setId); + } + + public long GetSortedSetCount(string setId, double fromScore, double toScore) + { + return this.TryCatch(() => this.client.GetSortedSetCount(setId, fromScore, toScore), setId); + } + + public long GetSortedSetCount(string setId, long fromScore, long toScore) + { + return this.TryCatch(() => this.client.GetSortedSetCount(setId, fromScore, toScore), setId); + } + + public long GetSortedSetCount(string setId, string fromStringScore, string toStringScore) + { + return this.TryCatch(() => this.client.GetSortedSetCount(setId, fromStringScore, toStringScore), setId); + } + + public string GetSubstring(string key, int fromIndex, int toIndex) + { + return this.TryCatch(delegate + { + byte[] bytes = ((RedisClient)this.client).GetRange(key, fromIndex, toIndex); + if (bytes != null) + { + return StringExtensions.FromUtf8Bytes(bytes); + } + return null; + }, key); + } + + public TimeSpan GetTimeToLive(string key) + { + return this.TryCatch(delegate + { + TimeSpan? t = this.client.GetTimeToLive(key); + if (!t.HasValue) + { + return TimeSpan.Zero; + } + return t.Value; + }, key); + } + + public HashSet GetUnionFromSets(params string[] setIds) + { + return this.TryCatch>(() => this.client.GetUnionFromSets(setIds), setIds[0]); + } + + public string GetValue(string key) + { + return this.TryCatch(() => this.client.GetValue(key), key); + } + + public string GetValueFromHash(string hashId, string key) + { + return this.TryCatch(() => this.client.GetValueFromHash(hashId, key), hashId); + } + + public List GetValues(List keys) + { + return this.TryCatch>(() => this.client.GetValues(keys), keys[0]); + } + + public List GetValues(List keys) + { + return this.TryCatch>(() => this.client.GetValues(keys), keys[0]); + } + + public List GetValuesFromHash(string hashId, params string[] keys) + { + return this.TryCatch>(() => this.client.GetValuesFromHash(hashId, keys), hashId); + } + + public Dictionary GetValuesMap(List keys) + { + return this.TryCatch>(() => this.client.GetValuesMap(keys), keys[0]); + } + + public Dictionary GetValuesMap(List keys) + { + return this.TryCatch>(() => this.client.GetValuesMap(keys), keys[0]); + } + + public bool HashContainsEntry(string hashId, string key) + { + return this.TryCatch(() => this.client.HashContainsEntry(hashId, key), hashId); + } + + public double IncrementItemInSortedSet(string setId, string value, double incrementBy) + { + return this.TryCatch(() => this.client.IncrementItemInSortedSet(setId, value, incrementBy), setId); + } + + public double IncrementItemInSortedSet(string setId, string value, long incrementBy) + { + return this.TryCatch(() => this.client.IncrementItemInSortedSet(setId, value, incrementBy), setId); + } + + public long IncrementValue(string key) + { + return this.TryCatch(() => this.client.IncrementValue(key), key); + } + + public long IncrementValueBy(string key, int count) + { + return this.TryCatch(() => this.client.IncrementValueBy(key, count), key); + } + + public long IncrementValueInHash(string hashId, string key, int incrementBy) + { + return this.TryCatch(() => this.client.IncrementValueInHash(hashId, key, incrementBy), hashId); + } + + public void MoveBetweenSets(string fromSetId, string toSetId, string item) + { + this.TryCatch(delegate + { + this.client.MoveBetweenSets(fromSetId, toSetId, item); + }, fromSetId); + } + + public string PopAndPushItemBetweenLists(string fromListId, string toListId) + { + return this.TryCatch(() => this.client.PopAndPushItemBetweenLists(fromListId, toListId), fromListId); + } + + public string PopItemFromList(string listId) + { + return this.TryCatch(() => this.client.PopItemFromList(listId), listId); + } + + public string PopItemFromSet(string setId) + { + return this.TryCatch(() => this.client.PopItemFromSet(setId), setId); + } + + public string PopItemWithHighestScoreFromSortedSet(string setId) + { + return this.TryCatch(() => this.client.PopItemWithHighestScoreFromSortedSet(setId), setId); + } + + public string PopItemWithLowestScoreFromSortedSet(string setId) + { + return this.TryCatch(() => this.client.PopItemWithLowestScoreFromSortedSet(setId), setId); + } + + public void PrependItemToList(string listId, string value) + { + this.TryCatch(delegate + { + this.client.PrependItemToList(listId, value); + }, listId); + } + + public void PrependRangeToList(string listId, List values) + { + this.TryCatch(delegate + { + this.client.PrependRangeToList(listId, values); + }, listId); + } + + public long PublishMessage(string toChannel, string message) + { + return this.TryCatch(() => this.client.PublishMessage(toChannel, message), string.Empty); + } + + public void PushItemToList(string listId, string value) + { + this.TryCatch(delegate + { + this.client.PushItemToList(listId, value); + }, listId); + } + + public void RemoveAllFromList(string listId) + { + this.TryCatch(delegate + { + this.client.Remove(listId); + }, listId); + } + + public string RemoveEndFromList(string listId) + { + return this.TryCatch(() => this.client.RemoveEndFromList(listId), listId); + } + + public bool RemoveEntry(params string[] args) + { + return this.TryCatch(() => this.client.RemoveEntry(args), args[0]); + } + + public bool RemoveEntryFromHash(string hashId, string key) + { + return this.TryCatch(() => this.client.RemoveEntryFromHash(hashId, key), hashId); + } + + public long RemoveItemFromList(string listId, string value) + { + return this.TryCatch(() => this.client.RemoveItemFromList(listId, value), listId); + } + + public long RemoveItemFromList(string listId, string value, int noOfMatches) + { + return this.TryCatch(() => this.client.RemoveItemFromList(listId, value, noOfMatches), listId); + } + + public void RemoveItemFromSet(string setId, string item) + { + this.TryCatch(delegate + { + this.client.RemoveItemFromSet(setId, item); + }, setId); + } + + public bool RemoveItemFromSortedSet(string setId, string value) + { + return this.TryCatch(() => this.client.RemoveItemFromSortedSet(setId, value), setId); + } + /// + /// 骚操作-- redis 连接池-- 如果出现高并发,客户端的连接数量会上限,为了节省资源,重复利用连接对象,通过线程池去获取连接 + /// + /// + /// + /// + /// + public static IRedisClientsManager GetPoolClient(string host, int port, int db) + { + return new PooledRedisClientManager(db, host + ":" + port); + } + public long RemoveRangeFromSortedSet(string setId, int minRank, int maxRank) + { + return this.TryCatch(() => this.client.RemoveRangeFromSortedSet(setId, minRank, maxRank), setId); + } + + public long RemoveRangeFromSortedSetByScore(string setId, double fromScore, double toScore) + { + return this.TryCatch(() => this.client.RemoveRangeFromSortedSetByScore(setId, fromScore, toScore), setId); + } + + public long RemoveRangeFromSortedSetByScore(string setId, long fromScore, long toScore) + { + return this.TryCatch(() => this.client.RemoveRangeFromSortedSetByScore(setId, fromScore, toScore), setId); + } + + public string RemoveStartFromList(string listId) + { + return this.TryCatch(() => this.client.RemoveStartFromList(listId), listId); + } + + public void RenameKey(string fromName, string toName) + { + this.TryCatch(delegate + { + this.client.RenameKey(fromName, toName); + }, string.Empty); + } + + public List SearchKeys(string pattern) + { + return this.TryCatch>(() => this.client.SearchKeys(pattern), pattern); + } + + public void SetAll(Dictionary map) + { + this.TryCatch(delegate + { + this.client.SetAll(map); + }, string.Empty); + } + + public void SetAll(IEnumerable keys, IEnumerable values) + { + this.TryCatch(delegate + { + this.client.SetAll(keys, values); + }, string.Empty); + } + + public bool SetContainsItem(string setId, string item) + { + return this.TryCatch(() => this.client.SetContainsItem(setId, item), setId); + } + + public void SetEntry(string key, string value) + { + this.TryCatch(delegate + { + this.client.SetValue(key, value); + }, key); + } + + public void SetEntry(string key, string value, TimeSpan expireIn) + { + this.TryCatch(delegate + { + this.client.SetValue(key, value, expireIn); + }, key); + } + + public bool SetEntryIfNotExists(string key, string value) + { + return this.TryCatch(() => this.client.SetValueIfNotExists(key, value), key); + } + + public bool SetEntryInHash(string hashId, string key, string value) + { + return this.TryCatch(() => this.client.SetEntryInHash(hashId, key, value), hashId); + } + + public bool SetEntryInHashIfNotExists(string hashId, string key, string value) + { + return this.TryCatch(() => this.client.SetEntryInHashIfNotExists(hashId, key, value), hashId); + } + + public void SetItemInList(string listId, int listIndex, string value) + { + this.TryCatch(delegate + { + this.client.SetItemInList(listId, listIndex, value); + }, listId); + } + + public void SetRangeInHash(string hashId, IEnumerable> keyValuePairs) + { + this.TryCatch(delegate + { + this.client.SetRangeInHash(hashId, keyValuePairs); + }, hashId); + } + + public bool SortedSetContainsItem(string setId, string value) + { + return this.TryCatch(() => this.client.SortedSetContainsItem(setId, value), setId); + } + + public void StoreAsHash(T entity) + { + this.TryCatch(delegate + { + this.client.StoreAsHash(entity); + }, string.Empty); + } + + + public bool SetEntryInHash(string hashId, string key, T value) + { + return this.TryCatch(() => this.client.SetEntryInHash(hashId, key, TextExtensions.SerializeToString(value)), hashId); + } + + public T GetValueFromHash(string hashId, string key) + { + return this.TryCatch(() => JsonSerializer.DeserializeFromString(this.client.GetValueFromHash(hashId, key)), hashId); + } + + public bool SetEntryInHashIfNotExists(string hashId, string key, T value) + { + return this.TryCatch(() => this.client.SetEntryInHashIfNotExists(hashId, key, TextExtensions.SerializeToString(value)), hashId); + } + + public IDisposable AcquireLock(string key) + { + return this.TryCatch(() => this.client.AcquireLock(key), key); + } + + public IDisposable AcquireLock(string key, TimeSpan timeOut) + { + return this.TryCatch(() => this.client.AcquireLock(key, timeOut), key); + } + + + public DateTime GetServerTime() + { + return this.TryCatch(() => this.client.GetServerTime(), string.Empty); + } + + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/ConsulExtend/ClienExtend/AbstractConsulDispatcher.cs b/Yi.Framework.Net6/Yi.Framework.Core/ConsulExtend/ClienExtend/AbstractConsulDispatcher.cs new file mode 100644 index 00000000..b603875c --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/ConsulExtend/ClienExtend/AbstractConsulDispatcher.cs @@ -0,0 +1,72 @@ +using Consul; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.IOCOptions; + +namespace Yi.Framework.Core.ConsulExtend +{ + public abstract class AbstractConsulDispatcher + { + protected ConsulClientOption _ConsulClientOption = null; + protected KeyValuePair[] _CurrentAgentServiceDictionary = null; + + public AbstractConsulDispatcher(IOptionsMonitor consulClientOption) + { + this._ConsulClientOption = consulClientOption.CurrentValue; + } + + /// + /// 负载均衡获取地址 + /// + /// Consul映射后的地址 + /// + public string GetAddress(string mappingUrl) + { + Uri uri = new Uri(mappingUrl); + string serviceName = uri.Host; + string addressPort = this.ChooseAddress(serviceName); + return $"{uri.Scheme}://{addressPort}{uri.PathAndQuery}"; + } + + protected virtual string ChooseAddress(string serviceName) + { + ConsulClient client = new ConsulClient(c => + { + c.Address = new Uri($"http://{this._ConsulClientOption.IP}:{this._ConsulClientOption.Port}/"); + c.Datacenter = this._ConsulClientOption.Datacenter; + }); + AgentService agentService = null; + //var response = client.Agent.Services().Result.Response; + ////foreach (var item in response) + ////{ + //// Console.WriteLine("***************************************"); + //// Console.WriteLine(item.Key); + //// var service = item.Value; + //// Console.WriteLine($"{service.Address}--{service.Port}--{service.Service}"); + //// Console.WriteLine("***************************************"); + ////} + + //this._CurrentAgentServiceDictionary = response.Where(s => s.Value.Service.Equals(serviceName, StringComparison.OrdinalIgnoreCase)).ToArray(); + + //升级consul实例获取 + var entrys = client.Health.Service(serviceName).Result.Response; + List> serviceList = new List>(); + for (int i = 0; i < entrys.Length; i++) + { + serviceList.Add(new KeyValuePair(i.ToString(), entrys[i].Service)); + } + this._CurrentAgentServiceDictionary = serviceList.ToArray(); + + int index = this.GetIndex(); + agentService = this._CurrentAgentServiceDictionary[index].Value; + + return $"{agentService.Address}:{agentService.Port}"; + } + + protected abstract int GetIndex(); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/ConsulExtend/ClienExtend/AverageDispatcher.cs b/Yi.Framework.Net6/Yi.Framework.Core/ConsulExtend/ClienExtend/AverageDispatcher.cs new file mode 100644 index 00000000..905a6ea7 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/ConsulExtend/ClienExtend/AverageDispatcher.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Consul; +using Microsoft.Extensions.Options; +using Yi.Framework.Common.IOCOptions; + +namespace Yi.Framework.Core.ConsulExtend +{ + /// + /// 平均 + /// + public class AverageDispatcher : AbstractConsulDispatcher + { + #region Identity + private static int _iTotalCount = 0; + private static int iTotalCount + { + get + { + return _iTotalCount; + } + set + { + _iTotalCount = value >= Int32.MaxValue ? 0 : value; + } + } + + + public AverageDispatcher(IOptionsMonitor consulClientOption) : base(consulClientOption) + { + } + #endregion + + /// + /// 平均 + /// + /// + protected override int GetIndex() + { + return new Random(iTotalCount++).Next(0, base._CurrentAgentServiceDictionary.Length); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/ConsulExtend/ClienExtend/PollingDispatcher.cs b/Yi.Framework.Net6/Yi.Framework.Core/ConsulExtend/ClienExtend/PollingDispatcher.cs new file mode 100644 index 00000000..882d7fbc --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/ConsulExtend/ClienExtend/PollingDispatcher.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Consul; +using Microsoft.Extensions.Options; +using Yi.Framework.Common.IOCOptions; + +namespace Yi.Framework.Core.ConsulExtend +{ + /// + /// 轮询 + /// + public class PollingDispatcher : AbstractConsulDispatcher + { + #region Identity + private static int _iTotalCount = 0; + private static int iTotalCount + { + get + { + return _iTotalCount; + } + set + { + _iTotalCount = value >= Int32.MaxValue ? 0 : value; + } + } + + public PollingDispatcher(IOptionsMonitor consulClientOption) : base(consulClientOption) + { + } + #endregion + + /// + /// 轮询 + /// + /// + /// + protected override int GetIndex() + { + return iTotalCount++ % base._CurrentAgentServiceDictionary.Length; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/ConsulExtend/ClienExtend/WeightDispatcher.cs b/Yi.Framework.Net6/Yi.Framework.Core/ConsulExtend/ClienExtend/WeightDispatcher.cs new file mode 100644 index 00000000..41a215f8 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/ConsulExtend/ClienExtend/WeightDispatcher.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Consul; +using Microsoft.Extensions.Options; +using Yi.Framework.Common.IOCOptions; + +namespace Yi.Framework.Core.ConsulExtend +{ + /// + /// 权重 + /// + public class WeightDispatcher : AbstractConsulDispatcher + { + #region Identity + private static int _iTotalCount = 0; + private static int iTotalCount + { + get + { + return _iTotalCount; + } + set + { + _iTotalCount = value >= Int32.MaxValue ? 0 : value; + } + } + public WeightDispatcher(IOptionsMonitor consulClientOption) : base(consulClientOption) + { + + } + #endregion + + protected override string ChooseAddress(string serviceName) + { + ConsulClient client = new ConsulClient(c => + { + c.Address = new Uri($"http://{base._ConsulClientOption.IP}:{base._ConsulClientOption.Port}/"); + c.Datacenter = base._ConsulClientOption.Datacenter; + }); + AgentService agentService = null; + var response = client.Agent.Services().Result.Response; + + this._CurrentAgentServiceDictionary = response.Where(s => s.Value.Service.Equals(serviceName, StringComparison.OrdinalIgnoreCase)).ToArray(); + + + var serviceDictionaryNew = new List(); + foreach (var service in base._CurrentAgentServiceDictionary) + { + serviceDictionaryNew.AddRange(Enumerable.Repeat(service.Value, int.TryParse(service.Value.Tags?[0], out int iWeight) ? 1 : iWeight)); + } + int index = new Random(DateTime.Now.Millisecond).Next(0, int.MaxValue) % serviceDictionaryNew.Count; + agentService = serviceDictionaryNew[index]; + + return $"{agentService.Address}:{agentService.Port}"; + } + /// + /// 不需要了 + /// + /// + protected override int GetIndex() + { + throw new NotImplementedException(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/ElasticSearchInvoker.cs b/Yi.Framework.Net6/Yi.Framework.Core/ElasticSearchInvoker.cs new file mode 100644 index 00000000..4b4556cc --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/ElasticSearchInvoker.cs @@ -0,0 +1,53 @@ +using Microsoft.Extensions.Options; +using Nest; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.IOCOptions; + +namespace Yi.Framework.Core +{ + public class ElasticSearchInvoker + { + private readonly ElasticSearchOptions _elasticSearchOptions; + + public ElasticSearchInvoker(IOptionsMonitor optionsMonitor) + { + _elasticSearchOptions = optionsMonitor.CurrentValue; + var settings = new ConnectionSettings(new Uri(_elasticSearchOptions.Url)).DefaultIndex(this._elasticSearchOptions.IndexName); + Client = new ElasticClient(settings); + } + private ElasticClient Client; + public ElasticClient GetElasticClient() + { + return Client; + } + public void Send(List model) where T : class + { + Client.IndexMany(model); + } + + public void InsertOrUpdata(T model) where T : class + { + Client.IndexDocument(model); + } + + public bool Delete(string id) where T : class + { + + var response = Client.Delete(id); + return response.IsValid; + } + public bool DropIndex(string indexName) + { + return Client.Indices.Delete(Indices.Parse(indexName)).IsValid; + } + public void CreateIndex(string indexName) + { + var settings = new ConnectionSettings(new Uri(_elasticSearchOptions.Url)).DefaultIndex(indexName); + this.Client = new ElasticClient(settings); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/Library/Microsoft.Bcl.AsyncInterfaces.dll b/Yi.Framework.Net6/Yi.Framework.Core/Library/Microsoft.Bcl.AsyncInterfaces.dll new file mode 100644 index 00000000..c695bdd5 Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.Core/Library/Microsoft.Bcl.AsyncInterfaces.dll differ diff --git a/Yi.Framework.Net6/Yi.Framework.Core/Library/ServiceStack.Common.dll b/Yi.Framework.Net6/Yi.Framework.Core/Library/ServiceStack.Common.dll new file mode 100644 index 00000000..f10b87b4 Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.Core/Library/ServiceStack.Common.dll differ diff --git a/Yi.Framework.Net6/Yi.Framework.Core/Library/ServiceStack.Interfaces.dll b/Yi.Framework.Net6/Yi.Framework.Core/Library/ServiceStack.Interfaces.dll new file mode 100644 index 00000000..4dbba7ef Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.Core/Library/ServiceStack.Interfaces.dll differ diff --git a/Yi.Framework.Net6/Yi.Framework.Core/Library/ServiceStack.Redis.dll b/Yi.Framework.Net6/Yi.Framework.Core/Library/ServiceStack.Redis.dll new file mode 100644 index 00000000..5faefa26 Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.Core/Library/ServiceStack.Redis.dll differ diff --git a/Yi.Framework.Net6/Yi.Framework.Core/Library/ServiceStack.Text.dll b/Yi.Framework.Net6/Yi.Framework.Core/Library/ServiceStack.Text.dll new file mode 100644 index 00000000..2f701811 Binary files /dev/null and b/Yi.Framework.Net6/Yi.Framework.Core/Library/ServiceStack.Text.dll differ diff --git a/Yi.Framework.Net6/Yi.Framework.Core/MakeJwt.cs b/Yi.Framework.Net6/Yi.Framework.Core/MakeJwt.cs new file mode 100644 index 00000000..841351a2 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/MakeJwt.cs @@ -0,0 +1,63 @@ +using Microsoft.IdentityModel.JsonWebTokens; +using Microsoft.IdentityModel.Tokens; +using System; +using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; +using System.Linq; +using System.Security.Claims; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.Const; +using Yi.Framework.Model.Models; +using JwtRegisteredClaimNames = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames; + +namespace Yi.Framework.Core +{ + + public class jwtUser + { + public user user { get; set; } + public List menuIds { get; set; } + + } + + public class MakeJwt + { + + /// + /// user需关联所有roles,还有一个menuIds + /// + /// + /// + public static string app(jwtUser _user) + { + //通过查询权限,把所有权限加入进令牌中 + List claims = new List(); + claims.Add(new Claim(JwtRegisteredClaimNames.Nbf, $"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}")); + claims.Add(new Claim(JwtRegisteredClaimNames.Exp, $"{new DateTimeOffset(DateTime.Now.AddMinutes(30)).ToUnixTimeSeconds()}")); + claims.Add(new Claim(ClaimTypes.Name, _user.user.username)); + claims.Add(new Claim(ClaimTypes.Sid, _user.user.id.ToString())); + foreach (var k in _user?.menuIds) + { + claims.Add(new Claim("menuIds",k.id.ToString())); + } + foreach (var k in _user.user.roles) + { + claims.Add(new Claim(ClaimTypes.Role, k.role_name)); + } + var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(JwtConst.SecurityKey)); + var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); + + var token = new JwtSecurityToken( + issuer: JwtConst.Domain, + audience: JwtConst.Domain, + claims: claims, + expires: DateTime.Now.AddMinutes(30), + signingCredentials: creds); + var tokenData = new JwtSecurityTokenHandler().WriteToken(token); + + return tokenData; + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/Quartz/MyQuartzFactory.cs b/Yi.Framework.Net6/Yi.Framework.Core/Quartz/MyQuartzFactory.cs new file mode 100644 index 00000000..098989f7 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/Quartz/MyQuartzFactory.cs @@ -0,0 +1,32 @@ +using Microsoft.Extensions.DependencyInjection; +using Quartz; +using Quartz.Spi; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Core.Quartz +{ + public class MyQuartzFactory : IJobFactory + { + private readonly IServiceProvider _serviceProvider; + + public MyQuartzFactory(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler) + { + return _serviceProvider.GetRequiredService(bundle.JobDetail.JobType) as IJob; + } + + public void ReturnJob(IJob job) + { + var disposable = job as IDisposable; + disposable?.Dispose(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/Quartz/QuartzInvoker.cs b/Yi.Framework.Net6/Yi.Framework.Core/Quartz/QuartzInvoker.cs new file mode 100644 index 00000000..7943078b --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/Quartz/QuartzInvoker.cs @@ -0,0 +1,150 @@ +using Microsoft.Extensions.Logging; +using Quartz; +using Quartz.Impl.Matchers; +using Quartz.Spi; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.Helper; +using Yi.Framework.Job; + +namespace Yi.Framework.Core +{ + public class QuartzInvoker + { + private readonly ISchedulerFactory _schedulerFactory; + private IScheduler _scheduler; + private ILogger _logger; + private IJobFactory _jobFactory; + public QuartzInvoker(ISchedulerFactory schedulerFactory, ILogger logger, IJobFactory jobFactory) + { + _schedulerFactory = schedulerFactory; + _logger = logger; + _jobFactory = jobFactory; + } + + /// + /// 开始任务 + /// + /// + /// + /// + /// + /// + /// + public async Task start(string cron, JobKey jobKey, string jobClass, long second = 0, IDictionary data = null) + { + if (data == null) + { + data = new Dictionary(); + } + + var myClass = AssemblyHelper.GetClass("Yi.Framework.Job", jobClass).FirstOrDefault(); + + _scheduler = await _schedulerFactory.GetScheduler(); + _scheduler.JobFactory = _jobFactory; + //开启调度器 + await _scheduler.Start(); + //创建一个触发器 + var trigger = TriggerBuilder.Create() + .StartAt(DateTimeOffset.Now.AddSeconds(second)) + .WithCronSchedule(cron) + .Build(); + //创建任务 + var jobDetail = JobBuilder.Create(myClass) + .UsingJobData(new JobDataMap(data)) + .WithIdentity(jobKey.Name, jobKey.Group) + .Build(); + //将触发器和任务器绑定到调度器中 + await _scheduler.ScheduleJob(jobDetail, trigger); + + _logger.LogWarning($"开始任务:{jobKey.Name},组别:{jobKey.Group}"); + } + + /// + /// 暂停任务 + /// + /// + /// + public async Task Stop(JobKey jobKey) + { + var _scheduler = await _schedulerFactory.GetScheduler(); + //LogUtil.Debug($"暂停任务{jobKey.Group},{jobKey.Name}"); + await _scheduler.PauseJob(jobKey); + _logger.LogWarning($"暂停任务:{jobKey.Name},组别:{jobKey.Group}"); + } + + + public async Task Delete(JobKey jobKey) + { + var _scheduler = await _schedulerFactory.GetScheduler(); + //LogUtil.Debug($"暂停任务{jobKey.Group},{jobKey.Name}"); + await _scheduler.DeleteJob(jobKey); + _logger.LogWarning($"删除任务:{jobKey.Name},组别:{jobKey.Group}"); + } + + public async Task Resume(JobKey jobKey) + { + var _scheduler = await _schedulerFactory.GetScheduler(); + //LogUtil.Debug($"恢复任务{jobKey.Group},{jobKey.Name}"); + await _scheduler.ResumeJob(jobKey); + _logger.LogWarning($"恢复任务:{jobKey.Name},组别:{jobKey.Group}"); + } + + + /// + /// 得到可运行的job列表 + /// + /// + public List getJobClassList() + { + var myClassList = AssemblyHelper.GetClass("Yi.Framework.Job"); + List data = new List(); + myClassList.ForEach(k => data.Add(k.Name)); + return data; + } + + /// + /// 得到现在正在运行的任务列表 + /// + /// + public async Task> getRunJobList() + { + _scheduler = await _schedulerFactory.GetScheduler(); + var groups = await _scheduler.GetJobGroupNames(); + var data = new List(); + foreach (var groupName in groups) + { + foreach (var jobKey in await _scheduler.GetJobKeys(GroupMatcher.GroupEquals(groupName))) + { + string jobName = jobKey.Name; + string jobGroup = jobKey.Group; + data.Add(jobKey); + var triggers = await _scheduler.GetTriggersOfJob(jobKey); + foreach (ITrigger trigger in triggers) + { + ///下一次的执行时间 + var utcTime =trigger.GetNextFireTimeUtc(); + string str = utcTime.ToString(); + //TimeZone.CurrentTimeZone.ToLocalTime(Convert.ToDateTime(str)); + + + } + } + } + + return data; + } + } + + + + public class JobKeyModel + { + public JobKey jobKey { get; set; } + public DateTime? nextTime { get; set; } + } +} + diff --git a/Yi.Framework.Net6/Yi.Framework.Core/RabbitMQInvoker.cs b/Yi.Framework.Net6/Yi.Framework.Core/RabbitMQInvoker.cs new file mode 100644 index 00000000..b28fc22f --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/RabbitMQInvoker.cs @@ -0,0 +1,257 @@ +using Microsoft.Extensions.Options; +using RabbitMQ.Client; +using RabbitMQ.Client.Events; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.IOCOptions; + +namespace Yi.Framework.Core +{ + /// + /// 一个Exchange----多个Queue-----弄个缓存映射关系,初始化+支持全新绑定 + /// 全局单例使用 + /// + /// 关系应该是直接配置到RabbitMQ了---程序只是向某个位置写入即可 + /// + /// + /// 全量更新--耗时---阻塞实时更新---换不同的exchange? + /// + public class RabbitMQInvoker + { + #region Identity + private readonly RabbitMQOptions _rabbitMQOptions; + private readonly string _HostName = null; + private readonly string _UserName = null; + private readonly string _Password = null; + private readonly int _Port = 0; + public RabbitMQInvoker(IOptionsMonitor optionsMonitor) : this(optionsMonitor.CurrentValue.HostName, optionsMonitor.CurrentValue.UserName, optionsMonitor.CurrentValue.Password,optionsMonitor.CurrentValue.Port) + { + this._rabbitMQOptions = optionsMonitor.CurrentValue; + } + + public RabbitMQInvoker(string hostName, string userName = "cc", string password = "cc",int port= 5672) + { + this._HostName = hostName; + this._UserName = userName; + this._Password = password; + this._Port = port; + } + #endregion + + #region Init + private static object RabbitMQInvoker_BindQueueLock = new object(); + private static Dictionary RabbitMQInvoker_ExchangeQueue = new Dictionary(); + private void InitBindQueue(RabbitMQConsumerModel rabbitMQConsumerModel) + { + if (!RabbitMQInvoker_ExchangeQueue.ContainsKey($"InitBindQueue_{rabbitMQConsumerModel.ExchangeName}_{rabbitMQConsumerModel.QueueName}")) + { + lock (RabbitMQInvoker_BindQueueLock) + { + if (!RabbitMQInvoker_ExchangeQueue.ContainsKey($"InitBindQueue_{rabbitMQConsumerModel.ExchangeName}_{rabbitMQConsumerModel.QueueName}")) + { + this.InitConnection(); + using (IModel channel = _CurrentConnection.CreateModel()) + { + channel.ExchangeDeclare(exchange: rabbitMQConsumerModel.ExchangeName, type: ExchangeType.Fanout, durable: true, autoDelete: false, arguments: null); + channel.QueueDeclare(queue: rabbitMQConsumerModel.QueueName, durable: true, exclusive: false, autoDelete: false, arguments: null); + channel.QueueBind(queue: rabbitMQConsumerModel.QueueName, exchange: rabbitMQConsumerModel.ExchangeName, routingKey: string.Empty, arguments: null); + } + RabbitMQInvoker_ExchangeQueue[$"InitBindQueue_{rabbitMQConsumerModel.ExchangeName}_{rabbitMQConsumerModel.QueueName}"] = true; + } + } + } + } + /// + /// 必须先声明exchange--检查+初始化 + /// + /// + private void InitExchange(string exchangeName) + { + if (!RabbitMQInvoker_ExchangeQueue.ContainsKey($"InitExchange_{exchangeName}"))//没用api确认 + { + lock (RabbitMQInvoker_BindQueueLock) + { + if (!RabbitMQInvoker_ExchangeQueue.ContainsKey($"InitExchange_{exchangeName}")) + { + this.InitConnection(); + using (IModel channel = _CurrentConnection.CreateModel()) + { + channel.ExchangeDeclare(exchange: exchangeName, type: ExchangeType.Fanout, durable: true, autoDelete: false, arguments: null); + } + RabbitMQInvoker_ExchangeQueue[$"InitExchange_{exchangeName}"] = true; + } + } + } + } + //public void UnBindQueue(string exchangeName, string queueName) + //{ + //} + + private static object RabbitMQInvoker_InitLock = new object(); + private static IConnection _CurrentConnection = null;//链接做成单例重用--channel是新的 + private void InitConnection() + { + //https://blog.csdn.net/weixin_30646315/article/details/99101279 + if (_CurrentConnection == null || !_CurrentConnection.IsOpen) + { + lock (RabbitMQInvoker_InitLock) + { + if (_CurrentConnection == null || !_CurrentConnection.IsOpen) + { + var factory = new ConnectionFactory() + { + HostName = this._HostName, + Password = this._Password, + UserName = this._UserName, + Port=this._Port + + }; + _CurrentConnection = factory.CreateConnection(); + } + } + } + } + #endregion + + /// + /// 只管exchange--- + /// 4种路由类型? + /// + /// Send前完成交换机初始化 + /// + /// + /// 建议Json格式 + public void Send(RabbitMQConsumerModel rabbitMQConsumerModel, string message) + { + this.InitExchange(rabbitMQConsumerModel.ExchangeName); + this.InitBindQueue(rabbitMQConsumerModel); + if (_CurrentConnection == null || !_CurrentConnection.IsOpen) + { + this.InitConnection(); + } + using (var channel = _CurrentConnection.CreateModel())//开辟新的信道通信 + { + try + { + channel.TxSelect();//开启Tx事务---RabbitMQ协议级的事务-----强事务 + + var body = Encoding.UTF8.GetBytes(message); + channel.BasicPublish(exchange: rabbitMQConsumerModel.ExchangeName, + routingKey: string.Empty, + basicProperties: null, + body: body); + channel.TxCommit();//提交 + Console.WriteLine($" [x] Sent {body.Length}"); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + Console.WriteLine($"【{message}】发送到Broker失败!{ex.Message}"); + channel.TxRollback(); //事务回滚--前面的所有操作就全部作废了。。。。 + } + } + } + + /// + /// 固定无消费队列名字---转移到目标队列---定好时间 + /// + /// + /// + /// + public void SendDelay(string targetExchangeName, string message, int delaySecond) + { + this.InitExchange(targetExchangeName); + + if (_CurrentConnection == null || !_CurrentConnection.IsOpen) + { + this.InitConnection(); + } + using (var channel = _CurrentConnection.CreateModel())//开辟新的信道通信 + { + try + { + string delayExchangeName = "ZhaoxiMSA_DelayExchange"; + + //普通交换器 + channel.ExchangeDeclare(delayExchangeName, "fanout", true, false, null); + //参数设置 + Dictionary args = new Dictionary(); + args.Add("x-message-ttl", delaySecond * 1000);//TTL 毫秒 + args.Add("x-dead-letter-exchange", targetExchangeName);//DLX + args.Add("x-dead-letter-routing-key", "routingkey");//routingKey + channel.QueueDeclare("ZhaoxiMSA_DelayQueue", true, false, false, args); + channel.QueueBind(queue: "ZhaoxiMSA_DelayQueue", + exchange: delayExchangeName, + routingKey: string.Empty, + arguments: null); + + ////DLX--- //死信队列绑定 + //channel.ExchangeDeclare("ZhaoxiMSA_exchange_dlx", "fanout", true, false, null); + //channel.QueueDeclare("ZhaoxiMSA_queue_dlx", true, false, false, null); + //channel.QueueBind("ZhaoxiMSA_queue_dlx", "ZhaoxiMSA_exchange_dlx", "routingkey", null); + + + channel.TxSelect();//开启Tx事务---RabbitMQ协议级的事务-----强事务 + var properties = channel.CreateBasicProperties(); + + var body = Encoding.UTF8.GetBytes(message); + channel.BasicPublish(exchange: delayExchangeName, + routingKey: string.Empty, + basicProperties: properties, + body: body); + channel.TxCommit();//提交 + Console.WriteLine($" [x] Sent {body.Length}"); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + Console.WriteLine($"【{message}】发送到Broker失败!{ex.Message}"); + channel.TxRollback(); //事务回滚--前面的所有操作就全部作废了。。。。 + } + } + } + + #region Receive + /// + /// 注册处理动作 + /// + /// + /// + public void RegistReciveAction(RabbitMQConsumerModel rabbitMQConsumerMode, Func func) + { + this.InitBindQueue(rabbitMQConsumerMode); + + Task.Run(() => + { + using (var channel = _CurrentConnection.CreateModel()) + { + var consumer = new EventingBasicConsumer(channel); + channel.BasicQos(0, 0, true); + consumer.Received += (sender, ea) => + { + string str = Encoding.UTF8.GetString(ea.Body.ToArray()); + if (func(str)) + { + channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);//确认已消费 + } + else + { + //channel.BasicReject(deliveryTag: ea.DeliveryTag, requeue: true);//放回队列--重新包装信息,放入其他队列 + } + }; + channel.BasicConsume(queue: rabbitMQConsumerMode.QueueName, + autoAck: false,//不ACK + consumer: consumer); + Console.WriteLine($" Register Consumer To {rabbitMQConsumerMode.ExchangeName}-{rabbitMQConsumerMode.QueueName}"); + Console.ReadLine(); + Console.WriteLine($" After Register Consumer To {rabbitMQConsumerMode.ExchangeName}-{rabbitMQConsumerMode.QueueName}"); + } + }); + } + #endregion + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/SMS/AliyunSMSInvoker.cs b/Yi.Framework.Net6/Yi.Framework.Core/SMS/AliyunSMSInvoker.cs new file mode 100644 index 00000000..eb5bcb4c --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/SMS/AliyunSMSInvoker.cs @@ -0,0 +1,46 @@ +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.IOCOptions; + +namespace Yi.Framework.Core.SMS +{ + public class AliyunSMSInvoker + { + private IOptionsMonitor _sMSOptions; + public AliyunSMSInvoker(IOptionsMonitor sMSOptions) + { + _sMSOptions = sMSOptions; + } + private static AlibabaCloud.SDK.Dysmsapi20170525.Client CreateClient(string accessKeyId, string accessKeySecret) + { + AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config + { + // 您的AccessKey ID + AccessKeyId = accessKeyId, + // 您的AccessKey Secret + AccessKeySecret = accessKeySecret, + }; + // 访问的域名 + config.Endpoint = "dysmsapi.aliyuncs.com"; + return new AlibabaCloud.SDK.Dysmsapi20170525.Client(config); + } + + public void SendCode(string code,string phone) + { + AlibabaCloud.SDK.Dysmsapi20170525.Client client = CreateClient(_sMSOptions.CurrentValue.ID, _sMSOptions.CurrentValue.Secret); + AlibabaCloud.SDK.Dysmsapi20170525.Models.SendSmsRequest sendSmsRequest = new AlibabaCloud.SDK.Dysmsapi20170525.Models.SendSmsRequest + { + PhoneNumbers = phone, + SignName = _sMSOptions.CurrentValue.Sign, + TemplateCode = _sMSOptions.CurrentValue.Template, + TemplateParam = "{\"code\":\""+ code + "\"}", + }; + // 复制代码运行请自行打印 API 的返回值 + client.SendSms(sendSmsRequest); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/TreeMenuBuild.cs b/Yi.Framework.Net6/Yi.Framework.Core/TreeMenuBuild.cs new file mode 100644 index 00000000..14b0e6f8 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/TreeMenuBuild.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Core +{ + public static class TreeMenuBuild + { + /// + /// 过滤所有已经删除的菜单 + /// + /// + /// + public static menu Normal(menu menu_data) + { + for (int i = menu_data.children.Count() - 1; i >= 0; i--) + { + if (menu_data.children[i].is_delete == (short)Common.Enum.DelFlagEnum.Deleted) + { + menu_data.children.Remove(menu_data.children[i]); + } + else if (menu_data.children[i] != null) + { + Normal(menu_data.children[i]); + } + } + return menu_data; + } + + + + public static menu ShowFormat(menu menu_data, List allMenuIds) + { + return Format(Show(menu_data, allMenuIds)); + } + + + + /// + /// 过滤用户不展示及已删除及未拥有的菜单 + /// + /// + /// + /// + private static menu Show(menu menu_data, List allMenuIds) + { + for (int i = menu_data.children.Count() - 1; i >= 0; i--) + { + if (!allMenuIds.Contains(menu_data.children[i].id) || menu_data.children[i].is_delete == (short)Common.Enum.DelFlagEnum.Deleted || menu_data.children[i].is_show == (short)Common.Enum.ShowFlagEnum.NoShow) + { + menu_data.children.Remove(menu_data.children[i]); + } + else + { + Show(menu_data.children[i], allMenuIds); + } + } + return menu_data; + } + + /// + /// 为了匹配前端格式,通常和show方法一起 + /// + /// + /// + private static menu Format(menu menu_data) + { + for (int i = menu_data.children.Count() - 1; i >= 0; i--) + { + if (menu_data.children[i].icon == null) + { + menu_data.children[i].icon = "mdi-view-dashboard"; + } + if (menu_data.children != null || menu_data.children.Count() != 0) + { + Format(menu_data.children[i]); + } + } + if (menu_data.children.Count() == 0) + { + menu_data.children = null; + } + + return menu_data; + } + + public static menu Sort(menu menu_data) + { + if (menu_data.children != null) + { + for (int i = menu_data.children.Count() - 1; i >= 0; i--) + { + menu_data.children = menu_data.children.AsEnumerable().OrderByDescending(u => u.sort).ToList(); + + if (menu_data.children != null || menu_data.children.Count() != 0) + { + Sort(menu_data.children[i]); + } + } + } + return menu_data; + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Core/Yi.Framework.Core.csproj b/Yi.Framework.Net6/Yi.Framework.Core/Yi.Framework.Core.csproj new file mode 100644 index 00000000..220faf6d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Core/Yi.Framework.Core.csproj @@ -0,0 +1,43 @@ + + + + net6.0 + + + + + + + + + + + + + + + + + + + + + + + Library\Microsoft.Bcl.AsyncInterfaces.dll + + + Library\ServiceStack.Common.dll + + + Library\ServiceStack.Interfaces.dll + + + Library\ServiceStack.Redis.dll + + + Library\ServiceStack.Text.dll + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/ChangePwdDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/ChangePwdDto.cs new file mode 100644 index 00000000..d8db8c1e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/ChangePwdDto.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.DTOModel +{ + public class ChangePwdDto + { + public user user { get; set; } + public string newPassword { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/ChildrenDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/ChildrenDto.cs new file mode 100644 index 00000000..18ee3742 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/ChildrenDto.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.DTOModel +{ + public class ChildrenDto + { + public int parentId { get; set; } + public T data { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/IdsDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/IdsDto.cs new file mode 100644 index 00000000..94a2ab1d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/IdsDto.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; + +namespace Yi.Framework.DTOModel +{ + public class IdDto + { + public T id1 { get; set; } + public T id2 { get; set; } + } + + public class IdsDto + { + public T id{ get; set; } + public List ids { get; set; } + } + + public class IdsListDto + { + public List ids1 { get; set; } + public List ids2 { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/SettingDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/SettingDto.cs new file mode 100644 index 00000000..3e3dca70 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/SettingDto.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.DTOModel +{ + public class SettingDto + { + public string InitIcon { get; set; } + public string InitRole { get; set; } + public string Title { get; set; } + public List ImageList { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/Yi.Framework.DTOModel.csproj b/Yi.Framework.Net6/Yi.Framework.DTOModel/Yi.Framework.DTOModel.csproj new file mode 100644 index 00000000..d0fe5f85 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/Yi.Framework.DTOModel.csproj @@ -0,0 +1,11 @@ + + + + net6.0 + + + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/InitESIndexWorker.cs b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/InitESIndexWorker.cs new file mode 100644 index 00000000..f18a0372 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/InitESIndexWorker.cs @@ -0,0 +1,84 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Yi.Framework.Common.IOCOptions; +using Yi.Framework.Common.Models; +using Yi.Framework.Core; + +namespace Yi.Framework.ElasticSearchProcessor +{ + public class InitESIndexWorker : BackgroundService + { + private readonly IConfiguration _configuration; + private readonly ILogger _logger; + private readonly RabbitMQInvoker _RabbitMQInvoker; + private readonly ElasticSearchInvoker _elasticSearchInvoker; + + public InitESIndexWorker(ILogger logger, RabbitMQInvoker rabbitMQInvoker, IConfiguration configuration, ElasticSearchInvoker elasticSearchInvoker) + { + this._logger = logger; + this._RabbitMQInvoker = rabbitMQInvoker; + this._configuration = configuration; + this._elasticSearchInvoker = elasticSearchInvoker; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + RabbitMQConsumerModel rabbitMQConsumerModel = new RabbitMQConsumerModel() + { + ExchangeName = RabbitMQExchangeQueueName.SKUCQRS_Exchange, + QueueName = RabbitMQExchangeQueueName.SKUCQRS_Queue_ESIndex + }; + HttpClient _HttpClient = new HttpClient(); + this._RabbitMQInvoker.RegistReciveAction(rabbitMQConsumerModel, message => + { + try + { + //õģ͡ + //SPUCQRSQueueModel spuCQRSQueueModel = JsonConvert.DeserializeObject(message); + + //жɾģesӦIJ + //switch (spuCQRSQueueModel.CQRSType) + //{ + // case (int)SPUCQRSQueueModelType.Insert: + // case (int)SPUCQRSQueueModelType.Update: + // { + // Goods goods = this._ISearchService.GetGoodsBySpuId(spuCQRSQueueModel.SpuId); + // this._IElasticSearchService.InsertOrUpdata(goods); + // break; + // } + // case (int)SPUCQRSQueueModelType.Delete: + // this._IElasticSearchService.Delete(spuCQRSQueueModel.SpuId.ToString()); + // break; + // default: + // throw new Exception("wrong spuCQRSQueueModel.CQRSType"); + //} + + this._logger.LogInformation($"{nameof(InitESIndexWorker)}.Init ESIndex succeed SpuId"); + return true; + } + catch (Exception ex) + { + LogModel logModel = new LogModel() + { + OriginalClassName = this.GetType().FullName, + OriginalMethodName = nameof(ExecuteAsync), + Remark = "ʱҵ־" + }; + this._logger.LogError(ex, $"{nameof(InitESIndexWorker)}.Init ESIndex failed message={message}, Exception:{ex.Message}", JsonConvert.SerializeObject(logModel)); + return false; + } + }); + await Task.CompletedTask; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Log4net.config b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Log4net.config new file mode 100644 index 00000000..958c7e78 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Log4net.config @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Program.cs b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Program.cs new file mode 100644 index 00000000..b0e05774 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Program.cs @@ -0,0 +1,68 @@ + +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using Yi.Framework.WebCore; +using Yi.Framework.WebCore.BuilderExtend; +using Yi.Framework.WebCore.MiddlewareExtend; + +namespace Yi.Framework.ElasticSearchProcessor +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) => + { + configurationBuilder.AddCommandLine(args); + configurationBuilder.AddJsonFileService(); + //configurationBuilder.AddJsonFile("configuration.json", optional: false, reloadOnChange: true); + #region + //Apollo配置 + #endregion + //configurationBuilder.AddApolloService("Yi"); + }) + .ConfigureLogging(loggingBuilder => + { + loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning); + loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning); + loggingBuilder.AddLog4Net(); + }) + .ConfigureServices((hostContext, services) => + { + + IConfiguration configuration = services.BuildServiceProvider().GetRequiredService(); + + #region + //Ioc配置 + #endregion + services.AddSingleton(new Appsettings(configuration)); + + services.AddHostedService(); + services.AddHostedService(); + services.AddHostedService(); + #region 服务注入 + //services.Configure(configuration.GetSection("MysqlConn")); + + + #region + //RabbitMQ服务配置 + #endregion + services.AddRabbitMQService(); + #endregion + + #region Consul + //services.Configure(configuration.GetSection("ConsulClientOption")); + //services.AddTransient(); + #endregion + + }); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/WarmupESIndexWorker.cs b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/WarmupESIndexWorker.cs new file mode 100644 index 00000000..8c57cb58 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/WarmupESIndexWorker.cs @@ -0,0 +1,79 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Yi.Framework.Common.IOCOptions; +using Yi.Framework.Common.Models; +using Yi.Framework.Common.QueueModel; +using Yi.Framework.Core; +using Yi.Framework.Interface; + +namespace Yi.Framework.ElasticSearchProcessor +{ + public class WarmupESIndexWorker : BackgroundService + { + private readonly IConfiguration _configuration; + private readonly ILogger _logger; + private readonly RabbitMQInvoker _RabbitMQInvoker; + private readonly ElasticSearchInvoker _elasticSearchInvoker; + private readonly IOptionsMonitor _ElasticSearchOptions = null; + + + public WarmupESIndexWorker(ILogger logger, RabbitMQInvoker rabbitMQInvoker, IConfiguration configuration, ElasticSearchInvoker elasticSearchInvoker, IOptionsMonitor optionsMonitor) + { + this._logger = logger; + this._RabbitMQInvoker = rabbitMQInvoker; + this._configuration = configuration; + this._elasticSearchInvoker = elasticSearchInvoker; + this._ElasticSearchOptions = optionsMonitor; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + RabbitMQConsumerModel rabbitMQConsumerModel = new RabbitMQConsumerModel() + { + ExchangeName = RabbitMQExchangeQueueName.SKUWarmup_Exchange, + QueueName = RabbitMQExchangeQueueName.SKUWarmup_Queue_ESIndex + }; + HttpClient _HttpClient = new HttpClient(); + this._RabbitMQInvoker.RegistReciveAction(rabbitMQConsumerModel, message => + { + //SKUWarmupQueueModel skuWarmupQueueModel = JsonConvert.DeserializeObject(message); + //õϢģ͡ + #region ɾIndex---½Index---ٽȫ + { + try + { + this._elasticSearchInvoker.DropIndex(this._ElasticSearchOptions.CurrentValue.IndexName); + //this._searchService.ImpDataBySpu(); + //esݵ + this._logger.LogInformation($"{nameof(WarmupESIndexWorker)}.InitAll succeed"); + return true; + } + catch (Exception ex) + { + var logModel = new LogModel() + { + OriginalClassName = this.GetType().FullName, + OriginalMethodName = nameof(ExecuteAsync), + Remark = "ʱҵ־" + }; + this._logger.LogError(ex, $"{nameof(WarmupESIndexWorker)}.Warmup ESIndex failed message={message}, Exception:{ex.Message}", JsonConvert.SerializeObject(logModel)); + return false; + } + } + #endregion + }); + await Task.CompletedTask; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Worker.cs b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Worker.cs new file mode 100644 index 00000000..2966fab6 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Worker.cs @@ -0,0 +1,29 @@ +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Yi.Framework.ElasticSearchProcessor +{ + public class Worker : BackgroundService + { + private readonly ILogger _logger; + + public Worker(ILogger logger) + { + _logger = logger; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); + await Task.Delay(100000, stoppingToken); + } + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Yi.Framework.ElasticSearchProcessor.csproj b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Yi.Framework.ElasticSearchProcessor.csproj new file mode 100644 index 00000000..d6bed982 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.ElasticSearchProcessor/Yi.Framework.ElasticSearchProcessor.csproj @@ -0,0 +1,36 @@ + + + + net6.0 + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + PreserveNewest + true + PreserveNewest + + + + + + + + + + + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IBaseService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IBaseService.cs new file mode 100644 index 00000000..2e9e8a03 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IBaseService.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Interface +{ + public interface IBaseService where T : class, new() + { + #region + //通过id得到实体 + #endregion + Task GetEntityById(int id); + + #region + //通过表达式得到实体 + #endregion + Task GetEntity(Expression> whereLambda); + + #region + //得到全部实体 + #endregion + Task> GetAllEntitiesAsync(); + + #region + //通过表达式得到实体 + #endregion + Task> GetEntitiesAsync(Expression> whereLambda); + + #region + //通过表达式得到实体,分页版本 + #endregion + Task GetCountAsync(Expression> whereLambda); + + #region + //通过表达式统计数量 + #endregion + IQueryable> GetGroup(Expression> whereLambda, Expression> groupByLambda); + + #region + //通过表达式分组 + #endregion + Task, int>> GetPageEntities(int pageSize, int pageIndex, Expression> whereLambda, Expression> orderByLambda, bool isAsc); + + #region + //添加实体 + #endregion + Task AddAsync(T entity); + + #region + //添加多个实体 + #endregion + Task AddAsync(IEnumerable entities); + + #region + //更新实体 + #endregion + Task UpdateAsync(T entity); + + #region + //更新多个实体 + #endregion + Task UpdateListAsync(IEnumerable entities); + + #region + //更新实体部分属性 + #endregion + Task DeleteAsync(T entity); + + #region + //删除实体 + #endregion + Task DeleteAsync(int id); + + #region + //通过id删除实体 + #endregion + Task DeleteAsync(IEnumerable ids); + + #region + //通过id列表删除多个实体 + #endregion + Task DeleteAsync(Expression> where); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IMenuService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IMenuService.cs new file mode 100644 index 00000000..aafce7e3 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IMenuService.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Interface +{ + public partial interface IMenuService:IBaseService + { + /// + /// 获取所有菜单,关联接口 + /// 这个是要递归的,但是要过滤掉删除的,所以,可以写一个通用过滤掉删除的方法 + /// + /// + Task GetMenuInMould(); + /// + /// 增 + /// 现在,top菜单只允许为一个 + /// + /// + Task AddTopMenu(menu _menu); + /// + /// 给一个菜单设置一个接口,Id1为菜单id,Id2为接口id + /// 用于给菜单设置接口 + /// + /// + Task SetMouldByMenu(int id1, int id2); + /// + /// 给一个菜单添加子节点(注意:添加,不是覆盖) + /// + /// + Task AddChildrenMenu(int menu_id, menu _children); + /// + /// 获取用户的目录菜单,不包含接口 + /// 用于账户信息页面,显示这个用户有哪些菜单,需要并列 + /// + /// + Task> GetTopMenusByTopMenuIds(List menuIds); + Task> GetTopMenuByUserId(int userId); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IMouldService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IMouldService.cs new file mode 100644 index 00000000..a9708a21 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IMouldService.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Interface +{ + public partial interface IMouldService : IBaseService + { + + + /// + /// 得到该接口属于哪个菜单的 + /// + /// + /// + Task GetMenuByMould(mould _mould); + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs new file mode 100644 index 00000000..5b0ea14e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Interface +{ + public partial interface IRoleService:IBaseService + { + + /// + /// 获取该角色的所有菜单 + /// + /// + /// + Task> GetMenusByRole(int roleId); + + /// + /// 给多个角色设置多个菜单 + /// + /// + /// + /// + Task SetMenusByRolesId(List menuIds, List roleIds); + /// + /// 获取多个用户的菜单,并列,不包含子菜单 + /// + /// + /// + Task> GetMenusByRoleId(List roleIds); + /// + /// 获取用户的角色 + /// + /// + /// + Task> GetRolesByUserId(int userId); + /// + /// 获取该角色的top菜单 + /// + /// + /// + Task> GetTopMenusByRoleId(int roleId); + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs new file mode 100644 index 00000000..86f11bce --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Interface +{ + public partial interface IUserService:IBaseService + { + + /// + /// 登录,传入_user需包含用户名与密码/角色 + /// + /// + Task Login(user _user); + + /// + /// 注册,需要检测是否用户名重复 + /// + /// + Task Register(user _user); + /// + /// 给多个用户设置多个角色 + /// + /// + /// + /// + Task SetRoleByUser(List roleIds, List userIds); + /// + /// 通过id获取用户信息,关联角色、菜单、子菜单、接口 + /// + /// + /// + Task GetUserById(int userId); + /// + /// email验证 + /// + /// + /// + Task EmailIsExsit(string emailAddress); + + /// + /// sms验证 + /// + /// + /// + Task PhoneIsExsit(string smsAddress); + + /// + /// 通过用户id,得到该用户的所有信息,关联角色 + /// + /// + /// + Task GetUserInRolesByHttpUser(int userId); + /// + /// 通过http获取用户id,得到该用户所有的菜单(递归的那种),把所有children为[]的值全部过滤成null,不要绑定mould + /// + /// + /// + Task GetMenuByHttpUser(List allMenuIds); + /// + /// 根据路由获取菜单 + /// + /// + /// + Task> GetAxiosByRouter(string router,int userId, List menuIds); + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/T4Iservice.cs b/Yi.Framework.Net6/Yi.Framework.Interface/T4Iservice.cs new file mode 100644 index 00000000..bf91c56d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/T4Iservice.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Interface +{ + + public partial interface IMenuService:IBaseService + { + Task DelListByUpdateAsync(List _ids); + Task> GetAllEntitiesTrueAsync(); + } + + public partial interface IMouldService:IBaseService + { + Task DelListByUpdateAsync(List _ids); + Task> GetAllEntitiesTrueAsync(); + } + + public partial interface IRoleService:IBaseService + { + Task DelListByUpdateAsync(List _ids); + Task> GetAllEntitiesTrueAsync(); + } + + public partial interface IUserService:IBaseService + { + Task DelListByUpdateAsync(List _ids); + Task> GetAllEntitiesTrueAsync(); + } + + public partial interface IVisitService:IBaseService + { + Task DelListByUpdateAsync(List _ids); + Task> GetAllEntitiesTrueAsync(); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/T4Iservice.tt b/Yi.Framework.Net6/Yi.Framework.Interface/T4Iservice.tt new file mode 100644 index 00000000..0357f5a4 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/T4Iservice.tt @@ -0,0 +1,43 @@ +<#@ template debug="false" hostspecific="true" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.IO" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +<# + string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径 + string dirPath= Path.Combine(solutionsPath,@"Yi.Framework.Model\Models\"); + DirectoryInfo dir = new DirectoryInfo(dirPath); + FileInfo[] finfo = dir.GetFiles(); + string filenames = string.Empty; + List filenameList = new List(); + for (int i = 0; i < finfo.Length; i++) + { + filenames = finfo[i].Name ; + string[] fname=filenames.Split('.'); + filenameList.Add(fname[0]); + } + + +#> +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Interface +{ + <# foreach(string k in filenameList){ + string fn= k.Substring(0,1).ToUpper()+k.Substring(1); + #> + + public partial interface I<#= fn #>Service:IBaseService<<#= k #>> + { + Task DelListByUpdateAsync(List _ids); + Task>> GetAllEntitiesTrueAsync(); + } +<# } #> +} diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/Yi - Backup.Framework.Interface.csproj b/Yi.Framework.Net6/Yi.Framework.Interface/Yi - Backup.Framework.Interface.csproj new file mode 100644 index 00000000..289ee267 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/Yi - Backup.Framework.Interface.csproj @@ -0,0 +1,19 @@ + + + + net5.0 + + + + + + + + + + + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/Yi.Framework.Interface.csproj b/Yi.Framework.Net6/Yi.Framework.Interface/Yi.Framework.Interface.csproj new file mode 100644 index 00000000..cd69cc15 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Interface/Yi.Framework.Interface.csproj @@ -0,0 +1,42 @@ + + + + net6.0 + + + + + + + + + True + True + T4Iservice.tt + + + + + + + + + + T4Iservice.cs + TextTemplatingFileGenerator + + + + + + + + + + True + True + T4IService.tt + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.MSUnitTest/UnitTest1.cs b/Yi.Framework.Net6/Yi.Framework.MSUnitTest/UnitTest1.cs new file mode 100644 index 00000000..67df934b --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.MSUnitTest/UnitTest1.cs @@ -0,0 +1,13 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Yi.Framework.MSUnitTest +{ + [TestClass] + public class UnitTest1 + { + [TestMethod] + public void TestMethod1() + { + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.MSUnitTest/Yi.Framework.MSUnitTest.csproj b/Yi.Framework.Net6/Yi.Framework.MSUnitTest/Yi.Framework.MSUnitTest.csproj new file mode 100644 index 00000000..ce8cacf4 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.MSUnitTest/Yi.Framework.MSUnitTest.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + + false + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.Model/BaseModels/baseModel.cs b/Yi.Framework.Net6/Yi.Framework.Model/BaseModels/baseModel.cs new file mode 100644 index 00000000..0229e997 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/BaseModels/baseModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Models +{ + public class baseModel + { + [Key] + [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] + public T id { get; set; } + public int is_delete { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/BaseModels/loopModel.cs b/Yi.Framework.Net6/Yi.Framework.Model/BaseModels/loopModel.cs new file mode 100644 index 00000000..dd2f16fd --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/BaseModels/loopModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Models +{ + public class loopModel:baseModel + { + public int is_top { get; set; } + public int sort { get; set; } + public int is_show { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/DataContext.cs b/Yi.Framework.Net6/Yi.Framework.Model/DataContext.cs new file mode 100644 index 00000000..40cd5730 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/DataContext.cs @@ -0,0 +1,55 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.Const; +using Yi.Framework.Common.IOCOptions; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Model +{ + //Add-Migration yi-1 + //Update-Database yi-1 + public partial class DataContext : DbContext + { + //private readonly IOptionsMonitor _optionsMonitor; + public static string _connStr; + public static string DbSelect = DbConst.Mysql; + //public DataContext(IOptionsMonitor optionsMonitor) + //{ + // _optionsMonitor = optionsMonitor; + // _connStr = _optionsMonitor.CurrentValue.WriteUrl; + //} + public DbContext ToWriteOrRead(string connstr) + { + _connStr = connstr; + return this; + } + + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { + switch (DbSelect) + { + case DbConst.Mysql: + var serverVersion = new MySqlServerVersion(new Version(8, 0, 21)); + optionsBuilder.UseMySql(_connStr, serverVersion); break; + case DbConst.Sqlite: + optionsBuilder.UseSqlite(_connStr); break; + case DbConst.Sqlserver: + optionsBuilder.UseSqlServer(_connStr);break; + case DbConst.Oracle: + optionsBuilder.UseOracle(_connStr);break; + default: + Console.WriteLine("错误!请确保你选择了正确的数据库!");break; + } + } + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106080544_ec1.Designer.cs b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106080544_ec1.Designer.cs new file mode 100644 index 00000000..98620124 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106080544_ec1.Designer.cs @@ -0,0 +1,219 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Yi.Framework.Model; + +namespace Yi.Framework.Model.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20211106080544_ec1")] + partial class ec1 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.11"); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("icon") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("is_show") + .HasColumnType("int"); + + b.Property("is_top") + .HasColumnType("int"); + + b.Property("menu_name") + .HasColumnType("longtext"); + + b.Property("menuid") + .HasColumnType("int"); + + b.Property("mouldid") + .HasColumnType("int"); + + b.Property("roleid") + .HasColumnType("int"); + + b.Property("router") + .HasColumnType("longtext"); + + b.Property("sort") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("menuid"); + + b.HasIndex("mouldid"); + + b.HasIndex("roleid"); + + b.ToTable("menu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.mould", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("mould_name") + .HasColumnType("longtext"); + + b.Property("url") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("mould"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("introduce") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("role_name") + .HasColumnType("longtext"); + + b.Property("userid") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("userid"); + + b.ToTable("role"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.user", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("address") + .HasColumnType("longtext"); + + b.Property("age") + .HasColumnType("int"); + + b.Property("email") + .HasColumnType("longtext"); + + b.Property("icon") + .HasColumnType("longtext"); + + b.Property("introduction") + .HasColumnType("longtext"); + + b.Property("ip") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("nick") + .HasColumnType("longtext"); + + b.Property("password") + .HasColumnType("longtext"); + + b.Property("phone") + .HasColumnType("int"); + + b.Property("username") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("user"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.visit", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("num") + .HasColumnType("int"); + + b.Property("time") + .HasColumnType("datetime(6)"); + + b.HasKey("id"); + + b.ToTable("visit"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.HasOne("Yi.Framework.Model.Models.menu", null) + .WithMany("children") + .HasForeignKey("menuid"); + + b.HasOne("Yi.Framework.Model.Models.mould", "mould") + .WithMany() + .HasForeignKey("mouldid"); + + b.HasOne("Yi.Framework.Model.Models.role", null) + .WithMany("menus") + .HasForeignKey("roleid"); + + b.Navigation("mould"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.HasOne("Yi.Framework.Model.Models.user", null) + .WithMany("roles") + .HasForeignKey("userid"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.Navigation("children"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.Navigation("menus"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.user", b => + { + b.Navigation("roles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106080544_ec1.cs b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106080544_ec1.cs new file mode 100644 index 00000000..baaf79d9 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106080544_ec1.cs @@ -0,0 +1,17 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Yi.Framework.Model.Migrations +{ + public partial class ec1 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106080646_ec2.Designer.cs b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106080646_ec2.Designer.cs new file mode 100644 index 00000000..6d9fb503 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106080646_ec2.Designer.cs @@ -0,0 +1,732 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Yi.Framework.Model; + +namespace Yi.Framework.Model.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20211106080646_ec2")] + partial class ec2 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.11"); + + modelBuilder.Entity("Yi.Framework.Model.Models.brand", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("image") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("letter") + .HasColumnType("longtext"); + + b.Property("name") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("brand"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.brand_category", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("brandId") + .HasColumnType("int"); + + b.Property("categoryId") + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("brandId"); + + b.HasIndex("categoryId"); + + b.ToTable("brand_category"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.category", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("categoryid") + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("is_parent") + .HasColumnType("int"); + + b.Property("name") + .HasColumnType("longtext"); + + b.Property("sort") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("categoryid"); + + b.ToTable("category"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("icon") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("is_show") + .HasColumnType("int"); + + b.Property("is_top") + .HasColumnType("int"); + + b.Property("menu_name") + .HasColumnType("longtext"); + + b.Property("menuid") + .HasColumnType("int"); + + b.Property("mouldid") + .HasColumnType("int"); + + b.Property("roleid") + .HasColumnType("int"); + + b.Property("router") + .HasColumnType("longtext"); + + b.Property("sort") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("menuid"); + + b.HasIndex("mouldid"); + + b.HasIndex("roleid"); + + b.ToTable("menu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.mould", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("mould_name") + .HasColumnType("longtext"); + + b.Property("url") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("mould"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.order", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("actual_pay") + .HasColumnType("int"); + + b.Property("buyer_message") + .HasColumnType("longtext"); + + b.Property("buyer_nick") + .HasColumnType("longtext"); + + b.Property("buyer_rate") + .HasColumnType("int"); + + b.Property("creat_time") + .HasColumnType("datetime(6)"); + + b.Property("invoice_type") + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("payment_type") + .HasColumnType("int"); + + b.Property("post_fee") + .HasColumnType("int"); + + b.Property("promotion_ids") + .HasColumnType("longtext"); + + b.Property("receiver") + .HasColumnType("longtext"); + + b.Property("receiver_address") + .HasColumnType("longtext"); + + b.Property("receiver_city") + .HasColumnType("longtext"); + + b.Property("receiver_district") + .HasColumnType("longtext"); + + b.Property("receiver_mobile") + .HasColumnType("longtext"); + + b.Property("receiver_state") + .HasColumnType("longtext"); + + b.Property("receiver_zip") + .HasColumnType("longtext"); + + b.Property("shipping_code") + .HasColumnType("longtext"); + + b.Property("shipping_name") + .HasColumnType("longtext"); + + b.Property("skuid") + .HasColumnType("int"); + + b.Property("source_type") + .HasColumnType("int"); + + b.Property("total_pay") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("skuid"); + + b.ToTable("order"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("introduce") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("role_name") + .HasColumnType("longtext"); + + b.Property("userid") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("userid"); + + b.ToTable("role"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.sku", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("crate_time") + .HasColumnType("datetime(6)"); + + b.Property("enable") + .HasColumnType("int"); + + b.Property("images") + .HasColumnType("longtext"); + + b.Property("indexes") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("last_update_time") + .HasColumnType("datetime(6)"); + + b.Property("own_spec") + .HasColumnType("longtext"); + + b.Property("price") + .HasColumnType("int"); + + b.Property("spuid") + .HasColumnType("int"); + + b.Property("title") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.HasIndex("spuid"); + + b.ToTable("sku"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_group", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("categoryid") + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("name") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.HasIndex("categoryid"); + + b.ToTable("spec_group"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_param", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("categoryid") + .HasColumnType("int"); + + b.Property("generic") + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("name") + .HasColumnType("longtext"); + + b.Property("numeric") + .HasColumnType("int"); + + b.Property("searching") + .HasColumnType("int"); + + b.Property("segments") + .HasColumnType("longtext"); + + b.Property("spec_Groupid") + .HasColumnType("int"); + + b.Property("unit") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.HasIndex("categoryid"); + + b.HasIndex("spec_Groupid"); + + b.ToTable("spec_param"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("brandid") + .HasColumnType("int"); + + b.Property("crate_time") + .HasColumnType("datetime(6)"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("last_update_time") + .HasColumnType("datetime(6)"); + + b.Property("saleable") + .HasColumnType("int"); + + b.Property("spu_Detailid") + .HasColumnType("int"); + + b.Property("sub_title") + .HasColumnType("longtext"); + + b.Property("title") + .HasColumnType("longtext"); + + b.Property("valid") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("brandid"); + + b.HasIndex("spu_Detailid"); + + b.ToTable("spu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu_detail", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("after_service") + .HasColumnType("longtext"); + + b.Property("description") + .HasColumnType("longtext"); + + b.Property("generic_spec") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("packing_list") + .HasColumnType("longtext"); + + b.Property("special_spec") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("spu_detail"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.stock", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("seckill_stock") + .HasColumnType("int"); + + b.Property("seckill_total") + .HasColumnType("int"); + + b.Property("skuid") + .HasColumnType("int"); + + b.Property("stock_count") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("skuid"); + + b.ToTable("stock"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.user", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("address") + .HasColumnType("longtext"); + + b.Property("age") + .HasColumnType("int"); + + b.Property("email") + .HasColumnType("longtext"); + + b.Property("icon") + .HasColumnType("longtext"); + + b.Property("introduction") + .HasColumnType("longtext"); + + b.Property("ip") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("nick") + .HasColumnType("longtext"); + + b.Property("password") + .HasColumnType("longtext"); + + b.Property("phone") + .HasColumnType("int"); + + b.Property("username") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("user"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.visit", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("num") + .HasColumnType("int"); + + b.Property("time") + .HasColumnType("datetime(6)"); + + b.HasKey("id"); + + b.ToTable("visit"); + }); + + modelBuilder.Entity("categoryspu", b => + { + b.Property("categoriesid") + .HasColumnType("int"); + + b.Property("spusid") + .HasColumnType("int"); + + b.HasKey("categoriesid", "spusid"); + + b.HasIndex("spusid"); + + b.ToTable("categoryspu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.brand_category", b => + { + b.HasOne("Yi.Framework.Model.Models.brand", "brand") + .WithMany("categories") + .HasForeignKey("brandId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.category", "category") + .WithMany("brands") + .HasForeignKey("categoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("brand"); + + b.Navigation("category"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.category", b => + { + b.HasOne("Yi.Framework.Model.Models.category", null) + .WithMany("chidrens") + .HasForeignKey("categoryid"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.HasOne("Yi.Framework.Model.Models.menu", null) + .WithMany("children") + .HasForeignKey("menuid"); + + b.HasOne("Yi.Framework.Model.Models.mould", "mould") + .WithMany() + .HasForeignKey("mouldid"); + + b.HasOne("Yi.Framework.Model.Models.role", null) + .WithMany("menus") + .HasForeignKey("roleid"); + + b.Navigation("mould"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.order", b => + { + b.HasOne("Yi.Framework.Model.Models.sku", null) + .WithMany("orders") + .HasForeignKey("skuid"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.HasOne("Yi.Framework.Model.Models.user", null) + .WithMany("roles") + .HasForeignKey("userid"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.sku", b => + { + b.HasOne("Yi.Framework.Model.Models.spu", "spu") + .WithMany("skus") + .HasForeignKey("spuid"); + + b.Navigation("spu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_group", b => + { + b.HasOne("Yi.Framework.Model.Models.category", "category") + .WithMany("spec_Groups") + .HasForeignKey("categoryid"); + + b.Navigation("category"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_param", b => + { + b.HasOne("Yi.Framework.Model.Models.category", "category") + .WithMany("spec_Params") + .HasForeignKey("categoryid"); + + b.HasOne("Yi.Framework.Model.Models.spec_group", "spec_Group") + .WithMany("spec_Params") + .HasForeignKey("spec_Groupid"); + + b.Navigation("category"); + + b.Navigation("spec_Group"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu", b => + { + b.HasOne("Yi.Framework.Model.Models.brand", "brand") + .WithMany("spus") + .HasForeignKey("brandid"); + + b.HasOne("Yi.Framework.Model.Models.spu_detail", "spu_Detail") + .WithMany() + .HasForeignKey("spu_Detailid"); + + b.Navigation("brand"); + + b.Navigation("spu_Detail"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.stock", b => + { + b.HasOne("Yi.Framework.Model.Models.sku", "sku") + .WithMany() + .HasForeignKey("skuid"); + + b.Navigation("sku"); + }); + + modelBuilder.Entity("categoryspu", b => + { + b.HasOne("Yi.Framework.Model.Models.category", null) + .WithMany() + .HasForeignKey("categoriesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.spu", null) + .WithMany() + .HasForeignKey("spusid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.brand", b => + { + b.Navigation("categories"); + + b.Navigation("spus"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.category", b => + { + b.Navigation("brands"); + + b.Navigation("chidrens"); + + b.Navigation("spec_Groups"); + + b.Navigation("spec_Params"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.Navigation("children"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.Navigation("menus"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.sku", b => + { + b.Navigation("orders"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_group", b => + { + b.Navigation("spec_Params"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu", b => + { + b.Navigation("skus"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.user", b => + { + b.Navigation("roles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106080646_ec2.cs b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106080646_ec2.cs new file mode 100644 index 00000000..6ffc7373 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106080646_ec2.cs @@ -0,0 +1,436 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Yi.Framework.Model.Migrations +{ + public partial class ec2 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "brand", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + name = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + image = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + letter = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_brand", x => x.id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "category", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + name = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + sort = table.Column(type: "int", nullable: false), + is_parent = table.Column(type: "int", nullable: false), + categoryid = table.Column(type: "int", nullable: true), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_category", x => x.id); + table.ForeignKey( + name: "FK_category_category_categoryid", + column: x => x.categoryid, + principalTable: "category", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "spu_detail", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + description = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + generic_spec = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + special_spec = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + packing_list = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + after_service = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_spu_detail", x => x.id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "brand_category", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + brandId = table.Column(type: "int", nullable: false), + categoryId = table.Column(type: "int", nullable: false), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_brand_category", x => x.id); + table.ForeignKey( + name: "FK_brand_category_brand_brandId", + column: x => x.brandId, + principalTable: "brand", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_brand_category_category_categoryId", + column: x => x.categoryId, + principalTable: "category", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "spec_group", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + name = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + categoryid = table.Column(type: "int", nullable: true), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_spec_group", x => x.id); + table.ForeignKey( + name: "FK_spec_group_category_categoryid", + column: x => x.categoryid, + principalTable: "category", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "spu", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + title = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + sub_title = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + saleable = table.Column(type: "int", nullable: false), + valid = table.Column(type: "int", nullable: false), + crate_time = table.Column(type: "datetime(6)", nullable: false), + last_update_time = table.Column(type: "datetime(6)", nullable: false), + brandid = table.Column(type: "int", nullable: true), + spu_Detailid = table.Column(type: "int", nullable: true), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_spu", x => x.id); + table.ForeignKey( + name: "FK_spu_brand_brandid", + column: x => x.brandid, + principalTable: "brand", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_spu_spu_detail_spu_Detailid", + column: x => x.spu_Detailid, + principalTable: "spu_detail", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "spec_param", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + name = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + numeric = table.Column(type: "int", nullable: false), + unit = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + generic = table.Column(type: "int", nullable: false), + searching = table.Column(type: "int", nullable: false), + segments = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + spec_Groupid = table.Column(type: "int", nullable: true), + categoryid = table.Column(type: "int", nullable: true), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_spec_param", x => x.id); + table.ForeignKey( + name: "FK_spec_param_category_categoryid", + column: x => x.categoryid, + principalTable: "category", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_spec_param_spec_group_spec_Groupid", + column: x => x.spec_Groupid, + principalTable: "spec_group", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "categoryspu", + columns: table => new + { + categoriesid = table.Column(type: "int", nullable: false), + spusid = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_categoryspu", x => new { x.categoriesid, x.spusid }); + table.ForeignKey( + name: "FK_categoryspu_category_categoriesid", + column: x => x.categoriesid, + principalTable: "category", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_categoryspu_spu_spusid", + column: x => x.spusid, + principalTable: "spu", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "sku", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + title = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + images = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + price = table.Column(type: "int", nullable: false), + indexes = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + enable = table.Column(type: "int", nullable: false), + own_spec = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + crate_time = table.Column(type: "datetime(6)", nullable: false), + last_update_time = table.Column(type: "datetime(6)", nullable: false), + spuid = table.Column(type: "int", nullable: true), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_sku", x => x.id); + table.ForeignKey( + name: "FK_sku_spu_spuid", + column: x => x.spuid, + principalTable: "spu", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "order", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + total_pay = table.Column(type: "int", nullable: false), + actual_pay = table.Column(type: "int", nullable: false), + payment_type = table.Column(type: "int", nullable: false), + post_fee = table.Column(type: "int", nullable: false), + promotion_ids = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + creat_time = table.Column(type: "datetime(6)", nullable: false), + shipping_name = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + shipping_code = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + buyer_message = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + buyer_nick = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + buyer_rate = table.Column(type: "int", nullable: false), + receiver_state = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + receiver_city = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + receiver_district = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + receiver_address = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + receiver_mobile = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + receiver_zip = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + receiver = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + invoice_type = table.Column(type: "int", nullable: false), + source_type = table.Column(type: "int", nullable: false), + skuid = table.Column(type: "int", nullable: true), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_order", x => x.id); + table.ForeignKey( + name: "FK_order_sku_skuid", + column: x => x.skuid, + principalTable: "sku", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "stock", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + seckill_stock = table.Column(type: "int", nullable: false), + seckill_total = table.Column(type: "int", nullable: false), + stock_count = table.Column(type: "int", nullable: false), + skuid = table.Column(type: "int", nullable: true), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_stock", x => x.id); + table.ForeignKey( + name: "FK_stock_sku_skuid", + column: x => x.skuid, + principalTable: "sku", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_brand_category_brandId", + table: "brand_category", + column: "brandId"); + + migrationBuilder.CreateIndex( + name: "IX_brand_category_categoryId", + table: "brand_category", + column: "categoryId"); + + migrationBuilder.CreateIndex( + name: "IX_category_categoryid", + table: "category", + column: "categoryid"); + + migrationBuilder.CreateIndex( + name: "IX_categoryspu_spusid", + table: "categoryspu", + column: "spusid"); + + migrationBuilder.CreateIndex( + name: "IX_order_skuid", + table: "order", + column: "skuid"); + + migrationBuilder.CreateIndex( + name: "IX_sku_spuid", + table: "sku", + column: "spuid"); + + migrationBuilder.CreateIndex( + name: "IX_spec_group_categoryid", + table: "spec_group", + column: "categoryid"); + + migrationBuilder.CreateIndex( + name: "IX_spec_param_categoryid", + table: "spec_param", + column: "categoryid"); + + migrationBuilder.CreateIndex( + name: "IX_spec_param_spec_Groupid", + table: "spec_param", + column: "spec_Groupid"); + + migrationBuilder.CreateIndex( + name: "IX_spu_brandid", + table: "spu", + column: "brandid"); + + migrationBuilder.CreateIndex( + name: "IX_spu_spu_Detailid", + table: "spu", + column: "spu_Detailid"); + + migrationBuilder.CreateIndex( + name: "IX_stock_skuid", + table: "stock", + column: "skuid"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "brand_category"); + + migrationBuilder.DropTable( + name: "categoryspu"); + + migrationBuilder.DropTable( + name: "order"); + + migrationBuilder.DropTable( + name: "spec_param"); + + migrationBuilder.DropTable( + name: "stock"); + + migrationBuilder.DropTable( + name: "spec_group"); + + migrationBuilder.DropTable( + name: "sku"); + + migrationBuilder.DropTable( + name: "category"); + + migrationBuilder.DropTable( + name: "spu"); + + migrationBuilder.DropTable( + name: "brand"); + + migrationBuilder.DropTable( + name: "spu_detail"); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106082100_yi-1.Designer.cs b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106082100_yi-1.Designer.cs new file mode 100644 index 00000000..2e948098 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106082100_yi-1.Designer.cs @@ -0,0 +1,248 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Yi.Framework.Model; + +namespace Yi.Framework.Model.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20211106082100_yi-1")] + partial class yi1 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.11"); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("icon") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("is_show") + .HasColumnType("int"); + + b.Property("is_top") + .HasColumnType("int"); + + b.Property("menu_name") + .HasColumnType("longtext"); + + b.Property("menuid") + .HasColumnType("int"); + + b.Property("mouldid") + .HasColumnType("int"); + + b.Property("router") + .HasColumnType("longtext"); + + b.Property("sort") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("menuid"); + + b.HasIndex("mouldid"); + + b.ToTable("menu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.mould", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("mould_name") + .HasColumnType("longtext"); + + b.Property("url") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("mould"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("introduce") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("role_name") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("role"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.user", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("address") + .HasColumnType("longtext"); + + b.Property("age") + .HasColumnType("int"); + + b.Property("email") + .HasColumnType("longtext"); + + b.Property("icon") + .HasColumnType("longtext"); + + b.Property("introduction") + .HasColumnType("longtext"); + + b.Property("ip") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("nick") + .HasColumnType("longtext"); + + b.Property("password") + .HasColumnType("longtext"); + + b.Property("phone") + .HasColumnType("longtext"); + + b.Property("username") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("user"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.visit", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("num") + .HasColumnType("int"); + + b.Property("time") + .HasColumnType("datetime(6)"); + + b.HasKey("id"); + + b.ToTable("visit"); + }); + + modelBuilder.Entity("menurole", b => + { + b.Property("menusid") + .HasColumnType("int"); + + b.Property("rolesid") + .HasColumnType("int"); + + b.HasKey("menusid", "rolesid"); + + b.HasIndex("rolesid"); + + b.ToTable("menurole"); + }); + + modelBuilder.Entity("roleuser", b => + { + b.Property("rolesid") + .HasColumnType("int"); + + b.Property("usersid") + .HasColumnType("int"); + + b.HasKey("rolesid", "usersid"); + + b.HasIndex("usersid"); + + b.ToTable("roleuser"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.HasOne("Yi.Framework.Model.Models.menu", null) + .WithMany("children") + .HasForeignKey("menuid"); + + b.HasOne("Yi.Framework.Model.Models.mould", "mould") + .WithMany() + .HasForeignKey("mouldid"); + + b.Navigation("mould"); + }); + + modelBuilder.Entity("menurole", b => + { + b.HasOne("Yi.Framework.Model.Models.menu", null) + .WithMany() + .HasForeignKey("menusid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.role", null) + .WithMany() + .HasForeignKey("rolesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("roleuser", b => + { + b.HasOne("Yi.Framework.Model.Models.role", null) + .WithMany() + .HasForeignKey("rolesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.user", null) + .WithMany() + .HasForeignKey("usersid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.Navigation("children"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106082100_yi-1.cs b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106082100_yi-1.cs new file mode 100644 index 00000000..0fc278db --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106082100_yi-1.cs @@ -0,0 +1,231 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Yi.Framework.Model.Migrations +{ + public partial class yi1 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "mould", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + mould_name = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + url = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_mould", x => x.id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "role", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + role_name = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + introduce = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_role", x => x.id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "user", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + username = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + password = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + icon = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + nick = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + email = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ip = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + age = table.Column(type: "int", nullable: true), + introduction = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + address = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + phone = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_user", x => x.id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "visit", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + time = table.Column(type: "datetime(6)", nullable: false), + num = table.Column(type: "int", nullable: false), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_visit", x => x.id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "menu", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + icon = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + router = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + menu_name = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + mouldid = table.Column(type: "int", nullable: true), + menuid = table.Column(type: "int", nullable: true), + is_delete = table.Column(type: "int", nullable: false), + is_top = table.Column(type: "int", nullable: false), + sort = table.Column(type: "int", nullable: false), + is_show = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_menu", x => x.id); + table.ForeignKey( + name: "FK_menu_menu_menuid", + column: x => x.menuid, + principalTable: "menu", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_menu_mould_mouldid", + column: x => x.mouldid, + principalTable: "mould", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "roleuser", + columns: table => new + { + rolesid = table.Column(type: "int", nullable: false), + usersid = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_roleuser", x => new { x.rolesid, x.usersid }); + table.ForeignKey( + name: "FK_roleuser_role_rolesid", + column: x => x.rolesid, + principalTable: "role", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_roleuser_user_usersid", + column: x => x.usersid, + principalTable: "user", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "menurole", + columns: table => new + { + menusid = table.Column(type: "int", nullable: false), + rolesid = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_menurole", x => new { x.menusid, x.rolesid }); + table.ForeignKey( + name: "FK_menurole_menu_menusid", + column: x => x.menusid, + principalTable: "menu", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_menurole_role_rolesid", + column: x => x.rolesid, + principalTable: "role", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_menu_menuid", + table: "menu", + column: "menuid"); + + migrationBuilder.CreateIndex( + name: "IX_menu_mouldid", + table: "menu", + column: "mouldid"); + + migrationBuilder.CreateIndex( + name: "IX_menurole_rolesid", + table: "menurole", + column: "rolesid"); + + migrationBuilder.CreateIndex( + name: "IX_roleuser_usersid", + table: "roleuser", + column: "usersid"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "menurole"); + + migrationBuilder.DropTable( + name: "roleuser"); + + migrationBuilder.DropTable( + name: "visit"); + + migrationBuilder.DropTable( + name: "menu"); + + migrationBuilder.DropTable( + name: "role"); + + migrationBuilder.DropTable( + name: "user"); + + migrationBuilder.DropTable( + name: "mould"); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106084427_ec3.Designer.cs b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106084427_ec3.Designer.cs new file mode 100644 index 00000000..8c0467c2 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106084427_ec3.Designer.cs @@ -0,0 +1,770 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Yi.Framework.Model; + +namespace Yi.Framework.Model.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20211106084427_ec3")] + partial class ec3 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.11"); + + modelBuilder.Entity("Yi.Framework.Model.Models.brand", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("image") + .HasColumnType("longtext") + .HasComment("品牌图片"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("letter") + .HasColumnType("longtext") + .HasComment("品牌首字母"); + + b.Property("name") + .HasColumnType("longtext") + .HasComment("品牌名称"); + + b.HasKey("id"); + + b.ToTable("brand"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.category", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("categoryid") + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("is_parent") + .HasColumnType("int") + .HasComment("是否父类别"); + + b.Property("name") + .HasColumnType("longtext") + .HasComment("类别名称"); + + b.Property("sort") + .HasColumnType("int") + .HasComment("排序"); + + b.HasKey("id"); + + b.HasIndex("categoryid"); + + b.ToTable("category"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("icon") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("is_show") + .HasColumnType("int"); + + b.Property("is_top") + .HasColumnType("int"); + + b.Property("menu_name") + .HasColumnType("longtext"); + + b.Property("menuid") + .HasColumnType("int"); + + b.Property("mouldid") + .HasColumnType("int"); + + b.Property("roleid") + .HasColumnType("int"); + + b.Property("router") + .HasColumnType("longtext"); + + b.Property("sort") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("menuid"); + + b.HasIndex("mouldid"); + + b.HasIndex("roleid"); + + b.ToTable("menu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.mould", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("mould_name") + .HasColumnType("longtext"); + + b.Property("url") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("mould"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.order", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("actual_pay") + .HasColumnType("int") + .HasComment("实付金额。单位:分。如:20007,表示:200元7分"); + + b.Property("buyer_message") + .HasColumnType("longtext") + .HasComment("买家留言"); + + b.Property("buyer_nick") + .HasColumnType("longtext") + .HasComment("买家昵称"); + + b.Property("buyer_rate") + .HasColumnType("int") + .HasComment("买家是否已经评价,0未评价,1已评价"); + + b.Property("creat_time") + .HasColumnType("datetime(6)") + .HasComment("订单创建时间"); + + b.Property("invoice_type") + .HasColumnType("int") + .HasComment("发票类型:0无发票1普通发票,2电子发票,3增值税发票"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("payment_type") + .HasColumnType("int") + .HasComment("支付类型,1、在线支付,2、货到付款"); + + b.Property("post_fee") + .HasColumnType("int") + .HasComment("邮费。单位:分。如:20007,表示:200元7分"); + + b.Property("promotion_ids") + .HasColumnType("longtext") + .HasComment("promotion_ids"); + + b.Property("receiver") + .HasColumnType("longtext") + .HasComment("收货人"); + + b.Property("receiver_address") + .HasColumnType("longtext") + .HasComment("收获地址(街道、住址等详细地址)"); + + b.Property("receiver_city") + .HasColumnType("longtext") + .HasComment("收获地址(市)"); + + b.Property("receiver_district") + .HasColumnType("longtext") + .HasComment("收获地址(区/县)"); + + b.Property("receiver_mobile") + .HasColumnType("longtext") + .HasComment("收货人手机"); + + b.Property("receiver_state") + .HasColumnType("longtext") + .HasComment("收获地址(省)"); + + b.Property("receiver_zip") + .HasColumnType("longtext") + .HasComment("收货人邮编"); + + b.Property("shipping_code") + .HasColumnType("longtext") + .HasComment("物流单号"); + + b.Property("shipping_name") + .HasColumnType("longtext") + .HasComment("物流名称"); + + b.Property("skuid") + .HasColumnType("int"); + + b.Property("source_type") + .HasColumnType("int") + .HasComment("订单来源:1:app端,2:pc端,3:M端,4:微信端,5:手机qq端"); + + b.Property("total_pay") + .HasColumnType("int") + .HasComment("总金额,单位为分"); + + b.HasKey("id"); + + b.HasIndex("skuid"); + + b.ToTable("order"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("introduce") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("role_name") + .HasColumnType("longtext"); + + b.Property("userid") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("userid"); + + b.ToTable("role"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.sku", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("crate_time") + .HasColumnType("datetime(6)") + .HasComment("创建时间"); + + b.Property("enable") + .HasColumnType("int") + .HasComment("是否有效,0无效,1有效"); + + b.Property("images") + .HasColumnType("longtext") + .HasComment("商品的图片,多个图片以‘,’分割"); + + b.Property("indexes") + .HasColumnType("longtext") + .HasComment("特有规格属性在spu属性模板中的对应下标组合"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("last_update_time") + .HasColumnType("datetime(6)") + .HasComment("最后更新时间"); + + b.Property("own_spec") + .HasColumnType("longtext") + .HasComment("sku的特有规格参数键值对,json格式,反序列化时请使用linkedHashMap,保证有序"); + + b.Property("price") + .HasColumnType("int") + .HasComment("销售价格,单位为分"); + + b.Property("spuid") + .HasColumnType("int"); + + b.Property("title") + .HasColumnType("longtext") + .HasComment("商品标题"); + + b.HasKey("id"); + + b.HasIndex("spuid"); + + b.ToTable("sku"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_group", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("categoryid") + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("name") + .HasColumnType("longtext") + .HasComment("规格组名称"); + + b.HasKey("id"); + + b.HasIndex("categoryid"); + + b.ToTable("spec_group"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_param", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("categoryid") + .HasColumnType("int"); + + b.Property("generic") + .HasColumnType("int") + .HasComment("是否是sku通用属性,true或false"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("name") + .HasColumnType("longtext") + .HasComment("参数名"); + + b.Property("numeric") + .HasColumnType("int") + .HasComment("是否是数字类型参数,true或false"); + + b.Property("searching") + .HasColumnType("int") + .HasComment("是否用于搜索过滤,true或false"); + + b.Property("segments") + .HasColumnType("longtext") + .HasComment("数值类型参数,如果需要搜索,则添加分段间隔值,如CPU频率间隔:0.5-1.0"); + + b.Property("spec_Groupid") + .HasColumnType("int"); + + b.Property("unit") + .HasColumnType("longtext") + .HasComment("数字类型参数的单位,非数字类型可以为空"); + + b.HasKey("id"); + + b.HasIndex("categoryid"); + + b.HasIndex("spec_Groupid"); + + b.ToTable("spec_param"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("brandid") + .HasColumnType("int"); + + b.Property("crate_time") + .HasColumnType("datetime(6)") + .HasComment("创建时间"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("last_update_time") + .HasColumnType("datetime(6)") + .HasComment("最后更新时间"); + + b.Property("saleable") + .HasColumnType("int") + .HasComment("是否上架"); + + b.Property("spu_Detailid") + .HasColumnType("int"); + + b.Property("sub_title") + .HasColumnType("longtext") + .HasComment("子标题"); + + b.Property("title") + .HasColumnType("longtext") + .HasComment("标题"); + + b.Property("valid") + .HasColumnType("int") + .HasComment("是否有效"); + + b.HasKey("id"); + + b.HasIndex("brandid"); + + b.HasIndex("spu_Detailid"); + + b.ToTable("spu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu_detail", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("after_service") + .HasColumnType("longtext") + .HasComment("售后服务"); + + b.Property("description") + .HasColumnType("longtext") + .HasComment("描述"); + + b.Property("generic_spec") + .HasColumnType("longtext") + .HasComment("通用规格参数数据"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("packing_list") + .HasColumnType("longtext") + .HasComment("包装清单"); + + b.Property("special_spec") + .HasColumnType("longtext") + .HasComment("特有规格参数及可选值信息,json格式"); + + b.HasKey("id"); + + b.ToTable("spu_detail"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.stock", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("seckill_stock") + .HasColumnType("int") + .HasComment("可秒杀库存"); + + b.Property("seckill_total") + .HasColumnType("int") + .HasComment("秒杀总数量"); + + b.Property("skuid") + .HasColumnType("int"); + + b.Property("stock_count") + .HasColumnType("int") + .HasComment("库存数量"); + + b.HasKey("id"); + + b.HasIndex("skuid"); + + b.ToTable("stock"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.user", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("address") + .HasColumnType("longtext"); + + b.Property("age") + .HasColumnType("int"); + + b.Property("email") + .HasColumnType("longtext"); + + b.Property("icon") + .HasColumnType("longtext"); + + b.Property("introduction") + .HasColumnType("longtext"); + + b.Property("ip") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("nick") + .HasColumnType("longtext"); + + b.Property("password") + .HasColumnType("longtext"); + + b.Property("phone") + .HasColumnType("int"); + + b.Property("username") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("user"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.visit", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("num") + .HasColumnType("int"); + + b.Property("time") + .HasColumnType("datetime(6)"); + + b.HasKey("id"); + + b.ToTable("visit"); + }); + + modelBuilder.Entity("brandcategory", b => + { + b.Property("brandsid") + .HasColumnType("int"); + + b.Property("categoriesid") + .HasColumnType("int"); + + b.HasKey("brandsid", "categoriesid"); + + b.HasIndex("categoriesid"); + + b.ToTable("brandcategory"); + }); + + modelBuilder.Entity("categoryspu", b => + { + b.Property("categoriesid") + .HasColumnType("int"); + + b.Property("spusid") + .HasColumnType("int"); + + b.HasKey("categoriesid", "spusid"); + + b.HasIndex("spusid"); + + b.ToTable("categoryspu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.category", b => + { + b.HasOne("Yi.Framework.Model.Models.category", null) + .WithMany("chidrens") + .HasForeignKey("categoryid"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.HasOne("Yi.Framework.Model.Models.menu", null) + .WithMany("children") + .HasForeignKey("menuid"); + + b.HasOne("Yi.Framework.Model.Models.mould", "mould") + .WithMany() + .HasForeignKey("mouldid"); + + b.HasOne("Yi.Framework.Model.Models.role", null) + .WithMany("menus") + .HasForeignKey("roleid"); + + b.Navigation("mould"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.order", b => + { + b.HasOne("Yi.Framework.Model.Models.sku", null) + .WithMany("orders") + .HasForeignKey("skuid"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.HasOne("Yi.Framework.Model.Models.user", null) + .WithMany("roles") + .HasForeignKey("userid"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.sku", b => + { + b.HasOne("Yi.Framework.Model.Models.spu", "spu") + .WithMany("skus") + .HasForeignKey("spuid"); + + b.Navigation("spu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_group", b => + { + b.HasOne("Yi.Framework.Model.Models.category", "category") + .WithMany("spec_Groups") + .HasForeignKey("categoryid"); + + b.Navigation("category"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_param", b => + { + b.HasOne("Yi.Framework.Model.Models.category", "category") + .WithMany("spec_Params") + .HasForeignKey("categoryid"); + + b.HasOne("Yi.Framework.Model.Models.spec_group", "spec_Group") + .WithMany("spec_Params") + .HasForeignKey("spec_Groupid"); + + b.Navigation("category"); + + b.Navigation("spec_Group"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu", b => + { + b.HasOne("Yi.Framework.Model.Models.brand", "brand") + .WithMany("spus") + .HasForeignKey("brandid"); + + b.HasOne("Yi.Framework.Model.Models.spu_detail", "spu_Detail") + .WithMany() + .HasForeignKey("spu_Detailid"); + + b.Navigation("brand"); + + b.Navigation("spu_Detail"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.stock", b => + { + b.HasOne("Yi.Framework.Model.Models.sku", "sku") + .WithMany() + .HasForeignKey("skuid"); + + b.Navigation("sku"); + }); + + modelBuilder.Entity("brandcategory", b => + { + b.HasOne("Yi.Framework.Model.Models.brand", null) + .WithMany() + .HasForeignKey("brandsid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.category", null) + .WithMany() + .HasForeignKey("categoriesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("categoryspu", b => + { + b.HasOne("Yi.Framework.Model.Models.category", null) + .WithMany() + .HasForeignKey("categoriesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.spu", null) + .WithMany() + .HasForeignKey("spusid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.brand", b => + { + b.Navigation("spus"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.category", b => + { + b.Navigation("chidrens"); + + b.Navigation("spec_Groups"); + + b.Navigation("spec_Params"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.Navigation("children"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.Navigation("menus"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.sku", b => + { + b.Navigation("orders"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_group", b => + { + b.Navigation("spec_Params"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu", b => + { + b.Navigation("skus"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.user", b => + { + b.Navigation("roles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106084427_ec3.cs b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106084427_ec3.cs new file mode 100644 index 00000000..c88a2028 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106084427_ec3.cs @@ -0,0 +1,1265 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Yi.Framework.Model.Migrations +{ + public partial class ec3 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "brand_category"); + + migrationBuilder.AlterColumn( + name: "stock_count", + table: "stock", + type: "int", + nullable: false, + comment: "库存数量", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "seckill_total", + table: "stock", + type: "int", + nullable: false, + comment: "秒杀总数量", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "seckill_stock", + table: "stock", + type: "int", + nullable: false, + comment: "可秒杀库存", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "special_spec", + table: "spu_detail", + type: "longtext", + nullable: true, + comment: "特有规格参数及可选值信息,json格式", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "packing_list", + table: "spu_detail", + type: "longtext", + nullable: true, + comment: "包装清单", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "generic_spec", + table: "spu_detail", + type: "longtext", + nullable: true, + comment: "通用规格参数数据", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "description", + table: "spu_detail", + type: "longtext", + nullable: true, + comment: "描述", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "after_service", + table: "spu_detail", + type: "longtext", + nullable: true, + comment: "售后服务", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "valid", + table: "spu", + type: "int", + nullable: false, + comment: "是否有效", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "title", + table: "spu", + type: "longtext", + nullable: true, + comment: "标题", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "sub_title", + table: "spu", + type: "longtext", + nullable: true, + comment: "子标题", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "saleable", + table: "spu", + type: "int", + nullable: false, + comment: "是否上架", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "last_update_time", + table: "spu", + type: "datetime(6)", + nullable: false, + comment: "最后更新时间", + oldClrType: typeof(DateTime), + oldType: "datetime(6)"); + + migrationBuilder.AlterColumn( + name: "crate_time", + table: "spu", + type: "datetime(6)", + nullable: false, + comment: "创建时间", + oldClrType: typeof(DateTime), + oldType: "datetime(6)"); + + migrationBuilder.AlterColumn( + name: "unit", + table: "spec_param", + type: "longtext", + nullable: true, + comment: "数字类型参数的单位,非数字类型可以为空", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "segments", + table: "spec_param", + type: "longtext", + nullable: true, + comment: "数值类型参数,如果需要搜索,则添加分段间隔值,如CPU频率间隔:0.5-1.0", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "searching", + table: "spec_param", + type: "int", + nullable: false, + comment: "是否用于搜索过滤,true或false", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "numeric", + table: "spec_param", + type: "int", + nullable: false, + comment: "是否是数字类型参数,true或false", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "name", + table: "spec_param", + type: "longtext", + nullable: true, + comment: "参数名", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "generic", + table: "spec_param", + type: "int", + nullable: false, + comment: "是否是sku通用属性,true或false", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "name", + table: "spec_group", + type: "longtext", + nullable: true, + comment: "规格组名称", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "title", + table: "sku", + type: "longtext", + nullable: true, + comment: "商品标题", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "price", + table: "sku", + type: "int", + nullable: false, + comment: "销售价格,单位为分", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "own_spec", + table: "sku", + type: "longtext", + nullable: true, + comment: "sku的特有规格参数键值对,json格式,反序列化时请使用linkedHashMap,保证有序", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "last_update_time", + table: "sku", + type: "datetime(6)", + nullable: false, + comment: "最后更新时间", + oldClrType: typeof(DateTime), + oldType: "datetime(6)"); + + migrationBuilder.AlterColumn( + name: "indexes", + table: "sku", + type: "longtext", + nullable: true, + comment: "特有规格属性在spu属性模板中的对应下标组合", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "images", + table: "sku", + type: "longtext", + nullable: true, + comment: "商品的图片,多个图片以‘,’分割", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "enable", + table: "sku", + type: "int", + nullable: false, + comment: "是否有效,0无效,1有效", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "crate_time", + table: "sku", + type: "datetime(6)", + nullable: false, + comment: "创建时间", + oldClrType: typeof(DateTime), + oldType: "datetime(6)"); + + migrationBuilder.AlterColumn( + name: "total_pay", + table: "order", + type: "int", + nullable: false, + comment: "总金额,单位为分", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "source_type", + table: "order", + type: "int", + nullable: false, + comment: "订单来源:1:app端,2:pc端,3:M端,4:微信端,5:手机qq端", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "shipping_name", + table: "order", + type: "longtext", + nullable: true, + comment: "物流名称", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "shipping_code", + table: "order", + type: "longtext", + nullable: true, + comment: "物流单号", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver_zip", + table: "order", + type: "longtext", + nullable: true, + comment: "收货人邮编", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver_state", + table: "order", + type: "longtext", + nullable: true, + comment: "收获地址(省)", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver_mobile", + table: "order", + type: "longtext", + nullable: true, + comment: "收货人手机", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver_district", + table: "order", + type: "longtext", + nullable: true, + comment: "收获地址(区/县)", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver_city", + table: "order", + type: "longtext", + nullable: true, + comment: "收获地址(市)", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver_address", + table: "order", + type: "longtext", + nullable: true, + comment: "收获地址(街道、住址等详细地址)", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver", + table: "order", + type: "longtext", + nullable: true, + comment: "收货人", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "promotion_ids", + table: "order", + type: "longtext", + nullable: true, + comment: "promotion_ids", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "post_fee", + table: "order", + type: "int", + nullable: false, + comment: "邮费。单位:分。如:20007,表示:200元7分", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "payment_type", + table: "order", + type: "int", + nullable: false, + comment: "支付类型,1、在线支付,2、货到付款", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "invoice_type", + table: "order", + type: "int", + nullable: false, + comment: "发票类型:0无发票1普通发票,2电子发票,3增值税发票", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "creat_time", + table: "order", + type: "datetime(6)", + nullable: false, + comment: "订单创建时间", + oldClrType: typeof(DateTime), + oldType: "datetime(6)"); + + migrationBuilder.AlterColumn( + name: "buyer_rate", + table: "order", + type: "int", + nullable: false, + comment: "买家是否已经评价,0未评价,1已评价", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "buyer_nick", + table: "order", + type: "longtext", + nullable: true, + comment: "买家昵称", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "buyer_message", + table: "order", + type: "longtext", + nullable: true, + comment: "买家留言", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "actual_pay", + table: "order", + type: "int", + nullable: false, + comment: "实付金额。单位:分。如:20007,表示:200元7分", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "sort", + table: "category", + type: "int", + nullable: false, + comment: "排序", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "name", + table: "category", + type: "longtext", + nullable: true, + comment: "类别名称", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "is_parent", + table: "category", + type: "int", + nullable: false, + comment: "是否父类别", + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "name", + table: "brand", + type: "longtext", + nullable: true, + comment: "品牌名称", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "letter", + table: "brand", + type: "longtext", + nullable: true, + comment: "品牌首字母", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "image", + table: "brand", + type: "longtext", + nullable: true, + comment: "品牌图片", + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "brandcategory", + columns: table => new + { + brandsid = table.Column(type: "int", nullable: false), + categoriesid = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_brandcategory", x => new { x.brandsid, x.categoriesid }); + table.ForeignKey( + name: "FK_brandcategory_brand_brandsid", + column: x => x.brandsid, + principalTable: "brand", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_brandcategory_category_categoriesid", + column: x => x.categoriesid, + principalTable: "category", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_brandcategory_categoriesid", + table: "brandcategory", + column: "categoriesid"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "brandcategory"); + + migrationBuilder.AlterColumn( + name: "stock_count", + table: "stock", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "库存数量"); + + migrationBuilder.AlterColumn( + name: "seckill_total", + table: "stock", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "秒杀总数量"); + + migrationBuilder.AlterColumn( + name: "seckill_stock", + table: "stock", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "可秒杀库存"); + + migrationBuilder.AlterColumn( + name: "special_spec", + table: "spu_detail", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "特有规格参数及可选值信息,json格式") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "packing_list", + table: "spu_detail", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "包装清单") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "generic_spec", + table: "spu_detail", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "通用规格参数数据") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "description", + table: "spu_detail", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "描述") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "after_service", + table: "spu_detail", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "售后服务") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "valid", + table: "spu", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "是否有效"); + + migrationBuilder.AlterColumn( + name: "title", + table: "spu", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "标题") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "sub_title", + table: "spu", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "子标题") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "saleable", + table: "spu", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "是否上架"); + + migrationBuilder.AlterColumn( + name: "last_update_time", + table: "spu", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime(6)", + oldComment: "最后更新时间"); + + migrationBuilder.AlterColumn( + name: "crate_time", + table: "spu", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime(6)", + oldComment: "创建时间"); + + migrationBuilder.AlterColumn( + name: "unit", + table: "spec_param", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "数字类型参数的单位,非数字类型可以为空") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "segments", + table: "spec_param", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "数值类型参数,如果需要搜索,则添加分段间隔值,如CPU频率间隔:0.5-1.0") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "searching", + table: "spec_param", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "是否用于搜索过滤,true或false"); + + migrationBuilder.AlterColumn( + name: "numeric", + table: "spec_param", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "是否是数字类型参数,true或false"); + + migrationBuilder.AlterColumn( + name: "name", + table: "spec_param", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "参数名") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "generic", + table: "spec_param", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "是否是sku通用属性,true或false"); + + migrationBuilder.AlterColumn( + name: "name", + table: "spec_group", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "规格组名称") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "title", + table: "sku", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "商品标题") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "price", + table: "sku", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "销售价格,单位为分"); + + migrationBuilder.AlterColumn( + name: "own_spec", + table: "sku", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "sku的特有规格参数键值对,json格式,反序列化时请使用linkedHashMap,保证有序") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "last_update_time", + table: "sku", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime(6)", + oldComment: "最后更新时间"); + + migrationBuilder.AlterColumn( + name: "indexes", + table: "sku", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "特有规格属性在spu属性模板中的对应下标组合") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "images", + table: "sku", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "商品的图片,多个图片以‘,’分割") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "enable", + table: "sku", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "是否有效,0无效,1有效"); + + migrationBuilder.AlterColumn( + name: "crate_time", + table: "sku", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime(6)", + oldComment: "创建时间"); + + migrationBuilder.AlterColumn( + name: "total_pay", + table: "order", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "总金额,单位为分"); + + migrationBuilder.AlterColumn( + name: "source_type", + table: "order", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "订单来源:1:app端,2:pc端,3:M端,4:微信端,5:手机qq端"); + + migrationBuilder.AlterColumn( + name: "shipping_name", + table: "order", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "物流名称") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "shipping_code", + table: "order", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "物流单号") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver_zip", + table: "order", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "收货人邮编") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver_state", + table: "order", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "收获地址(省)") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver_mobile", + table: "order", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "收货人手机") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver_district", + table: "order", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "收获地址(区/县)") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver_city", + table: "order", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "收获地址(市)") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver_address", + table: "order", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "收获地址(街道、住址等详细地址)") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "receiver", + table: "order", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "收货人") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "promotion_ids", + table: "order", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "promotion_ids") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "post_fee", + table: "order", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "邮费。单位:分。如:20007,表示:200元7分"); + + migrationBuilder.AlterColumn( + name: "payment_type", + table: "order", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "支付类型,1、在线支付,2、货到付款"); + + migrationBuilder.AlterColumn( + name: "invoice_type", + table: "order", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "发票类型:0无发票1普通发票,2电子发票,3增值税发票"); + + migrationBuilder.AlterColumn( + name: "creat_time", + table: "order", + type: "datetime(6)", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime(6)", + oldComment: "订单创建时间"); + + migrationBuilder.AlterColumn( + name: "buyer_rate", + table: "order", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "买家是否已经评价,0未评价,1已评价"); + + migrationBuilder.AlterColumn( + name: "buyer_nick", + table: "order", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "买家昵称") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "buyer_message", + table: "order", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "买家留言") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "actual_pay", + table: "order", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "实付金额。单位:分。如:20007,表示:200元7分"); + + migrationBuilder.AlterColumn( + name: "sort", + table: "category", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "排序"); + + migrationBuilder.AlterColumn( + name: "name", + table: "category", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "类别名称") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "is_parent", + table: "category", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int", + oldComment: "是否父类别"); + + migrationBuilder.AlterColumn( + name: "name", + table: "brand", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "品牌名称") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "letter", + table: "brand", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "品牌首字母") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "image", + table: "brand", + type: "longtext", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true, + oldComment: "品牌图片") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "brand_category", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + brandId = table.Column(type: "int", nullable: false), + categoryId = table.Column(type: "int", nullable: false), + is_delete = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_brand_category", x => x.id); + table.ForeignKey( + name: "FK_brand_category_brand_brandId", + column: x => x.brandId, + principalTable: "brand", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_brand_category_category_categoryId", + column: x => x.categoryId, + principalTable: "category", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_brand_category_brandId", + table: "brand_category", + column: "brandId"); + + migrationBuilder.CreateIndex( + name: "IX_brand_category_categoryId", + table: "brand_category", + column: "categoryId"); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106110713_ec4.Designer.cs b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106110713_ec4.Designer.cs new file mode 100644 index 00000000..9c033a51 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106110713_ec4.Designer.cs @@ -0,0 +1,799 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Yi.Framework.Model; + +namespace Yi.Framework.Model.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20211106110713_ec4")] + partial class ec4 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.11"); + + modelBuilder.Entity("Yi.Framework.Model.Models.brand", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("image") + .HasColumnType("longtext") + .HasComment("品牌图片"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("letter") + .HasColumnType("longtext") + .HasComment("品牌首字母"); + + b.Property("name") + .HasColumnType("longtext") + .HasComment("品牌名称"); + + b.HasKey("id"); + + b.ToTable("brand"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.category", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("categoryid") + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("is_parent") + .HasColumnType("int") + .HasComment("是否父类别"); + + b.Property("name") + .HasColumnType("longtext") + .HasComment("类别名称"); + + b.Property("sort") + .HasColumnType("int") + .HasComment("排序"); + + b.HasKey("id"); + + b.HasIndex("categoryid"); + + b.ToTable("category"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("icon") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("is_show") + .HasColumnType("int"); + + b.Property("is_top") + .HasColumnType("int"); + + b.Property("menu_name") + .HasColumnType("longtext"); + + b.Property("menuid") + .HasColumnType("int"); + + b.Property("mouldid") + .HasColumnType("int"); + + b.Property("router") + .HasColumnType("longtext"); + + b.Property("sort") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("menuid"); + + b.HasIndex("mouldid"); + + b.ToTable("menu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.mould", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("mould_name") + .HasColumnType("longtext"); + + b.Property("url") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("mould"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.order", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("actual_pay") + .HasColumnType("int") + .HasComment("实付金额。单位:分。如:20007,表示:200元7分"); + + b.Property("buyer_message") + .HasColumnType("longtext") + .HasComment("买家留言"); + + b.Property("buyer_nick") + .HasColumnType("longtext") + .HasComment("买家昵称"); + + b.Property("buyer_rate") + .HasColumnType("int") + .HasComment("买家是否已经评价,0未评价,1已评价"); + + b.Property("creat_time") + .HasColumnType("datetime(6)") + .HasComment("订单创建时间"); + + b.Property("invoice_type") + .HasColumnType("int") + .HasComment("发票类型:0无发票1普通发票,2电子发票,3增值税发票"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("payment_type") + .HasColumnType("int") + .HasComment("支付类型,1、在线支付,2、货到付款"); + + b.Property("post_fee") + .HasColumnType("int") + .HasComment("邮费。单位:分。如:20007,表示:200元7分"); + + b.Property("promotion_ids") + .HasColumnType("longtext") + .HasComment("promotion_ids"); + + b.Property("receiver") + .HasColumnType("longtext") + .HasComment("收货人"); + + b.Property("receiver_address") + .HasColumnType("longtext") + .HasComment("收获地址(街道、住址等详细地址)"); + + b.Property("receiver_city") + .HasColumnType("longtext") + .HasComment("收获地址(市)"); + + b.Property("receiver_district") + .HasColumnType("longtext") + .HasComment("收获地址(区/县)"); + + b.Property("receiver_mobile") + .HasColumnType("longtext") + .HasComment("收货人手机"); + + b.Property("receiver_state") + .HasColumnType("longtext") + .HasComment("收获地址(省)"); + + b.Property("receiver_zip") + .HasColumnType("longtext") + .HasComment("收货人邮编"); + + b.Property("shipping_code") + .HasColumnType("longtext") + .HasComment("物流单号"); + + b.Property("shipping_name") + .HasColumnType("longtext") + .HasComment("物流名称"); + + b.Property("skuid") + .HasColumnType("int"); + + b.Property("source_type") + .HasColumnType("int") + .HasComment("订单来源:1:app端,2:pc端,3:M端,4:微信端,5:手机qq端"); + + b.Property("total_pay") + .HasColumnType("int") + .HasComment("总金额,单位为分"); + + b.HasKey("id"); + + b.HasIndex("skuid"); + + b.ToTable("order"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("introduce") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("role_name") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("role"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.sku", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("crate_time") + .HasColumnType("datetime(6)") + .HasComment("创建时间"); + + b.Property("enable") + .HasColumnType("int") + .HasComment("是否有效,0无效,1有效"); + + b.Property("images") + .HasColumnType("longtext") + .HasComment("商品的图片,多个图片以‘,’分割"); + + b.Property("indexes") + .HasColumnType("longtext") + .HasComment("特有规格属性在spu属性模板中的对应下标组合"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("last_update_time") + .HasColumnType("datetime(6)") + .HasComment("最后更新时间"); + + b.Property("own_spec") + .HasColumnType("longtext") + .HasComment("sku的特有规格参数键值对,json格式,反序列化时请使用linkedHashMap,保证有序"); + + b.Property("price") + .HasColumnType("int") + .HasComment("销售价格,单位为分"); + + b.Property("spuid") + .HasColumnType("int"); + + b.Property("title") + .HasColumnType("longtext") + .HasComment("商品标题"); + + b.HasKey("id"); + + b.HasIndex("spuid"); + + b.ToTable("sku"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_group", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("categoryid") + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("name") + .HasColumnType("longtext") + .HasComment("规格组名称"); + + b.HasKey("id"); + + b.HasIndex("categoryid"); + + b.ToTable("spec_group"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_param", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("categoryid") + .HasColumnType("int"); + + b.Property("generic") + .HasColumnType("int") + .HasComment("是否是sku通用属性,true或false"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("name") + .HasColumnType("longtext") + .HasComment("参数名"); + + b.Property("numeric") + .HasColumnType("int") + .HasComment("是否是数字类型参数,true或false"); + + b.Property("searching") + .HasColumnType("int") + .HasComment("是否用于搜索过滤,true或false"); + + b.Property("segments") + .HasColumnType("longtext") + .HasComment("数值类型参数,如果需要搜索,则添加分段间隔值,如CPU频率间隔:0.5-1.0"); + + b.Property("spec_Groupid") + .HasColumnType("int"); + + b.Property("unit") + .HasColumnType("longtext") + .HasComment("数字类型参数的单位,非数字类型可以为空"); + + b.HasKey("id"); + + b.HasIndex("categoryid"); + + b.HasIndex("spec_Groupid"); + + b.ToTable("spec_param"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("brandid") + .HasColumnType("int"); + + b.Property("crate_time") + .HasColumnType("datetime(6)") + .HasComment("创建时间"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("last_update_time") + .HasColumnType("datetime(6)") + .HasComment("最后更新时间"); + + b.Property("saleable") + .HasColumnType("int") + .HasComment("是否上架"); + + b.Property("spu_Detailid") + .HasColumnType("int"); + + b.Property("sub_title") + .HasColumnType("longtext") + .HasComment("子标题"); + + b.Property("title") + .HasColumnType("longtext") + .HasComment("标题"); + + b.Property("valid") + .HasColumnType("int") + .HasComment("是否有效"); + + b.HasKey("id"); + + b.HasIndex("brandid"); + + b.HasIndex("spu_Detailid"); + + b.ToTable("spu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu_detail", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("after_service") + .HasColumnType("longtext") + .HasComment("售后服务"); + + b.Property("description") + .HasColumnType("longtext") + .HasComment("描述"); + + b.Property("generic_spec") + .HasColumnType("longtext") + .HasComment("通用规格参数数据"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("packing_list") + .HasColumnType("longtext") + .HasComment("包装清单"); + + b.Property("special_spec") + .HasColumnType("longtext") + .HasComment("特有规格参数及可选值信息,json格式"); + + b.HasKey("id"); + + b.ToTable("spu_detail"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.stock", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("seckill_stock") + .HasColumnType("int") + .HasComment("可秒杀库存"); + + b.Property("seckill_total") + .HasColumnType("int") + .HasComment("秒杀总数量"); + + b.Property("skuid") + .HasColumnType("int"); + + b.Property("stock_count") + .HasColumnType("int") + .HasComment("库存数量"); + + b.HasKey("id"); + + b.HasIndex("skuid"); + + b.ToTable("stock"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.user", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("address") + .HasColumnType("longtext"); + + b.Property("age") + .HasColumnType("int"); + + b.Property("email") + .HasColumnType("longtext"); + + b.Property("icon") + .HasColumnType("longtext"); + + b.Property("introduction") + .HasColumnType("longtext"); + + b.Property("ip") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("nick") + .HasColumnType("longtext"); + + b.Property("password") + .HasColumnType("longtext"); + + b.Property("phone") + .HasColumnType("longtext"); + + b.Property("username") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("user"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.visit", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("num") + .HasColumnType("int"); + + b.Property("time") + .HasColumnType("datetime(6)"); + + b.HasKey("id"); + + b.ToTable("visit"); + }); + + modelBuilder.Entity("brandcategory", b => + { + b.Property("brandsid") + .HasColumnType("int"); + + b.Property("categoriesid") + .HasColumnType("int"); + + b.HasKey("brandsid", "categoriesid"); + + b.HasIndex("categoriesid"); + + b.ToTable("brandcategory"); + }); + + modelBuilder.Entity("categoryspu", b => + { + b.Property("categoriesid") + .HasColumnType("int"); + + b.Property("spusid") + .HasColumnType("int"); + + b.HasKey("categoriesid", "spusid"); + + b.HasIndex("spusid"); + + b.ToTable("categoryspu"); + }); + + modelBuilder.Entity("menurole", b => + { + b.Property("menusid") + .HasColumnType("int"); + + b.Property("rolesid") + .HasColumnType("int"); + + b.HasKey("menusid", "rolesid"); + + b.HasIndex("rolesid"); + + b.ToTable("menurole"); + }); + + modelBuilder.Entity("roleuser", b => + { + b.Property("rolesid") + .HasColumnType("int"); + + b.Property("usersid") + .HasColumnType("int"); + + b.HasKey("rolesid", "usersid"); + + b.HasIndex("usersid"); + + b.ToTable("roleuser"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.category", b => + { + b.HasOne("Yi.Framework.Model.Models.category", null) + .WithMany("chidrens") + .HasForeignKey("categoryid"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.HasOne("Yi.Framework.Model.Models.menu", null) + .WithMany("children") + .HasForeignKey("menuid"); + + b.HasOne("Yi.Framework.Model.Models.mould", "mould") + .WithMany() + .HasForeignKey("mouldid"); + + b.Navigation("mould"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.order", b => + { + b.HasOne("Yi.Framework.Model.Models.sku", null) + .WithMany("orders") + .HasForeignKey("skuid"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.sku", b => + { + b.HasOne("Yi.Framework.Model.Models.spu", "spu") + .WithMany("skus") + .HasForeignKey("spuid"); + + b.Navigation("spu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_group", b => + { + b.HasOne("Yi.Framework.Model.Models.category", "category") + .WithMany("spec_Groups") + .HasForeignKey("categoryid"); + + b.Navigation("category"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_param", b => + { + b.HasOne("Yi.Framework.Model.Models.category", "category") + .WithMany("spec_Params") + .HasForeignKey("categoryid"); + + b.HasOne("Yi.Framework.Model.Models.spec_group", "spec_Group") + .WithMany("spec_Params") + .HasForeignKey("spec_Groupid"); + + b.Navigation("category"); + + b.Navigation("spec_Group"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu", b => + { + b.HasOne("Yi.Framework.Model.Models.brand", "brand") + .WithMany("spus") + .HasForeignKey("brandid"); + + b.HasOne("Yi.Framework.Model.Models.spu_detail", "spu_Detail") + .WithMany() + .HasForeignKey("spu_Detailid"); + + b.Navigation("brand"); + + b.Navigation("spu_Detail"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.stock", b => + { + b.HasOne("Yi.Framework.Model.Models.sku", "sku") + .WithMany() + .HasForeignKey("skuid"); + + b.Navigation("sku"); + }); + + modelBuilder.Entity("brandcategory", b => + { + b.HasOne("Yi.Framework.Model.Models.brand", null) + .WithMany() + .HasForeignKey("brandsid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.category", null) + .WithMany() + .HasForeignKey("categoriesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("categoryspu", b => + { + b.HasOne("Yi.Framework.Model.Models.category", null) + .WithMany() + .HasForeignKey("categoriesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.spu", null) + .WithMany() + .HasForeignKey("spusid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("menurole", b => + { + b.HasOne("Yi.Framework.Model.Models.menu", null) + .WithMany() + .HasForeignKey("menusid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.role", null) + .WithMany() + .HasForeignKey("rolesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("roleuser", b => + { + b.HasOne("Yi.Framework.Model.Models.role", null) + .WithMany() + .HasForeignKey("rolesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.user", null) + .WithMany() + .HasForeignKey("usersid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.brand", b => + { + b.Navigation("spus"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.category", b => + { + b.Navigation("chidrens"); + + b.Navigation("spec_Groups"); + + b.Navigation("spec_Params"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.Navigation("children"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.sku", b => + { + b.Navigation("orders"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_group", b => + { + b.Navigation("spec_Params"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu", b => + { + b.Navigation("skus"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106110713_ec4.cs b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106110713_ec4.cs new file mode 100644 index 00000000..dc279917 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/20211106110713_ec4.cs @@ -0,0 +1,161 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Yi.Framework.Model.Migrations +{ + public partial class ec4 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_menu_role_roleid", + table: "menu"); + + migrationBuilder.DropForeignKey( + name: "FK_role_user_userid", + table: "role"); + + migrationBuilder.DropIndex( + name: "IX_role_userid", + table: "role"); + + migrationBuilder.DropIndex( + name: "IX_menu_roleid", + table: "menu"); + + migrationBuilder.DropColumn( + name: "userid", + table: "role"); + + migrationBuilder.DropColumn( + name: "roleid", + table: "menu"); + + migrationBuilder.AlterColumn( + name: "phone", + table: "user", + type: "longtext", + nullable: true, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "menurole", + columns: table => new + { + menusid = table.Column(type: "int", nullable: false), + rolesid = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_menurole", x => new { x.menusid, x.rolesid }); + table.ForeignKey( + name: "FK_menurole_menu_menusid", + column: x => x.menusid, + principalTable: "menu", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_menurole_role_rolesid", + column: x => x.rolesid, + principalTable: "role", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "roleuser", + columns: table => new + { + rolesid = table.Column(type: "int", nullable: false), + usersid = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_roleuser", x => new { x.rolesid, x.usersid }); + table.ForeignKey( + name: "FK_roleuser_role_rolesid", + column: x => x.rolesid, + principalTable: "role", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_roleuser_user_usersid", + column: x => x.usersid, + principalTable: "user", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_menurole_rolesid", + table: "menurole", + column: "rolesid"); + + migrationBuilder.CreateIndex( + name: "IX_roleuser_usersid", + table: "roleuser", + column: "usersid"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "menurole"); + + migrationBuilder.DropTable( + name: "roleuser"); + + migrationBuilder.AlterColumn( + name: "phone", + table: "user", + type: "int", + nullable: true, + oldClrType: typeof(string), + oldType: "longtext", + oldNullable: true) + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AddColumn( + name: "userid", + table: "role", + type: "int", + nullable: true); + + migrationBuilder.AddColumn( + name: "roleid", + table: "menu", + type: "int", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_role_userid", + table: "role", + column: "userid"); + + migrationBuilder.CreateIndex( + name: "IX_menu_roleid", + table: "menu", + column: "roleid"); + + migrationBuilder.AddForeignKey( + name: "FK_menu_role_roleid", + table: "menu", + column: "roleid", + principalTable: "role", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_role_user_userid", + table: "role", + column: "userid", + principalTable: "user", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs new file mode 100644 index 00000000..7fcf5023 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs @@ -0,0 +1,797 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Yi.Framework.Model; + +namespace Yi.Framework.Model.Migrations +{ + [DbContext(typeof(DataContext))] + partial class DataContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 64) + .HasAnnotation("ProductVersion", "5.0.11"); + + modelBuilder.Entity("Yi.Framework.Model.Models.brand", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("image") + .HasColumnType("longtext") + .HasComment("品牌图片"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("letter") + .HasColumnType("longtext") + .HasComment("品牌首字母"); + + b.Property("name") + .HasColumnType("longtext") + .HasComment("品牌名称"); + + b.HasKey("id"); + + b.ToTable("brand"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.category", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("categoryid") + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("is_parent") + .HasColumnType("int") + .HasComment("是否父类别"); + + b.Property("name") + .HasColumnType("longtext") + .HasComment("类别名称"); + + b.Property("sort") + .HasColumnType("int") + .HasComment("排序"); + + b.HasKey("id"); + + b.HasIndex("categoryid"); + + b.ToTable("category"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("icon") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("is_show") + .HasColumnType("int"); + + b.Property("is_top") + .HasColumnType("int"); + + b.Property("menu_name") + .HasColumnType("longtext"); + + b.Property("menuid") + .HasColumnType("int"); + + b.Property("mouldid") + .HasColumnType("int"); + + b.Property("router") + .HasColumnType("longtext"); + + b.Property("sort") + .HasColumnType("int"); + + b.HasKey("id"); + + b.HasIndex("menuid"); + + b.HasIndex("mouldid"); + + b.ToTable("menu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.mould", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("mould_name") + .HasColumnType("longtext"); + + b.Property("url") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("mould"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.order", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("actual_pay") + .HasColumnType("int") + .HasComment("实付金额。单位:分。如:20007,表示:200元7分"); + + b.Property("buyer_message") + .HasColumnType("longtext") + .HasComment("买家留言"); + + b.Property("buyer_nick") + .HasColumnType("longtext") + .HasComment("买家昵称"); + + b.Property("buyer_rate") + .HasColumnType("int") + .HasComment("买家是否已经评价,0未评价,1已评价"); + + b.Property("creat_time") + .HasColumnType("datetime(6)") + .HasComment("订单创建时间"); + + b.Property("invoice_type") + .HasColumnType("int") + .HasComment("发票类型:0无发票1普通发票,2电子发票,3增值税发票"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("payment_type") + .HasColumnType("int") + .HasComment("支付类型,1、在线支付,2、货到付款"); + + b.Property("post_fee") + .HasColumnType("int") + .HasComment("邮费。单位:分。如:20007,表示:200元7分"); + + b.Property("promotion_ids") + .HasColumnType("longtext") + .HasComment("promotion_ids"); + + b.Property("receiver") + .HasColumnType("longtext") + .HasComment("收货人"); + + b.Property("receiver_address") + .HasColumnType("longtext") + .HasComment("收获地址(街道、住址等详细地址)"); + + b.Property("receiver_city") + .HasColumnType("longtext") + .HasComment("收获地址(市)"); + + b.Property("receiver_district") + .HasColumnType("longtext") + .HasComment("收获地址(区/县)"); + + b.Property("receiver_mobile") + .HasColumnType("longtext") + .HasComment("收货人手机"); + + b.Property("receiver_state") + .HasColumnType("longtext") + .HasComment("收获地址(省)"); + + b.Property("receiver_zip") + .HasColumnType("longtext") + .HasComment("收货人邮编"); + + b.Property("shipping_code") + .HasColumnType("longtext") + .HasComment("物流单号"); + + b.Property("shipping_name") + .HasColumnType("longtext") + .HasComment("物流名称"); + + b.Property("skuid") + .HasColumnType("int"); + + b.Property("source_type") + .HasColumnType("int") + .HasComment("订单来源:1:app端,2:pc端,3:M端,4:微信端,5:手机qq端"); + + b.Property("total_pay") + .HasColumnType("int") + .HasComment("总金额,单位为分"); + + b.HasKey("id"); + + b.HasIndex("skuid"); + + b.ToTable("order"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("introduce") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("role_name") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("role"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.sku", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("crate_time") + .HasColumnType("datetime(6)") + .HasComment("创建时间"); + + b.Property("enable") + .HasColumnType("int") + .HasComment("是否有效,0无效,1有效"); + + b.Property("images") + .HasColumnType("longtext") + .HasComment("商品的图片,多个图片以‘,’分割"); + + b.Property("indexes") + .HasColumnType("longtext") + .HasComment("特有规格属性在spu属性模板中的对应下标组合"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("last_update_time") + .HasColumnType("datetime(6)") + .HasComment("最后更新时间"); + + b.Property("own_spec") + .HasColumnType("longtext") + .HasComment("sku的特有规格参数键值对,json格式,反序列化时请使用linkedHashMap,保证有序"); + + b.Property("price") + .HasColumnType("int") + .HasComment("销售价格,单位为分"); + + b.Property("spuid") + .HasColumnType("int"); + + b.Property("title") + .HasColumnType("longtext") + .HasComment("商品标题"); + + b.HasKey("id"); + + b.HasIndex("spuid"); + + b.ToTable("sku"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_group", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("categoryid") + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("name") + .HasColumnType("longtext") + .HasComment("规格组名称"); + + b.HasKey("id"); + + b.HasIndex("categoryid"); + + b.ToTable("spec_group"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_param", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("categoryid") + .HasColumnType("int"); + + b.Property("generic") + .HasColumnType("int") + .HasComment("是否是sku通用属性,true或false"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("name") + .HasColumnType("longtext") + .HasComment("参数名"); + + b.Property("numeric") + .HasColumnType("int") + .HasComment("是否是数字类型参数,true或false"); + + b.Property("searching") + .HasColumnType("int") + .HasComment("是否用于搜索过滤,true或false"); + + b.Property("segments") + .HasColumnType("longtext") + .HasComment("数值类型参数,如果需要搜索,则添加分段间隔值,如CPU频率间隔:0.5-1.0"); + + b.Property("spec_Groupid") + .HasColumnType("int"); + + b.Property("unit") + .HasColumnType("longtext") + .HasComment("数字类型参数的单位,非数字类型可以为空"); + + b.HasKey("id"); + + b.HasIndex("categoryid"); + + b.HasIndex("spec_Groupid"); + + b.ToTable("spec_param"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("brandid") + .HasColumnType("int"); + + b.Property("crate_time") + .HasColumnType("datetime(6)") + .HasComment("创建时间"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("last_update_time") + .HasColumnType("datetime(6)") + .HasComment("最后更新时间"); + + b.Property("saleable") + .HasColumnType("int") + .HasComment("是否上架"); + + b.Property("spu_Detailid") + .HasColumnType("int"); + + b.Property("sub_title") + .HasColumnType("longtext") + .HasComment("子标题"); + + b.Property("title") + .HasColumnType("longtext") + .HasComment("标题"); + + b.Property("valid") + .HasColumnType("int") + .HasComment("是否有效"); + + b.HasKey("id"); + + b.HasIndex("brandid"); + + b.HasIndex("spu_Detailid"); + + b.ToTable("spu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu_detail", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("after_service") + .HasColumnType("longtext") + .HasComment("售后服务"); + + b.Property("description") + .HasColumnType("longtext") + .HasComment("描述"); + + b.Property("generic_spec") + .HasColumnType("longtext") + .HasComment("通用规格参数数据"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("packing_list") + .HasColumnType("longtext") + .HasComment("包装清单"); + + b.Property("special_spec") + .HasColumnType("longtext") + .HasComment("特有规格参数及可选值信息,json格式"); + + b.HasKey("id"); + + b.ToTable("spu_detail"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.stock", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("seckill_stock") + .HasColumnType("int") + .HasComment("可秒杀库存"); + + b.Property("seckill_total") + .HasColumnType("int") + .HasComment("秒杀总数量"); + + b.Property("skuid") + .HasColumnType("int"); + + b.Property("stock_count") + .HasColumnType("int") + .HasComment("库存数量"); + + b.HasKey("id"); + + b.HasIndex("skuid"); + + b.ToTable("stock"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.user", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("address") + .HasColumnType("longtext"); + + b.Property("age") + .HasColumnType("int"); + + b.Property("email") + .HasColumnType("longtext"); + + b.Property("icon") + .HasColumnType("longtext"); + + b.Property("introduction") + .HasColumnType("longtext"); + + b.Property("ip") + .HasColumnType("longtext"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("nick") + .HasColumnType("longtext"); + + b.Property("password") + .HasColumnType("longtext"); + + b.Property("phone") + .HasColumnType("longtext"); + + b.Property("username") + .HasColumnType("longtext"); + + b.HasKey("id"); + + b.ToTable("user"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.visit", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("is_delete") + .HasColumnType("int"); + + b.Property("num") + .HasColumnType("int"); + + b.Property("time") + .HasColumnType("datetime(6)"); + + b.HasKey("id"); + + b.ToTable("visit"); + }); + + modelBuilder.Entity("brandcategory", b => + { + b.Property("brandsid") + .HasColumnType("int"); + + b.Property("categoriesid") + .HasColumnType("int"); + + b.HasKey("brandsid", "categoriesid"); + + b.HasIndex("categoriesid"); + + b.ToTable("brandcategory"); + }); + + modelBuilder.Entity("categoryspu", b => + { + b.Property("categoriesid") + .HasColumnType("int"); + + b.Property("spusid") + .HasColumnType("int"); + + b.HasKey("categoriesid", "spusid"); + + b.HasIndex("spusid"); + + b.ToTable("categoryspu"); + }); + + modelBuilder.Entity("menurole", b => + { + b.Property("menusid") + .HasColumnType("int"); + + b.Property("rolesid") + .HasColumnType("int"); + + b.HasKey("menusid", "rolesid"); + + b.HasIndex("rolesid"); + + b.ToTable("menurole"); + }); + + modelBuilder.Entity("roleuser", b => + { + b.Property("rolesid") + .HasColumnType("int"); + + b.Property("usersid") + .HasColumnType("int"); + + b.HasKey("rolesid", "usersid"); + + b.HasIndex("usersid"); + + b.ToTable("roleuser"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.category", b => + { + b.HasOne("Yi.Framework.Model.Models.category", null) + .WithMany("chidrens") + .HasForeignKey("categoryid"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.HasOne("Yi.Framework.Model.Models.menu", null) + .WithMany("children") + .HasForeignKey("menuid"); + + b.HasOne("Yi.Framework.Model.Models.mould", "mould") + .WithMany() + .HasForeignKey("mouldid"); + + b.Navigation("mould"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.order", b => + { + b.HasOne("Yi.Framework.Model.Models.sku", null) + .WithMany("orders") + .HasForeignKey("skuid"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.sku", b => + { + b.HasOne("Yi.Framework.Model.Models.spu", "spu") + .WithMany("skus") + .HasForeignKey("spuid"); + + b.Navigation("spu"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_group", b => + { + b.HasOne("Yi.Framework.Model.Models.category", "category") + .WithMany("spec_Groups") + .HasForeignKey("categoryid"); + + b.Navigation("category"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_param", b => + { + b.HasOne("Yi.Framework.Model.Models.category", "category") + .WithMany("spec_Params") + .HasForeignKey("categoryid"); + + b.HasOne("Yi.Framework.Model.Models.spec_group", "spec_Group") + .WithMany("spec_Params") + .HasForeignKey("spec_Groupid"); + + b.Navigation("category"); + + b.Navigation("spec_Group"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu", b => + { + b.HasOne("Yi.Framework.Model.Models.brand", "brand") + .WithMany("spus") + .HasForeignKey("brandid"); + + b.HasOne("Yi.Framework.Model.Models.spu_detail", "spu_Detail") + .WithMany() + .HasForeignKey("spu_Detailid"); + + b.Navigation("brand"); + + b.Navigation("spu_Detail"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.stock", b => + { + b.HasOne("Yi.Framework.Model.Models.sku", "sku") + .WithMany() + .HasForeignKey("skuid"); + + b.Navigation("sku"); + }); + + modelBuilder.Entity("brandcategory", b => + { + b.HasOne("Yi.Framework.Model.Models.brand", null) + .WithMany() + .HasForeignKey("brandsid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.category", null) + .WithMany() + .HasForeignKey("categoriesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("categoryspu", b => + { + b.HasOne("Yi.Framework.Model.Models.category", null) + .WithMany() + .HasForeignKey("categoriesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.spu", null) + .WithMany() + .HasForeignKey("spusid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("menurole", b => + { + b.HasOne("Yi.Framework.Model.Models.menu", null) + .WithMany() + .HasForeignKey("menusid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.role", null) + .WithMany() + .HasForeignKey("rolesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("roleuser", b => + { + b.HasOne("Yi.Framework.Model.Models.role", null) + .WithMany() + .HasForeignKey("rolesid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Yi.Framework.Model.Models.user", null) + .WithMany() + .HasForeignKey("usersid") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.brand", b => + { + b.Navigation("spus"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.category", b => + { + b.Navigation("chidrens"); + + b.Navigation("spec_Groups"); + + b.Navigation("spec_Params"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.menu", b => + { + b.Navigation("children"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.sku", b => + { + b.Navigation("orders"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spec_group", b => + { + b.Navigation("spec_Params"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.spu", b => + { + b.Navigation("skus"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/ModelFactory/DbContextExtend.cs b/Yi.Framework.Net6/Yi.Framework.Model/ModelFactory/DbContextExtend.cs new file mode 100644 index 00000000..d4cb3846 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/ModelFactory/DbContextExtend.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Yi.Framework.Model.ModelFactory +{ + public static class DbContextExtend + { + public static DbContext ToWriteOrRead(this DbContext dbContext, string conn) + { + if (dbContext is DataContext) + { + + var context= (DataContext)dbContext; // context 是 EFCoreContext 实例; + + return context.ToWriteOrRead(conn); + } + else + throw new Exception(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/ModelFactory/DbContextFactory.cs b/Yi.Framework.Net6/Yi.Framework.Model/ModelFactory/DbContextFactory.cs new file mode 100644 index 00000000..a156afdf --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/ModelFactory/DbContextFactory.cs @@ -0,0 +1,100 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Text; +using Yi.Framework.Common.Enum; +using Yi.Framework.Common.IOCOptions; + +namespace Yi.Framework.Model.ModelFactory +{ + public class DbContextFactory : IDbContextFactory + { + + private DbContext _Context = null; + + private DbConnOptions _readAndWrite = null; + + public static bool MutiDB_Enabled = false; + //private static int _iSeed = 0;//应该long + + /// + ///能把链接信息也注入进来 + ///需要IOptionsMonitor + /// + /// + public DbContextFactory(DbContext context, IOptionsMonitor options) + { + _readAndWrite = options.CurrentValue; + this._Context = context; + } + public DbContext ConnWriteOrRead(WriteAndReadEnum writeAndRead) + { + //判断枚举,不同的枚举可以创建不同的Context 或者更换Context链接; + if (MutiDB_Enabled) + { + switch (writeAndRead) + { + case WriteAndReadEnum.Write: + ToWrite(); + break; //选择链接//更换_Context链接 //选择链接 + case WriteAndReadEnum.Read: + ToRead(); + break; //选择链接//更换_Context链接 + default: + break; + } + } + else + { + ToWrite(); + } + + return _Context; + } + + /// + /// 更换成主库连接 + /// + /// + private void ToWrite() + { + string conn = _readAndWrite.WriteUrl; + //_Context.Database.GetDbConnection().; + _Context.ToWriteOrRead(conn); + } + + + private static int _iSeed = 0; + + /// + /// 更换成主库连接 + /// + /// ///策略---数据库查询的负载均衡 + /// + /// + private void ToRead() + { + string conn = string.Empty; + { + // //随机 + //int Count= _readAndWrite.ReadConnectionList.Count; + //int index= new Random().Next(0, Count); + //conn = _readAndWrite.ReadConnectionList[index]; + } + { + //来一个轮询 + conn = this._readAndWrite.ReadUrl[_iSeed++ % this._readAndWrite.ReadUrl.Count];//轮询; + } + { + ///是不是可以直接配置到配置文件里面 + } + _Context.ToWriteOrRead(conn); + } + + //public DbContext CreateContext() + //{ + + //} + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/ModelFactory/IDbContextFactory.cs b/Yi.Framework.Net6/Yi.Framework.Model/ModelFactory/IDbContextFactory.cs new file mode 100644 index 00000000..818bca67 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/ModelFactory/IDbContextFactory.cs @@ -0,0 +1,13 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Text; +using Yi.Framework.Common.Enum; + +namespace Yi.Framework.Model.ModelFactory +{ + public interface IDbContextFactory + { + public DbContext ConnWriteOrRead(WriteAndReadEnum writeAndRead); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Models/menu.cs b/Yi.Framework.Net6/Yi.Framework.Model/Models/menu.cs new file mode 100644 index 00000000..0a562163 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Models/menu.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Models +{ + public class menu :loopModel + { + public string icon { get; set; } + public string router { get; set; } + public string menu_name { get; set; } + + + + public List children { get; set; } + + public List roles { get; set; } + + public mould mould { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Models/mould.cs b/Yi.Framework.Net6/Yi.Framework.Model/Models/mould.cs new file mode 100644 index 00000000..f86a5489 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Models/mould.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Models +{ + public class mould:baseModel + { + public string mould_name { get; set; } + public string url { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Models/role.cs b/Yi.Framework.Net6/Yi.Framework.Model/Models/role.cs new file mode 100644 index 00000000..8516124f --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Models/role.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Models +{ + public class role:baseModel + { + public string role_name { get; set; } + public string introduce { get; set; } + + + public List menus { get; set; } + public List users { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Models/user.cs b/Yi.Framework.Net6/Yi.Framework.Model/Models/user.cs new file mode 100644 index 00000000..58857e36 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Models/user.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Models +{ + public class user:baseModel + { + public string username { get; set; } + public string password { get; set; } + public string icon { get; set; } + public string nick { get; set; } + public string email { get; set; } + public string ip { get; set; } + public int? age { get; set; } + public string introduction { get; set; } + public string address { get; set; } + public string phone { get; set; } + + + public List roles { get; set; } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Models/visit.cs b/Yi.Framework.Net6/Yi.Framework.Model/Models/visit.cs new file mode 100644 index 00000000..845b753c --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Models/visit.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Models +{ + public class visit:baseModel + { + public DateTime time { get; set; } + public int num { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Search/PageResult.cs b/Yi.Framework.Net6/Yi.Framework.Model/Search/PageResult.cs new file mode 100644 index 00000000..52fde5cb --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Search/PageResult.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Yi.Framework.Model.Search +{ + public class PageResult + { + public static readonly long serialVersionUID = 4612105649493688532L; + public long total; // 总记录数 + public int totalPages; //总页数 + public List rows; // 每页显示的数据集合 + + public PageResult(long total, List rows) + { + this.total = total; + this.rows = rows; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Search/SearchRequest.cs b/Yi.Framework.Net6/Yi.Framework.Model/Search/SearchRequest.cs new file mode 100644 index 00000000..a3853d37 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Search/SearchRequest.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Model.Search +{ + public class SearchRequest + { + public static readonly int DEFAULT_PAGE = 1; + public static readonly int DEFAULT_SIZE = 20; + public string key { get; set; } + public int page { get; set; } + //排序字段 + public string sortBy { get; set; } + //是否降序 + public bool descending { get; set; } + //过滤字段 + public Dictionary filter = new Dictionary(); + + public int getPage() + { + if (page == 0) + { + return DEFAULT_PAGE; + } + // 获取页码时做一些校验,不能小于1 + return Math.Max(DEFAULT_PAGE, page); + } + + public int getSize() + { + return DEFAULT_SIZE; + } + + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/T4DataContext.cs b/Yi.Framework.Net6/Yi.Framework.Model/T4DataContext.cs new file mode 100644 index 00000000..071e4b24 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/T4DataContext.cs @@ -0,0 +1,18 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Text; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Model +{ + public partial class DataContext :DbContext + { + public DbSet menu { get; set; } + public DbSet mould { get; set; } + public DbSet role { get; set; } + public DbSet user { get; set; } + public DbSet visit { get; set; } + } +} + diff --git a/Yi.Framework.Net6/Yi.Framework.Model/T4DataContext.tt b/Yi.Framework.Net6/Yi.Framework.Model/T4DataContext.tt new file mode 100644 index 00000000..ecc01244 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/T4DataContext.tt @@ -0,0 +1,40 @@ +<#@ template debug="false" hostspecific="true" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.IO" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +<# + string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径 + string dirPath= Path.Combine(solutionsPath,@"Yi.Framework.Model\Models\"); + DirectoryInfo dir = new DirectoryInfo(dirPath); + FileInfo[] finfo = dir.GetFiles(); + string filenames = string.Empty; + List filenameList = new List(); + for (int i = 0; i < finfo.Length; i++) + { + filenames = finfo[i].Name ; + string[] f=filenames.Split('.'); + filenameList.Add(f[0]); + } + + +#> +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Text; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Model +{ + public partial class DataContext :DbContext + { +<# foreach(string k in filenameList){ + #> + public DbSet<<#=k #>> <#=k #> { get; set; } +<# } #> + } +} + diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Yi - Backup (1).Framework.Model.csproj b/Yi.Framework.Net6/Yi.Framework.Model/Yi - Backup (1).Framework.Model.csproj new file mode 100644 index 00000000..a18e350c --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Yi - Backup (1).Framework.Model.csproj @@ -0,0 +1,59 @@ + + + + net5.0 + + + + + True + True + T4DataContext.tt + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + TextTemplatingFileGenerator + T4DaraContext.cs + + + TextTemplatingFileGenerator + T4DataContext.cs + + + + + + + + + + True + True + T4DaraContext.tt + + + True + True + T4DataContext.tt + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Yi - Backup.Framework.Model.csproj b/Yi.Framework.Net6/Yi.Framework.Model/Yi - Backup.Framework.Model.csproj new file mode 100644 index 00000000..7cfe4b70 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Yi - Backup.Framework.Model.csproj @@ -0,0 +1,23 @@ + + + + net5.0 + + + + + + + + + + + + + + + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj b/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj new file mode 100644 index 00000000..5b11fbb3 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/Yi.Framework.Model.csproj @@ -0,0 +1,59 @@ + + + + net6.0 + + + + + True + True + T4DataContext.tt + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + TextTemplatingFileGenerator + T4DaraContext.cs + + + TextTemplatingFileGenerator + T4DataContext.cs + + + + + + + + + + True + True + T4DaraContext.tt + + + True + True + T4DataContext.tt + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.OcelotGateway/Log4net.config b/Yi.Framework.Net6/Yi.Framework.OcelotGateway/Log4net.config new file mode 100644 index 00000000..958c7e78 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.OcelotGateway/Log4net.config @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.OcelotGateway/Program.cs b/Yi.Framework.Net6/Yi.Framework.OcelotGateway/Program.cs new file mode 100644 index 00000000..c2e35d88 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.OcelotGateway/Program.cs @@ -0,0 +1,42 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Yi.Framework.OcelotGateway +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) => + { + configurationBuilder.AddCommandLine(args); + configurationBuilder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false); + configurationBuilder.AddJsonFile("configuration.json", optional: false, reloadOnChange: true); + #region + //Apollo + #endregion + //configurationBuilder.AddApolloService("Yi"); + }) + .ConfigureLogging(loggingBuilder => + { + loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning); + loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning); + loggingBuilder.AddLog4Net(); + }) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup().UseUrls("http://*:7200"); + }); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.OcelotGateway/Startup.cs b/Yi.Framework.Net6/Yi.Framework.OcelotGateway/Startup.cs new file mode 100644 index 00000000..25a2f4b2 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.OcelotGateway/Startup.cs @@ -0,0 +1,80 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; +using Ocelot.DependencyInjection; +using Ocelot.Middleware; +using Ocelot.Provider.Consul; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Ocelot.Cache.CacheManager; +using Yi.Framework.WebCore.MiddlewareExtend; +using Ocelot.Provider.Polly; + +namespace Yi.Framework.OcelotGateway +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + + services.AddControllers(); + #region + // + #endregion + services.AddCorsService(); + + #region + //ط + #endregion + services.AddOcelot().AddConsul().AddCacheManager(x =>{x.WithDictionaryHandle();}).AddPolly(); + + #region + //Swagger + #endregion + services.AddSwaggerService("Yi.Framework.OcelotGateway"); + #region + //JwtȨ + #endregion + services.AddJwtService(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + //if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + #region + //Swaggerע + #endregion + app.UseSwaggerService(new SwaggerModel("api/api/swagger/v1/swagger.json","API"), new SwaggerModel("api/item/swagger/v1/swagger.json", "̬ҳ")); + } + #region + //طע + #endregion + app.UseOcelot(); + + #region + //Ȩע + #endregion + app.UseAuthentication(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.OcelotGateway/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.OcelotGateway/SwaggerDoc.xml new file mode 100644 index 00000000..16f3de1b --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.OcelotGateway/SwaggerDoc.xml @@ -0,0 +1,8 @@ + + + + Yi.Framework.OcelotGateway + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.OcelotGateway/Yi.Framework.OcelotGateway.csproj b/Yi.Framework.Net6/Yi.Framework.OcelotGateway/Yi.Framework.OcelotGateway.csproj new file mode 100644 index 00000000..f3fac333 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.OcelotGateway/Yi.Framework.OcelotGateway.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + + + + D:\CC.Yi\CC.Yi\Yi.Framework\Yi.Framework.OcelotGateway\SwaggerDoc.xml + 1701;1702;CS1591 + + + + + + + + + + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Log4net.config b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Log4net.config new file mode 100644 index 00000000..958c7e78 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Log4net.config @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Program.cs b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Program.cs new file mode 100644 index 00000000..a0dfebec --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Program.cs @@ -0,0 +1,77 @@ +using Com.Ctrip.Framework.Apollo; +using Com.Ctrip.Framework.Apollo.Core; +using Com.Ctrip.Framework.Apollo.Enums; +using Com.Ctrip.Framework.Apollo.Logging; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using Yi.Framework.Common.IOCOptions; +using Yi.Framework.Core; +using Yi.Framework.Core.ConsulExtend; +using Yi.Framework.WebCore; +using Yi.Framework.WebCore.MiddlewareExtend; + +namespace Yi.Framework.SMSProcessor +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) => + { + configurationBuilder.AddCommandLine(args); + configurationBuilder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false); + //configurationBuilder.AddJsonFile("configuration.json", optional: false, reloadOnChange: true); + #region + //Apollo配置 + #endregion + //configurationBuilder.AddApolloService("Yi"); + }) + .ConfigureLogging(loggingBuilder => + { + loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning); + loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning); + loggingBuilder.AddLog4Net(); + }) + .ConfigureServices((hostContext, services) => + { + + IConfiguration configuration = services.BuildServiceProvider().GetRequiredService(); + + #region + //Ioc配置 + #endregion + services.AddSingleton(new Appsettings(configuration)); + services.AddHostedService(); + services.AddHostedService(); + + #region 服务注入 + //services.Configure(configuration.GetSection("MysqlConn")); + + + #region + //RabbitMQ服务配置 + #endregion + services.AddRabbitMQService(); + #endregion + + #region + //短信服务配置 + #endregion + services.AddSMSService(); + + #region Consul + //services.Configure(configuration.GetSection("ConsulClientOption")); + //services.AddTransient(); + #endregion + + }); + } + } diff --git a/Yi.Framework.Net6/Yi.Framework.SMSProcessor/SendWorker.cs b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/SendWorker.cs new file mode 100644 index 00000000..a2c942e3 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/SendWorker.cs @@ -0,0 +1,68 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Yi.Framework.Common.Const; +using Yi.Framework.Common.IOCOptions; +using Yi.Framework.Common.Models; +using Yi.Framework.Common.QueueModel; +using Yi.Framework.Core; +using Yi.Framework.Core.ConsulExtend; +using Yi.Framework.Core.SMS; + +namespace Yi.Framework.SMSProcessor +{ + public class SendWorker : BackgroundService + { + private readonly ILogger _logger; + private readonly RabbitMQInvoker _RabbitMQInvoker; + private readonly AliyunSMSInvoker _aliyunSMSInvoker; + public SendWorker(ILogger logger, RabbitMQInvoker rabbitMQInvoker,AliyunSMSInvoker aliyunSMSInvoker) + { + this._logger = logger; + this._RabbitMQInvoker = rabbitMQInvoker; + _aliyunSMSInvoker = aliyunSMSInvoker; + + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + RabbitMQConsumerModel rabbitMQConsumerModel = new RabbitMQConsumerModel() + { + ExchangeName = RabbitConst.SMS_Exchange, + QueueName = RabbitConst.SMS_Queue_Send + }; + HttpClient _HttpClient = new HttpClient(); + this._RabbitMQInvoker.RegistReciveAction(rabbitMQConsumerModel, message => + { + var data= Common.Helper.JsonHelper.StrToObj(message); + try + { + _aliyunSMSInvoker.SendCode(data.code, data.phone); + + return true; + } + catch (Exception ex) + { + var logModel = new LogModel() + { + OriginalClassName = this.GetType().FullName, + OriginalMethodName = nameof(ExecuteAsync), + Remark = "Ϣд־" + }; + this._logger.LogError(ex, $"{nameof(SendWorker)}, Exception:{ex.Message}", JsonConvert.SerializeObject(logModel)); + return false; + } + }); + await Task.CompletedTask; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Worker.cs b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Worker.cs new file mode 100644 index 00000000..d6039afb --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Worker.cs @@ -0,0 +1,32 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Yi.Framework.SMSProcessor +{ + public class Worker : BackgroundService + { + private readonly ILogger _logger; + private readonly IConfiguration _IConfiguration; + public Worker(ILogger logger, IConfiguration configuration) + { + this._logger = logger; + this._IConfiguration = configuration; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); + _logger.LogInformation($"Worker appsetting ConsulClientOption:Ip={this._IConfiguration["ConsulClientOption:Ip"]}"); + await Task.Delay(100000, stoppingToken); + } + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Yi.Framework.SMSProcessor.csproj b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Yi.Framework.SMSProcessor.csproj new file mode 100644 index 00000000..a2d9162d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.SMSProcessor/Yi.Framework.SMSProcessor.csproj @@ -0,0 +1,38 @@ + + + + net6.0 + Exe + Yi.Framework.SMSProcessor.Program + + + + + + + + + Always + true + PreserveNewest + + + + + + + + + + + + + + Always + + + Always + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.Service/BaseService.cs b/Yi.Framework.Net6/Yi.Framework.Service/BaseService.cs new file mode 100644 index 00000000..c74a9760 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/BaseService.cs @@ -0,0 +1,136 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.Enum; +using Yi.Framework.Interface; +using Yi.Framework.Model.ModelFactory; + +namespace Yi.Framework.Service +{ + public class BaseService : IBaseService where T : class, new() + { + public DbContext _Db; + public DbContext _DbRead; + public IDbContextFactory _DbFactory; + public BaseService(IDbContextFactory DbFactory) + { + _DbFactory = DbFactory; + _Db = DbFactory.ConnWriteOrRead(WriteAndReadEnum.Write); + _DbRead = DbFactory.ConnWriteOrRead(WriteAndReadEnum.Read); + } + + public async Task GetEntityById(int id) + { + return await _Db.Set().FindAsync(id); + } + + + public async Task> GetAllEntitiesAsync() + { + return await _Db.Set().ToListAsync(); + } + + public async Task> GetEntitiesAsync(Expression> whereLambda) + { + return await _Db.Set().Where(whereLambda).ToListAsync(); + } + + public async Task GetCountAsync(Expression> whereLambda) //统计数量 + { + return await _Db.Set().CountAsync(whereLambda); + } + + public IQueryable> GetGroup(Expression> whereLambda, Expression> groupByLambda) //分组 + { + return _Db.Set().Where(whereLambda).GroupBy(groupByLambda).AsQueryable(); + } + + public async Task, int>> GetPageEntities(int pageSize, int pageIndex, Expression> whereLambda, Expression> orderByLambda, bool isAsc) + { + int total = await GetCountAsync(whereLambda); + + IEnumerable pageData; + if (isAsc) + { + pageData = await _Db.Set().Where(whereLambda) + .OrderBy(orderByLambda) + .Skip(pageSize * (pageIndex - 1)) + .Take(pageSize).ToListAsync(); + } + else + { + pageData = await _Db.Set().Where(whereLambda) + .OrderByDescending(orderByLambda) + .Skip(pageSize * (pageIndex - 1)) + .Take(pageSize).ToListAsync(); + } + + return Tuple.Create, int>(pageData, total); + } + + public async Task AddAsync(T entity) + { + _Db.Set().Add(entity); + return await _Db.SaveChangesAsync() > 0; + } + + public async Task AddAsync(IEnumerable entities) + { + _Db.Set().AddRange(entities); + return await _Db.SaveChangesAsync() > 0; + } + + public async Task UpdateAsync(T entity) + { + _Db.Set().Update(entity); + return await _Db.SaveChangesAsync() > 0; + } + + public async Task UpdateListAsync(IEnumerable entities) + { + _Db.Set().UpdateRange(entities); + return await _Db.SaveChangesAsync() > 0; + } + + public async Task DeleteAsync(T entity) + { + _Db.Set().Remove(entity); + return await _Db.SaveChangesAsync() > 0; + } + + public async Task DeleteAsync(int id) + { + _Db.Set().Remove(await GetEntityById(id)); + return await _Db.SaveChangesAsync() > 0; + } + + public async Task DeleteAsync(IEnumerable ids) + { + foreach (var id in ids) + { + _Db.Set().RemoveRange(await GetEntityById(id)); + } + return await _Db.SaveChangesAsync() > 0; + } + public async Task DeleteAsync(Expression> where) + { + IEnumerable entities = await GetEntitiesAsync(where); + if (entities != null) + { + _Db.Set().RemoveRange(entities); + + return await _Db.SaveChangesAsync() > 0; + } + return false; + } + + public async Task GetEntity(Expression> whereLambda) + { + return await _Db.Set().Where(whereLambda).FirstOrDefaultAsync(); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Service/MenuService.cs b/Yi.Framework.Net6/Yi.Framework.Service/MenuService.cs new file mode 100644 index 00000000..41f71ca9 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/MenuService.cs @@ -0,0 +1,73 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Core; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Service +{ + public partial class MenuService:BaseService, IMenuService + { + short Normal = (short)Common.Enum.DelFlagEnum.Normal; + public async Task AddChildrenMenu(int menu_id, menu _children) + { + var menu_data = await _DbRead.Set().Include(u => u.children).Where(u => u.id == menu_id).FirstOrDefaultAsync(); + _children.is_top = (short)Common.Enum.TopFlagEnum.Children; + menu_data.children.Add(_children); + await UpdateAsync(menu_data); + return menu_data; + } + + public async Task AddTopMenu(menu _menu) + { + _menu.is_top = (short)Common.Enum.TopFlagEnum.Children; + + return await AddAsync(_menu); + } + + public async Task GetMenuInMould() + { + var menu_data= await _DbRead.Set().Include(u=>u.mould) + .Include(u => u.children).ThenInclude(u => u.mould).OrderByDescending(u => u.sort) + .Include(u=>u.children).ThenInclude(u => u.children).ThenInclude(u => u.mould) + .Include(u => u.children).ThenInclude(u => u.children).ThenInclude(u => u.children).ThenInclude(u => u.mould) + .Include(u => u.children).ThenInclude(u => u.children).ThenInclude(u => u.children).ThenInclude(u => u.children).ThenInclude(u => u.mould) + .Where(u =>u.is_delete == Normal && u.is_show == (short)Common.Enum.ShowFlagEnum.Show && u.is_top == (short)Common.Enum.TopFlagEnum.Top) + .FirstOrDefaultAsync(); + return TreeMenuBuild.Sort(TreeMenuBuild.Normal(menu_data)); + } + + + public async Task> GetTopMenusByTopMenuIds(List menuIds) + { + return await _DbRead.Set().AsNoTracking().Where(u => menuIds.Contains(u.id)).OrderBy(u=>u.sort).ToListAsync(); + } + + public async Task SetMouldByMenu(int id1,int id2) + { + var menu_data = await _DbRead.Set().Include(u => u.mould).Where(u => u.id == id1).FirstOrDefaultAsync(); + var mould_data = await _DbRead.Set().Where(u => u.id == id1).FirstOrDefaultAsync(); + menu_data.mould = mould_data; + _Db.Update(menu_data); + return menu_data; + } + + + public async Task> GetTopMenuByUserId(int userId) + { + var user_data = await _DbRead.Set().Include(u => u.roles).ThenInclude(u => u.menus).Where(u=>u.id==userId).FirstOrDefaultAsync(); + List menuList = new(); + user_data.roles.ForEach(u => + { + var m = u.menus.Where(u => u.is_delete == Normal).ToList(); + menuList = menuList.Union(m).ToList(); + }); + return menuList; + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Service/MouldService.cs b/Yi.Framework.Net6/Yi.Framework.Service/MouldService.cs new file mode 100644 index 00000000..21409683 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/MouldService.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Service +{ + public partial class MouldService:BaseService, IMouldService + { + /// + /// 这个获取的是菜单,用的是菜单表,应该放到菜单service里面,像这种只用到id的,就传一个id就可以了 + /// + /// + /// + public async Task GetMenuByMould(mould _mould) + { + var menu_data = await _Db.Set().Include(u => u.mould).Where(u => u.mould == _mould && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync(); + return menu_data; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs b/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs new file mode 100644 index 00000000..1461c1af --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs @@ -0,0 +1,65 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Interface; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Service +{ + public partial class RoleService:BaseService, IRoleService + { + short Normal = (short)Common.Enum.DelFlagEnum.Normal; + + public async Task> GetRolesByUserId(int userId) + { + var user_data =await _Db.Set().Include(u => u.roles).Where(u => u.id==userId).FirstOrDefaultAsync(); + var roleList = user_data.roles.Where(u=>u.is_delete==Normal).ToList(); + roleList.ForEach(u => u.users = null); + return roleList; + } + + + public async Task SetMenusByRolesId(List menuIds,List roleIds) + { + var role_data = await _Db.Set().Include(u => u.menus).ThenInclude(u => u.children).Where(u =>roleIds.Contains(u.id) && u.is_delete == Normal).ToListAsync(); + var menuList = await _Db.Set().Where(u => menuIds.Contains(u.id)&&u.is_delete ==Normal).ToListAsync(); + foreach(var role in role_data) + { + role.menus =menuList; + } + return await UpdateListAsync(role_data); + } + + public async Task> GetMenusByRoleId(List< int> roleIds) + { + var role_data = await _Db.Set().Include(u => u.menus).Where(u => roleIds.Contains(u.id) && u.is_delete == Normal).ToListAsync(); + List menuList = new(); + role_data.ForEach(u => + { + var m = u.menus.Where(u => u.is_delete == Normal).ToList(); + menuList = menuList.Union(m).ToList(); + }); + return menuList; + } + public async Task> GetTopMenusByRoleId(int roleId) + { + var role_data = await _Db.Set().Include(u=>u.menus).Where(u => u.id == roleId).FirstOrDefaultAsync(); + var menuList = role_data.menus.Where(u => u.is_delete == Normal).ToList(); + + menuList.ForEach(u => u.roles = null); + + return menuList; + } + + public async Task> GetMenusByRole(int roleId) + { + var role_data = await _Db.Set().Include(u => u.menus).Where(u => u.id == roleId).FirstOrDefaultAsync(); + var menuList = role_data.menus.Where(u => u.is_delete == Normal).ToList(); + return menuList; + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Service/T4Service.cs b/Yi.Framework.Net6/Yi.Framework.Service/T4Service.cs new file mode 100644 index 00000000..1b59d0eb --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/T4Service.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; +using Yi.Framework.Interface; +using Microsoft.EntityFrameworkCore; +using Yi.Framework.Model.ModelFactory; + +namespace Yi.Framework.Service +{ + + public partial class MenuService:BaseService,IMenuService + { + public MenuService(IDbContextFactory DbFactory):base(DbFactory){ } + + public async Task DelListByUpdateAsync(List _ids) + { + var menuList = await GetEntitiesAsync(u=>_ids.Contains(u.id)); + menuList.ToList().ForEach(u => u.is_delete = (short)Common.Enum.DelFlagEnum.Deleted); + return await UpdateListAsync(menuList); + } + + public async Task> GetAllEntitiesTrueAsync() + { + return await GetEntitiesAsync(u=> u.is_delete == (short)Common.Enum.DelFlagEnum.Normal); + } + + } + + public partial class MouldService:BaseService,IMouldService + { + public MouldService(IDbContextFactory DbFactory):base(DbFactory){ } + + public async Task DelListByUpdateAsync(List _ids) + { + var mouldList = await GetEntitiesAsync(u=>_ids.Contains(u.id)); + mouldList.ToList().ForEach(u => u.is_delete = (short)Common.Enum.DelFlagEnum.Deleted); + return await UpdateListAsync(mouldList); + } + + public async Task> GetAllEntitiesTrueAsync() + { + return await GetEntitiesAsync(u=> u.is_delete == (short)Common.Enum.DelFlagEnum.Normal); + } + + } + + public partial class RoleService:BaseService,IRoleService + { + public RoleService(IDbContextFactory DbFactory):base(DbFactory){ } + + public async Task DelListByUpdateAsync(List _ids) + { + var roleList = await GetEntitiesAsync(u=>_ids.Contains(u.id)); + roleList.ToList().ForEach(u => u.is_delete = (short)Common.Enum.DelFlagEnum.Deleted); + return await UpdateListAsync(roleList); + } + + public async Task> GetAllEntitiesTrueAsync() + { + return await GetEntitiesAsync(u=> u.is_delete == (short)Common.Enum.DelFlagEnum.Normal); + } + + } + + public partial class UserService:BaseService,IUserService + { + public UserService(IDbContextFactory DbFactory):base(DbFactory){ } + + public async Task DelListByUpdateAsync(List _ids) + { + var userList = await GetEntitiesAsync(u=>_ids.Contains(u.id)); + userList.ToList().ForEach(u => u.is_delete = (short)Common.Enum.DelFlagEnum.Deleted); + return await UpdateListAsync(userList); + } + + public async Task> GetAllEntitiesTrueAsync() + { + return await GetEntitiesAsync(u=> u.is_delete == (short)Common.Enum.DelFlagEnum.Normal); + } + + } + + public partial class VisitService:BaseService,IVisitService + { + public VisitService(IDbContextFactory DbFactory):base(DbFactory){ } + + public async Task DelListByUpdateAsync(List _ids) + { + var visitList = await GetEntitiesAsync(u=>_ids.Contains(u.id)); + visitList.ToList().ForEach(u => u.is_delete = (short)Common.Enum.DelFlagEnum.Deleted); + return await UpdateListAsync(visitList); + } + + public async Task> GetAllEntitiesTrueAsync() + { + return await GetEntitiesAsync(u=> u.is_delete == (short)Common.Enum.DelFlagEnum.Normal); + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Service/T4Service.tt b/Yi.Framework.Net6/Yi.Framework.Service/T4Service.tt new file mode 100644 index 00000000..ba340807 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/T4Service.tt @@ -0,0 +1,58 @@ +<#@ template debug="false" hostspecific="true" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.IO" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension=".cs" #> +<# + string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径 + string dirPath= Path.Combine(solutionsPath,@"Yi.Framework.Model\Models\"); + DirectoryInfo dir = new DirectoryInfo(dirPath); + FileInfo[] finfo = dir.GetFiles(); + string filenames = string.Empty; + List filenameList = new List(); + for (int i = 0; i < finfo.Length; i++) + { + filenames = finfo[i].Name ; + string[] fname=filenames.Split('.'); + filenameList.Add(fname[0]); + } + + +#> +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; +using Yi.Framework.Interface; +using Microsoft.EntityFrameworkCore; +using Yi.Framework.Model.ModelFactory; + +namespace Yi.Framework.Service +{ + <# foreach(string k in filenameList){ + string fn= k.Substring(0,1).ToUpper()+k.Substring(1); + #> + + public partial class <#= fn #>Service:BaseService<<#= k #>>,I<#= fn #>Service + { + public <#= fn #>Service(IDbContextFactory DbFactory):base(DbFactory){ } + + public async Task DelListByUpdateAsync(List _ids) + { + var <#= k #>List = await GetEntitiesAsync(u=>_ids.Contains(u.id)); + <#= k #>List.ToList().ForEach(u => u.is_delete = (short)Common.Enum.DelFlagEnum.Deleted); + return await UpdateListAsync(<#= k #>List); + } + + public async Task>> GetAllEntitiesTrueAsync() + { + return await GetEntitiesAsync(u=> u.is_delete == (short)Common.Enum.DelFlagEnum.Normal); + } + + } +<# } #> +} diff --git a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs new file mode 100644 index 00000000..6e9396cf --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs @@ -0,0 +1,104 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Core; +using Yi.Framework.Interface; +using Yi.Framework.Model; +using Yi.Framework.Model.ModelFactory; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Service +{ + public partial class UserService : BaseService, IUserService + { + short Normal = (short)Common.Enum.DelFlagEnum.Normal; + public async Task PhoneIsExsit(string smsAddress) + { + var userList = await GetEntity(u => u.phone == smsAddress); + if (userList == null) + { + return false; + } + return true; + } + + public async Task EmailIsExsit(string emailAddress) + { + var userList = await GetEntity(u => u.email == emailAddress); + if (userList == null) + { + return false; + } + return true; + } + /// + /// + /// + /// + /// + public async Task GetUserById(int userId) + { + return await _DbRead.Set().Include(u => u.roles).ThenInclude(u => u.menus).ThenInclude(u => u.children).ThenInclude(u => u.mould).Where(u=>u.id==userId).FirstOrDefaultAsync(); + + } + public async Task> GetAxiosByRouter(string router, int userId, List menuIds) + { + var user_data =await GetUserById(userId); + List menuList = new(); + foreach(var item in user_data.roles) + { + var m=item.menus.Where(u =>u?.router?.ToUpper() == router.ToUpper()).FirstOrDefault(); + if (m == null) { break; } + menuList = m.children?.Where(u => menuIds.Contains(u.id)&&u.is_delete==Normal).ToList(); + + } + return menuList; + } + + public async Task GetMenuByHttpUser(List allMenuIds) + { + var topMenu =await _DbRead.Set().Include(u => u.children).ThenInclude(u => u.children).ThenInclude(u => u.children).ThenInclude(u => u.children).ThenInclude(u => u.children).Where(u => u.is_top == (short)Common.Enum.ShowFlagEnum.Show).FirstOrDefaultAsync(); + //现在要开始关联菜单了 + return TreeMenuBuild.Sort(TreeMenuBuild.ShowFormat(topMenu, allMenuIds)); ; + } + public async Task GetUserInRolesByHttpUser(int userId) + { + var data = await GetUserById(userId); + data.roles?.ForEach(u=> { + u.users = null; + u.menus = null; + }); + return data; + } + + public async Task Login(user _user) + { + var user_data = await _DbRead.Set().Include(u => u.roles).Where(u => u.username == _user.username && u.password ==_user.password &&u.is_delete == Normal).FirstOrDefaultAsync(); + return user_data; + } + + public async Task Register(user _user) + { + var user_data = await GetEntity(u => u.username == _user.username); + if (user_data != null) + { + return false; + } + return await UpdateAsync(_user); + } + + public async Task SetRoleByUser(List roleIds, List userIds) + { + var user_data = await _DbRead.Set().Include(u => u.roles).Where(u => userIds.Contains(u.id)).ToListAsync(); + var roleList = await _DbRead.Set().Where(u => roleIds.Contains(u.id)).ToListAsync(); + user_data.ForEach(u => u.roles = roleList); + return await UpdateListAsync(user_data); + } + + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Service/Yi - Backup.Framework.Service.csproj b/Yi.Framework.Net6/Yi.Framework.Service/Yi - Backup.Framework.Service.csproj new file mode 100644 index 00000000..c54fe835 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/Yi - Backup.Framework.Service.csproj @@ -0,0 +1,20 @@ + + + + net5.0 + + + + + + + + + + + + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.Service/Yi.Framework.Service.csproj b/Yi.Framework.Net6/Yi.Framework.Service/Yi.Framework.Service.csproj new file mode 100644 index 00000000..7d3c9014 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Service/Yi.Framework.Service.csproj @@ -0,0 +1,44 @@ + + + + net6.0 + + + + + + + + + True + True + T4Service.tt + + + + + + + + + + + + T4Service.cs + TextTemplatingFileGenerator + + + + + + + + + + True + True + T4Service.tt + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.Task/HttpJob.cs b/Yi.Framework.Net6/Yi.Framework.Task/HttpJob.cs new file mode 100644 index 00000000..bb16da9e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Task/HttpJob.cs @@ -0,0 +1,44 @@ +using Microsoft.Extensions.Logging; +using Quartz; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; + +namespace Yi.Framework.Job +{ + public class HttpJob : IJob + { + private ILogger _logger; + public HttpJob(ILogger logger) + { + _logger = logger; + } + + public Task Execute(IJobExecutionContext context) + { + return Task.Run(() => + { + var jobData = context.JobDetail.JobDataMap; + string method= jobData[Common.Const.JobConst.method].ToString(); + string url = jobData[Common.Const.JobConst.url].ToString(); + string data="异常!"; + switch (method) + { + case "post": + data = Common.Helper.HttpHelper.HttpPost(url); + break; + case "get": + data = Common.Helper.HttpHelper.HttpGet(url); + break; + } + + + _logger.LogWarning("定时任务开始调度:" + nameof(HttpJob) + ":" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + $":访问地址为:{url},结果为:{data}"); + Console.WriteLine($"结果:{data}"); + }); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Task/VisitJob.cs b/Yi.Framework.Net6/Yi.Framework.Task/VisitJob.cs new file mode 100644 index 00000000..2c95b7cf --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Task/VisitJob.cs @@ -0,0 +1,43 @@ + +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Quartz; +using System; +using System.IO; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; +using Yi.Framework.Model.ModelFactory; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Job +{ + public class VisitJob : IJob + { + private ILogger _logger; + private DbContext _DBWrite; + public VisitJob(ILogger logger, IDbContextFactory DbFactory) + { + _logger = logger; + _DBWrite = DbFactory.ConnWriteOrRead(Common.Enum.WriteAndReadEnum.Write); + } + + /// + /// 应该将拜访清零,并且写入数据库中的拜访表中 + /// + /// + /// + public Task Execute(IJobExecutionContext context) + { + return Task.Run(() => + { + _DBWrite.Set().Add(new visit() { num = JobModel.visitNum, time = DateTime.Now }); + _DBWrite.SaveChanges(); + _logger.LogWarning("定时任务开始调度:" + nameof(VisitJob) + ":" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + $":访问总数为:{JobModel.visitNum}"); + JobModel.visitNum = 0; + } + ); + } + } +} + diff --git a/Yi.Framework.Net6/Yi.Framework.Task/Yi.Framework.Job.csproj b/Yi.Framework.Net6/Yi.Framework.Task/Yi.Framework.Job.csproj new file mode 100644 index 00000000..2939eae1 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Task/Yi.Framework.Job.csproj @@ -0,0 +1,16 @@ + + + + net6.0 + + + + + + + + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Appsettings.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/Appsettings.cs new file mode 100644 index 00000000..ae8963cb --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Appsettings.cs @@ -0,0 +1,92 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration.Json; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Yi.Framework.WebCore +{ + /// + /// appsettings.json操作类 + /// + public class Appsettings + { + static IConfiguration Configuration { get; set; } + static string contentPath { get; set; } + + public Appsettings(string contentPath) + { + string Path = "appsettings.json"; + + //如果你把配置文件 是 根据环境变量来分开了,可以这样写 + //Path = $"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json"; + + Configuration = new ConfigurationBuilder() + .SetBasePath(contentPath) + .Add(new JsonConfigurationSource { Path = Path, Optional = false, ReloadOnChange = true })//这样的话,可以直接读目录里的json文件,而不是 bin 文件夹下的,所以不用修改复制属性 + .Build(); + } + + public Appsettings(IConfiguration configuration) + { + Configuration = configuration; + } + + /// + /// 封装要操作的字符 + /// + /// 节点配置 + /// + public static string app(params string[] sections) + { + try + { + + if (sections.Any()) + { + return Configuration[string.Join(":", sections)]; + } + } + catch (Exception) { } + + return ""; + } + + public static bool appBool(params string[] sections) + { + + return Bool(app(sections)); + + } + + public static bool Bool(object thisValue) + { + bool reval = false; + if (thisValue != null && thisValue != DBNull.Value && bool.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return reval; + } + + /// + /// 递归获取配置信息数组 + /// + /// + /// + /// + public static T app(params string[] sections) + { + T app = Activator.CreateInstance(); + // 引用 Microsoft.Extensions.Configuration.Binder 包 + Configuration.Bind(string.Join(":", sections), app); + return app; + } + + + public static IConfiguration appConfiguration(params string[] sections) + { + return Configuration.GetSection(string.Join(":", sections)); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/ApolloExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/ApolloExtension.cs new file mode 100644 index 00000000..313fce11 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/ApolloExtension.cs @@ -0,0 +1,64 @@ +using Com.Ctrip.Framework.Apollo; +using Microsoft.Extensions.Configuration; +using System; +using System.Collections.Generic; +using System.Linq; +using Com.Ctrip.Framework.Apollo.Enums; +using Com.Ctrip.Framework.Apollo.Logging; +using Microsoft.Extensions.Primitives; +using System.Reflection; + +namespace Yi.Framework.WebCore.BuilderExtend +{ + public static class ApolloExtension + { + /// + /// 接入Apollo + /// + /// + /// apollo配置文件路径 如果写入appsettings.json中 则jsonPath传null即可 + public static void AddApolloService(this IConfigurationBuilder builder, params string[] NameSpace) + { + //阿波罗的日志级别调整 + LogManager.UseConsoleLogging(LogLevel.Warn); + var root = builder.Build(); + + if (Appsettings.Bool(root["Apollo_Enabled"])) + { + var apolloBuilder = builder.AddApollo(root.GetSection("apollo")).AddDefault(); + + foreach (var item in NameSpace) + { + apolloBuilder.AddNamespace(item, ConfigFileFormat.Json); + } + //监听apollo配置 + Monitor(builder.Build()); + } + + } + #region private + /// + /// 监听配置 + /// + private static void Monitor(IConfigurationRoot root) + { + //TODO 需要根据改变执行特定的操作 如 mq redis 等其他跟配置相关的中间件 + //TODO 初步思路:将需要执行特定的操作key和value放入内存字典中,在赋值操作时通过标准事件来执行特定的操作。 + + //要重新Build 此时才将Apollo provider加入到ConfigurationBuilder中 + ChangeToken.OnChange(() => root.GetReloadToken(), () => + { + foreach (var apolloProvider in root.Providers.Where(p => p is ApolloConfigurationProvider)) + { + var property = apolloProvider.GetType().BaseType.GetProperty("Data", BindingFlags.Instance | BindingFlags.NonPublic); + var data = property.GetValue(apolloProvider) as IDictionary; + foreach (var item in data) + { + Console.WriteLine($"key {item.Key} value {item.Value}"); + } + } + }); + } + #endregion + } +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/JsonExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/JsonExtension.cs new file mode 100644 index 00000000..ccf52354 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/JsonExtension.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.BuilderExtend +{ + public static class JsonExtension + { + public static void AddJsonFileService(this IMvcBuilder builder) + { + builder.AddNewtonsoftJson(options => + { + options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; + options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm"; + }); + + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/JsonFileExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/JsonFileExtension.cs new file mode 100644 index 00000000..0f00c052 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/JsonFileExtension.cs @@ -0,0 +1,32 @@ +using Microsoft.Extensions.Configuration; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.BuilderExtend +{ + public static class JsonFileExtension + { + public static void AddJsonFileService(this IConfigurationBuilder builder, params string[] JsonFile) + { + if (JsonFile==null) + { + string[] myJsonFile = new string[] { "appsettings.json", "configuration.json" }; + foreach (var item in myJsonFile) + { + builder.AddJsonFile(item, optional: true, reloadOnChange: false); + } + } + else + { + foreach (var item in JsonFile) + { + builder.AddJsonFile(item, optional: true, reloadOnChange: false); + } + } + + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs new file mode 100644 index 00000000..35bf7cda --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/CommonExtend.cs @@ -0,0 +1,61 @@ +using Yi.Framework.Model; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.WebCore +{ + public static class CommonExtend + { + /// + /// 判断是否为异步请求 + /// + /// + /// + public static bool IsAjaxRequest(this HttpRequest request) + { + string header = request.Headers["X-Requested-With"]; + return "XMLHttpRequest".Equals(header); + } + + /// + /// 基于HttpContext,当前鉴权方式解析,获取用户信息 + /// + /// + /// + public static user GetCurrentUserInfo(this HttpContext httpContext, out List menuIds) + { + IEnumerable claimlist = httpContext.AuthenticateAsync().Result.Principal.Claims; + + Int32.TryParse(claimlist.FirstOrDefault(u => u.Type == ClaimTypes.Sid).Value, out int resId); + + + menuIds = claimlist.Where(u => u.Type == "menuIds").ToList().Select(u => Convert.ToInt32(u.Value)).ToList(); + + + return new user() + { + id = resId, + username = claimlist.FirstOrDefault(u => u.Type == ClaimTypes.Name).Value ?? "匿名" + }; + } + public static user GetCurrentUserInfo(this HttpContext httpContext) + { + IEnumerable claimlist = httpContext.AuthenticateAsync().Result.Principal.Claims; + + Int32.TryParse(claimlist.FirstOrDefault(u => u.Type == ClaimTypes.Sid).Value, out int resId); + + return new user() + { + id = resId, + username = claimlist.FirstOrDefault(u => u.Type == ClaimTypes.Name).Value ?? "匿名" + }; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CORSFilter.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CORSFilter.cs new file mode 100644 index 00000000..d697230a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CORSFilter.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Mvc.Filters; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.FilterExtend +{ + /// + /// 跨域过滤器 + /// + public class CORSFilter : ActionFilterAttribute + { + public override void OnActionExecuting(ActionExecutingContext context) + { + context.HttpContext.Response.Headers.Add("Access-Control-Allow-Origin", "*"); + context.HttpContext.Response.Headers.Add("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE,PUT"); + context.HttpContext.Response.Headers.Add("Access-Control-Allow-Credentials", "true"); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomAction2CommitFilterAttribute.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomAction2CommitFilterAttribute.cs new file mode 100644 index 00000000..49fe510c --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomAction2CommitFilterAttribute.cs @@ -0,0 +1,83 @@ +using Yi.Framework.Common.Models; +using Yi.Framework.Core; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; +using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common.Helper; + +namespace Yi.Framework.WebCore.FilterExtend +{ + /// + /// 重复提交过滤器 + /// + public class CustomAction2CommitFilterAttribute : ActionFilterAttribute + { + /// + /// 防重复提交周期 单位秒 + /// + //public int TimeOut = 1; + + //#region Identity + //private readonly ILogger _logger; + //private readonly CacheClientDB _cacheClientDB; + //private static string KeyPrefix = "2CommitFilter"; + + // public CustomAction2CommitFilterAttribute(ILogger logger, CacheClientDB cacheClientDB) + // { + // this._logger = logger; + // this._cacheClientDB = cacheClientDB; + // } + // #endregion + + + //if (this.IsAjaxRequest(context.HttpContext.Request)) + // //{ } + // context.Result = new RedirectResult("~/Fourth/Login"); + //} + //else + //{ + // this._logger.LogDebug($"{currentUser.Name} 访问系统"); + //} + //} public override void OnActionExecuting(ActionExecutingContext context) + //{ + // string url = context.HttpContext.Request.Path.Value; + // string argument = JsonConvert.SerializeObject(context.ActionArguments); + // string ip = context.HttpContext.Connection.RemoteIpAddress.ToString(); + // string agent = context.HttpContext.Request.Headers["User-Agent"]; + // string sInfo = $"{url}-{argument}-{ip}-{agent}"; + // string summary = MD5Helper.MD5EncodingOnly(sInfo); + + // string totalKey = $"{KeyPrefix}-{summary}"; + + // string result = this._cacheClientDB.Get(totalKey); + // if (string.IsNullOrEmpty(result)) + // { + // this._cacheClientDB.Add(totalKey, "1", TimeSpan.FromSeconds(3));//3秒有效期 + // this._logger.LogInformation($"CustomAction2CommitFilterAttribute:{sInfo}"); + // } + // else + // { + // //已存在 + // this._logger.LogWarning($"CustomAction2CommitFilterAttribute重复请求:{sInfo}"); + // context.Result = new JsonResult(Result.Error("请勿重复提交")); + // } + + // //CurrentUser currentUser = context.HttpContext.GetCurrentUserBySession(); + // //if (currentUser == null) + // //{ + // // // + //private bool IsAjaxRequest(HttpRequest request) + //{ + // string header = request.Headers["X-Requested-With"]; + // return "XMLHttpRequest".Equals(header); + //} + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomActionCacheFilterAttribute.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomActionCacheFilterAttribute.cs new file mode 100644 index 00000000..cf976d29 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomActionCacheFilterAttribute.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc.Filters; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.FilterExtend +{ + /// + /// 缓存过滤器 + /// + public class CustomActionCacheFilterAttribute : ActionFilterAttribute + { + public override void OnActionExecuted(ActionExecutedContext context) + { + context.HttpContext.Response.Headers.Add("Cache-Control", "public,max-age=6000"); + Console.WriteLine($"This {nameof(CustomActionCacheFilterAttribute)} OnActionExecuted{this.Order}"); + } + public override void OnActionExecuting(ActionExecutingContext context) + { + Console.WriteLine($"This {nameof(CustomActionCacheFilterAttribute)} OnActionExecuting{this.Order}"); + } + public override void OnResultExecuting(ResultExecutingContext context) + { + Console.WriteLine($"This {nameof(CustomActionCacheFilterAttribute)} OnResultExecuting{this.Order}"); + } + public override void OnResultExecuted(ResultExecutedContext context) + { + Console.WriteLine($"This {nameof(CustomActionCacheFilterAttribute)} OnResultExecuted{this.Order}"); + } + } + +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomActionCheckFilterAttribute.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomActionCheckFilterAttribute.cs new file mode 100644 index 00000000..a328775d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomActionCheckFilterAttribute.cs @@ -0,0 +1,42 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; +using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.FilterExtend +{ + /// + /// 控制器检查过滤器 + /// + public class CustomActionCheckFilterAttribute : ActionFilterAttribute + { + #region Identity + private readonly ILogger _logger; + public CustomActionCheckFilterAttribute(ILogger logger) + { + this._logger = logger; + } + #endregion + + public override void OnActionExecuting(ActionExecutingContext context) + { + //CurrentUser currentUser = context.HttpContext.GetCurrentUserBySession(); + //if (currentUser == null) + //{ + // //if (this.IsAjaxRequest(context.HttpContext.Request)) + // //{ } + // context.Result = new RedirectResult("~/Fourth/Login"); + //} + //else + //{ + // this._logger.LogDebug($"{currentUser.Name} 访问系统"); + //} + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomExceptionFilterAttribute.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomExceptionFilterAttribute.cs new file mode 100644 index 00000000..0af7e9f8 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomExceptionFilterAttribute.cs @@ -0,0 +1,44 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using Yi.Framework.Common.Models; + +namespace Yi.Framework.WebCore.FilterExtend +{ + /// + /// 异常抓取过滤器 + /// + public class CustomExceptionFilterAttribute : IExceptionFilter + { + private ILogger _logger = null; + public CustomExceptionFilterAttribute(ILogger logger) + { + this._logger = logger; + } + + public void OnException(ExceptionContext context) + { + if (context.ExceptionHandled == false) + { + context.Result = new JsonResult( + Result.Error("操作失败").SetData(context.Exception.Message)); + string url = context.HttpContext.Request.Path.Value; + string actionName = context.ActionDescriptor.DisplayName; + + var logModel = new LogModel() + { + OriginalClassName = "", + OriginalMethodName = actionName, + Remark = $"来源于{nameof(CustomExceptionFilterAttribute)}.{nameof(OnException)}" + }; + this._logger.LogError(context.Exception, $"{url}----->actionName={actionName} Message={context.Exception.Message}", JsonConvert.SerializeObject(logModel)); + } + context.ExceptionHandled = true; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomIOCFilterFactoryAttribute.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomIOCFilterFactoryAttribute.cs new file mode 100644 index 00000000..77a08bcf --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomIOCFilterFactoryAttribute.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Mvc.Filters; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.FilterExtend +{ + /// + /// 依赖注入工厂过滤器 + /// + public class CustomIOCFilterFactoryAttribute : Attribute, IFilterFactory + { + private readonly Type _FilterType = null; + + public CustomIOCFilterFactoryAttribute(Type type) + { + this._FilterType = type; + } + public bool IsReusable => true; + + public IFilterMetadata CreateInstance(IServiceProvider serviceProvider) + { + //return (IFilterMetadata)serviceProvider.GetService(typeof(CustomExceptionFilterAttribute)); + + return (IFilterMetadata)serviceProvider.GetService(this._FilterType); + } + } + + +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomResourceFilterAttribute.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomResourceFilterAttribute.cs new file mode 100644 index 00000000..c8640ef7 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomResourceFilterAttribute.cs @@ -0,0 +1,45 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.FilterExtend +{ + /// + /// 资源过滤器 + /// + public class CustomResourceFilterAttribute : Attribute, IResourceFilter, IFilterMetadata + { + private static Dictionary CustomCache = new Dictionary(); + /// + /// 发生在其他动作之前 + /// + /// + public void OnResourceExecuting(ResourceExecutingContext context) + { + Console.WriteLine($"This is {nameof(CustomResourceFilterAttribute) }OnResourceExecuting"); + //if 有缓存,直接返回缓存 + string key = context.HttpContext.Request.Path; + if (CustomCache.ContainsKey(key)) + { + context.Result = CustomCache[key];//断路器--到Result生成了,但是Result还需要转换成Html + } + } + /// + /// 发生在其他动作之后 + /// + /// + public void OnResourceExecuted(ResourceExecutedContext context) + { + Console.WriteLine($"This is {nameof(CustomResourceFilterAttribute) }OnResourceExecuted"); + //这个应该缓存起来 + string key = context.HttpContext.Request.Path; + if (!CustomCache.ContainsKey(key)) + { + CustomCache.Add(key, context.Result); + } + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/LogActionFilterAttribute.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/LogActionFilterAttribute.cs new file mode 100644 index 00000000..50cbca85 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/LogActionFilterAttribute.cs @@ -0,0 +1,83 @@ +using Yi.Framework.Common.Models; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.FilterExtend +{ + /// + /// 日志处理过滤器 + /// + public class LogActionFilterAttribute : ActionFilterAttribute + { + private ILogger _logger = null; + public LogActionFilterAttribute(ILogger logger) + { + this._logger = logger; + } + + public override void OnActionExecuting(ActionExecutingContext context) + { + string url = context.HttpContext.Request.Path.Value; + string argument = JsonConvert.SerializeObject(context.ActionArguments); + + string controllerName = context.Controller.GetType().FullName; + string actionName = context.ActionDescriptor.DisplayName; + + LogModel logModel = new LogModel() + { + OriginalClassName = controllerName, + OriginalMethodName = actionName, + Remark = $"来源于{nameof(LogActionFilterAttribute)}.{nameof(OnActionExecuting)}" + }; + + //this._logger.LogInformation($"url={url}---argument={argument}",new object[] { JsonConvert.SerializeObject(logModel) } ); + this._logger.LogInformation($"url={url}---argument={argument}"); + } + } + + public class CustomActionFilterAttribute : ActionFilterAttribute + { + public override void OnActionExecuted(ActionExecutedContext context) + { + Console.WriteLine($"This {nameof(LogActionFilterAttribute)} OnActionExecuted{this.Order}"); + } + public override void OnActionExecuting(ActionExecutingContext context) + { + Console.WriteLine($"This {nameof(LogActionFilterAttribute)} OnActionExecuting{this.Order}"); + } + public override void OnResultExecuting(ResultExecutingContext context) + { + Console.WriteLine($"This {nameof(LogActionFilterAttribute)} OnResultExecuting{this.Order}"); + } + public override void OnResultExecuted(ResultExecutedContext context) + { + Console.WriteLine($"This {nameof(LogActionFilterAttribute)} OnResultExecuted{this.Order}"); + } + } + + public class CustomControllerFilterAttribute : ActionFilterAttribute + { + public override void OnActionExecuted(ActionExecutedContext context) + { + Console.WriteLine($"This {nameof(CustomControllerFilterAttribute)} OnActionExecuted {this.Order}"); + } + public override void OnActionExecuting(ActionExecutingContext context) + { + Console.WriteLine($"This {nameof(CustomControllerFilterAttribute)} OnActionExecuting{this.Order}"); + } + public override void OnResultExecuting(ResultExecutingContext context) + { + Console.WriteLine($"This {nameof(CustomControllerFilterAttribute)} OnResultExecuting{this.Order}"); + } + public override void OnResultExecuted(ResultExecutedContext context) + { + Console.WriteLine($"This {nameof(CustomControllerFilterAttribute)} OnResultExecuted{this.Order}"); + } + } + +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Init/DataSeed.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/Init/DataSeed.cs new file mode 100644 index 00000000..0129b67e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Init/DataSeed.cs @@ -0,0 +1,258 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.ModelFactory; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.WebCore.Init +{ + public class DataSeed + { + public async static Task SeedAsync(IDbContextFactory _DbFactory) + { + var _Db = _DbFactory.ConnWriteOrRead(Common.Enum.WriteAndReadEnum.Write); + if (!_Db.Set().Any()) + { + await _Db.Set().AddAsync(new user + { + username = "admin", + password = "123", + roles = new List() + { + new role(){ role_name="普通用户"}, + + new role() + { + role_name="管理员", + menus = new List() + { + new menu() + { + menu_name="根",is_show=1,is_top=1, children=new List(){ + new menu() + { + menu_name="首页",is_show=1,router="/" + }, + + new menu() + { + menu_name="用户角色管理",is_show=1, children=new List() + { + new menu() + { + menu_name="用户管理",router="/AdmUser/", is_show=1,children=new List() + { + new menu() + { + menu_name="get",is_show=0, + mould=new mould() + { + mould_name="get",url="/user/getuser" + } + }, + new menu() + { + menu_name="update",is_show=0, + mould=new mould() + { + mould_name="update",url="/user/updateuser" + } + }, + new menu() + { + menu_name="del",is_show=0, + mould=new mould() + { + mould_name="del",url="/user/dellistUser" + } + }, + new menu() + { + menu_name="add",is_show=0, + mould=new mould() + { + mould_name="add",url="/user/adduser" + } + } + } + }, + new menu() + { + menu_name="角色管理",router="/admrole/", is_show=1,children=new List() + { + new menu() + { + menu_name="get",is_show=0, + mould=new mould() + { + mould_name="get",url="/role/getrole" + } + }, + new menu() + { + menu_name="update",is_show=0, + mould=new mould() + { + mould_name="update",url="/role/updaterole" + } + }, + new menu() + { + menu_name="del",is_show=0, + mould=new mould() + { + mould_name="del",url="/role/dellistrole" + } + }, + new menu() + { + menu_name="add",is_show=0, + mould=new mould() + { + mould_name="add",url="/role/addrole" + } + } + } + } + } + + }, + new menu() + { + menu_name="角色接口管理",is_show=1, children=new List() + { + new menu() + { + menu_name="菜单管理",router="/AdmMenu/", is_show=1,children=new List() + { + new menu() + { + menu_name="get",is_show=0, + mould=new mould() + { + mould_name="get",url="/Menu/getMenu" + } + }, + new menu() + { + menu_name="update",is_show=0, + mould=new mould() + { + mould_name="update",url="/Menu/updateMenu" + } + }, + new menu() + { + menu_name="del",is_show=0, + mould=new mould() + { + mould_name="del",url="/Menu/dellistMenu" + } + }, + new menu() + { + menu_name="add",is_show=0, + mould=new mould() + { + mould_name="add",url="/Menu/addMenu" + } + } + } + }, + new menu() + { + menu_name="接口管理",router="/admMould/", is_show=1,children=new List() + { + new menu() + { + menu_name="get",is_show=0, + mould=new mould() + { + mould_name="get",url="/Mould/getMould" + } + }, + new menu() + { + menu_name="update",is_show=0, + mould=new mould() + { + mould_name="update",url="/Mould/updateMould" + } + }, + new menu() + { + menu_name="del",is_show=0, + mould=new mould() + { + mould_name="del",url="/Mould/dellistMould" + } + }, + new menu() + { + menu_name="add",is_show=0, + mould=new mould() + { + mould_name="add",url="/Mould/addMould" + } + } + } + }, + new menu() + { + menu_name="角色菜单分配管理",router="/admRoleMenu/", is_show=1, children=null + } + } + + }, + new menu() + { + menu_name="路由管理",is_show=1,children=new List() + { + new menu() + { + menu_name="用户信息",router="/userinfo/", is_show=1,children=null + + } + } + + } + + + + + + + + + + + + + + + + + + + + + + + + } + } + + } + } + } + }); + } + await _Db.SaveChangesAsync(); + + Console.WriteLine(nameof(DbContext) + ":数据库初始成功!"); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Init/RedisInit.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/Init/RedisInit.cs new file mode 100644 index 00000000..7856785c --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Init/RedisInit.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.Const; +using Yi.Framework.Core; +using Yi.Framework.DTOModel; + +namespace Yi.Framework.WebCore.Init +{ + public class RedisInit + { + public static void Seed(CacheClientDB _cacheClientDB) + { + var setDto = Common.Helper.JsonHelper.ObjToStr(new SettingDto() + { + ImageList =new List { "默认图片", "默认图片" }, + InitRole = "普通用户", + Title = "YiFramework", + InitIcon = "默认头像" + }); + if (_cacheClientDB.Get(RedisConst.key)==null) + { + _cacheClientDB.Add(RedisConst.key,setDto) ; + } + + Console.WriteLine(nameof(RedisInit) + ":Redis初始成功!"); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/CAPExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/CAPExtend.cs new file mode 100644 index 00000000..b7014130 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/CAPExtend.cs @@ -0,0 +1,59 @@ +using DotNetCore.CAP.Dashboard.NodeDiscovery; +using DotNetCore.CAP.Messages; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + public static class CAPExtend + { + public static IServiceCollection AddCAPService(this IServiceCollection services) + { + if (Appsettings.appBool("CAP_Enabled")) + { + services.AddCap(x => + { + x.UseMySql(Appsettings.app("DbConn", "WriteUrl")); + + x.UseRabbitMQ(optios => { + optios.HostName = Appsettings.app("RabbitConn", "HostName"); + optios.Port =Convert.ToInt32(Appsettings.app("RabbitConn", "Port")); + optios.UserName = Appsettings.app("RabbitConn", "UserName"); + optios.Password = Appsettings.app("RabbitConn", "Password"); + + }); + x.FailedRetryCount = 30; + x.FailedRetryInterval = 60;//second + x.FailedThresholdCallback = failed => + { + var logger = failed.ServiceProvider.GetService>(); + logger.LogError($@"MessageType {failed.MessageType} 失败了, 重试了 {x.FailedRetryCount} 次, + 消息名称: {failed.Message.GetName()}");//do anything + }; + if (Appsettings.appBool("CAPDashboard_Enabled")) + { + x.UseDashboard(); + var discoveryOptions = Appsettings.app(); + x.UseDiscovery(d => + { + d.DiscoveryServerHostName = discoveryOptions.DiscoveryServerHostName; + d.DiscoveryServerPort = discoveryOptions.DiscoveryServerPort; + d.CurrentNodeHostName = discoveryOptions.CurrentNodeHostName; + d.CurrentNodePort = discoveryOptions.CurrentNodePort; + d.NodeId = discoveryOptions.NodeId; + d.NodeName = discoveryOptions.NodeName; + d.MatchPath = discoveryOptions.MatchPath; + }); + } + }); + + } + return services; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ConsulRegiterExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ConsulRegiterExtend.cs new file mode 100644 index 00000000..7c8ab310 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ConsulRegiterExtend.cs @@ -0,0 +1,61 @@ +using Consul; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.IOCOptions; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// HTTP模式 + /// + public static class ConsulRegiterExtend + { + /// + /// 基于提供信息完成注册 + /// + /// + /// + /// + public static void UseConsulService(this IApplicationBuilder app) + { + + if (Appsettings.appBool("Consul_Enabled")) + { + var consulRegisterOption = Appsettings.app("ConsulRegisterOption"); + + var consulClientOption = Appsettings.app("ConsulClientOption"); + using (ConsulClient client = new ConsulClient(c => + { + c.Address = new Uri($"http://{consulClientOption.IP}:{consulClientOption.Port}/"); + c.Datacenter = consulClientOption.Datacenter; + })) + { + client.Agent.ServiceRegister(new AgentServiceRegistration() + { + ID = $"{consulRegisterOption.IP}-{consulRegisterOption.Port}-{Guid.NewGuid()}",//唯一Id + Name = consulRegisterOption.GroupName,//组名称-Group + Address = consulRegisterOption.IP, + Port = consulRegisterOption.Port, + Tags = new string[] { consulRegisterOption.Tag }, + Check = new AgentServiceCheck() + { + Interval = TimeSpan.FromSeconds(consulRegisterOption.Interval), + HTTP = $"http://{consulRegisterOption.IP}:{consulRegisterOption.Port}{consulRegisterOption.HealthCheckUrl}", + Timeout = TimeSpan.FromSeconds(consulRegisterOption.Timeout), + DeregisterCriticalServiceAfter = TimeSpan.FromSeconds(consulRegisterOption.DeregisterCriticalServiceAfter) + } + }).Wait(); + Console.WriteLine($"{JsonConvert.SerializeObject(consulRegisterOption)} 完成注册"); + } + } + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/CorsExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/CorsExtension.cs new file mode 100644 index 00000000..cdfd12fe --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/CorsExtension.cs @@ -0,0 +1,39 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.IO; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// 通用跨域扩展 + /// + public static class CorsExtension + { + public static IServiceCollection AddCorsService(this IServiceCollection services) + { + + if (Appsettings.appBool("Cors_Enabled")) + { + services.AddCors(options => options.AddPolicy("CorsPolicy",//解决跨域问题 + builder => + { + builder.AllowAnyMethod() + .SetIsOriginAllowed(_ => true) + .AllowAnyHeader() + .AllowCredentials(); + })); + } + return services; + } + + public static void UseCorsService(this IApplicationBuilder app) + { + if (Appsettings.appBool("Cors_Enabled")) + { + app.UseCors("CorsPolicy"); + } + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/DbExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/DbExtend.cs new file mode 100644 index 00000000..afc20ff6 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/DbExtend.cs @@ -0,0 +1,24 @@ +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.IOCOptions; +using Yi.Framework.Model; +using Yi.Framework.Model.ModelFactory; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + public static class DbExtend + { + public static IServiceCollection AddDbService(this IServiceCollection services) + { + DbContextFactory.MutiDB_Enabled = Appsettings.appBool("MutiDB_Enabled"); + DataContext.DbSelect = Appsettings.app("DbSelect"); + DataContext._connStr = Appsettings.app("DbConn", "WriteUrl"); + services.Configure(Appsettings.appConfiguration("DbConn")); + return services; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/DbSeedInitExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/DbSeedInitExtend.cs new file mode 100644 index 00000000..d43e2913 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/DbSeedInitExtend.cs @@ -0,0 +1,36 @@ +using log4net; +using Microsoft.AspNetCore.Builder; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.ModelFactory; +using Yi.Framework.WebCore.Init; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + public static class DbSeedInitExtend + { + private static readonly ILog log = LogManager.GetLogger(typeof(DbSeedInitExtend)); + public static void UseDbSeedInitService(this IApplicationBuilder app, IDbContextFactory _DbFactory) + { + + if (Appsettings.appBool("DbSeed_Enabled")) + { + if (app == null) throw new ArgumentNullException(nameof(app)); + + try + { + DataSeed.SeedAsync(_DbFactory).Wait(); + } + catch (Exception e) + { + log.Error($"Error occured seeding the Database.\n{e.Message}"); + throw; + } + } + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ElasticSeachExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ElasticSeachExtend.cs new file mode 100644 index 00000000..cfdaff61 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ElasticSeachExtend.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; +using System; +using System.IO; +using Yi.Framework.Common.IOCOptions; +using Yi.Framework.Core; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// Redis扩展 + /// + public static class ElasticSeachExtend + { + public static IServiceCollection AddElasticSeachService(this IServiceCollection services) + { + if (Appsettings.appBool("ElasticSeach_Enabled")) + { + services.Configure(Appsettings.appConfiguration("ElasticSeachConn")); + services.AddTransient(); + } + return services; + + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs new file mode 100644 index 00000000..eed13c4c --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/ErrorHandExtension.cs @@ -0,0 +1,82 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Common.Models; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// 异常抓取反馈扩展 + /// + public class ErrorHandExtension + { + private readonly RequestDelegate next; + + public ErrorHandExtension(RequestDelegate next) + { + this.next = next; + } + + public async Task Invoke(HttpContext context) + { + try + { + await next(context); + } + catch (Exception ex) + { + var statusCode = context.Response.StatusCode; + if (ex is ArgumentException) + { + statusCode = 200; + } + await HandleExceptionAsync(context, statusCode, ex.Message); + } + finally + { + var statusCode = context.Response.StatusCode; + var msg = ""; + + switch (statusCode) + { + case 401: msg = "未授权";break; + case 403: msg = "未授权"; break; + case 404: msg = "未找到服务"; break; + case 502: msg = "请求错误"; break; + } + if (!string.IsNullOrWhiteSpace(msg)) + { + await HandleExceptionAsync(context, statusCode, msg); + } + } + } + //异常错误信息捕获,将错误信息用Json方式返回 + private static Task HandleExceptionAsync(HttpContext context, int statusCode, string msg) + { + Result resp; + if (statusCode == 401) + { + resp = Result.UnAuthorize(msg); + } + else + { + resp = Result.Error(msg); + } + var result = JsonConvert.SerializeObject(resp); + context.Response.ContentType = "application/json;charset=utf-8"; + return context.Response.WriteAsync(result); + } + } + //扩展方法 + public static class ErrorHandlingExtensions + { + public static IApplicationBuilder UseErrorHandlingService(this IApplicationBuilder builder) + { + return builder.UseMiddleware(); + } + } +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/HealthCheckExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/HealthCheckExtension.cs new file mode 100644 index 00000000..0a489f8a --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/HealthCheckExtension.cs @@ -0,0 +1,39 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// 健康检测扩展 + /// + public static class HealthCheckExtension + { + /// + /// 设置心跳响应 + /// + /// + /// 默认是/Health + /// + public static void UseHealthCheckMiddleware(this IApplicationBuilder app, string checkPath = "/Health") + { + if (Appsettings.appBool("HealthCheck_Enabled")) + { + app.Map(checkPath, applicationBuilder => applicationBuilder.Run(async context => + { + Console.WriteLine($"This is Health Check"); + context.Response.StatusCode = (int)HttpStatusCode.OK; + await context.Response.WriteAsync("OK"); + })); + } + + + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/IocExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/IocExtension.cs new file mode 100644 index 00000000..b7d73f4f --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/IocExtension.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.IO; +using Yi.Framework.Model; +using Yi.Framework.Model.ModelFactory; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// 通用跨域扩展 + /// + public static class IocExtension + { + public static IServiceCollection AddIocService(this IServiceCollection services, IConfiguration configuration) + { + #region + //配置文件使用配置 + #endregion + services.AddSingleton(new Appsettings(configuration)); + #region + //数据库配置 + #endregion + services.AddTransient(); + return services; + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs new file mode 100644 index 00000000..eb8b04a4 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/JwtExtension.cs @@ -0,0 +1,39 @@ +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Tokens; +using System; +using System.IO; +using System.Text; +using Yi.Framework.Common.Const; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// 通用跨域扩展 + /// + public static class JwtExtension + { + public static IServiceCollection AddJwtService(this IServiceCollection services) + { + services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(options => + { + options.TokenValidationParameters = new TokenValidationParameters + { + ValidateIssuer = true,//是否验证Issuer + ValidateAudience = true,//是否验证Audience + ValidateLifetime = true,//是否验证失效时间 + ClockSkew = TimeSpan.FromDays(1), + + ValidateIssuerSigningKey = true,//是否验证SecurityKey + ValidAudience = JwtConst.Domain,//Audience + ValidIssuer = JwtConst.Domain,//Issuer,这两项和前面签发jwt的设置一致 + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(JwtConst.SecurityKey))//拿到SecurityKey + }; + }); + + return services; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/PreOptionRequestExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/PreOptionRequestExtension.cs new file mode 100644 index 00000000..c8d4a251 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/PreOptionRequestExtension.cs @@ -0,0 +1,47 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// 预检请求扩展 + /// + public class PreOptionRequestExtension + { + private readonly RequestDelegate _next; + + public PreOptionRequestExtension(RequestDelegate next) + { + _next = next; + } + + public async Task Invoke(HttpContext context) + { + if (context.Request.Method.ToUpper() == "OPTIONS") + { + //context.Response.Headers.Add("Access-Control-Allow-Origin", "http://localhost:8070"); + //context.Response.Headers.Add("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,PATCH,OPTIONS"); + //context.Response.Headers.Add("Access-Control-Allow-Headers", "*"); + context.Response.StatusCode = 200; + return; + } + await _next.Invoke(context); + } + } + + /// + /// 扩展中间件 + /// + public static class PreOptionsRequestMiddlewareExtensions + { + public static IApplicationBuilder UsePreOptionsRequest(this IApplicationBuilder app) + { + return app.UseMiddleware(); + } + } + +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/QuartzExtensions.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/QuartzExtensions.cs new file mode 100644 index 00000000..4dca1fd7 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/QuartzExtensions.cs @@ -0,0 +1,34 @@ +using Autofac.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; +using Quartz; +using Quartz.Impl; +using Quartz.Spi; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Yi.Framework.Core; +using Yi.Framework.Core.Quartz; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// 启动定时器服务,后台服务 + /// + public static class QuartzExtensions + { + /// + /// 使用定时器 + /// + /// + /// + public static IServiceCollection AddQuartzService(this IServiceCollection services) + { + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + return services; + } + } + +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RabbitMQExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RabbitMQExtension.cs new file mode 100644 index 00000000..e98b49c8 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RabbitMQExtension.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; +using System; +using System.IO; +using Yi.Framework.Common.IOCOptions; +using Yi.Framework.Core; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// Redis扩展 + /// + public static class RabbitMQExtension + { + public static IServiceCollection AddRabbitMQService(this IServiceCollection services) + { + if (Appsettings.appBool("RabbitMQ_Enabled")) + { + services.Configure(Appsettings.appConfiguration("RabbitConn")); + services.AddTransient(); + } + return services; + + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RedisExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RedisExtension.cs new file mode 100644 index 00000000..2d17b857 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RedisExtension.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; +using System; +using System.IO; +using Yi.Framework.Common.IOCOptions; +using Yi.Framework.Core; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// Redis扩展 + /// + public static class RedisExtension + { + public static IServiceCollection AddRedisService(this IServiceCollection services) + { + if (Appsettings.appBool("Redis_Enabled")) + { + services.Configure(Appsettings.appConfiguration("RedisConnOptions")); + services.AddTransient(); + } + return services; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RedisInitExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RedisInitExtend.cs new file mode 100644 index 00000000..010bb42e --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/RedisInitExtend.cs @@ -0,0 +1,37 @@ +using log4net; +using Microsoft.AspNetCore.Builder; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Core; +using Yi.Framework.Model.ModelFactory; +using Yi.Framework.WebCore.Init; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + public static class RedisInitExtend + { + private static readonly ILog log = LogManager.GetLogger(typeof(RedisInitExtend)); + public static void UseRedisSeedInitService(this IApplicationBuilder app, CacheClientDB _cacheClientDB) + { + + if (Appsettings.appBool("RedisSeed_Enabled")) + { + if (app == null) throw new ArgumentNullException(nameof(app)); + + try + { + RedisInit.Seed(_cacheClientDB); + } + catch (Exception e) + { + log.Error($"Error occured seeding the RedisInit.\n{e.Message}"); + throw; + } + } + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SMSExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SMSExtension.cs new file mode 100644 index 00000000..487f02d4 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SMSExtension.cs @@ -0,0 +1,29 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; +using System; +using System.IO; +using Yi.Framework.Common.IOCOptions; +using Yi.Framework.Core; +using Yi.Framework.Core.SMS; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// Redis扩展 + /// + public static class SMSExtension + { + public static IServiceCollection AddSMSService(this IServiceCollection services) + { + if (Appsettings.appBool("SMS_Enabled")) + { + + services.Configure(Appsettings.appConfiguration("SMS")); + services.AddTransient(); + } + return services; + + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/StaticPageExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/StaticPageExtension.cs new file mode 100644 index 00000000..429fdce7 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/StaticPageExtension.cs @@ -0,0 +1,156 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// 静态化页面处理扩展 + /// + public class StaticPageExtension + { + private readonly RequestDelegate _next; + private string _directoryPath = @"D:/cc-yi/"; + private bool _supportDelete = false; + private bool _supportWarmup = false; + + public StaticPageExtension(RequestDelegate next, string directoryPath, bool supportDelete, bool supportWarmup) + { + this._next = next; + this._directoryPath = directoryPath; + this._supportDelete = supportDelete; + this._supportWarmup = supportWarmup; + } + + public async Task InvokeAsync(HttpContext context) + { + if (this._supportDelete && "Delete".Equals(context.Request.Query["ActionHeader"])) + { + this.DeleteHmtl(context.Request.Path.Value); + context.Response.StatusCode = 200; + } + else if (this._supportWarmup && "ClearAll".Equals(context.Request.Query["ActionHeader"])) + { + this.ClearDirectory(10);//考虑数据量 + context.Response.StatusCode = 200; + } + else if (!context.Request.IsAjaxRequest()) + { + Console.WriteLine($"This is StaticPageMiddleware InvokeAsync {context.Request.Path.Value}"); + #region context.Response.Body + var originalStream = context.Response.Body; + using (var copyStream = new MemoryStream()) + { + context.Response.Body = copyStream; + await _next(context); + + copyStream.Position = 0; + var reader = new StreamReader(copyStream); + var content = await reader.ReadToEndAsync(); + string url = context.Request.Path.Value; + + this.SaveHmtl(url, content); + + copyStream.Position = 0; + await copyStream.CopyToAsync(originalStream); + context.Response.Body = originalStream; + } + #endregion + } + else + { + await _next(context); + } + } + + private void SaveHmtl(string url, string html) + { + try + { + //Console.WriteLine($"Response: {html}"); + if (string.IsNullOrWhiteSpace(html)) + return; + if (!url.EndsWith(".html")) + return; + + if (Directory.Exists(_directoryPath) == false) + Directory.CreateDirectory(_directoryPath); + + var totalPath = Path.Combine(_directoryPath, url.Split("/").Last()); + File.WriteAllText(totalPath, html);//直接覆盖 + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } + + /// + /// 删除某个页面 + /// + /// + /// + private void DeleteHmtl(string url) + { + try + { + if (!url.EndsWith(".html")) + return; + var totalPath = Path.Combine(_directoryPath, url.Split("/").Last()); + File.Delete(totalPath);//直接删除 + } + catch (Exception ex) + { + Console.WriteLine($"Delete {url} 异常,{ex.Message}"); + } + } + + /// + /// 清理文件,支持重试 + /// + /// 最多重试次数 + private void ClearDirectory(int index) + { + if (index > 0)//简陋版---重试index次 + { + try + { + var files = Directory.GetFiles(_directoryPath); + foreach (var file in files) + { + File.Delete(file); + } + } + catch (Exception ex) + { + Console.WriteLine($"ClearDirectory failed {ex.Message}"); + ClearDirectory(index--); + } + } + } + } + + /// + /// 扩展中间件 + /// + public static class StaticPageMiddlewareExtensions + { + /// + /// + /// + /// + /// 文件写入地址,文件夹目录 + /// 是否支持删除 + /// 是否支持全量删除 + /// + public static IApplicationBuilder UseStaticPageMiddleware(this IApplicationBuilder app, string directoryPath, bool supportDelete, bool supportClear) + { + return app.UseMiddleware(directoryPath, supportDelete, supportClear); + } + } +} \ No newline at end of file diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs new file mode 100644 index 00000000..5eb04bca --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs @@ -0,0 +1,124 @@ +using IGeekFan.AspNetCore.Knife4jUI; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; +using System; +using System.IO; +using Yi.Framework.Common.Models; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// Swagger扩展 + /// + public static class SwaggerExtension + { + public static IServiceCollection AddSwaggerService(this IServiceCollection services, string title = "Yi意框架-API接口") + { + var apiInfo = new OpenApiInfo + { + Title = title, + Version = "v1", + Contact = new OpenApiContact { Name = "橙子", Email = "454313500@qq.com", Url = new System.Uri("https://ccnetcore.com") } + }; + #region 注册Swagger服务 + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", apiInfo); + + //添加注释服务 + //为 Swagger JSON and UI设置xml文档注释路径 + //获取应用程序所在目录(绝对路径,不受工作目录影响,建议采用此方法获取路径使用windwos&Linux) + var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location); + var apiXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//控制器层注释 + //var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释 + //c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释 + c.IncludeXmlComments(apiXmlPath,true); + + //添加控制器注释 + //c.DocumentFilter(); + + //添加header验证信息 + //c.OperationFilter(); + //var security = new Dictionary> { { "Bearer", new string[] { } }, }; + + c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme() + { + Description = "文本框里输入从服务器获取的Token。格式为:Bearer + 空格+token",//JWT授权(数据将在请求头中进行传输) 参数结构: \"Authorization: Bearer {token}\" + Name = "Authorization",////jwt默认的参数名称 + In = ParameterLocation.Header,////jwt默认存放Authorization信息的位置(请求头中) + Type = SecuritySchemeType.ApiKey, + }); + c.AddSecurityRequirement(new OpenApiSecurityRequirement + { + { new OpenApiSecurityScheme + { + Reference = new OpenApiReference() + { + Id = "Bearer", + Type = ReferenceType.SecurityScheme + } + }, Array.Empty() } + }); + + c.AddServer(new OpenApiServer() + { + Url = "https://ccnetcore.com", + Description = "Yi-Framework" + }); + c.CustomOperationIds(apiDesc => + { + var controllerAction = apiDesc.ActionDescriptor as ControllerActionDescriptor; + return controllerAction.ActionName; + }); + }); + #endregion + + return services; + } + + public static void UseSwaggerService(this IApplicationBuilder app, params SwaggerModel[] swaggerModels) + { + //在 Startup.Configure 方法中,启用中间件为生成的 JSON 文档和 Swagger UI 提供服务: + // Enable middleware to serve generated Swagger as a JSON endpoint. + app.UseSwagger(); + + + app.UseKnife4UI(c => + { + c.RoutePrefix = "swagger"; // serve the UI at root + if (swaggerModels.Length == 0) + { + c.SwaggerEndpoint("/v1/swagger.json", "Yi.Framework"); + } + else + { + foreach (var k in swaggerModels) + { + c.SwaggerEndpoint(k.url, k.name); + } + } + }); + + //app.UseSwaggerUI(c => + //{ + // if (swaggerModels.Length == 0) + // { + // c.SwaggerEndpoint("/swagger/v1/swagger.json", "Yi.Framework"); + // } + // else + // { + // foreach (var k in swaggerModels) + // { + // c.SwaggerEndpoint(k.url, k.name); + // } + // } + + //} + + //); + } + + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomAutofacAop.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomAutofacAop.cs new file mode 100644 index 00000000..85b0c251 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomAutofacAop.cs @@ -0,0 +1,21 @@ +using Castle.DynamicProxy; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Yi.Framework.WebCore.Utility +{ + public class CustomAutofacAop : IInterceptor + { + public void Intercept(IInvocation invocation) + { + Console.WriteLine($"invocation.Methond={invocation.Method}"); + Console.WriteLine($"invocation.Arguments={string.Join(",", invocation.Arguments)}"); + + invocation.Proceed(); //继续执行 + + Console.WriteLine($"方法{invocation.Method}执行完成了"); + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs new file mode 100644 index 00000000..f39b0d8d --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomAutofacModule.cs @@ -0,0 +1,88 @@ +using Autofac; +using Autofac.Extras.DynamicProxy; +using Castle.DynamicProxy; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc.ApplicationParts; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using Yi.Framework.Job; +using Yi.Framework.Model.ModelFactory; +using Yi.Framework.WebCore.Utility; +using Module = Autofac.Module; + +namespace Yi.Framework.WebCore.Utility +{ + public class CustomAutofacModule : Module + { + private Assembly GetDll(string ass) + { + var basePath = AppContext.BaseDirectory; + var servicesDllFile = Path.Combine(basePath, ass); + if (!(File.Exists(servicesDllFile))) + { + var msg = "service.dll 丢失,请编译后重新生成。"; + throw new Exception(msg); + } + return Assembly.LoadFrom(servicesDllFile); ; + } + + protected override void Load(ContainerBuilder containerBuilder) + { + + containerBuilder.RegisterType().As().InstancePerDependency().EnableInterfaceInterceptors(); + + containerBuilder.RegisterType< HttpContextAccessor>().As().SingleInstance(); + + + + ///反射注入服务层及接口层 + var assemblysServices = GetDll( "Yi.Framework.Service.dll"); + containerBuilder.RegisterAssemblyTypes(assemblysServices) + .AsImplementedInterfaces() + .InstancePerDependency() + .EnableInterfaceInterceptors(); + +///反射注册任务调度层 + var assemblysJob = GetDll("Yi.Framework.Job.dll"); + containerBuilder.RegisterAssemblyTypes(assemblysJob) + .InstancePerDependency(); + + + + containerBuilder.Register(c => new CustomAutofacAop());//AOP注册 + + + //containerBuilder.RegisterType().As().EnableInterfaceInterceptors();开启Aop + + //将数据库对象注入 + //containerBuilder.RegisterType().As().InstancePerLifetimeScope().EnableInterfaceInterceptors(); + + //containerBuilder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).InstancePerDependency().EnableInterfaceInterceptors(); + + + + } + + } +} + + +public interface IAutofacTest +{ + void Show(int id, string name); +} + +[Intercept(typeof(CustomAutofacAop))] +public class AutofacTest : IAutofacTest +{ + public void Show(int id, string name) + { + Console.WriteLine($"This is {id} _ {name}"); + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomHostingStartup.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomHostingStartup.cs new file mode 100644 index 00000000..58fcabb7 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Utility/CustomHostingStartup.cs @@ -0,0 +1,54 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +[assembly: HostingStartup(typeof(Yi.Framework.WebCore.Utility.CustomHostingStartup))] +namespace Yi.Framework.WebCore.Utility +{ + /// + /// 必须实现IHostingStartup接口 + /// 必须标记HostingStartup特性 + /// + /// 就像木马一样 + /// + public class CustomHostingStartup : IHostingStartup + { + public void Configure(IWebHostBuilder builder) + { + Console.WriteLine("This is CustomHostingStartup Invoke"); + + //有IWebHostBuilder,一切都可以做。。 + #region MyRegion + //builder.ConfigureAppConfiguration(configurationBuilder => + //{ + // configurationBuilder.AddXmlFile("appsettings1.xml", optional: false, reloadOnChange: true); + //});//添加配置 + + //builder.ConfigureServices(services => + //{ + // services.AddTransient(); + //});//IOC注册 + + //builder.Configure(app => + //{ + // app.Use(next => + // { + // Console.WriteLine("This is CustomHostingStartup-Middleware Init"); + // return new RequestDelegate( + // async context => + // { + // Console.WriteLine("This is CustomHostingStartup-Middleware start"); + // await next.Invoke(context); + // Console.WriteLine("This is CustomHostingStartup-Middleware end"); + // }); + // }); + //});//甚至来个中间件 + #endregion + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj b/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj new file mode 100644 index 00000000..b0418029 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj @@ -0,0 +1,34 @@ + + + + net6.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Yi.Framework.Net6/Yi.Framework.sln b/Yi.Framework.Net6/Yi.Framework.sln new file mode 100644 index 00000000..73747fd5 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.sln @@ -0,0 +1,129 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BackGround", "BackGround", "{D6B44435-EAFA-4D55-90D0-3AF80485FB83}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Client", "Client", "{C90E38FB-69EA-4997-8B3A-2C71EFA65B2B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{DB2506F5-05FD-4E76-940E-41D7AA148550}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{9ABAF6B1-6C02-498A-90A2-ABC1140CF89A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MicroServiceInstance", "MicroServiceInstance", "{026D2797-07D1-4BA5-8070-50CDE0258C59}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.DTOModel", "Yi.Framework.DTOModel\Yi.Framework.DTOModel.csproj", "{5B6C87F0-CEBA-4A0A-8C30-02E927AB4AEF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Interface", "Yi.Framework.Interface\Yi.Framework.Interface.csproj", "{5935EC64-7414-47D8-B934-E5896DD89E4E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Model", "Yi.Framework.Model\Yi.Framework.Model.csproj", "{F0EE03CF-30C9-4C48-BF32-FED6F3BCFB4C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Service", "Yi.Framework.Service\Yi.Framework.Service.csproj", "{C5E41276-A30F-4098-BA79-2E8920BBD02A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Common", "Yi.Framework.Common\Yi.Framework.Common.csproj", "{4816AA7B-7222-4B3B-A178-C2A70713E9D1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Core", "Yi.Framework.Core\Yi.Framework.Core.csproj", "{07A80C17-E03E-475D-9BBF-98E3B1393652}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.WebCore", "Yi.Framework.WebCore\Yi.Framework.WebCore.csproj", "{E4734315-158C-4D35-AF01-1122C22F2955}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.ApiMicroservice", "Yi.Framework.ApiMicroservice\Yi.Framework.ApiMicroservice.csproj", "{A95157D2-907F-411E-BA1D-A17F48C54A0E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.OcelotGateway", "Yi.Framework.OcelotGateway\Yi.Framework.OcelotGateway.csproj", "{671E38D8-ECAF-484B-A2AE-63DDC469C315}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.AuthenticationCenter", "Yi.Framework.AuthenticationCenter\Yi.Framework.AuthenticationCenter.csproj", "{694C0EC0-ED32-4E5D-8EA1-FB82E1303EAB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.ElasticSearchProcessor", "Yi.Framework.ElasticSearchProcessor\Yi.Framework.ElasticSearchProcessor.csproj", "{EEF89893-A6A9-4C02-818C-D116C8EAE0EF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.MSUnitTest", "Yi.Framework.MSUnitTest\Yi.Framework.MSUnitTest.csproj", "{531255B3-9669-4BC1-B4E5-A0C6E0540F0D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.Job", "Yi.Framework.Task\Yi.Framework.Job.csproj", "{F1C990DD-32C3-4F02-83B0-6E52B18B0B17}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.SMSProcessor", "Yi.Framework.SMSProcessor\Yi.Framework.SMSProcessor.csproj", "{7C58FB7C-9AB5-47CF-ACEB-B784CF820E7E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5B6C87F0-CEBA-4A0A-8C30-02E927AB4AEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5B6C87F0-CEBA-4A0A-8C30-02E927AB4AEF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5B6C87F0-CEBA-4A0A-8C30-02E927AB4AEF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5B6C87F0-CEBA-4A0A-8C30-02E927AB4AEF}.Release|Any CPU.Build.0 = Release|Any CPU + {5935EC64-7414-47D8-B934-E5896DD89E4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5935EC64-7414-47D8-B934-E5896DD89E4E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5935EC64-7414-47D8-B934-E5896DD89E4E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5935EC64-7414-47D8-B934-E5896DD89E4E}.Release|Any CPU.Build.0 = Release|Any CPU + {F0EE03CF-30C9-4C48-BF32-FED6F3BCFB4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F0EE03CF-30C9-4C48-BF32-FED6F3BCFB4C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F0EE03CF-30C9-4C48-BF32-FED6F3BCFB4C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F0EE03CF-30C9-4C48-BF32-FED6F3BCFB4C}.Release|Any CPU.Build.0 = Release|Any CPU + {C5E41276-A30F-4098-BA79-2E8920BBD02A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5E41276-A30F-4098-BA79-2E8920BBD02A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5E41276-A30F-4098-BA79-2E8920BBD02A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5E41276-A30F-4098-BA79-2E8920BBD02A}.Release|Any CPU.Build.0 = Release|Any CPU + {4816AA7B-7222-4B3B-A178-C2A70713E9D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4816AA7B-7222-4B3B-A178-C2A70713E9D1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4816AA7B-7222-4B3B-A178-C2A70713E9D1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4816AA7B-7222-4B3B-A178-C2A70713E9D1}.Release|Any CPU.Build.0 = Release|Any CPU + {07A80C17-E03E-475D-9BBF-98E3B1393652}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {07A80C17-E03E-475D-9BBF-98E3B1393652}.Debug|Any CPU.Build.0 = Debug|Any CPU + {07A80C17-E03E-475D-9BBF-98E3B1393652}.Release|Any CPU.ActiveCfg = Release|Any CPU + {07A80C17-E03E-475D-9BBF-98E3B1393652}.Release|Any CPU.Build.0 = Release|Any CPU + {E4734315-158C-4D35-AF01-1122C22F2955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E4734315-158C-4D35-AF01-1122C22F2955}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E4734315-158C-4D35-AF01-1122C22F2955}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E4734315-158C-4D35-AF01-1122C22F2955}.Release|Any CPU.Build.0 = Release|Any CPU + {A95157D2-907F-411E-BA1D-A17F48C54A0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A95157D2-907F-411E-BA1D-A17F48C54A0E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A95157D2-907F-411E-BA1D-A17F48C54A0E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A95157D2-907F-411E-BA1D-A17F48C54A0E}.Release|Any CPU.Build.0 = Release|Any CPU + {671E38D8-ECAF-484B-A2AE-63DDC469C315}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {671E38D8-ECAF-484B-A2AE-63DDC469C315}.Debug|Any CPU.Build.0 = Debug|Any CPU + {671E38D8-ECAF-484B-A2AE-63DDC469C315}.Release|Any CPU.ActiveCfg = Release|Any CPU + {671E38D8-ECAF-484B-A2AE-63DDC469C315}.Release|Any CPU.Build.0 = Release|Any CPU + {694C0EC0-ED32-4E5D-8EA1-FB82E1303EAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {694C0EC0-ED32-4E5D-8EA1-FB82E1303EAB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {694C0EC0-ED32-4E5D-8EA1-FB82E1303EAB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {694C0EC0-ED32-4E5D-8EA1-FB82E1303EAB}.Release|Any CPU.Build.0 = Release|Any CPU + {EEF89893-A6A9-4C02-818C-D116C8EAE0EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EEF89893-A6A9-4C02-818C-D116C8EAE0EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EEF89893-A6A9-4C02-818C-D116C8EAE0EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EEF89893-A6A9-4C02-818C-D116C8EAE0EF}.Release|Any CPU.Build.0 = Release|Any CPU + {531255B3-9669-4BC1-B4E5-A0C6E0540F0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {531255B3-9669-4BC1-B4E5-A0C6E0540F0D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {531255B3-9669-4BC1-B4E5-A0C6E0540F0D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {531255B3-9669-4BC1-B4E5-A0C6E0540F0D}.Release|Any CPU.Build.0 = Release|Any CPU + {F1C990DD-32C3-4F02-83B0-6E52B18B0B17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1C990DD-32C3-4F02-83B0-6E52B18B0B17}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1C990DD-32C3-4F02-83B0-6E52B18B0B17}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1C990DD-32C3-4F02-83B0-6E52B18B0B17}.Release|Any CPU.Build.0 = Release|Any CPU + {7C58FB7C-9AB5-47CF-ACEB-B784CF820E7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7C58FB7C-9AB5-47CF-ACEB-B784CF820E7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7C58FB7C-9AB5-47CF-ACEB-B784CF820E7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7C58FB7C-9AB5-47CF-ACEB-B784CF820E7E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {5B6C87F0-CEBA-4A0A-8C30-02E927AB4AEF} = {DB2506F5-05FD-4E76-940E-41D7AA148550} + {5935EC64-7414-47D8-B934-E5896DD89E4E} = {DB2506F5-05FD-4E76-940E-41D7AA148550} + {F0EE03CF-30C9-4C48-BF32-FED6F3BCFB4C} = {DB2506F5-05FD-4E76-940E-41D7AA148550} + {C5E41276-A30F-4098-BA79-2E8920BBD02A} = {DB2506F5-05FD-4E76-940E-41D7AA148550} + {4816AA7B-7222-4B3B-A178-C2A70713E9D1} = {9ABAF6B1-6C02-498A-90A2-ABC1140CF89A} + {07A80C17-E03E-475D-9BBF-98E3B1393652} = {9ABAF6B1-6C02-498A-90A2-ABC1140CF89A} + {E4734315-158C-4D35-AF01-1122C22F2955} = {9ABAF6B1-6C02-498A-90A2-ABC1140CF89A} + {A95157D2-907F-411E-BA1D-A17F48C54A0E} = {026D2797-07D1-4BA5-8070-50CDE0258C59} + {671E38D8-ECAF-484B-A2AE-63DDC469C315} = {D6B44435-EAFA-4D55-90D0-3AF80485FB83} + {694C0EC0-ED32-4E5D-8EA1-FB82E1303EAB} = {D6B44435-EAFA-4D55-90D0-3AF80485FB83} + {EEF89893-A6A9-4C02-818C-D116C8EAE0EF} = {D6B44435-EAFA-4D55-90D0-3AF80485FB83} + {531255B3-9669-4BC1-B4E5-A0C6E0540F0D} = {C90E38FB-69EA-4997-8B3A-2C71EFA65B2B} + {F1C990DD-32C3-4F02-83B0-6E52B18B0B17} = {9ABAF6B1-6C02-498A-90A2-ABC1140CF89A} + {7C58FB7C-9AB5-47CF-ACEB-B784CF820E7E} = {D6B44435-EAFA-4D55-90D0-3AF80485FB83} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1ED77A6E-377F-4EEF-A3D0-D65C94657DAF} + EndGlobalSection +EndGlobal diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Properties/launchSettings.json b/Yi.Framework/Yi.Framework.ApiMicroservice/Properties/launchSettings.json deleted file mode 100644 index 394d1b04..00000000 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Properties/launchSettings.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:56243", - "sslPort": 44329 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Yi.Framework.ApiMicroservice": { - "commandName": "Project", - "dotnetRunMessages": "true", - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "https://localhost:5001;http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/Yi.Framework/Yi.Framework.AuthenticationCenter/Properties/launchSettings.json b/Yi.Framework/Yi.Framework.AuthenticationCenter/Properties/launchSettings.json deleted file mode 100644 index 3a968be9..00000000 --- a/Yi.Framework/Yi.Framework.AuthenticationCenter/Properties/launchSettings.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:55249", - "sslPort": 44360 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Yi.Framework.AuthenticationCenter": { - "commandName": "Project", - "dotnetRunMessages": "true", - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "https://localhost:5001;http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/Yi.Framework/Yi.Framework.AuthenticationCenter/appsettings.Development.json b/Yi.Framework/Yi.Framework.AuthenticationCenter/appsettings.Development.json deleted file mode 100644 index 8983e0fc..00000000 --- a/Yi.Framework/Yi.Framework.AuthenticationCenter/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/Yi.Framework/Yi.Framework.AuthenticationCenter/appsettings.json b/Yi.Framework/Yi.Framework.AuthenticationCenter/appsettings.json deleted file mode 100644 index d9d9a9bf..00000000 --- a/Yi.Framework/Yi.Framework.AuthenticationCenter/appsettings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "AllowedHosts": "*" -} diff --git a/Yi.Framework/Yi.Framework.ElasticSearchProcessor/configuration.json b/Yi.Framework/Yi.Framework.ElasticSearchProcessor/configuration.json deleted file mode 100644 index 3fa71f14..00000000 --- a/Yi.Framework/Yi.Framework.ElasticSearchProcessor/configuration.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Apollo": { - "AppId": "Yi.Framework.ApiMicroservice", - "Env": "DEV", - "MetaServer": "http://192.168.2.168:8080", - "ConfigServer": [ "http://192.168.2.168:8080" ] - } -} \ No newline at end of file diff --git a/Yi.Framework/Yi.Framework.OcelotGateway/Properties/launchSettings.json b/Yi.Framework/Yi.Framework.OcelotGateway/Properties/launchSettings.json deleted file mode 100644 index 45ed6a09..00000000 --- a/Yi.Framework/Yi.Framework.OcelotGateway/Properties/launchSettings.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:54400", - "sslPort": 44373 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Yi.Framework.OcelotGateway": { - "commandName": "Project", - "dotnetRunMessages": "true", - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "https://localhost:5001;http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/Yi.Framework/Yi.Framework.OcelotGateway/appsettings.Development.json b/Yi.Framework/Yi.Framework.OcelotGateway/appsettings.Development.json deleted file mode 100644 index 8983e0fc..00000000 --- a/Yi.Framework/Yi.Framework.OcelotGateway/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/Yi.Framework/Yi.Framework.OcelotGateway/appsettings.json b/Yi.Framework/Yi.Framework.OcelotGateway/appsettings.json deleted file mode 100644 index 3d943a6e..00000000 --- a/Yi.Framework/Yi.Framework.OcelotGateway/appsettings.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "AllowedHosts": "*", - "Apollo": { - "AppId": "Yi.Framework.OcelotGateway", - "Env": "DEV", - "MetaServer": "http://192.168.2.168:8080", - "ConfigServer": [ "http://192.168.2.168:8080" ] - }, - "JWTTokenOptions": { - "Audience": "http://localhost:7000", - "Issuer": "http://localhost:7000", - "SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB" - } -} diff --git a/Yi.Framework/Yi.Framework.OcelotGateway/configuration.json b/Yi.Framework/Yi.Framework.OcelotGateway/configuration.json deleted file mode 100644 index 026deea0..00000000 --- a/Yi.Framework/Yi.Framework.OcelotGateway/configuration.json +++ /dev/null @@ -1,432 +0,0 @@ -////*****************************ַʵؾ+Consul******************************** -//{ -// "Routes": [ -// { -// "DownstreamPathTemplate": "/api/{url}", //ַ--url -// "DownstreamScheme": "http", -// "UpstreamPathTemplate": "/T/{url}", //صַ--url -// "UpstreamHttpMethod": [ "Get", "Post" ], -// "UseServiceDiscovery": true, -// "ServiceName": "ZhaoxiService", //consul -// "LoadBalancerOptions": { -// "Type": "RoundRobin" //ѯ LeastConnection-ķ NoLoadBalanceؾ -// } -// } -// ], -// "GlobalConfiguration": { -// "BaseUrl": "http://127.0.0.1:6299", //ضַ -// "ServiceDiscoveryProvider": { -// "Host": "47.95.2.2", -// "Port": 8089, -// "Type": "Consul" //Consulṩ, ÿȥconsul -// } //Ocelotû֧öConsul - -// //,"ServiceDiscoveryProvider": { -// // "Host": "localhost", -// // "Port": 8500, -// // "Type": "PollConsul", //Consulṩ, -// // "PollingInterval": 1000 //ѯconsul,Ƶʺ--downDz֪ -// // //"Token": "footoken"//ҪACLĻ -// //} -// } -//} - - - -//*****************************Ocelot+Consul******************************** -{ - "Routes": [ - { - "UpstreamPathTemplate": "api/api/{url}", //ַ-- - "UpstreamHttpMethod": [ "Get", "Post", "Put", "PATCH", "Delete", "Options" ], - "UseServiceDiscovery": true, - "ServiceName": "ApiMicroservice", - "LoadBalancerOptions": { - "Type": "RoundRobin" //ѯ LeastConnection-ķ NoLoadBalanceؾ - }, - "DownstreamPathTemplate": "api/api/{url}", //ַ--url - "DownstreamScheme": "https", - "DownstreamHeaderTransform": { - "Access-Control-Allow-Origin": "*", //ھ - "Access-Control-Allow-Methods": "*", - "Access-Control-Allow-Headers": "*" - } - }, - { - "UpstreamPathTemplate": "api/item/{url}", //ַ-- - "UpstreamHttpMethod": [ "Get", "Post", "Put", "PATCH", "Delete", "Options" ], - "UseServiceDiscovery": true, - "ServiceName": "PageDetail", - "LoadBalancerOptions": { - "Type": "RoundRobin" //ѯ LeastConnection-ķ NoLoadBalanceؾ - }, - "DownstreamPathTemplate": "api/item/{url}", //ַ--url - "DownstreamScheme": "https", - "DownstreamHeaderTransform": { - "Access-Control-Allow-Origin": "*", //ھ - "Access-Control-Allow-Methods": "*", - "Access-Control-Allow-Headers": "*" - } - } - ], - "GlobalConfiguration": { - "BaseUrl": "http://127.0.0.1:7200", //ضַ - "ServiceDiscoveryProvider": { - "Host": "192.168.2.128", - "Port": 8500, - "Type": "Consul" //Consulṩ, ÿȥconsul - }, - "RateLimitOptions": { - "QuotaExceededMessage": "ƵԺԣ", // رضʱصϢ - "HttpStatusCode": 666 // رضʱصhttp status - //"ClientIdHeader": "client_id" // ʶͻ˵ͷĬ ClientId - } - - //,"ServiceDiscoveryProvider": { - // "Host": "localhost", - // "Port": 8500, - // "Type": "PollConsul", //Consulṩ, - // "PollingInterval": 1000 //ѯconsul,Ƶʺ--downDz֪ - // //"Token": "footoken"//ҪACLĻ - //} - } -} - -////*****************************ַ--Consul******************************** -//{ -// "Routes": [ -// { -// "UpstreamPathTemplate": "/api/auth/{url}", //ַ-- -// "UpstreamHttpMethod": [ "Get", "Post", "Put", "PATCH", "Delete", "Options" ], -// "DownstreamHostAndPorts": [ -// { -// "Host": "localhost", -// "Port": 7200 //api ˿ -// } -// ], -// "DownstreamPathTemplate": "/api/{url}", //ַ--url -// "DownstreamScheme": "http", -// "DownstreamHeaderTransform": { -// "Access-Control-Allow-Origin": "*", //ھ -// "Access-Control-Allow-Methods": "*", -// "Access-Control-Allow-Headers": "*" -// } -// } -// ] -//} - -////*****************************ַȫƥ******************************** -//{ -// "Routes": [ -// { -// "DownstreamPathTemplate": "/{url}", //ַ--url -// "DownstreamScheme": "http", -// "DownstreamHostAndPorts": [ -// { -// "Host": "localhost", -// "Port": 5726 //˿ -// } -// ], -// "UpstreamPathTemplate": "/{url}", //صַ--url //ͻĻԼȨPriority -// "UpstreamHttpMethod": [ "Get", "Post" ] -// } -// ] -//} - -////*****************************ַʵ******************************** -//{ -// "Routes": [ -// { -// "DownstreamPathTemplate": "/api/{url}", //ַ--url -// "DownstreamScheme": "http", -// "DownstreamHostAndPorts": [ -// { -// "Host": "localhost", -// "Port": 5726 //˿ -// } -// ], -// "UpstreamPathTemplate": "/T5726/{url}", //صַ--url -// "UpstreamHttpMethod": [ "Get", "Post" ] -// }, -// { -// "DownstreamPathTemplate": "/api/{url}", //ַ--url -// "DownstreamScheme": "http", -// "DownstreamHostAndPorts": [ -// { -// "Host": "localhost", -// "Port": 5727 //˿ -// } -// ], -// "UpstreamPathTemplate": "/T5727/{url}", //صַ--url -// "UpstreamHttpMethod": [ "Get", "Post" ] -// }, -// { -// "DownstreamPathTemplate": "/api/{url}", //ַ--url -// "DownstreamScheme": "http", -// "DownstreamHostAndPorts": [ -// { -// "Host": "localhost", -// "Port": 5728 //˿ -// } -// ], -// "UpstreamPathTemplate": "/T5728/{url}", //صַ--url -// "UpstreamHttpMethod": [ "Get", "Post" ] -// } -// ] -//} - -//////MVC·ɹǽˮ¥̨ȵ-- -////*****************************·ɳͻ+Ȩƥ******************************** -//{ -// "Routes": [ -// { -// "DownstreamPathTemplate": "/{url}", //ַ--url -// "DownstreamScheme": "http", -// "DownstreamHostAndPorts": [ -// { -// "Host": "localhost", -// "Port": 5726 //˿ -// } -// ], -// "UpstreamPathTemplate": "/{url}", //صַ--url //ͻĻԼȨPriority -// "UpstreamHttpMethod": [ "Get", "Post" ], -// "Priority": 0 //Ĭ0 Ӹ1 -// }, -// { -// "DownstreamPathTemplate": "/api/users/get?id={id}", //ַ--url -// "DownstreamScheme": "http", -// "DownstreamHostAndPorts": [ -// { -// "Host": "localhost", -// "Port": 5727 //˿ -// } -// ], -// "UpstreamPathTemplate": "/api/users/get/{id}", //صַ--url //ͻĻԼȨPriority -// "UpstreamHttpMethod": [ "Get", "Post" ], -// "Priority": 1 //Ĭ0 Ӹ1 -// }, -// { -// "DownstreamPathTemplate": "/api/users/{url}?id={id}", //ַ--url -// "DownstreamScheme": "http", -// "DownstreamHostAndPorts": [ -// { -// "Host": "localhost", -// "Port": 5728 //˿ -// } -// ], -// "UpstreamPathTemplate": "/api/users/{url}/{id}", //صַ--url //ͻĻԼȨPriority -// "UpstreamHttpMethod": [ "Get", "Post" ], -// "Priority": 2 //Ĭ0 Ӹ1 -// } -// ] -//} - -////*****************************ַʵؾ******************************** -//{ -// "Routes": [ -// { -// "DownstreamPathTemplate": "/api/{url}", //ַ--url -// "DownstreamScheme": "http", -// "DownstreamHostAndPorts": [ -// { -// "Host": "47.95.2.2", -// "Port": 5726 -// }, //Ocelotؾ -// { -// "Host": "47.95.2.2", -// "Port": 5727 -// }, -// { -// "Host": "47.95.2.2", -// "Port": 5728 -// } -// ], -// "UpstreamPathTemplate": "/T/{url}", //صַ--url //ͻĻԼȨPriority -// "UpstreamHttpMethod": [ "Get", "Post" ], -// "LoadBalancerOptions": { -// "Type": "RoundRobin" //ѯ //"LeastConnection" //ķ "NoLoadBalance" //ؾ //"CookieStickySessions" //Ựճ // -// } -// //"LoadBalancerOptions": { -// // "Type": "CookieStickySessions", -// // "Key": "ASP.NET_SessionId", -// // "Expiry": 1800000 -// //} -// } -// ] -//} - -////*****************************ַʵؾ+Consul******************************** -//{ -// "Routes": [ -// { -// "DownstreamPathTemplate": "/api/{url}", //ַ--url -// "DownstreamScheme": "http", -// "UpstreamPathTemplate": "/T/{url}", //صַ--url -// "UpstreamHttpMethod": [ "Get", "Post" ], -// "UseServiceDiscovery": true, -// "ServiceName": "ZhaoxiService", //consul -// "LoadBalancerOptions": { -// "Type": "RoundRobin" //ѯ LeastConnection-ķ NoLoadBalanceؾ -// } -// } -// ], -// "GlobalConfiguration": { -// "BaseUrl": "http://127.0.0.1:6299", //ضַ -// "ServiceDiscoveryProvider": { -// "Host": "47.95.2.2", -// "Port": 8089, -// "Type": "Consul" //Consulṩ, ÿȥconsul -// } //Ocelotû֧öConsul - -// //,"ServiceDiscoveryProvider": { -// // "Host": "localhost", -// // "Port": 8500, -// // "Type": "PollConsul", //Consulṩ, -// // "PollingInterval": 1000 //ѯconsul,Ƶʺ--downDz֪ -// // //"Token": "footoken"//ҪACLĻ -// //} -// } -//} - -////*****************************Consul+Cache******************************** -//{ -// "Routes": [ -// { -// "DownstreamPathTemplate": "/api/{url}", //ַ--url -// "DownstreamScheme": "http", -// "UpstreamPathTemplate": "/T/{url}", //صַ--url -// "UpstreamHttpMethod": [ "Get", "Post" ], -// "UseServiceDiscovery": true, -// "ServiceName": "ZhaoxiService", //consul -// "LoadBalancerOptions": { -// "Type": "RoundRobin" //ѯ LeastConnection-ķ NoLoadBalanceؾ -// }, -// "FileCacheOptions": { -// "TtlSeconds": 15, //Second -// "Region": "UserCache" //ԵApi -// } -// } -// ], -// "GlobalConfiguration": { -// "BaseUrl": "http://127.0.0.1:6299", //ضַ -// "ServiceDiscoveryProvider": { -// "Host": "47.95.2.2", -// "Port": 8089, -// "Type": "Consul" //Consulṩ, ÿȥconsul -// } -// //"ServiceDiscoveryProvider": { -// // "Host": "localhost", -// // "Port": 8500, -// // "Type": "PollConsul", //Consulṩ, -// // "PollingInterval": 1000 //ѯconsul,Ƶʺ--downDz֪ -// // //"Token": "footoken"//ҪACLĻ -// //} -// } -//} - -////*****************************ʱ++۶++Consul+Polly******************************** -//{ -// "Routes": [ -// { -// "DownstreamPathTemplate": "/api/{url}", //ַ--url -// "DownstreamScheme": "http", -// "UpstreamPathTemplate": "/T/{url}", //صַ--url -// "UpstreamHttpMethod": [ "Get", "Post" ], -// "UseServiceDiscovery": true, -// "ServiceName": "ZhaoxiService", //consul -// "LoadBalancerOptions": { -// "Type": "RoundRobin" //ѯ LeastConnection-ķ NoLoadBalanceؾ -// }, -// "RateLimitOptions": { -// "ClientWhitelist": [ "eleven", "seven" ], // ClientId ִСд -// "EnableRateLimiting": true, -// "Period": "5m", //1s, 5m, 1h, 1d -// "PeriodTimespan": 30, //֮ͻ˿ -// "Limit": 5 //ͳʱ -// }, -// "AuthenticationOptions": { -// "AuthenticationProviderKey": "UserGatewayKey", -// "AllowedScopes": [] -// }, -// "QoSOptions": { -// "ExceptionsAllowedBeforeBreaking": 3, //ٸ쳣 -// "DurationOfBreak": 10000, // ۶ϵʱ䣬λΪms -// "TimeoutValue": 2000 //λms Ĵʱ䳬罫Ϊʱ Ĭ90 -// } -// //"FileCacheOptions": { -// // "TtlSeconds": 15, -// // "Region": "UserCache" //ԵApi -// //} -// } -// ], -// "GlobalConfiguration": { -// "BaseUrl": "http://127.0.0.1:6299", //ضַ -// "ServiceDiscoveryProvider": { -// "Host": "47.95.2.2", -// "Port": 8089, -// "Type": "Consul" //Consulṩ -// }, -// "RateLimitOptions": { -// "QuotaExceededMessage": "Too many requests, maybe later? 11", // رضʱصϢ -// "HttpStatusCode": 666, // رضʱصhttp status -// //"ClientIdHeader": "client_id" // ʶͻ˵ͷĬ ClientId -// } -// } -//} - -////*****************************ۺAggregator******************************** -//{ -// "Routes": [ -// { -// "DownstreamPathTemplate": "/api/users/all", -// "DownstreamScheme": "http", -// "DownstreamHostAndPorts": [ -// { -// "Host": "localhost", -// "Port": 5726 //˿ -// } //Զиؾ -// ], -// "UpstreamPathTemplate": "/T5726/users/all", -// "UpstreamHttpMethod": [ "Get", "Post" ], -// "key": "T5726" -// }, -// { -// "DownstreamPathTemplate": "/api/users/all", -// "DownstreamScheme": "http", -// "DownstreamHostAndPorts": [ -// { -// "Host": "localhost", -// "Port": 5727 //˿ -// } -// ], -// "UpstreamPathTemplate": "/T5727/users/all", -// "UpstreamHttpMethod": [ "Get", "Post" ], -// "key": "T5727" -// }, -// { -// "DownstreamPathTemplate": "/api/users/all", -// "DownstreamScheme": "http", -// "DownstreamHostAndPorts": [ -// { -// "Host": "localhost", -// "Port": 5728 //˿ -// } -// ], -// "UpstreamPathTemplate": "/T5728/users/all", -// "UpstreamHttpMethod": [ "Get", "Post" ], -// "key": "T5728" -// } -// ], -// "Aggregates": [ -// { -// "RouteKeys": [ -// "T5726", -// "T5727", -// "T5728" -// ], -// "UpstreamPathTemplate": "/UserAggregator", //ij404 DzӰ췵أnull -// "Aggregator": "CustomUserAggregator" //Զۺ -// } -// ] -//} - diff --git a/Yi.Framework/Yi.Framework.PageDetail/Properties/launchSettings.json b/Yi.Framework/Yi.Framework.PageDetail/Properties/launchSettings.json deleted file mode 100644 index fff2465e..00000000 --- a/Yi.Framework/Yi.Framework.PageDetail/Properties/launchSettings.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:55468", - "sslPort": 44333 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "Yi.Framework.PageDetail": { - "commandName": "Project", - "dotnetRunMessages": "true", - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "https://localhost:5001;http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/Yi.Framework/Yi.Framework.SMSProcessor/appsettings.Development.json b/Yi.Framework/Yi.Framework.SMSProcessor/appsettings.Development.json deleted file mode 100644 index 8983e0fc..00000000 --- a/Yi.Framework/Yi.Framework.SMSProcessor/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/Yi.Framework/Yi.Framework.SMSProcessor/appsettings.json b/Yi.Framework/Yi.Framework.SMSProcessor/appsettings.json deleted file mode 100644 index be9e72f1..00000000 --- a/Yi.Framework/Yi.Framework.SMSProcessor/appsettings.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "RabbitMQ_Enabled": true, - "SMS_Enabled": true, - "RedisConn": { - "Host": "192.168.2.128", - "Prot": 6379, - "DB": 0, - "Password": "123456" - }, - "RabbitConn": { - "HostName": "118.195.191.41", - "UserName": "cc", - "Password": "cc", - "Port": 5672 - }, - //"DetailPageUrl": "http://localhost:5728/item/", - "DetailPageUrl": "http://PageDetail/item/", - "ConsulClientOption": { - "IP": "192.168.2.128", - "Port": "8500", - "Datacenter": "dc1" - }, - "MysqlConn": { - "Url": "server=192.168.2.128;port=3306;database=ECDB;user id=root;password=123456" - }, - "Apollo": { - "AppId": "Yi.Framework.StaticPageProcessor", - "Env": "DEV", - "MetaServer": "http://192.168.2.168:8080", - "ConfigServer": [ "http://192.168.2.168:8080" ] - }, - "SMS": { - "ID": "LTAI5tJvjPaXCyyPMfXLNbVA", - "Secret": "fLQv7jjj57fUKLFK8REeAQPFVDjUYn", - "Sign": "JiftCC", - "Template": "SMS_221640732" - } -} diff --git a/Yi.Framework/Yi.Framework.StaticPageProcessor/appsettings.Development.json b/Yi.Framework/Yi.Framework.StaticPageProcessor/appsettings.Development.json deleted file mode 100644 index 8983e0fc..00000000 --- a/Yi.Framework/Yi.Framework.StaticPageProcessor/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/Yi.Framework/Yi.Framework.StaticPageProcessor/appsettings.json b/Yi.Framework/Yi.Framework.StaticPageProcessor/appsettings.json deleted file mode 100644 index e1db65d8..00000000 --- a/Yi.Framework/Yi.Framework.StaticPageProcessor/appsettings.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "RedisConn": { - "Host": "192.168.2.128", - "Prot": 6379, - "DB": 0, - "Password": "123456" - }, - "RabbitMQOptions": { - "HostName": "192.168.2.128", - "UserName": "cc", - "Password": "cc" - }, - //"DetailPageUrl": "http://localhost:5728/item/", - "DetailPageUrl": "http://PageDetail/item/", - "ConsulClientOption": { - "IP": "192.168.2.128", - "Port": "8500", - "Datacenter": "dc1" - }, - "MysqlConn": { - "Url": "server=192.168.2.128;port=3306;database=ECDB;user id=root;password=123456" - }, - "Apollo": { - "AppId": "Yi.Framework.StaticPageProcessor", - "Env": "DEV", - "MetaServer": "http://192.168.2.168:8080", - "ConfigServer": [ "http://192.168.2.168:8080" ] - } -}