commit ef69cb5d5bd12c55e19f11989c55dc2230c6616f Author: 易大师 <156663459@qq.com> Date: Fri Jan 29 13:00:03 2021 +0800 first commit init diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3729ff0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md \ No newline at end of file diff --git a/.docs/contents/.vuepress/config.js b/.docs/contents/.vuepress/config.js new file mode 100644 index 0000000..982fb80 --- /dev/null +++ b/.docs/contents/.vuepress/config.js @@ -0,0 +1,46 @@ +module.exports = { + title: 'New_College', + description: 'Hello, 欢迎使用前后端分离之 ASP.NET Core 后端全家桶框架!', + base : '/.doc/', + head: [ + ['link', { + rel: 'icon', + href: `/favicon.ico` + }] + ], + dest: './contents/.vuepress/dist', + ga: '', + evergreen: true, + themeConfig: { + nav: [ + { text: '首页', link: '/' }, + { text: '指南', link: '/guide/' }, + { text: '更新日志', link: '/Update/' }, + { text: '压测', link: '/PressureTest/' }, + { text: '参与贡献', link: '/Contribution/' }, + { text: '社区', link: '/QQ/' }, + { text: '接口API', link: 'http://apk.neters.club' }, + { text: '管理后台', link: 'http://vueadmin.neters.club' }, + { text: 'Github', link: 'https://github.com/anjoy8/New_College' }, + ], + sidebarDepth: 2, + sidebar: { + '/guide/': getGuideSidebar('Guide'), + } + } +} + +function getGuideSidebar (groupA) { + return [ + { + title: groupA, + collapsable: false, + children: [ + '', + 'getting-started', + 'function-sheet', + 'cheat-sheet' + ] + } + ] + } \ No newline at end of file diff --git a/.docs/contents/.vuepress/public/bcvphomelogo.png b/.docs/contents/.vuepress/public/bcvphomelogo.png new file mode 100644 index 0000000..e1bf0f7 Binary files /dev/null and b/.docs/contents/.vuepress/public/bcvphomelogo.png differ diff --git a/.docs/contents/.vuepress/public/favicon.ico b/.docs/contents/.vuepress/public/favicon.ico new file mode 100644 index 0000000..68062fe Binary files /dev/null and b/.docs/contents/.vuepress/public/favicon.ico differ diff --git a/.docs/contents/Contribution/README.md b/.docs/contents/Contribution/README.md new file mode 100644 index 0000000..492e70b --- /dev/null +++ b/.docs/contents/Contribution/README.md @@ -0,0 +1,84 @@ +# 贡献 + + +欢迎一起完善文档, +参与打赏的小可爱名单如下(单位:元),你们的贡献是我继续的动力: +(2020年8月6日 10点47分) + + +|序号|微信昵称|助力值|备注| +|-|-|-|-| +|01|排 * * 瓜|100|| +|02|船 * * 长|100|| +|03|二 * * 生|1|| +|04||1|未留微信号| +|05|旭 * * 光|10|| +|06||12.66|未留微信号| +|07|Ro * * st|10|| +|08|陈 * * 朝|10|| +|09|勇 * * 勇|10|| +|10|袁 * * 嘉|10|| +|11|En * * us|20|| +|12|风 * * 在|18|| +|13|林 * * 杰|10|| +|14|枫 * * 叶|10|| +|15|火 * * 鸟 |50|| +|16|阿 * * 福|10|| +|17||20|未留微信号| +|18|Er * * or|100|未留微信号| +|19|陶 * * ve|20|| +|20|熊 * * 育|50|| +|21|点 * * 痕|20|| +|22|夏 * * 目|20|| +|23|CL * * L|50|| +|24|rm * * rf|100|| +|25|Je * * ca|30|搜不到微信号| +|26|W * * 生|50|| +|27|鹏 * * 郎|20|| +|28|ws * * ai|10|| +|29|逐 * * 梦|20|| +|30|Jo * * aH|10|| +|31|Do * * n|10|| +|32|灰 * * 白|50|| +|33|Ne * * er|100|| +|34|Ar * * as|10|| +|35|吉 * * 祥|36|| +|36|ma * * y|10|| +|37|Yu * * ic|30|| +|38|亡 * * 死|30|| +|39|板 * * 根|20|| +|40|-- * * -|100|未留微信号| +|41|t * * |20|| +|42|王 * * 聪 |10|未留微信号| +|43|哈 * * 方|50|| +|44|le * * on|30|| +|45|李 * * |10|| +|46|不 * * 染|10|未留微信号| +|47|林 * * LIN|10|| +|48|阿 * * 奇|30|| +|49|哒 * * 哒|10|| +|50|王 * * 龙|100|| +|51|Ja * * Tu|100|| +|52|it * * hi|100|| +|53|沙 * * 锋|50|未留微信号| +|54|Ba * * ai|10|| +|55|古 * * 桐|10|| +|56|小 * * 柜|20|| +|57|rm * * rf|100|| + + + + + + +## 参与贡献的开源项目 + +如果帮忙以前完善文档,可以在这里留下你的开源项目,做推广。 + +``` +1、https://github.com/GeorGeWzw/Sukt.Core(作者:kawhi) +2、https://github.com/wmowm/Gourd(作者:提伯斯) +3、https://github.com/GeorGeWzw/Destiny.Core.Flow(作者:大黄瓜|kawhi)备注:重写的Identity的用户角色 + + +``` \ No newline at end of file diff --git a/.docs/contents/PressureTest/README.md b/.docs/contents/PressureTest/README.md new file mode 100644 index 0000000..5a5247c --- /dev/null +++ b/.docs/contents/PressureTest/README.md @@ -0,0 +1,54 @@ +# 框架压测报告 + + +## 1、测试工具 +使用 `JMeter` 进行压力测试。 +测试时间:2020年7月1日 13点14分。 +服务器报告: + + + + +## 2、测试准备 +因为 `JMeter` 是使用 `JAVA` 写的,所以使用 `JMeter` 之前,先安装 `JAVA` 环境。 +安装好后,在 `bin` 文件夹下,点击 `jmeter.bat` 启动程序。 +启动之后会有两个窗口,一个cmd窗口,一个JMeter的 GUI。前面不要忽略CMD窗口的提示信息,不要关闭它。 + +## 3、配置数据 +本地发布后的 `windows` 环境,直接用 `kestrel` 启动。 +线程数:100 +循环数:10000 +HTTP默认值:协议:`http`;服务器或IP:`localhost`;端口号:`8081`; +HTTP请求:方法:GET;路径:`/api/blog/ApacheTestUpdate` +HTTP信息请求管理器:无 +响应断言:无 + + + +## 项目配置 +目前采用 `New_College` 默认的配置, +开启了内存 `AOP` 和日志 `AOP`, +其他的都是默认的,然后也把任务调度也关闭了, +最后注意要把 `IP限流`给关闭,不然压测没效果,因为限流了: + + + +## 压测结果 +1、为了显示正确性,我用动图,来显示日志生成情况,整个阶段无任何异常: + + + + +2、内存方面,`100*10000` 的压测过程中,项目保证所占内存在 `160~220m` 之间: + + + +## 压测配置文件下载 + [配置文件](https://img.neters.club/doc/new_collegetest.jmx) + 下载后,导入到工具里,可以直接测试,察看结果树。 + + ## Docker 镜像 + 已经提交到 `docker hub` 自行拉取操作即可: + ``` + docker pull laozhangisphi/apkimg:latest + ``` \ No newline at end of file diff --git a/.docs/contents/QQ/README.md b/.docs/contents/QQ/README.md new file mode 100644 index 0000000..485261c --- /dev/null +++ b/.docs/contents/QQ/README.md @@ -0,0 +1,11 @@ +## QQ 群 + +群1 +群2 + + +## 微信公众号 + +公众号 + + diff --git a/.docs/contents/README.md b/.docs/contents/README.md new file mode 100644 index 0000000..e7e1b12 --- /dev/null +++ b/.docs/contents/README.md @@ -0,0 +1,14 @@ +--- +home: true +heroImage: /bcvphomelogo.png +actionText: 快速上手 → +actionLink: /guide/ +features: +- title: 详尽的文档 + details: 通过详细的文章和视频讲解,将知识点各个击破,入门ASP.Net Core不再难 +- title: 强大的社区 + details: 通过 QQ 群,和数千位同业大佬一起切磋交流。 +- title: 丰富的内容 + details: 框架涵盖ASP.Net Core开发中常见的基本知识点,不仅适合初学者入门,同时也适用于企业级别的开发。 +footer: MIT Licensed | Copyright © 2018-2020-老张的哲学 +--- \ No newline at end of file diff --git a/.docs/contents/Update/README.md b/.docs/contents/Update/README.md new file mode 100644 index 0000000..b8cdfca --- /dev/null +++ b/.docs/contents/Update/README.md @@ -0,0 +1,121 @@ + +## 更新日志 + +### 2020-08-06 + +项目更新:更新项目模板 `Update New_College.Webapi.Template.2.2.0.nupkg` 。 +> 1、根据解决方案名,来自动导入model; +> 2、单独封装服务扩展层 `New_College.Extensions` ; +> 3、代码生成器,支持控制器文件的生成; +> 4、弱化仓储层,用泛型仓储基类注入服务; + + + + +### 2020-08-01 + +> 重大结构更新:弱化仓储层,通过泛型仓储基类,来实现仓储服务注入,并去掉`New_College.IRepository` 接口层; + +### 2020-07-03 + +> 更新:`DbFirstController` 生成四层文件,目前新增支持 `控制器Controller` 文件的输出; + + +### 2020-06-22 + +> 项目更新:将服务扩展和自定义中间件,单独封装一层 `New_College.Extensions` ,更解耦。 + + + +### 2020-06-08 + +> 简单项目更新:生成数据库表结构的时候,利用反射机制,自动生成固定命名空间 `New_College.Model.Models` 下的全部实体. +> 同时判断表是否存在,如果存在下次不再重复生成。 + + +### 2020-06-06 + +项目更新:更新项目模板 `Update New_College.Webapi.Template.2.1.0.nupkg` [1a726f8](https://github.com/anjoy8/New_College/commit/1a726f890e527c978982071462e82db4478632f0),更新项目即可 。 +> 1、配置内容展示到控制台; +> 2、简化封装 `Startup.cs` 类文件; +> 3、`DbFirst` 模式支持多库模式; +> 4、`Log4net` 讲异常和 `Info` 分开; +> 5、修复 `BlogLogAop` 偶尔卡顿问题; +> 6、将生成种子数据和任务调度功能,封装到中间件; +> 7、获取当前项目在服务器中的运行信息; +> 8、删除所有的不需要的 `using` 指令; + + + + +### 2020-05-29 +项目启动开启 `QuzrtzNet` 调度任务,并且在 `Admin` 后台管理中配置操作界面; +> 内容更新:封装生成种子数据的入口方法; + + + +### 2020-05-12 +修复:支持多库模式下,生成项目模板代码 `DbFirstController` [102c6d6](https://github.com/anjoy8/New_College/commit/102c6d6bfcafd06bf5241844759dea5e7a6815da) +> 注意:`T4` 模板不能此功能,一次只能一个数据库,且只能 `SqlServer` + + +### 2020-05-07 +> 重大内容更新:更新项目模板 `Update New_College.Webapi.Template.2.1.0.nupkg` [7f64fde](https://github.com/anjoy8/New_College/commit/7f64fde5507f7a8572372dcadb6af5110bd37d68) + + +### 2020-05-06 +> 重大内容更新:优化Log4Net使用方案,完美配合 `NetCore` 官方的 `ILogger`, [ecaffb6](https://github.com/anjoy8/New_College/commit/ecaffb66bdf10a90c087d01e6e817e54f23a97d4) + + +### 2020-05-01 + +> 重要内容更新:配合Admin全部完成按钮级别权限,更新初始化种子数据 + +### 2020-04-27 + +增加功能:配合前端Admin,增加页面 `KeepAlive` 功能; +增加功能:增加 `Sql` 语句查询Demo,支持返回 `DataTable`; + + +### 2020-04-25 + +增加功能:`Http api` 接口调用,满足微服务需求 +> 重要内容更新:优化 `Appsettings.app()` 方法,通过官方 `IConfiguration` 接口来获取DBS连接字符串; +> 优化 `BlogLogAOP.cs` + + +### 2020-04-15 + +> 重大内容更新:更新项目模板 `Update New_College.Webapi.Template.1.11.30.nupkg` + + +### 2020-04-14 +> 重大内容更新:主分支,可以通过配置,一键切换JWT和Ids4认证授权模式 + + +### 2020-03-30 +> 重大内容更新:统一所有接口返回格式 + + +### 2020-03-25 +增加功能:支持读写分离(目前是三种模式:单库、多库、读写分离) +> 重大BUG更新:系统登录接口,未对用户软删除进行判断,现已修复 +> API: /api/login/GetJwtToken3 +> Code: await _sysUserInfoServices.Query(d => d.uLoginName == name && d.uLoginPWD == pass && d.tdIsDelete == false); + + + +### 2020-03-18 +增加功能:创建 Quartz.net 任务调度服务 + + +### 2020-01-09 +增加功能:项目迁移到IdentityServer4,统一授权认证中心 + + +### 2020-01-05 +增加功能:设计一个简单的中间件,可以查看所有已经注入的服务 + + +### 2020-01-04 +增加功能:Ip限流,防止过多刷数据 diff --git a/.docs/contents/guide/README.md b/.docs/contents/guide/README.md new file mode 100644 index 0000000..adcccf9 --- /dev/null +++ b/.docs/contents/guide/README.md @@ -0,0 +1,89 @@ +# J 介绍 + +最新的前后端完全分离框架【 ASP.NET Core 3.1 Api + Vue 2.x + ele】。 +ASP.NET Core 3.1 教程,前后端分离的后端接口,vue教程的姊妹篇。 +BCVP(New_College&Vue Project)开箱即用的企业级前后端分离【 .NET Core3.1 Api + Vue 2.x + RBAC】权限框架。 + +## 你能得到什么? +1、从 0 到 1 快速入门 ASP.NET Core 框架。 +2、掌握开发中的常用知识点,为跨平台、微服务打好基础。 +3、下载即用,简单高效开发属于自己公司项目,配置简单,功能完善。 + + + +## 功能与进度 + +- [√] 采用仓储+服务+接口的形式封装框架; +- [√] 使用Swagger做api文档; +- [√] 使用MiniProfiler做接口性能分析; +- [√] 使用Automapper做Dto处理; +- [√] 接入SqlSugar ORM,封装数据库操作; +- [√] 项目启动,自动生成seed种子数据; +- [√] 提供五种日志输出; +- [√] 支持自由切换多种数据库,Sqlite/SqlServer/MySql/PostgreSQL/Oracle; +- [√] 异步async/await开发; +- [√] 支持事务; +- [√] AutoFac接入做依赖注入; +- [√] 支持AOP切面编程; +- [√] 支持CORS跨域; +- [√] 支持T4代码模板,自动生成每层代码; +- [√] 支持一键创建自己项目; +- [√] 封装 JWT 自定义策略授权; +- [√] 使用Log4Net日志框架+自定义日志输出; +- [√] 使用SingleR推送日志信息到管理后台; +- [√] 搭配前端Blog项目,vue开发; +- [√] 搭配一个Admin管理后台,用vue+ele开发; +- [√] IdentityServer4 认证; +- [√] API 限速; +- [√] 作业调度 Quartz.net; +- [√] Sqlsugar 读写分离; +- [ ] Redis 队列; +- [ ] 支付; +- [ ] 数据部门权限; + + + +## 它是如何工作的? + +这是一个基于 ASP.NET Core 3.1 的 api 项目,配合搭建 VUE 实现前后端分离工程。 + +************************************************************** +系统环境 + +> windows 10、SQL server 2012、Visual Studio 2017、Windows Server 2008 R2 + +后端技术: + +> 1、ASP.NET Core 3.1 API + 2、Swagger 前后端文档说明,基于RESTful风格编写接口 + 3、Repository + Service 仓储模式编程 + 4、Async和Await 异步编程 + 5、CORS 简单的跨域解决方案 + 6、AOP基于切面编程技术 + 7、Autofac 轻量级IoC和DI依赖注入 + 8、Vue 本地代理跨域方案,Nginx跨域代理 + 9、JWT权限验证 +10、Filter 过滤器 +11、Middleware 中间件 +12、AutoMapper 自动对象映射 +13、Redis + + +数据库技术 + +> SqlSugar 轻量级ORM框架,CodeFirst + T4 模板生成框架结构 + 支持SqlServer、Mysql、Sqlite、Oracle、Pgql数据库 + 支持多库操作 + + + + +前端技术 + +> Vue 2.x 框架全家桶 Vue2 + VueRouter2 + Webpack + Axios + vue-cli + vuex +ElementUI 基于Vue 2.0的组件库 +Nuxt.js服务端渲染SSR + + + diff --git a/.docs/contents/guide/cheat-sheet.md b/.docs/contents/guide/cheat-sheet.md new file mode 100644 index 0000000..6f6dd6a --- /dev/null +++ b/.docs/contents/guide/cheat-sheet.md @@ -0,0 +1,580 @@ +# Z 主要知识点 + + + +## AOP + +本项目多处采用面向切面编程思想——AOP,除了广义上的过滤器和中间件以外,主要通过动态代理的形式来实现AOP编程思想,主要的案例共有四个,分别是: +1、服务日志AOP; +2、服务InMemory缓存AOP; +3、服务Redis缓存AOP; +4、服务事务AOP; + + +具体的代码可以在 `New_College\New_College\AOP` 文件夹下查看。 + +与此同时,多个AOP也设置了阀门来控制是否开启,具体的可以查看 `appsettings.json` 中的: + +``` + "AppSettings": { + "RedisCachingAOP": { + "Enabled": false, + "ConnectionString": "127.0.0.1:6319" + }, + "MemoryCachingAOP": { + "Enabled": true + }, + "LogAOP": { + "Enabled": false + }, + "TranAOP": { + "Enabled": false + }, + "SqlAOP": { + "Enabled": false + } + }, + +``` + +## Appsettings + +整个系统通过一个封装的操作类 `Appsettings.cs` 来控制配置文件 `appsettings.json` 文件, +操作类地址在:`\New_College.Common\Helper` 文件夹下。 +具体的使用方法是: + +``` +Appsettings.app(new string[] { "AppSettings", "RedisCachingAOP", "Enabled" }) + +// 里边的参数,按照 appsettings.json 中设置的层级顺序来写,可以获取到指定的任意内容。 + +``` + + + +## AspNetCoreRateLimit + +系统使用 `AspNetCoreRateLimit` 组件来实现ip限流: +1、添加 `nuget` 包: +``` + +``` + +2、注入服务 `IpPolicyRateLimitSetup.cs` +``` +services.AddIpPolicyRateLimitSetup(Configuration); +``` + +3、配置中间件 +``` + // Ip限流,尽量放管道外层 + app.UseIpRateLimiting(); +``` + +4、配置数据 + +具体的内容,自行百度即可 +``` + "IpRateLimiting": { + "EnableEndpointRateLimiting": true, + "StackBlockedRequests": false, + "RealIpHeader": "X-Real-IP", + "ClientIdHeader": "X-ClientId", + "HttpStatusCode": 429,//返回状态码 + "GeneralRules": [//规则,结尾一定要带* + { + "Endpoint": "*", + "Period": "1m", + "Limit": 120 + }, + { + "Endpoint": "*:/api/blog*", + "Period": "1m", + "Limit": 30 + } + ] + + } +``` + + + +## Async-Await + +整个系统采用 async/await 异步编程,符合主流的开发模式, +特别是对多线程开发很友好。 + + + +## Authorization-Ids4 + +本系统 v2.0 版本(目前的系统已经集成 `ids4` 和 `jwt`,并且可以自由切换),已经支持了统一授权认证,和 `blog` 项目、`Admin` 项目、`DDD` 项目等一起,使用一个统一的认证中心。 + +具体的代码参考:`.\New_College\Extensions` 文件夹下的 `Authorization_Ids4Setup.cs` ,注意需要引用指定的 `nuget` 包,核心代码如下: + +``` + //【认证】 + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.DefaultChallengeScheme = nameof(ApiResponseHandler); + o.DefaultForbidScheme = nameof(ApiResponseHandler); + }) + // 2.添加Identityserver4认证 + .AddIdentityServerAuthentication(options => + { + options.Authority = Appsettings.app(new string[] { "Startup", "IdentityServer4", "AuthorizationUrl" }); + options.RequireHttpsMetadata = false; + options.ApiName = Appsettings.app(new string[] { "Startup", "IdentityServer4", "ApiName" }); + options.SupportedTokens = IdentityServer4.AccessTokenValidation.SupportedTokens.Jwt; + options.ApiSecret = "api_secret"; + + }) + + +``` + +### 如何在Swagger中配置Ids4? +很简单,直接在 `SwaggerSetup.cs` 中直接接入 `oauth、Implicit` 即可: + +``` + //接入identityserver4 + c.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme + { + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows + { + Implicit = new OpenApiOAuthFlow + { + AuthorizationUrl = new Uri($"{Appsettings.app(new string[] { "Startup", "IdentityServer4", "AuthorizationUrl" })}/connect/authorize"), + Scopes = new Dictionary { + { + "new_college.api","ApiResource id" + } + } + } + } + }); + +``` + +然后在 `IdentityServer4` 项目中,做指定的修改,配置 `8081` 的回调地址: + +``` + new Client { + ClientId = "blogadminjs", + ClientName = "Blog.Admin JavaScript Client", + AllowedGrantTypes = GrantTypes.Implicit, + AllowAccessTokensViaBrowser = true, + + RedirectUris = + { + "http://vueadmin.neters.club/callback", + // 这里要配置回调地址 + "http://localhost:8081/oauth2-redirect.html" + }, + PostLogoutRedirectUris = { "http://vueadmin.neters.club" }, + AllowedCorsOrigins = { "http://vueadmin.neters.club" }, + + AllowedScopes = { + IdentityServerConstants.StandardScopes.OpenId, + IdentityServerConstants.StandardScopes.Profile, + "roles", + "new_college.api" + } + }, + +``` + +然后再 `Swagger` 中,配置登录授权: + +swagger + + +## Authorization-JWT + +如果你不想使用 `IdentityServer4` 的话,也可以使用 `JWT` 认证,同样是是`New_College\New_College\Extensions` 文件夹下的 `AuthorizationSetup.cs` 中有关认证的部分: + +``` + 1.添加JwtBearer认证服务 +.AddJwtBearer(o => +{ + o.TokenValidationParameters = tokenValidationParameters; + o.Events = new JwtBearerEvents + { + OnAuthenticationFailed = context => + { + // 如果过期,则把<是否过期>添加到,返回头信息中 + if (context.Exception.GetType() == typeof(SecurityTokenExpiredException)) + { + context.Response.Headers.Add("Token-Expired", "true"); + } + return Task.CompletedTask; + } + }; +}) + +``` + + +## AutoMapper + +使用 `AutoMapper` 组件来实现 `Dto` 模型的传输转换,具体的用法,可以查看: +`New_College\New_College\Extensions` 文件夹下的 `AutoMapperSetup.cs` 扩展类, +通过引用 `AutoMapper` 和 `AutoMapper.Extensions.Microsoft.DependencyInjection` 两个 `nuget` 包,并设置指定的 `profile` 文件,来实现模型转换控制。 + +``` +// 比如如何定义: + public class CustomProfile : Profile + { + /// + /// 配置构造函数,用来创建关系映射 + /// + public CustomProfile() + { + CreateMap(); + CreateMap(); + } + } + + +// 比如如何使用 +models = _mapper.Map(blogArticle); + +``` + +具体的查看项目中代码即可。 + + + + +## CORS + +在线项目使用的是 `nginx` 跨域代理,但是同时也是支持 `CORS` 代理: +1、注入服务 `services.AddCorsSetup();` 具体代码 `New_College\New_College\Extensions` 文件夹下的 `CorsSetup.cs` 扩展类; +2、配置中间件 `app.UseCors("LimitRequests");` ,要注意中间件顺序; +3、配置自己项目的前端端口,通过在 `appsettings.json` 文件中配置自己的前端项目 `ip:端口` ,来实现跨域: + +``` + "Startup": { + "Cors": { + "IPs": "http://127.0.0.1:2364,http://localhost:2364,http://localhost:8080,http://localhost:8021,http://localhost:1818" + } + }, + +``` + + +## DI-AutoFac + +项目使用了依赖注入,除了原生的依赖注入以外,更多的使用的是第三方组件 `Autofac` : +1、引用依赖包: +``` + + + +``` +主要是第一个 `nuget` 包,下边的是为了实现动态代理 `AOP` 操作; + +2、项目之间采用引用解耦的方式,通过反射来注入服务层和仓储层的程序集 `dll` 来实现批量注入,更方便,以后每次新增和修改 `Service` 层和 `Repository` 层,只需要 `F6` 编译一下即可,具体代码查看 `Startup.cs`: + +``` + + + // 注意在CreateDefaultBuilder中,添加Autofac服务工厂 + public void ConfigureContainer(ContainerBuilder builder) + { + var basePath = Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.ApplicationBasePath; + //builder.RegisterType().As(); + + + #region 带有接口层的服务注入 + + + var servicesDllFile = Path.Combine(basePath, "New_College.Services.dll"); + var repositoryDllFile = Path.Combine(basePath, "New_College.Repository.dll"); + + if (!(File.Exists(servicesDllFile) && File.Exists(repositoryDllFile))) + { + throw new Exception("Repository.dll和service.dll 丢失,因为项目解耦了,所以需要先F6编译,再F5运行,请检查 bin 文件夹,并拷贝。"); + } + + + + // AOP 开关,如果想要打开指定的功能,只需要在 appsettigns.json 对应对应 true 就行。 + var cacheType = new List(); + if (Appsettings.app(new string[] { "AppSettings", "RedisCachingAOP", "Enabled" }).ObjToBool()) + { + builder.RegisterType(); + cacheType.Add(typeof(BlogRedisCacheAOP)); + } + if (Appsettings.app(new string[] { "AppSettings", "MemoryCachingAOP", "Enabled" }).ObjToBool()) + { + builder.RegisterType(); + cacheType.Add(typeof(BlogCacheAOP)); + } + if (Appsettings.app(new string[] { "AppSettings", "TranAOP", "Enabled" }).ObjToBool()) + { + builder.RegisterType(); + cacheType.Add(typeof(BlogTranAOP)); + } + if (Appsettings.app(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool()) + { + builder.RegisterType(); + cacheType.Add(typeof(BlogLogAOP)); + } + + // 获取 Service.dll 程序集服务,并注册 + var assemblysServices = Assembly.LoadFrom(servicesDllFile); + builder.RegisterAssemblyTypes(assemblysServices) + .AsImplementedInterfaces() + .InstancePerDependency() + .EnableInterfaceInterceptors()//引用Autofac.Extras.DynamicProxy; + .InterceptedBy(cacheType.ToArray());//允许将拦截器服务的列表分配给注册。 + + // 获取 Repository.dll 程序集服务,并注册 + var assemblysRepository = Assembly.LoadFrom(repositoryDllFile); + builder.RegisterAssemblyTypes(assemblysRepository) + .AsImplementedInterfaces() + .InstancePerDependency(); + + #endregion + + #region 没有接口层的服务层注入 + + //因为没有接口层,所以不能实现解耦,只能用 Load 方法。 + //注意如果使用没有接口的服务,并想对其使用 AOP 拦截,就必须设置为虚方法 + //var assemblysServicesNoInterfaces = Assembly.Load("New_College.Services"); + //builder.RegisterAssemblyTypes(assemblysServicesNoInterfaces); + + #endregion + + #region 没有接口的单独类 class 注入 + + //只能注入该类中的虚方法 + builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(Love))) + .EnableClassInterceptors() + .InterceptedBy(cacheType.ToArray()); + + #endregion + + + // 这里和注入没关系,只是获取注册列表,请忽略 + tsDIAutofac.AddRange(assemblysServices.GetTypes().ToList()); + tsDIAutofac.AddRange(assemblysRepository.GetTypes().ToList()); + } + +``` + +3、然后 `Program.cs` 中也要加一句话:` .UseServiceProviderFactory(new AutofacServiceProviderFactory()) //<--NOTE THIS ` + + + +## DI-NetCore + +除了主要的 `Autofac` 依赖注入以外,也减少的使用了原生的依赖注入方式,很简单,比如这样的: +``` + + services.AddSingleton(); + // 注入权限处理器 + services.AddScoped(); + services.AddSingleton(permissionRequirement); +``` + + +## Filter + +项目中一共有四个过滤器 +``` +1、GlobalAuthorizeFilter.cs —— 全局授权配置,添加后,就可以不用在每一个控制器上添加 [Authorize] 特性,但是3.1版本好像有些问题,【暂时放弃使用】; +2、GlobalExceptionFilter.cs —— 全局异常处理,实现 actionContext 级别的异常日志收集; +3、GlobalRoutePrefixFilter.cs —— 全局路由前缀公约,统计在路由上加上前缀; +4、UseServiceDIAttribute.cs —— 测试注入,【暂时无用】; +``` +文件地址在 `.\New_College\Filter` 文件夹下,其中核心的是 `2` 个,重点使用的是 `1` 个 —— 全局异常错误日志 `GlobalExceptionsFilter`: +通过注册在 `MVC` 服务 `services.AddControllers()` 中,实现全局异常过滤: +``` + services.AddControllers(o => + { + // 全局异常过滤 + o.Filters.Add(typeof(GlobalExceptionsFilter)); + // 全局路由权限公约 + //o.Conventions.Insert(0, new GlobalRouteAuthorizeConvention()); + // 全局路由前缀,统一修改路由 + o.Conventions.Insert(0, new GlobalRoutePrefixFilter(new RouteAttribute(RoutePrefix.Name))); + }) +``` + + + +## Framework + +项目采用 `服务+仓储+接口` 的多层结构,使用依赖注入,并且通过解耦项目,较完整的实现了 `DIP` 原则: +高层模块不应该依赖于底层模块,二者都应该依赖于抽象。 +抽象不应该依赖于细节,细节应该依赖于抽象。 + +同时项目也封装了: +`CodeFirst` 初始化数据库以及数据; +`DbFirst` 根据数据库(支持多库),生成多层代码,算是简单代码生成器; +其他功能,[核心功能与进度](http://apk.neters.club/.doc/guide/#%E5%8A%9F%E8%83%BD%E4%B8%8E%E8%BF%9B%E5%BA%A6) + + + + +## Log + +通过集成 `Log4Net` 组件,完美配合 `NetCore` 官方的 `ILogger` 接口,实现对日志的管控,引用 `nuget` 包 `Microsoft.Extensions.Logging.Log4Net.AspNetCore`: +Program.cs +``` + webBuilder + .UseStartup() + .ConfigureLogging((hostingContext, builder) => + { + //该方法需要引入Microsoft.Extensions.Logging名称空间 + builder.AddFilter("System", LogLevel.Error); //过滤掉系统默认的一些日志 + builder.AddFilter("Microsoft", LogLevel.Error);//过滤掉系统默认的一些日志 + + //添加Log4Net + //var path = Directory.GetCurrentDirectory() + "\\log4net.config"; + //不带参数:表示log4net.config的配置文件就在应用程序根目录下,也可以指定配置文件的路径 + //需要添加nuget包:Microsoft.Extensions.Logging.Log4Net.AspNetCore + builder.AddLog4Net(); + }); + +``` + +然后直接在需要的地方注入使用,比如在控制器中 +` public UserController(ILogger logger)` + +然后就可以使用了。 + +> 注意:日志 其实是分为两部分的: +> netcore输出(控制台、输出窗口等) 和 `ILogger` 持久化 +> 两者对应配置也不一样,就比如上边的过滤,是针对日志持久化的,如果想要对控制台进行控制,需要配置 `appsettings.json` 中的 `Logging` 节点 + + +## MemoryCache + +精力有限,还是更新中... +如果你愿意帮忙,可以直接在GitHub中,提交pull request, +我会在后边的贡献者页面里,列出你的名字和项目地址做推广 + +## Middleware + +精力有限,还是更新中... +如果你愿意帮忙,可以直接在GitHub中,提交pull request, +我会在后边的贡献者页面里,列出你的名字和项目地址做推广 +## MiniProfiler + +精力有限,还是更新中... +如果你愿意帮忙,可以直接在GitHub中,提交pull request, +我会在后边的贡献者页面里,列出你的名字和项目地址做推广 + +## publish +精力有限,还是更新中... +如果你愿意帮忙,可以直接在GitHub中,提交pull request, +我会在后边的贡献者页面里,列出你的名字和项目地址做推广 + + +## Redis + +精力有限,还是更新中... +如果你愿意帮忙,可以直接在GitHub中,提交pull request, +我会在后边的贡献者页面里,列出你的名字和项目地址做推广 +## Repository +精力有限,还是更新中... +如果你愿意帮忙,可以直接在GitHub中,提交pull request, +我会在后边的贡献者页面里,列出你的名字和项目地址做推广 +## SeedData + +精力有限,还是更新中... +如果你愿意帮忙,可以直接在GitHub中,提交pull request, +我会在后边的贡献者页面里,列出你的名字和项目地址做推广 +## SignalR + +精力有限,还是更新中... +如果你愿意帮忙,可以直接在GitHub中,提交pull request, +我会在后边的贡献者页面里,列出你的名字和项目地址做推广 +## SqlSugar + +精力有限,还是更新中... +如果你愿意帮忙,可以直接在GitHub中,提交pull request, +我会在后边的贡献者页面里,列出你的名字和项目地址做推广 +## SqlSugar-Codefirst&DataSeed + +精力有限,还是更新中... +如果你愿意帮忙,可以直接在GitHub中,提交pull request, +我会在后边的贡献者页面里,列出你的名字和项目地址做推广 +## SqlSugar-SqlAOP + +精力有限,还是更新中... +如果你愿意帮忙,可以直接在GitHub中,提交pull request, +我会在后边的贡献者页面里,列出你的名字和项目地址做推广 +## Swagger + +精力有限,还是更新中... +如果你愿意帮忙,可以直接在GitHub中,提交pull request, +我会在后边的贡献者页面里,列出你的名字和项目地址做推广 +## T4 + +项目集成 `T4` 模板 `.\New_College.FrameWork` 层,目的是可以一键生成项目模板代码。 +1、需要在 `DbHelper.ttinclude` 中配置连接数据库连接字符串; +2、针对每一层的代码,就去指定的 `.tt` 模板,直接 `CTRL+S` 保存即可; + +> 注意,目前的代码是 `SqlServer` 版本的,其他数据库版本的,可以去群文件查看。 + + +## Test-xUnit + +项目简单使用了单元测试,通过 `xUnit` 组件,具体的可以查看 `New_College.Tests` 层相关代码。 +目前单元测试用例还比较少,大家可以自行添加。 + + +## Temple-Nuget + +本项目封装了 `Nuget` 自定义模板,你可以根据这个模板,一键创建自己的项目名,具体的操作,可以双击项目根目录下的 `CreateYourProject.bat` ,可以参考 [#如何项目重命名](http://apk.neters.club/.doc/guide/getting-started.html#%E5%A6%82%E4%BD%95%E9%A1%B9%E7%9B%AE%E9%87%8D%E5%91%BD%E5%90%8D) + +同时,你也可以再 `Nuget` 管理器中,搜索到: +nuget + + + +## UserInfo + + +项目中封装了获取用户信息的代码: +在 `.\New_College.Common\HttpContextUser` 文件夹下 `AspNetUser.cs` 实现类和 `IUser.cs` 接口。 + +如果使用,首先需要注册相应的服务,参见:`.\New_College\Extensions` 文件夹下的 `HttpContextSetup.cs`; +然后,就直接在控制器构造函数中,注入接口 `IUser` 即可; + +> `注意`: +> 1、如果要想获取指定的服务,必须登录,也就是必须要在 `Header` 中传递有效 `Token` ,这是肯定的。 +> 2、如果要获取用户信息,一定要在中间件 `app.UseAuthentication()` 之后(不要问为什么),控制器肯定在它之后,所以能获取到; +> 3、`【并不是】`一定需要添加 `[Authorize]` 特性,如果你加了这个特性,可以直接获取,但是如果不加,可以从我的 `AspNetUser.cs` 方法中,有一个直接从 `Header` 中解析的方法 `List GetUserInfoFromToken(string ClaimType);`: + +``` + public string GetToken() + { + return _accessor.HttpContext.Request.Headers["Authorization"].ObjToString().Replace("Bearer ", ""); + } + + public List GetUserInfoFromToken(string ClaimType) + { + + var jwtHandler = new JwtSecurityTokenHandler(); + if (!string.IsNullOrEmpty(GetToken())) + { + JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(GetToken()); + + return (from item in jwtToken.Claims + where item.Type == ClaimType + select item.Value).ToList(); + } + else + { + return new List() { }; + } + } + +``` diff --git a/.docs/contents/guide/function-sheet.md b/.docs/contents/guide/function-sheet.md new file mode 100644 index 0000000..3119a36 --- /dev/null +++ b/.docs/contents/guide/function-sheet.md @@ -0,0 +1,471 @@ +# H 核心功能一览表 + +## 一、表结构解析 + +`New_College` 项目共包含四部分的数据库表结构,分别是:用户角色管理部分、接口菜单权限管理部分、博客文章管理部分、以及其他不重要部分。 +> 注意:目前不提供与维护数据库数据,直接通过 `SeedData` 生成种子数据; + +### 1、用户角色管理部分[必须] +主要是三个表:分别对应用户表(sysUserInfo)、角色表(Role)、用户角色关系表(UserRole)。 + +usermanager + + + +### 2、接口菜单权限管理部分[必须] + +主要是四个表:分别对应接口表(Module)、菜单表(Permission)、接口菜单关系表(ModulePermission)暂时没用到、角色接口菜单关系表(RoleModulePermission)。 + +permissionmanager + + + + +### 3、博客文章管理部分[可选] +主要是三个表:分别对应博客表(BlogArticle)、Bug专题表(Topic)、Bug内容表(TopicDetail)。 + +blogmanager + + + + +### 4、其他不重要部分 + +主要是三个表:分别对应Job调度表(TasksQz)、密码库表(PasswordLib)、操作日志表(OperateLog)、广告表(Advertisement)、公告表(Guestbook)。 + +othersmanager + + + + + + +## 二、日志记录 + +本框架涵盖了不同领域的日志记录,共五个,分别是: + +1、全局异常日志 + + 开启方式:无需操作。 + 文件路径:web目录下,Log/GlobalExcepLogs_{日期}.log。 + 功能描述:记录项目启动后出现的所有异常日志,不包括中间件中异常。 + + +2、IP 请求日志 + + 开启方式:无需操作。 + 文件路径:web目录下,Log/RequestIpInfoLog.log。 + 功能描述:记录项目启动后客户端请求的ip和接口信息。 + 举例来说: + {"Ip":"xxx.xx.xx.x","Url":"/api/values","Datetime":"2020-01-06 18:02:19","Date":"2020-01-06","Week":"周一"} + + +3、全部请求与响应日志 + + 开启方式:appsettings.json -> Middlewar -> RequestResponseLog 节点为true。 + 文件路径:web目录下,Log/RequestIpInfoLog.log。 + 功能描述:记录项目启动后客户端所有的请求和响应日志,包括url参数、body以及相应json。 + + +4、服务层请求响应AOP日志 + + 开启方式:appsettings.json -> AppSettings -> LogAOP 节点为true。 + 文件路径:web目录下,Log/AOPLog.log。 + 功能描述:记录项目启动请求api后,所有的service层日志,包括方法名、参数、响应结果或用户(非必须)。 + + +5、数据库操作日志 + + 开启方式:appsettings.json -> AppSettings -> SqlAOP 节点为true。 + 文件路径:web目录下,Log/SqlLog.log。 + 功能描述:记录项目启动请求api并访问service后,所有的db操作日志,包括Sql参数与Sql语句。 + 举例来说: + -------------------------------- + 1/6/2020 6:13:04 PM| + 【SQL参数】:@bID0:1 + 【SQL语句】:SELECT `bID`,`bsubmitter`,`btitle`,`bcategory`,`bcontent`,`btraffic`,`bcommentNum`,`bUpdateTime`,`bCreateTime`,`bRemark`,`IsDeleted` FROM `BlogArticle` WHERE ( `bID` = @bID0 ) + + + ## 三、控制台信息展示 + + 配置 + + + + ## 四、Nginx一览表 + + + +``` +#user nobody; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +#error_log logs/error.log info; + +#pid logs/nginx.pid; +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + server_names_hash_bucket_size 64; + + #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + # '$status $body_bytes_sent "$http_referer" ' + # '"$http_user_agent" "$http_x_forwarded_for"'; + + #access_log logs/access.log main; + sendfile on; + #tcp_nopush on; + + #keepalive_timeout 0; + keepalive_timeout 600; + proxy_read_timeout 600; + proxy_send_timeout 600; + + proxy_buffer_size 128k; + proxy_buffers 32 32k; + proxy_busy_buffers_size 128k; + + #gzip on; + + ###################################################################### + server { + listen 80; + server_name www.neters.club; + + #charset koi8-r; + + #access_log logs/host.access.log main; + location / { + root C:\code\Code\Neters\home; + index index.html index.htm; + } + } + + server { + listen 80; + server_name neters.club; + + #charset koi8-r; + + #access_log logs/host.access.log main; + location / { + root C:\code\Code\Neters\home; + + index index.html index.htm; + } + } + + server { + listen 80; + server_name ids.neters.club; + rewrite ^(.*)$ https://$host$1 permanent;#把http的域名请求转成https,第二种写法在此节的末端 + + #charset koi8-r; + + #access_log logs/host.access.log main; + location / { + #proxy_pass http://localhost:5004; + root html; + index index.html index.htm; + } + } + + server { + listen 443 ssl; + server_name ids.neters.club; #网站域名,和80端口保持一致 + ssl on; + ssl_certificate 1_ids.neters.club_bundle.crt; #证书公钥 + ssl_certificate_key 2_ids.neters.club.key; #证书私钥 + ssl_session_cache shared:SSL:1m; + ssl_session_timeout 5m; + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_ciphers ECDH:AESGCM:HIGH:!RC4:!DH:!MD5:!3DES:!aNULL:!eNULL; + ssl_prefer_server_ciphers on; + + error_page 497 https://$host$uri?$args; + + location / { + proxy_pass http://localhost:5004; + proxy_redirect off; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_set_header Cookie $http_cookie; + #proxy_cookie_path + chunked_transfer_encoding off; + } + } + + server { + listen 80; + server_name apk.neters.club; + + #charset koi8-r; + + #access_log logs/host.access.log main; + location / { + root html; + proxy_pass http://localhost:8081; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection keep-alive; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_cache_bypass $http_upgrade; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + index index.html index.htm; + } + + location /.doc/ { + proxy_pass http://docs.neters.club/; + } + } + + server { + listen 80; + server_name docs.neters.club; + + location / { + root C:\code\Code\New_College\.docs\contents\.vuepress\dist; + index index.html index.htm; + } + } + + server { + listen 80; + server_name vueadmin.neters.club; + + location / { + try_files $uri $uri/ /index.html; + root C:\code\Code\Blog.Admin\distis; + #proxy_pass http://localhost:2364; + index index.html index.htm; + } + + location /api/ { + rewrite ^.+apb/?(.*)$ /$1 break; + include uwsgi_params; + proxy_pass http://localhost:8081; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + #proxy_set_header Connection "upgrade"; + #proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /api2/ { + rewrite ^.+apb/?(.*)$ /$1 break; + include uwsgi_params; + proxy_pass http://localhost:8081; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /images/ { + include uwsgi_params; + proxy_pass http://localhost:8081; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + #proxy_set_header Connection "upgrade"; + #proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + location /.doc/ { + proxy_pass http://docsadmin.neters.club/; + } + + error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } + + server { + listen 80; + server_name docsadmin.neters.club; + + location / { + root C:\code\Code\Blog.Admin\.doc\contents\.vuepress\dist; + index index.html index.htm; + } + } + + + server { + listen 80; + server_name ddd.neters.club; + location / { + proxy_pass http://localhost:4773; + index index.php index.html index.htm; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection keep-alive; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + } + } + + + server { + listen 80; + server_name ask.neters.club; + + #charset koi8-r; + + #access_log logs/host.access.log main; + location / { + root html; + proxy_pass http://localhost:5020; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + #proxy_set_header Connection "upgrade"; + #proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + index index.html index.htm; + } + } + + + server { + listen 80; + server_name vueblog.neters.club; + + location / { + try_files $uri $uri/ /index.html; + root C:\code\Code\Blog.Vue\dist; + index index.html index.htm; + } + + + location /api { + rewrite ^.+apb/?(.*)$ /$1 break; + include uwsgi_params; + proxy_pass http://localhost:8081; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + + location /images { + include uwsgi_params; + proxy_pass http://localhost:8081; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } + + upstream nodenuxt { + server 127.0.0.1:3089; # nuxt 项目监听PC端端口 + keepalive 64; + } + server { + listen 80; + server_name tibug.neters.club; + + location / { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Nginx-Proxy true; + proxy_cache_bypass $http_upgrade; + proxy_pass http://nodenuxt; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } + + server { + listen 80; + server_name jwt.neters.club; + + location / { + root C:\code\Code\jwttoken; + index index.html index.htm; + } + + error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } +} + +``` +> 这里说明下,我的 `Nginx` 文件中,`Ids4` 项目强制使用 `Https` ,采用的是直接跳转,这也是一个办法,当然还有第二种办法(感谢 `tibos`): +``` +server { + listen 80; + server_name admin.wmowm.com; + location / { + proxy_pass http://localhost:9002; + index index.php index.html index.htm; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection keep-alive; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + } +} + +server { + listen 443 ssl;#监听443端口(https默认端口) + server_name admin.wmowm.com; #填写绑定证书的域名 + ssl_certificate /etc/nginx/conf.d/key/admin.wm.crt;#填写你的证书所在的位置 + ssl_certificate_key /etc/nginx/conf.d/key/admin.wm.key;#填写你的key所在的位置 + ssl_session_timeout 5m; + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置 + ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置 + ssl_prefer_server_ciphers on; + location / { + proxy_pass http://localhost:9002; + index index.php index.html index.htm; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection keep-alive; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + +} +``` \ No newline at end of file diff --git a/.docs/contents/guide/getting-started.md b/.docs/contents/guide/getting-started.md new file mode 100644 index 0000000..f6dd463 --- /dev/null +++ b/.docs/contents/guide/getting-started.md @@ -0,0 +1,125 @@ +# K 快速上手 +注意 + +请确保你的 `Visual Studio 2019` 版本 >= `16.4`。 + + +## 下载 +Github(国际) 下载 [https://github.com/anjoy8/New_College](https://github.com/anjoy8/New_College) + +Gitee(国内) 下载 [https://gitee.com/laozhangIsPhi/New_College](https://gitee.com/laozhangIsPhi/New_College) + + +## 编译与运行 +1、拿到项目后,双击 `New_College.sln` 解决方案; +2、首先 `F6` 编译,看是否有错误; +3、然后 `F5` 运行,调起 `8081` 端口,浏览器查看效果; +4、因为系统默认的是 `sqlite` 数据库,如果你想换其他数据库,请看下边; +5、注意:本系统是直接自动生成数据库和数据的,不用手动创建数据库; + + + + +## CodeFirst 与 DbFirst +1、项目同时支持两个常见开发模式:`CodeFirst` 和 `DbFirst`; +2、首先 如果你是第一次下载我的项目,肯定是想要浏览效果和直接使用对应的权限相关的内容,这个时候肯定需要用到数据库表结构,那就肯定需要 `CodeFirst` ,只需要在`appsettings.json` 里配置好数据库连接字符串(下文会说到如何配置),就能正确运行; +3、浏览器查看效果,或者配合 `Admin` 项目查看效果后,如果感觉项目可行,并打算在此基础上二次开发,那肯定会在你刚刚创建的数据库种去创建新的表结构,这个时候就需要使用 `DbFirst` 模式,来生成四层项目问题:Model+Service+Repository等; +4、你可以使用T4模板,但是我更建议使用 `/api/DbFirst/GetFrameFiles` 接口来生成,不仅支持多种类型的数据库,还支持同时多库模式的输出; +5、如果你不想用我的表结构和实体类,在项目启动的时候,把配置文件的 `SeedDBEnabled`节点设置成False即可,然后配置对应的你自己的数据库连接字符串,比如是商城的,然后使用 `/api/DbFirst/GetFrameFiles` 接口来生成你的数据库四层类文件; + + + +## 如何配置数据库连接字符串 + +1、打开 `New_College` 项目下的 `appsettings.json` 文件; +2、修改 `DBS` 字节内容,配置对应的连接字符串,注意`DBType`对应不同的数据库类型; +3、把你想要运行的数据库 `Enabled` 为 `true` 即可,其他都要设置 `false`; +4、然后 `MainDB` 设置为下边你使用的指定 `ConnId`: + +``` + "MainDB": "WMBLOG_MSSQL", //当前项目的主库,所对应的连接字符串的Enabled必须为true + "MutiDBEnabled": false, //是否开启多库 + "DBS": [ + { + "ConnId": "WMBLOG_SQLITE", + "DBType": 2,// sqlite数据库 + "Enabled": true,// 设置为true,启用1 + "Connection": "WMBlog.db" //只写数据库名就行 + }, + { + "ConnId": "WMBLOG_MSSQL", + "DBType": 1,// sqlserver数据库 + "Enabled": true,// 设置为true,启用2 + "Connection": "Server=.;Database=WMBlogDB;User ID=sa;Password=123;", + "ProviderName": "System.Data.SqlClient" + }, + { + "ConnId": "WMBLOG_MYSQL", + "DBType": 0,// mysql + "Enabled": false,// false 不启用 + "Connection": "Server=localhost; Port=3306;Stmt=; Database=wmblogdb; Uid=root; Pwd=456;" + }, + { + "ConnId": "WMBLOG_ORACLE", + "DBType": 3,// Oracle + "Enabled": false,// 不启用 + "Connection": "Provider=OraOLEDB.Oracle; Data Source=WMBlogDB; User Id=sss; Password=789;" + } + ], +``` + + +5、如果你想多库操作,需要配置 +``` + a:MainDB 设置为主库的 ConnId; + b:MutiDBEnabled设置为true, + c:把下边想要连接的多个连接字符串都设置为true +``` + +## 如何配置项目端口号 +1、在 `New_College` 层下的 `program.cs` 文件中,将 `8081`端口,修改为自己想要的端口号; +2、或者在 `launchSettings.json` 中设置; + +## 如何项目重命名 +1、双击项目根目录下的 `CreateYourProject.bat` 批处理文件; +2、根据提示,输入自己想要的项目名称即可; +3、在根目录会有一个 `.1YourProject` 文件夹,里边即你的项目; + + +## 新增实体模块后如何迁移到数据库 +1、在 `New_College.Model` 项目目录下的 `Seed` 文件夹下,找到 `DBSeed` 类; +2、根据提示,找到生成table的地方 `myContext.CreateTableByEntity`; +3、添加进去你新增的实体类,当然也可以用下边的单独写法; +4、编译项目,没错后,运行,则数据库更新完毕; + + +## 新增实体,如何进行增删改查CURD操作 +1、随便找一个含有业务逻辑的 `controller` 参考一下即可; +2、主要 `api` 是通过 `Service` 服务层提供业务逻辑; +3、然后服务层通过 `Repository` 仓储层封装持久化操作; +4、每一个表基本上对应一个仓储类,基本的操作都封装到了 `BaseRepository.cs` 基类仓储中; +5、添加完业务逻辑,记得要 `F6` 重新编译一下,因为项目间引用解耦了; +6、项目已经自动注入了,直接在控制器使用对应的服务层接口就行: `IxxxxService` ; + + +## 新增数据库表,如何反向生成四层文件 +1、可以通过 `T4` 模板来生成,在 `New_College.FrameWork` 层,使用方法: [9757999.html](https://www.cnblogs.com/laozhang-is-phi/p/9757999.html#autoid-4-3-0) ; +> 注意:这种方案,目前默认的只能是 `SqlServer` ,其他类型的数据库,可以看上边文章中的代码,或者群文件里对应的代码。 + +2、也可以通过 `Sqlsugar` 所带的方法来实现 `DbFirst`,具体查看 `Controller` 层下的 `DbFirstController.cs`; + +3、总体操作过程,可以参考我的视频:[av77612407](https://www.bilibili.com/video/av77612407?p=2) ; + + +## 发布与部署 +1、双击项目根目录下的 `New_College.Publish.bat`批处理文件; +2、执行完成后,根目录会有一个`.PublishFiles` 文件夹,就是发布后的项目; + + +## 如何更新项目模板 +1、着急的话自己打包,不着急就提 `issue`,等我更新; +2、我的开源项目中,有个模板项目 `BlogCoreTempl` [地址](https://github.com/anjoy8/BlogCoreTempl),下载下来; +3、下载最新的 `New_College` 源代码; +4、将源代码拷贝到模板项目的 `content` 文件夹下; +5、双击 `Package.bat` 文件,就生成了最新的模板了; + diff --git a/.docs/package.json b/.docs/package.json new file mode 100644 index 0000000..3f0483b --- /dev/null +++ b/.docs/package.json @@ -0,0 +1,12 @@ +{ + "name": "BCVP", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC" +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7711e94 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# IDE0005: Using 指令是不需要的。 +dotnet_diagnostic.IDE0005.severity = warning diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..7c3b424 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: http://apk.neters.club/laozhangisphigood.jpg diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..80815c1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,22 @@ +blank_issues_enabled: false +contact_links: + - name: 🚨 Bug report | Bug 提交 + url: https://github.com/anjoy8/New_College/issues/new + about: | + Please report bugs here. + 请在此提交 Bug。 + - name: 🙋 Feature request | 新功能提案 + url: https://github.com/anjoy8/New_College/issues/new + about: | + Please request features here. + 请在此提交新功能提案。 + - name: 🤔 Consulting from the New_College team | 咨询 作者 + url: https://github.com/anjoy8/New_College/issues/new + about: | + Get technical support, project audits, app deployments, and custom development from the core New_College team. + 咨询核心 New_College 团队以获得技术支持,项目审核,应用程序部署以及自定义开发等方面上的帮助。 + - name: ❗️ All other issues | 其他问题 + url: https://github.com/anjoy8/New_College/issues/new + about: | + Please create all other issues here. + 请在此创建其他类型问题。 \ No newline at end of file diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml new file mode 100644 index 0000000..b72c6aa --- /dev/null +++ b/.github/workflows/dotnetcore.yml @@ -0,0 +1,17 @@ +name: .NET Core + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.100 + - name: Build with dotnet + run: dotnet build --configuration Release diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..832276b --- /dev/null +++ b/.gitignore @@ -0,0 +1,353 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ +# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true +**/wwwroot/lib/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + + +# wwwroot/images +*images/ +.1YourProject +.PublishFiles +!.template.config/*.nupkg +!New_College.Webapi.Template.*.nupkg +New_College/WMBlog.db +.docs/contents/.vuepress/dist/* +New_College/New_College*.xml +New_College.Api/WMBlog.db diff --git a/CreateYourProject.bat b/CreateYourProject.bat new file mode 100644 index 0000000..eb904eb --- /dev/null +++ b/CreateYourProject.bat @@ -0,0 +1,23 @@ +color 3 + +dotnet new -i .template.config\New_College.Webapi.Template.2.1.0.nupkg + +set /p OP=Please set your project name(for example:Baidu.Api): + +md .1YourProject + +cd .1YourProject + +dotnet new blogcoretpl -n %OP% + +cd ../ + + +echo "Create Successfully!!!! ^ please see the folder .1YourProject" + +dotnet new -u New_College.Webapi.Template + + +echo "Delete Template Successfully" + +pause \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/New_College.AdminMvc/New_College.AdminMvc.csproj b/New_College.AdminMvc/New_College.AdminMvc.csproj new file mode 100644 index 0000000..92605c5 --- /dev/null +++ b/New_College.AdminMvc/New_College.AdminMvc.csproj @@ -0,0 +1,7 @@ + + + + netcoreapp3.1 + + + diff --git a/New_College.AdminMvc/Program.cs b/New_College.AdminMvc/Program.cs new file mode 100644 index 0000000..1397a74 --- /dev/null +++ b/New_College.AdminMvc/Program.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace New_College.AdminMvc +{ + 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/New_College.AdminMvc/Properties/launchSettings.json b/New_College.AdminMvc/Properties/launchSettings.json new file mode 100644 index 0000000..f53df01 --- /dev/null +++ b/New_College.AdminMvc/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:51491", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "New_College.AdminMvc": { + "commandName": "Project", + "launchBrowser": true, + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/New_College.AdminMvc/Startup.cs b/New_College.AdminMvc/Startup.cs new file mode 100644 index 0000000..13a4baa --- /dev/null +++ b/New_College.AdminMvc/Startup.cs @@ -0,0 +1,42 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace New_College.AdminMvc +{ + public class Startup + { + /** + *┌──────────────────────────────────────────────────────────────┐ + *│ 描 述:当前项目为空,只是模拟一个MVC客户端 + *│ 作 者:anson zhang + *└──────────────────────────────────────────────────────────────┘ + */ + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + } + + // 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.UseRouting(); + + app.UseEndpoints(endpoints => + { + endpoints.MapGet("/", async context => + { + await context.Response.WriteAsync("Hello World!"); + }); + }); + } + } +} diff --git a/New_College.AdminMvc/appsettings.Development.json b/New_College.AdminMvc/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/New_College.AdminMvc/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/New_College.AdminMvc/appsettings.json b/New_College.AdminMvc/appsettings.json new file mode 100644 index 0000000..d9d9a9b --- /dev/null +++ b/New_College.AdminMvc/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/New_College.Api/.config/dotnet-tools.json b/New_College.Api/.config/dotnet-tools.json new file mode 100644 index 0000000..c6f5df7 --- /dev/null +++ b/New_College.Api/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "3.1.9", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file diff --git a/New_College.Api/Controllers/Back/AutoController.cs b/New_College.Api/Controllers/Back/AutoController.cs new file mode 100644 index 0000000..ed39c17 --- /dev/null +++ b/New_College.Api/Controllers/Back/AutoController.cs @@ -0,0 +1,183 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.IRepository; +using New_College.IServices; +using New_College.Model; + +namespace New_College.Api.Controllers.Back +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class AutoController : ControllerBase + { + private readonly ITest_CycleTimeInfoServices test_CycleTimeInfoServices; + private readonly ID_LongIdMapServices d_LongIdMapServices; + private readonly IT_LongIdMapServices t_LongIdMapServices; + private readonly IT_EnrollmentPlaneServices t_EnrollmentPlaneServices; + private readonly ID_UniversityServices d_UniversityServices; + private readonly ID_MajorSalaryServices d_MajorSalaryServices; + + public AutoController(ITest_CycleTimeInfoServices ITest_CycleTimeInfoServices + , ID_LongIdMapServices ID_LongIdMapServices + , IT_LongIdMapServices IT_LongIdMapServices + , IT_EnrollmentPlaneServices IT_EnrollmentPlaneServices + , ID_UniversityServices ID_UniversityServices + , ID_MajorSalaryServices ID_MajorSalaryServices) + { + + test_CycleTimeInfoServices = ITest_CycleTimeInfoServices; + d_LongIdMapServices = ID_LongIdMapServices; + t_LongIdMapServices = IT_LongIdMapServices; + t_EnrollmentPlaneServices = IT_EnrollmentPlaneServices; + d_UniversityServices = ID_UniversityServices; + d_MajorSalaryServices = ID_MajorSalaryServices; + } + #region old + ///// + ///// 生成周期 + ///// + ///// + //[HttpPost] + //public async Task> AutoCycleTime() + //{ + // var result = await test_CycleTimeInfoServices.AutoCycleTime(); + // return new MessageModel() + // { + // success = result, + // response = result, + // msg = result == true ? "成功" : "失败" + // }; + //} + + ///// + ///// + ///// + ///// + //[HttpPost] + //public async Task> Import() + //{ + // var result = await d_LongIdMapServices.Import(); + // return new MessageModel() + // { + // success = true, + // msg = "成功", + // response = result + // }; + //} + #endregion + + #region new T + ///// + ///// EnrollmentBatch + ///// + ///// + //[HttpPost] + //public async Task> ImportEnrollmentBatch() + //{ + // return new MessageModel() + // { + // success = true, + // msg = "成功", + // response = await t_LongIdMapServices.ImportEnrollmentBatch() + // }; + //} + + ///// + ///// EnrollmentPlane + ///// + ///// + //[HttpPost] + //public async Task> ImportEnrollmentPlane() + //{ + // return new MessageModel() + // { + // success = true, + // msg = "成功", + // response = await t_LongIdMapServices.ImportEnrollmentPlane() + // }; + //} + + ///// + ///// EnrollmentPlanedesc + ///// + ///// + //[HttpPost] + //public async Task> ImportEnrollmentPlanedesc() + //{ + // return new MessageModel() + // { + // success = true, + // msg = "成功", + // response = await t_LongIdMapServices.ImportEnrollmentPlanedesc() + // }; + //} + + ///// + ///// Batchline + ///// + ///// + //[HttpPost] + //public async Task> ImportBatchline() + //{ + // return new MessageModel() + // { + // success = true, + // msg = "成功", + // response = await t_LongIdMapServices.ImportBatchline() + // }; + //} + + ///// + ///// BatchTypeInfo + ///// + ///// + //[HttpPost] + //public async Task> ImportBatchTypeInfo() + //{ + // return new MessageModel() + // { + // success = true, + // msg = "成功", + // response = await t_LongIdMapServices.ImportBatchTypeInfo() + // }; + //} + #endregion + + ///// + ///// 2019上海招生分数更新 + ///// + ///// + //[HttpPost] + //public async Task> Import() + //{ + // var result = await t_EnrollmentPlaneServices.Import(); + // return new MessageModel() { success = true }; + //} + + ///// + ///// 下载图片 + ///// + ///// + //[HttpPost] + //public async Task> SaveImg() + //{ + // var result = await d_UniversityServices.SaveImg(); + // return new MessageModel() { success = true, msg = "成功" }; + //} + + + ///// + ///// 专业薪酬 + ///// + ///// + //[HttpPost] + //public async Task Import() + //{ + // return await d_MajorSalaryServices.Import(); + //} + } +} diff --git a/New_College.Api/Controllers/Back/CustomerController.cs b/New_College.Api/Controllers/Back/CustomerController.cs new file mode 100644 index 0000000..2c79b8d --- /dev/null +++ b/New_College.Api/Controllers/Back/CustomerController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; +using New_College.IServices; +using New_College.Model; +using New_College.Model.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace New_College.Api.Controllers.Back +{ + [Route("api/back/[controller]/[action]")] + [ApiController] + //[Authorize] + public class CustomerController : ControllerBase + { + private readonly IV_CustomerInfoServices v_CustomerInfoServices; + public CustomerController(IV_CustomerInfoServices IV_CustomerInfoServices) + { + v_CustomerInfoServices = IV_CustomerInfoServices; + } + /// + /// 获取分页 + /// + /// + /// + [HttpGet] + public async Task>> GetCustomerInfoListByPage([FromQuery] CustomerSeachQuery query) + { + return await v_CustomerInfoServices.GetCustomerInfoListByPage(query); + } + } +} diff --git a/New_College.Api/Controllers/Back/ExaminationPolicyController.cs b/New_College.Api/Controllers/Back/ExaminationPolicyController.cs new file mode 100644 index 0000000..07259ef --- /dev/null +++ b/New_College.Api/Controllers/Back/ExaminationPolicyController.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.IServices; +using New_College.Model; +using New_College.Model.ViewModels; + +namespace New_College.Api.Controllers.Back +{ + [Route("api/back/[controller]/[action]")] + [ApiController] + [Authorize] + public class ExaminationPolicyController : ControllerBase + { + private readonly IV_ExaminationPolicyServices iV_ExaminationPolicyServices; + public ExaminationPolicyController(IV_ExaminationPolicyServices IV_ExaminationPolicyServices) + { + iV_ExaminationPolicyServices = IV_ExaminationPolicyServices; + } + + /// + /// 获取分页 + /// + /// + /// + [HttpGet] + public async Task>> GetExaminationPolicyByPage([FromQuery] ExaminationPolicySearchQuery query) + { + return await iV_ExaminationPolicyServices.GetExaminationPolicyByPage(query); + } + + /// + /// 获取单个 + /// + /// + /// + [HttpGet] + public async Task> GetExaminationPolicyOne([FromQuery] IdQuery query) + { + return await iV_ExaminationPolicyServices.GetExaminationPolicyOne(query); + } + + /// + /// 添加 + /// + /// + /// + [HttpPost] + public async Task> AddExaminationPolicy([FromBody] ExaminationPolicyQuery query) + { + return await iV_ExaminationPolicyServices.AddExaminationPolicy(query); + } + + /// + /// 修改 + /// + /// + /// + [HttpPut] + public async Task> UpdateExaminationPolicy(ExaminationPolicyQuery query) + { + return await iV_ExaminationPolicyServices.UpdateExaminationPolicy(query); + } + + /// + /// 删除 + /// + /// + /// + [HttpPost] + public async Task> DeleteExaminationPolicy([FromBody] IdQuery query) + { + return await iV_ExaminationPolicyServices.DeleteExaminationPolicy(query); + } + } +} diff --git a/New_College.Api/Controllers/Back/OrderInfoController.cs b/New_College.Api/Controllers/Back/OrderInfoController.cs new file mode 100644 index 0000000..85d553a --- /dev/null +++ b/New_College.Api/Controllers/Back/OrderInfoController.cs @@ -0,0 +1,43 @@ +using Microsoft.AspNetCore.Mvc; +using New_College.IServices; +using New_College.Model; +using New_College.Model.ViewModels; +using System.Threading.Tasks; + +namespace New_College.Api.Controllers.Back +{ + [Route("api/back/[controller]/[action]")] + [ApiController] + public class OrderInfoController : ControllerBase + { + private readonly IV_OrderInfoServices v_OrderInfoServices; + private readonly IV_VipCardTypeServices iV_VipCardTypeServices; + public OrderInfoController(IV_OrderInfoServices IV_OrderInfoServices, IV_VipCardTypeServices IV_VipCardTypeServices) + { + v_OrderInfoServices = IV_OrderInfoServices; + iV_VipCardTypeServices = IV_VipCardTypeServices; + } + + /// + /// 获取分页 + /// + /// + /// + [HttpGet] + public async Task>> GetVipCardInfoByPage([FromQuery] SearchOrderQuery query) + { + return await v_OrderInfoServices.GetOrderInfoByPage(query); + } + + /// + /// 获取分页 + /// + /// + /// + [HttpGet] + public async Task>> GetOrderInfoList([FromQuery] SearchOrderQuery query) + { + return await v_OrderInfoServices.GetOrderInfoByPage(query); + } + } +} diff --git a/New_College.Api/Controllers/Back/VipCardController.cs b/New_College.Api/Controllers/Back/VipCardController.cs new file mode 100644 index 0000000..ad19718 --- /dev/null +++ b/New_College.Api/Controllers/Back/VipCardController.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using New_College.Model.ViewModels.Query; + +namespace New_College.Api.Controllers.Back +{ + [Route("api/back/[controller]/[action]")] + [ApiController] + public class VipCardController : ControllerBase + { + private readonly IV_VipCardInfoServices iV_VipCardInfoServices; + private readonly IV_VipCardTypeServices iV_VipCardTypeServices; + private readonly IV_OrderInfoServices iV_OrderInfoServices; + public VipCardController(IV_VipCardInfoServices IV_VipCardInfoServices, IV_VipCardTypeServices IV_VipCardTypeServices, IV_OrderInfoServices IV_OrderInfoServices) + { + iV_VipCardInfoServices = IV_VipCardInfoServices; + iV_VipCardTypeServices = IV_VipCardTypeServices; + iV_OrderInfoServices= IV_OrderInfoServices; + } + /// + /// 生成卡信息 + /// + /// + /// + [HttpPost] + public async Task>> AutoVipCardInfo([FromBody] AutoVipInfoQuery query) + { + return await iV_VipCardInfoServices.AutoVipCardInfo(query); + } + /// + /// 获取分页 + /// + /// + /// + [HttpGet] + public async Task>> GetVipCardInfoByPage([FromQuery] VipCardInfoSearchQuery query) + { + return await iV_VipCardInfoServices.GetVipCardInfoByPage(query); + } + + /// + /// 获取单个 + /// + /// + /// + [HttpGet] + public async Task> GetVipCardInfoOne([FromQuery] IdQuery query) + { + return await iV_VipCardInfoServices.GetVipCardInfoOne(query); + } + + /// + /// 添加 + /// + /// + /// + [HttpPost] + public async Task> AddVipCardInfo([FromBody] VipCardInfoQuery query) + { + return await iV_VipCardInfoServices.AddVipCardInfo(query); + } + + /// + /// 修改 + /// + /// + /// + [HttpPut] + public async Task> UpdateVipCardInfo(VipCardInfoQuery query) + { + return await iV_VipCardInfoServices.UpdateVipCardInfo(query); + } + + /// + /// 删除 + /// + /// + /// + [HttpPost] + public async Task> DeleteVipCardInfo([FromBody] IdQuery query) + { + return await iV_VipCardInfoServices.DeleteVipCardInfo(query); + } + /// + /// 获取vipcardTypeList + /// + /// + [HttpPost] + public async Task> GetVipCardType() + { + return await iV_VipCardTypeServices.GetVipCardType(); + } + } +} diff --git a/New_College.Api/Controllers/BlogController.cs b/New_College.Api/Controllers/BlogController.cs new file mode 100644 index 0000000..a2ccf4b --- /dev/null +++ b/New_College.Api/Controllers/BlogController.cs @@ -0,0 +1,336 @@ +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Threading.Tasks; +using New_College.Common.Helper; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using New_College.SwaggerHelper; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using StackExchange.Profiling; +using static New_College.Extensions.CustomApiVersion; + +namespace New_College.Controllers +{ + /// + /// 博客管理 + /// + [Produces("application/json")] + [Route("api/Blog")] + public class BlogController : Controller + { + readonly IBlogArticleServices _blogArticleServices; + private readonly ILogger _logger; + + /// + /// 构造函数 + /// + /// + /// + public BlogController(IBlogArticleServices blogArticleServices, ILogger logger) + { + _blogArticleServices = blogArticleServices; + _logger = logger; + } + + + /// + /// 获取博客列表【无权限】 + /// + /// + /// + /// + /// + /// + [HttpGet] + public async Task>> Get(int id, int page = 1, string bcategory = "技术博文", string key = "") + { + int intPageSize = 6; + if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) + { + key = ""; + } + + Expression> whereExpression = a => (a.bcategory == bcategory && a.IsDeleted == false) && ((a.btitle != null && a.btitle.Contains(key)) || (a.bcontent != null && a.bcontent.Contains(key))); + + var pageModelBlog = await _blogArticleServices.QueryPage(whereExpression, page, intPageSize, " bID desc "); + + using (MiniProfiler.Current.Step("获取成功后,开始处理最终数据")) + { + foreach (var item in pageModelBlog.data) + { + if (!string.IsNullOrEmpty(item.bcontent)) + { + item.bRemark = (HtmlHelper.ReplaceHtmlTag(item.bcontent)).Length >= 200 ? (HtmlHelper.ReplaceHtmlTag(item.bcontent)).Substring(0, 200) : (HtmlHelper.ReplaceHtmlTag(item.bcontent)); + int totalLength = 500; + if (item.bcontent.Length > totalLength) + { + item.bcontent = item.bcontent.Substring(0, totalLength); + } + } + } + } + + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = new PageModel() + { + page = page, + dataCount = pageModelBlog.dataCount, + data = pageModelBlog.data, + pageCount = pageModelBlog.pageCount, + } + }; + } + + + /// + /// 获取博客详情 + /// + /// + /// + [HttpGet("{id}")] + [Authorize(Policy = "Scope_BlogModule_Policy")] + public async Task> Get(int id) + { + return new MessageModel() + { + msg = "获取成功", + success = true, + response = await _blogArticleServices.GetBlogDetails(id) + }; + } + + + /// + /// 获取详情【无权限】 + /// + /// + /// + [HttpGet] + [Route("DetailNuxtNoPer")] + public async Task> DetailNuxtNoPer(int id) + { + _logger.LogInformation("xxxxxxxxxxxxxxxxxxx"); + return new MessageModel() + { + msg = "获取成功", + success = true, + response = await _blogArticleServices.GetBlogDetails(id) + }; + } + + [HttpGet] + [Route("GoUrl")] + public async Task GoUrl(int id) + { + var response = await _blogArticleServices.QueryById(id); + if (response != null && response.bsubmitter.IsNotEmptyOrNull()) + { + response.btraffic += 1; + await _blogArticleServices.Update(response); + return Redirect(response.bsubmitter); + } + + return null; + } + + [HttpGet] + [Route("GetBlogsByTypesForMVP")] + public async Task>> GetBlogsByTypesForMVP(string types = "", int id = 0) + { + if (types.IsNotEmptyOrNull()) + { + var blogs = await _blogArticleServices.Query(d => d.bcategory != null && types.Contains(d.bcategory) && d.IsDeleted == false); + return new MessageModel>() + { + msg = "获取成功", + success = true, + response = blogs + }; + } + + return new MessageModel>() { }; + } + + [HttpGet] + [Route("GetBlogByIdForMVP")] + public async Task> GetBlogByIdForMVP(int id = 0) + { + if (id > 0) + { + return new MessageModel() + { + msg = "获取成功", + success = true, + response = await _blogArticleServices.QueryById(id) + }; + } + + return new MessageModel() { }; + } + + /// + /// 获取博客测试信息 v2版本 + /// + /// + [HttpGet] + ////MVC自带特性 对 api 进行组管理 + //[ApiExplorerSettings(GroupName = "v2")] + ////路径 如果以 / 开头,表示绝对路径,反之相对 controller 的想u地路径 + //[Route("/api/v2/blog/Blogtest")] + //和上边的版本控制以及路由地址都是一样的 + + [CustomRoute(ApiVersions.V2, "Blogtest")] + public MessageModel V2_Blogtest() + { + return new MessageModel() + { + msg = "获取成功", + success = true, + response = "我是第二版的博客信息" + }; + } + + /// + /// 添加博客【无权限】 + /// + /// + /// + [HttpPost] + [Authorize(Policy = "Scope_BlogModule_Policy")] + public async Task> Post([FromBody] BlogArticle blogArticle) + { + var data = new MessageModel(); + + blogArticle.bCreateTime = DateTime.Now; + blogArticle.bUpdateTime = DateTime.Now; + blogArticle.IsDeleted = false; + blogArticle.bcategory = "技术博文"; + + var id = (await _blogArticleServices.Add(blogArticle)); + data.success = id > 0; + if (data.success) + { + data.response = id.ObjToString(); + data.msg = "添加成功"; + } + + return data; + } + + + /// + /// + /// + /// + /// + [HttpPost] + [Route("AddForMVP")] + [Authorize(Permissions.Name)] + public async Task> AddForMVP([FromBody] BlogArticle blogArticle) + { + var data = new MessageModel(); + + blogArticle.bCreateTime = DateTime.Now; + blogArticle.bUpdateTime = DateTime.Now; + blogArticle.IsDeleted = false; + + var id = (await _blogArticleServices.Add(blogArticle)); + data.success = id > 0; + if (data.success) + { + data.response = id.ObjToString(); + data.msg = "添加成功"; + } + + return data; + } + /// + /// 更新博客信息 + /// + /// + /// + // PUT: api/User/5 + [HttpPut] + [Route("Update")] + [Authorize(Permissions.Name)] + public async Task> Put([FromBody] BlogArticle BlogArticle) + { + var data = new MessageModel(); + if (BlogArticle != null && BlogArticle.bID > 0) + { + var model = await _blogArticleServices.QueryById(BlogArticle.bID); + + if (model != null) + { + model.btitle = BlogArticle.btitle; + model.bcategory = BlogArticle.bcategory; + model.bsubmitter = BlogArticle.bsubmitter; + model.bcontent = BlogArticle.bcontent; + model.btraffic = BlogArticle.btraffic; + + data.success = await _blogArticleServices.Update(model); + if (data.success) + { + data.msg = "更新成功"; + data.response = BlogArticle?.bID.ObjToString(); + } + } + + } + + return data; + } + + + + /// + /// 删除博客 + /// + /// + /// + [HttpDelete] + [Authorize(Permissions.Name)] + [Route("Delete")] + public async Task> Delete(int id) + { + var data = new MessageModel(); + if (id > 0) + { + var blogArticle = await _blogArticleServices.QueryById(id); + blogArticle.IsDeleted = true; + data.success = await _blogArticleServices.Update(blogArticle); + if (data.success) + { + data.msg = "删除成功"; + data.response = blogArticle?.bID.ObjToString(); + } + } + + return data; + } + /// + /// apache jemeter 压力测试 + /// 更新接口 + /// + /// + [HttpGet] + [Route("ApacheTestUpdate")] + public async Task> ApacheTestUpdate() + { + return new MessageModel() + { + success = true, + msg = "更新成功", + response = await _blogArticleServices.Update(new { bsubmitter = $"laozhang{DateTime.Now.Millisecond}", bID = 1 }) + }; + } + } +} \ No newline at end of file diff --git a/New_College.Api/Controllers/DbFirst/DbFirstController.cs b/New_College.Api/Controllers/DbFirst/DbFirstController.cs new file mode 100644 index 0000000..9083bcf --- /dev/null +++ b/New_College.Api/Controllers/DbFirst/DbFirstController.cs @@ -0,0 +1,133 @@ +using New_College.Common; +using New_College.Common.DB; +using New_College.Model; +using New_College.Model.Seed; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Hosting; +using SqlSugar; +using System.Linq; + +namespace New_College.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + //[Authorize(Permissions.Name)] + public class DbFirstController : ControllerBase + { + private readonly SqlSugarClient _sqlSugarClient; + private readonly IWebHostEnvironment Env; + + /// + /// 构造函数 + /// + public DbFirstController(ISqlSugarClient sqlSugarClient, IWebHostEnvironment env) + { + _sqlSugarClient = sqlSugarClient as SqlSugarClient; + Env = env; + } + + /// + /// 获取 整体框架 文件 + /// + /// + [HttpGet] + public MessageModel GetFrameFiles() + { + var data = new MessageModel() { success = true, msg = "" }; + data.response += @"file path is:C:\my-file\}"; + var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); + if (Env.IsDevelopment()) + { + data.response += $"Controller层生成:{FrameSeed.CreateControllers(_sqlSugarClient)} || "; + + BaseDBConfig.MutiConnectionString.Item1.ToList().ForEach(m => + { + _sqlSugarClient.ChangeDatabase(m.ConnId.ToLower()); + data.response += $"库{m.ConnId}-Model层生成:{FrameSeed.CreateModels(_sqlSugarClient, m.ConnId, isMuti)} || "; + data.response += $"库{m.ConnId}-IRepositorys层生成:{FrameSeed.CreateIRepositorys(_sqlSugarClient, m.ConnId, isMuti)} || "; + data.response += $"库{m.ConnId}-IServices层生成:{FrameSeed.CreateIServices(_sqlSugarClient, m.ConnId, isMuti)} || "; + data.response += $"库{m.ConnId}-Repository层生成:{FrameSeed.CreateRepository(_sqlSugarClient, m.ConnId, isMuti)} || "; + data.response += $"库{m.ConnId}-Services层生成:{FrameSeed.CreateServices(_sqlSugarClient, m.ConnId, isMuti)} || "; + }); + + // 切回主库 + _sqlSugarClient.ChangeDatabase(MainDb.CurrentDbConnId.ToLower()); + } + else + { + data.success = false; + data.msg = "当前不处于开发模式,代码生成不可用!"; + } + + return data; + } + + /// + /// 根据数据库表名 生成整体框架 + /// 仅针对通过CodeFirst生成表的情况 + /// + /// 数据库链接名称 + /// 需要生成的表名 + /// + [HttpPost] + public MessageModel GetFrameFilesByTableNames([FromBody]string[] tableNames, [FromQuery]string ConnID = null) + { + ConnID = ConnID == null ? MainDb.CurrentDbConnId.ToLower() : ConnID; + + var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); + var data = new MessageModel() { success = true, msg = "" }; + if (Env.IsDevelopment()) + { + + data.response += $"库{ConnID}-IRepositorys层生成:{FrameSeed.CreateIRepositorys(_sqlSugarClient, ConnID, isMuti, tableNames)} || "; + data.response += $"库{ConnID}-IServices层生成:{FrameSeed.CreateIServices(_sqlSugarClient, ConnID, isMuti, tableNames)} || "; + data.response += $"库{ConnID}-Repository层生成:{FrameSeed.CreateRepository(_sqlSugarClient, ConnID, isMuti, tableNames)} || "; + data.response += $"库{ConnID}-Services层生成:{FrameSeed.CreateServices(_sqlSugarClient, ConnID, isMuti, tableNames)} || "; + } + else + { + data.success = false; + data.msg = "当前不处于开发模式,代码生成不可用!"; + } + + return data; + } + + /// + /// DbFrist 根据数据库表名 生成整体框架,包含Model层 + /// + /// 数据库链接名称 + /// 需要生成的表名 + /// + [HttpPost] + public MessageModel GetAllFrameFilesByTableNames([FromBody]string[] tableNames, [FromQuery]string ConnID = null) + { + ConnID = ConnID == null ? MainDb.CurrentDbConnId.ToLower() : ConnID; + + var isMuti = Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool(); + var data = new MessageModel() { success = true, msg = "" }; + if (Env.IsDevelopment()) + { + _sqlSugarClient.ChangeDatabase(ConnID.ToLower()); + data.response += $"Controller层生成:{FrameSeed.CreateControllers(_sqlSugarClient, ConnID, isMuti, tableNames)} || "; + data.response += $"库{ConnID}-Model层生成:{FrameSeed.CreateModels(_sqlSugarClient, ConnID, isMuti, tableNames)} || "; + data.response += $"库{ConnID}-IRepositorys层生成:{FrameSeed.CreateIRepositorys(_sqlSugarClient, ConnID, isMuti, tableNames)} || "; + data.response += $"库{ConnID}-IServices层生成:{FrameSeed.CreateIServices(_sqlSugarClient, ConnID, isMuti, tableNames)} || "; + data.response += $"库{ConnID}-Repository层生成:{FrameSeed.CreateRepository(_sqlSugarClient, ConnID, isMuti, tableNames)} || "; + data.response += $"库{ConnID}-Services层生成:{FrameSeed.CreateServices(_sqlSugarClient, ConnID, isMuti, tableNames)} || "; + // 切回主库 + _sqlSugarClient.ChangeDatabase(MainDb.CurrentDbConnId.ToLower()); + } + else + { + data.success = false; + data.msg = "当前不处于开发模式,代码生成不可用!"; + } + + return data; + } + + + } +} \ No newline at end of file diff --git a/New_College.Api/Controllers/DbFirst/MigrateController.cs b/New_College.Api/Controllers/DbFirst/MigrateController.cs new file mode 100644 index 0000000..2476e46 --- /dev/null +++ b/New_College.Api/Controllers/DbFirst/MigrateController.cs @@ -0,0 +1,191 @@ +using New_College.Common.Helper; +using New_College.IRepository.UnitOfWork; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Hosting; +using Newtonsoft.Json; +using System; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + //[Authorize(Permissions.Name)] + public class MigrateController : ControllerBase + { + private readonly IUnitOfWork _unitOfWork; + private readonly IRoleModulePermissionServices _roleModulePermissionServices; + private readonly IUserRoleServices _userRoleServices; + private readonly IRoleServices _roleServices; + private readonly IPermissionServices _permissionServices; + private readonly IModuleServices _moduleServices; + private readonly IWebHostEnvironment _env; + + public MigrateController(IUnitOfWork unitOfWork, + IRoleModulePermissionServices roleModulePermissionServices, + IUserRoleServices userRoleServices, + IRoleServices roleServices, + IPermissionServices permissionServices, + IModuleServices moduleServices, + IWebHostEnvironment env) + { + _unitOfWork = unitOfWork; + _roleModulePermissionServices = roleModulePermissionServices; + _userRoleServices = userRoleServices; + _roleServices = roleServices; + _permissionServices = permissionServices; + _moduleServices = moduleServices; + _env = env; + } + + /// + /// 获取权限部分Map数据(从库) + /// 迁移到新库(主库) + /// + /// + [HttpGet] + public async Task> DataMigrateFromOld2New() + { + var data = new MessageModel() { success = true, msg = "" }; + if (_env.IsDevelopment()) + { + try + { + // 获取权限集合数据 + var rmps = await _roleModulePermissionServices.GetRMPMaps(); + // 当然,你可以做个where查询 + //rmps = rmps.Where(d => d.ModuleId > 88).ToList(); + + // 开启事务,保证数据一致性 + _unitOfWork.BeginTran(); + + var rid = 0; + var pid = 0; + var mid = 0; + var rpmid = 0; + + // 注意信息的完整性,不要重复添加,确保主库没有要添加的数据 + foreach (var item in rmps) + { + // 角色信息,防止重复添加,做了判断 + if (item.Role != null) + { + var isExit = (await _roleServices.Query(d => d.Name == item.Role.Name && d.IsDeleted == false)).FirstOrDefault(); + if (isExit == null) + { + rid = await _roleServices.Add(item.Role); + Console.WriteLine($"Role Added:{item.Role.Name}"); + } + else + { + rid = isExit.Id; + } + } + + // 菜单 + if (item.Permission != null) + { + pid = await _permissionServices.Add(item.Permission); + Console.WriteLine($"Permission Added:{item.Permission.Name}"); + } + + // 接口 + if (item.Module != null) + { + mid = await _moduleServices.Add(item.Module); + Console.WriteLine($"Module Added:{item.Module.LinkUrl}"); + } + + // 关系 + if (rid > 0 && pid > 0 && mid > 0) + { + rpmid = await _roleModulePermissionServices.Add(new RoleModulePermission() + { + IsDeleted = false, + CreateTime = DateTime.Now, + ModifyTime = DateTime.Now, + ModuleId = mid, + PermissionId = pid, + RoleId = rid, + }); + Console.WriteLine($"RMP Added:{rpmid}"); + } + + } + + + _unitOfWork.CommitTran(); + + data.success = true; + data.msg = "导入成功!"; + } + catch (Exception) + { + _unitOfWork.RollbackTran(); + + } + } + else + { + data.success = false; + data.msg = "当前不处于开发模式,代码生成不可用!"; + } + + return data; + } + + + /// + /// 权限数据库导出tsv + /// + /// + [HttpGet] + public async Task> SaveData2TsvAsync() + { + var data = new MessageModel() { success = true, msg = "" }; + if (_env.IsDevelopment()) + { + try + { + // 取出数据,序列化,自己可以处理判空 + var rolesJson = JsonConvert.SerializeObject(await _roleServices.Query(d => d.IsDeleted == false)); + FileHelper.WriteFile(Path.Combine(_env.WebRootPath, "BlogCore.Data.json", "Role_New.tsv"), rolesJson, Encoding.UTF8); + + + var permissionsJson = JsonConvert.SerializeObject(await _permissionServices.Query(d => d.IsDeleted == false)); + FileHelper.WriteFile(Path.Combine(_env.WebRootPath, "BlogCore.Data.json", "Permission_New.tsv"), permissionsJson, Encoding.UTF8); + + + var modulesJson = JsonConvert.SerializeObject(await _moduleServices.Query(d => d.IsDeleted == false)); + FileHelper.WriteFile(Path.Combine(_env.WebRootPath, "BlogCore.Data.json", "Modules_New.tsv"), modulesJson, Encoding.UTF8); + + + var rmpsJson = JsonConvert.SerializeObject(await _roleModulePermissionServices.Query(d => d.IsDeleted == false)); + FileHelper.WriteFile(Path.Combine(_env.WebRootPath, "BlogCore.Data.json", "RoleModulePermission_New.tsv"), rmpsJson, Encoding.UTF8); + } + catch (Exception) + { + } + + + data.success = true; + data.msg = "生成成功!"; + } + else + { + data.success = false; + data.msg = "当前不处于开发模式,代码生成不可用!"; + } + + return data; + } + + } +} \ No newline at end of file diff --git a/New_College.Api/Controllers/Front/CustomerController.cs b/New_College.Api/Controllers/Front/CustomerController.cs new file mode 100644 index 0000000..bb009b5 --- /dev/null +++ b/New_College.Api/Controllers/Front/CustomerController.cs @@ -0,0 +1,199 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.AuthHelper.OverWrite; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Request; +using New_College.Model.ViewModels; + +namespace New_College.Api.Controllers.Front +{ + [Route("api/front/[controller]/[action]")] + [ApiController] + [Authorize(Roles = "users")] + public class CustomerController : ControllerBase + { + private readonly IV_CustomerInfoServices _services; + public CustomerController(IV_CustomerInfoServices IV_CustomerInfoServices) + { + _services = IV_CustomerInfoServices; + } + + + /// + /// 获取微信openid + /// + /// + /// + [HttpPost] + [AllowAnonymous] + public MessageModel GetWeixinAuthinfo(WeixinLogin login) + { + var response = new CustomerInfoResult(); + try + { + var result = _services.AuthCode2Session(login.code); + if (result.openid != "" && result.openid != null) + { + var loginstatus = _services.Logined(new LoginQuery() { openId = result.openid }).Result; + if (loginstatus.Item1) + { + response = loginstatus.Item2; + } + else + { + var save = _services.CustomerSave(new DecryptUserInfoRequest() { openid = result.openid }).Result; + response.OpenId = result.openid; + response.Id = save; + } + TokenModelJwt tokenModel = new TokenModelJwt { Uid = response.Id, Role = "users" }; + response.Token = JwtHelper.IssueJwt(tokenModel); + return new MessageModel() + { + success = true, + msg = "success", + response = response + }; + } + else + { + return new MessageModel() + { + success = false, + response = response + }; + } + } + catch (Exception ex) + { + return new MessageModel() + { + msg = ex.ToString(), + success = false, + response = response + }; + } + } + + + + + + /// + /// 解密手机号同时保存用户信息 + /// + /// + /// + [HttpPost] + public async Task> WeixinDecryptUserInfo(DecryptUserInfoRequest request) + { + var phoneinfo = _services.GetWeixinPhone(new GetPhoneInfo() + { + + encryptedData = request.encryptedData, + iv = request.iv, + openid = request.openid, + session_key = request.session_key + }); + request.phone = phoneinfo; + var customerinfo = (await _services.Query(e => e.OpenId == request.openid)).FirstOrDefault(); + customerinfo.AvatarUrl = request.avatarUrl; + customerinfo.NickName = request.nickName; + customerinfo.Gender = request.gender; + customerinfo.Phone = phoneinfo; + var result = await _services.Update(customerinfo); + return new MessageModel() + { + msg = result ? "修改成功" : "保存失败", + response = result, + success = result + }; + + } + + + + + /// + ///用户获取用户信息有OpenId 调用此接口 + /// + /// + /// + [HttpGet] + public async Task> GetUserInfo([FromQuery] LoginQuery query) + { + var result = await _services.GetUserInfo(query); + return new MessageModel() + { + response = result.Item2, + success = result.Item1, + msg = result.Item1 ? "登陆成功" : "用户不存在" + }; + } + + + + + + + /// + /// 更改分数 + /// + /// + /// + [HttpPost] + public async Task> UpdateScore(UpdateScoreQuery query) + { + var result = await _services.UpdateScore(query); + if (result.Id > 0) + { + var token = JwtHelper.IssueJwt(new TokenModelJwt() { Uid = result.Id, Role = "学生" }); + result.Token = token; + } + return new MessageModel() + { + success = result.Status == 1, + msg = result.Status == 1 ? "修改成功" : "修改失败", + response = result + }; + } + + /// + /// 完善用户信息 + /// + /// + /// + [HttpPost] + public async Task> UpdateCustomer(CustomerUpdateQuery query) + { + var result = await _services.UpdateCustomer(query); + if (result.Id > 0) + { + var token = JwtHelper.IssueJwt(new TokenModelJwt() { Uid = result.Id, Role = "学生" }); + result.Token = token; + } + return new MessageModel() + { + success = result.Status == 1, + msg = result.Status == 1 ? "成功" : "失败", + response = result + }; + } + + /// + /// 根绝Id获取用户信息 + /// + /// + /// + [HttpGet] + public async Task> GetCustomerInfoById([FromQuery] IdQuery query) + { + return await _services.GetCustomerInfoById(query); + } + } +} diff --git a/New_College.Api/Controllers/Front/ExaminationPolicyController.cs b/New_College.Api/Controllers/Front/ExaminationPolicyController.cs new file mode 100644 index 0000000..525da47 --- /dev/null +++ b/New_College.Api/Controllers/Front/ExaminationPolicyController.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.AuthHelper.OverWrite; +using New_College.IServices; +using New_College.Model; +using New_College.Model.ViewModels; + +namespace New_College.Api.Controllers.Front +{ + [Route("api/front/[controller]/[action]")] + [ApiController] + [Authorize] + public class ExaminationPolicyController : ControllerBase + { + private readonly IV_ExaminationPolicyServices iV_ExaminationPolicyServices; + public ExaminationPolicyController(IV_ExaminationPolicyServices IV_ExaminationPolicyServices) + { + iV_ExaminationPolicyServices = IV_ExaminationPolicyServices; + } + + /// + /// 获取考试时间 + /// + /// + /// + [HttpGet] + public async Task> GetExaminationPolicyDetail([FromQuery] ExaminationPolicyAreaQuery query) + { + return await iV_ExaminationPolicyServices.GetExaminationPolicyDetail(query); + } + } +} diff --git a/New_College.Api/Controllers/Front/LibraryController.cs b/New_College.Api/Controllers/Front/LibraryController.cs new file mode 100644 index 0000000..1ddf48d --- /dev/null +++ b/New_College.Api/Controllers/Front/LibraryController.cs @@ -0,0 +1,334 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.IServices; +using New_College.Model; +using New_College.Model.ViewModels; + + +namespace New_College.Api.Controllers.Front +{ + [Route("api/front/[controller]/[action]")] + [ApiController] + public class LibraryController : ControllerBase + { + private readonly ID_LongIdMapServices iD_LongIdMapServices; + public LibraryController(ID_LongIdMapServices ID_LongIdMapServices) + { + iD_LongIdMapServices = ID_LongIdMapServices; + } + + /// + /// 获取院校库 + /// + /// + /// + [HttpGet] + public async Task>> GetUniversitys([FromQuery] UniversityQuery query) + { + var result = await iD_LongIdMapServices.GetUniversitys(query); + if (result.data == null || result.data.Count <= 0) + { + return new MessageModel>() + { + success = false, + msg = "获取失败", + }; + } + else + { + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = result + }; + + } + + } + + /// + /// 专业库 一级二级列表 + /// + /// + /// + [HttpGet] + public async Task>> uniGetMajorInfo([FromQuery] MajorcategoryQuery query) + { + var result = await iD_LongIdMapServices.uniGetMajorInfo(query); + return new MessageModel>() + { + success = result.Count <= 0 ? false : true, + msg = result.Count <= 0 ? "获取失败" : "获取成功", + response = result + }; + } + + /// + /// 获取推荐职业 + /// + /// + [HttpGet] + public async Task>> GetRecommendOccupation() + { + var result = await iD_LongIdMapServices.GetRecommendOccupation(); + return new MessageModel>() + { + success = result.Count <= 0 ? false : true, + msg = result.Count <= 0 ? "获取失败" : "获取成功", + response = result + }; + } + + /// + /// 职业库 一级二级列表 + /// + /// + [HttpGet] + public async Task>> uniGetOccupationInfo() + { + var result = await iD_LongIdMapServices.uniGetOccupationInfo(); + return new MessageModel>() + { + success = result.Count <= 0 ? false : true, + msg = result.Count <= 0 ? "获取失败" : "获取成功", + response = result + }; + } + + /// + /// 获取职业第三级 + /// + /// + /// + [HttpGet] + public async Task>> GetOccupationThree([FromQuery] IdQuery query) + { + return await iD_LongIdMapServices.GetOccupationThree(query); + } + + /// + /// 院校详情 + /// + /// + /// + [HttpGet] + public async Task> GetUniversityDetails([FromQuery] IdQuery query) + { + var result = await iD_LongIdMapServices.GetUniversityDetails(query); + return new MessageModel() + { + success = result.Status == 1 ? true : false, + msg = result.Status == 1 ? "获取成功" : "获取失败", + response = result + }; + } + + /// + /// 获取专业介绍 + /// + /// + /// + [HttpGet] + public async Task> GetMajorDetail([FromQuery] MajorQuery query) + { + var result = await iD_LongIdMapServices.GetMajorDetail(query); + return new MessageModel() + { + success = result.id > 0 ? true : false, + msg = result.id > 0 ? "获取成功" : "获取失败", + response = result + }; + } + + /// + /// 相关院校 + /// + /// + /// + [HttpGet] + public async Task>> GetRelevantSchool([FromQuery] MajorSchoolQuery query) + { + var result = await iD_LongIdMapServices.GetRelevantSchool(query); + return new MessageModel>() + { + success = (result.data == null || result.data.Count <= 0) == true ? false : true, + msg = (result.data == null || result.data.Count <= 0) == true ? "获取失败" : "获取成功", + response = result + }; + } + + /// + /// 获取专业就业前景 + /// + /// + /// + [HttpGet] + public async Task> GetCareerProspects([FromQuery] MajorCareerQuery query) + { + var result = await iD_LongIdMapServices.GetCareerProspects(query); + return new MessageModel() + { + success = true, + msg = "获取成功", + response = result + }; + } + + /// + /// 获取第三级 + /// + /// + /// + [HttpGet] + public async Task>> uniGetMajorThree([FromQuery] ManageMajorQuery query) + { + return await iD_LongIdMapServices.uniGetMajorThree(query); + } + + /// + /// 根据标签推荐专业 + /// + /// + /// + [HttpGet] + public async Task>> GetMajorThreeByTag([FromQuery] MajorThreeByTagQuery query) + { + return await iD_LongIdMapServices.GetMajorThreeByTag(query); + } + + /// + /// 获取职业详情-职业介绍 + /// + /// + [HttpGet] + public async Task> GetRecommendIntroduce([FromQuery] IdQuery query) + { + var result = await iD_LongIdMapServices.GetRecommendIntroduce(query); + return new MessageModel() + { + success = result.Status == 1 ? true : false, + msg = result.Status == 1 ? "获取成功" : "获取失败", + response = result + }; + } + + /// + /// 院校相关专业专用 + /// + /// + /// + [HttpGet] + public async Task>> GetUniversityMajor([FromQuery] IdQuery query) + { + var result = await iD_LongIdMapServices.GetUniversityMajor(query); + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = result + }; + } + + /// + /// 查学校省份的 年份批次 + /// + /// + /// + [HttpGet] + public async Task> GetBatchYearBySchoolId([FromQuery] PlanYearQuery query) + { + var result = await iD_LongIdMapServices.GetBatchYearBySchoolId(query); + return new MessageModel() + { + success = result != null, + msg = result != null ? "获取成功" : "获取失败", + response = result + }; + } + + /// + /// 获取招生计划 院校详情 + /// + /// + /// + [HttpGet] + public async Task>> GetPlanBySchollId([FromQuery] PlanQuery query) + { + var result = await iD_LongIdMapServices.GetPlanBySchollId(query); + if (result == null || result.Count() <= 0) + { + return new MessageModel>() + { + success = false, + msg = "获取失败" + }; + } + else + { + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = result + }; + } + } + + /// + /// 获取院校排名 + /// + /// + /// + [HttpGet] + public async Task>> GetUniversityRank([FromQuery] UniversityRankQuery query) + { + var result = await iD_LongIdMapServices.GetUniversityRank(query); + return new MessageModel>() + { + success = result.Count > 0, + msg = result.Count > 0 ? "获取成功" : "获取失败", + response = result + }; + } + + /// + /// 专业搜索 + /// + /// + /// + [HttpGet] + public async Task>> uniGetSearchMajor([FromQuery] NameBaseQuery query) + { + return await iD_LongIdMapServices.uniGetSearchMajor(query); + } + + /// + /// 获取招生简章列表 + /// + /// + /// + [HttpGet] + public async Task>> GetRequestEnrollmentinproductionResult([FromQuery] UniversityIdQuery query) + { + return await iD_LongIdMapServices.GetRequestEnrollmentinproductionResult(query); + } + + + /// + /// 获取招生简介详情 + /// + /// + /// + [HttpGet] + public async Task> GetRequestEnrollmentinproductionDetailResult([FromQuery] StringIdQuery query) + { + return await iD_LongIdMapServices.GetRequestEnrollmentinproductionDetailResult(query); + } + } +} diff --git a/New_College.Api/Controllers/Front/MajorSalaryController.cs b/New_College.Api/Controllers/Front/MajorSalaryController.cs new file mode 100644 index 0000000..0851dec --- /dev/null +++ b/New_College.Api/Controllers/Front/MajorSalaryController.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.IServices; +using New_College.Model; +using New_College.Model.ViewModels; + +namespace New_College.Api.Controllers.Front +{ + [Route("api/front/[controller]/[action]")] + [ApiController] + public class MajorSalaryController : ControllerBase + { + private readonly ID_MajorSalaryServices iD_MajorSalaryServices; + public MajorSalaryController(ID_MajorSalaryServices ID_MajorSalaryServices) + { + iD_MajorSalaryServices = ID_MajorSalaryServices; + } + + /// + /// 获取高薪推荐 + /// + /// + [HttpGet] + public async Task>> GetMajorSalaryResult([FromQuery] MajorSalaryQuery query) + { + return await iD_MajorSalaryServices.GetMajorSalaryResult(query); + } + } +} diff --git a/New_College.Api/Controllers/Front/OrderController.cs b/New_College.Api/Controllers/Front/OrderController.cs new file mode 100644 index 0000000..fd9e908 --- /dev/null +++ b/New_College.Api/Controllers/Front/OrderController.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.IServices; +using New_College.Model; +using New_College.Model.ViewModels; + +namespace New_College.Api.Controllers.Front +{ + [Route("api/front/[controller]/[action]")] + [ApiController] + public class OrderController : ControllerBase + { + private readonly IV_OrderInfoServices v_OrderInfoServices; + public OrderController(IV_OrderInfoServices IV_OrderInfoServices) + { + v_OrderInfoServices = IV_OrderInfoServices; + } + + /// + /// 下订单 + /// + /// + [HttpPost] + public async Task> CreateOrder(UniOrderQuery query) + { + var result = await v_OrderInfoServices.CreateOrder(query); + return new MessageModel() + { + success = result.success, + msg = result.msg, + response = result + }; + } + } +} diff --git a/New_College.Api/Controllers/Front/RegionController.cs b/New_College.Api/Controllers/Front/RegionController.cs new file mode 100644 index 0000000..6336681 --- /dev/null +++ b/New_College.Api/Controllers/Front/RegionController.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.IServices; +using New_College.Model; +using New_College.Model.ViewModels; + +namespace New_College.Api.Controllers.Front +{ + [Route("api/front/[controller]/[action]")] + [ApiController] + public class RegionController : ControllerBase + { + private readonly ISysRegionServices sysRegionServices; + public RegionController(ISysRegionServices ISysRegionServices) + { + sysRegionServices = ISysRegionServices; + } + + /// + /// 获取省市区 + /// + /// + /// + [HttpGet] + public async Task>> GetRegionList([FromQuery] SysRegionQuery query) + { + List list = new List() { }; + list.Add(new SysRegionResult() { Id = 0, Code = "0", Name = "全国" }); + var result = await sysRegionServices.GetRegionList(query); + list.AddRange(result); + return new MessageModel>() + { + success = true, + msg = "成功", + response = list + }; + } + } +} diff --git a/New_College.Api/Controllers/Front/TestController.cs b/New_College.Api/Controllers/Front/TestController.cs new file mode 100644 index 0000000..edc0096 --- /dev/null +++ b/New_College.Api/Controllers/Front/TestController.cs @@ -0,0 +1,325 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.IServices; +using New_College.Model; +using New_College.Model.ViewModels; + +namespace New_College.Api.Controllers.Front +{ + [Route("api/front/[controller]/[action]")] + [ApiController] + + public class TestController : ControllerBase + { + private readonly ITest_CategoryInfoServices test_CategoryInfoServices; + private readonly ITest_QuestionInfoServices test_QuestionInfoServices; + private readonly IV_SubjectSelectServices v_SubjectSelectServices; + private readonly ITest_PsychMeasurementInfoServices test_PsychMeasurementInfoServices; + private readonly IT_EnrollmentPlanedescServices t_EnrollmentPlanedescServices; + + public TestController(ITest_CategoryInfoServices ITest_CategoryInfoServices + , ITest_QuestionInfoServices ITest_QuestionInfoServices + , ITest_PsychMeasurementInfoServices ITest_PsychMeasurementInfoServices + , IV_SubjectSelectServices IV_SubjectSelectServices + , IT_EnrollmentPlanedescServices IT_EnrollmentPlanedescServices) + { + test_CategoryInfoServices = ITest_CategoryInfoServices; + test_QuestionInfoServices = ITest_QuestionInfoServices; + test_PsychMeasurementInfoServices = ITest_PsychMeasurementInfoServices; + v_SubjectSelectServices = IV_SubjectSelectServices; + t_EnrollmentPlanedescServices = IT_EnrollmentPlanedescServices; + } + + /// + /// 获取分类 根绝type + /// + /// + [HttpGet] + public async Task>> GetCateSelectByType([FromQuery] CategoryInfoQuery query) + { + var result = await test_CategoryInfoServices.GetCateSelectByType(query); + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = result + }; + } + + /// + /// 获取个人某个维度测评结果 + /// + /// + /// + [HttpGet] + [Authorize] + public async Task>> GetPsychListByCateAndCustomerId([FromQuery] PsychMeasurementQuery query) + { + var result = await test_PsychMeasurementInfoServices.GetPsychListByCateAndCustomerId(query); + return new MessageModel>() + { + msg = "获取成功", + success = true, + response = result + }; + } + + /// + /// 获取测评状态 + /// + /// + /// + [HttpGet] + [Authorize] + public async Task> GetTestStatus([FromQuery] CategoryStatusQuery query) + { + var result = await test_CategoryInfoServices.GetTestStatus(query); + return new MessageModel() + { + msg = "获取成功", + success = true, + response = result + }; + } + + /// + /// 获取问题 + /// + /// + /// + [HttpGet] + [Authorize] + public async Task>> GetQuestion([FromQuery] appQuestionQuery query) + { + var result = await test_QuestionInfoServices.GetQuestion(query); + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = result + }; + } + + /// + /// 获取mbti试题 + /// + /// + [HttpGet] + [Authorize] + public async Task>> GetQuestionMBTI() + { + var result = await test_QuestionInfoServices.GetQuestionMBTI(); + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = result + }; + } + + /// + /// 提交 + /// + /// + [HttpPost] + [Authorize] + public async Task> SavePsych([FromBody] SavePsychQuery query) + { + var result = await test_PsychMeasurementInfoServices.SavePsych(query); + return new MessageModel() + { + success = result, + msg = result == true ? "提交成功" : "提交失败", + response = result + }; + } + + /// + /// 提交 霍兰德和MBTI + /// + /// + /// + [HttpPost] + [Authorize] + public async Task> SaveHolland(SaveHollandQuery query) + { + var result = await test_PsychMeasurementInfoServices.SaveHolland(query); + return new MessageModel() + { + success = result, + msg = result == true ? "提交成功" : "提交失败", + response = result + }; + } + + /// + /// 获取学生发展 + /// + /// + /// + [HttpGet] + [Authorize] + public async Task> GetPsychDetail([FromQuery] ResultLookQuery query) + { + var result = await test_PsychMeasurementInfoServices.GetPsychDetail(query); + return new MessageModel() + { + success = true, + msg = "获取成功", + response = result + }; + } + + /// + /// 获取霍兰德测评结果 + /// + /// + /// + [HttpGet] + [Authorize] + public async Task> GetHollandResult([FromQuery] ResultLookQuery query) + { + var result = await test_PsychMeasurementInfoServices.GetHollandResult(query); + return new MessageModel() + { + success = true, + msg = "获取成功", + response = result + }; + } + + /// + /// 获取MBTI测评结果 + /// + /// + /// + [HttpGet] + [Authorize] + public async Task> GetMBTIResult([FromQuery] ResultLookQuery query) + { + var result = await test_PsychMeasurementInfoServices.GetMBTIResult(query); + return new MessageModel() + { + success = true, + msg = "获取成功", + response = result + }; + } + + + /// + /// 学科探索 结果 + /// + /// + /// + [HttpGet] + [Authorize] + public async Task> SubjectChartRadar([FromQuery] ResultLookQuery query) + { + return await test_PsychMeasurementInfoServices.SubjectChartRadar(query); + } + + /// + /// 传入用户Id 获取霍兰德测评状态 + /// + /// + /// + [HttpGet] + [Authorize] + public async Task> GetHollandStatus([FromQuery] IdQuery query) + { + return await test_PsychMeasurementInfoServices.GetHollandStatus(query); + } + + /// + /// 传入用户Id 获取学科探索测评状态 + /// + /// + /// + [HttpGet] + [Authorize] + public async Task> GetSubjectSelectStatus([FromQuery] IdQuery query) + { + return await test_PsychMeasurementInfoServices.GetSubjectSelectStatus(query); + } + + + /// + /// 获取我的自选科目 + /// + /// + /// + [HttpGet] + [Authorize] + public async Task> GetSubjectSelect([FromQuery] IdQuery query) + { + return await v_SubjectSelectServices.GetSubjectSelect(query); + } + + /// + /// 保存我的选科 + /// + /// + /// + [HttpPost] + [Authorize] + public async Task> SaveSubjectSelect([FromBody] SubjectSelectQuery query) + { + return await v_SubjectSelectServices.SaveSubjectSelect(query); + } + + /// + /// 根据标签推荐选科 + /// + /// + /// + [HttpGet] + [Authorize] + public async Task> GetSubjectSelectByTag([FromQuery] ByTagSubjectSelectQuery query) + { + return await t_EnrollmentPlanedescServices.GetSubjectSelectByTag(query); + } + + /// + /// 获取测评最新周期Id + /// + /// + /// + [HttpGet] + [Authorize] + public async Task> GetReportCycleInfo([FromQuery] IdQuery query) + { + return await test_PsychMeasurementInfoServices.GetReportCycleInfo(query); + } + + /// + /// 获取三种推荐选科 + /// + /// + /// + [HttpGet] + //[Authorize] + public async Task>> GetSubjectSelectResult([FromQuery] NewSubjectQuery query) + { + return await test_PsychMeasurementInfoServices.GetSubjectSelectResult(query); + } + + + /// + /// 根绝霍兰德获取推荐选科 + /// + /// + /// + [HttpGet] + //[Authorize] + public async Task> GetHollandSubject([FromQuery]HollandSubjectQuery query) + { + return await test_PsychMeasurementInfoServices.GetHollandSubject(query); + } + } +} diff --git a/New_College.Api/Controllers/Front/UniversityCollectionController.cs b/New_College.Api/Controllers/Front/UniversityCollectionController.cs new file mode 100644 index 0000000..30ca777 --- /dev/null +++ b/New_College.Api/Controllers/Front/UniversityCollectionController.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.IServices; +using New_College.Model; +using New_College.Model.ViewModels; +namespace New_College.Api.Controllers.Front +{ + [Route("api/front/[controller]/[action]")] + [ApiController] + [Authorize] + public class UniversityCollectionController : ControllerBase + { + private readonly ID_UniversityCollectionServices d_UniversityCollectionServices; + private readonly ID_UniversityServices d_UniversityServices; + public UniversityCollectionController(ID_UniversityCollectionServices ID_UniversityCollectionServices + , ID_UniversityServices ID_UniversityServices) + { + d_UniversityCollectionServices = ID_UniversityCollectionServices; + d_UniversityServices = ID_UniversityServices; + } + + /// + /// 获取收藏和对比 + /// + /// + /// + [HttpGet] + public async Task>> GetUniversityCollection([FromQuery] UniversityCollectionQuery query) + { + return await d_UniversityCollectionServices.GetUniversityCollection(query); + } + + /// + /// 删除 + /// + /// + /// + [HttpPost] + public async Task> DeleteCollection(UniversityCollectionAddQuery query) + { + return await d_UniversityCollectionServices.DeleteCollection(query); + } + + /// + /// 添加收藏、对比 + /// + /// + /// + [HttpPost] + public async Task> AddCollection([FromBody] UniversityCollectionAddQuery query) + { + return await d_UniversityCollectionServices.AddCollection(query); + } + + /// + /// 获取院校对比结果 传Ids + /// + /// + [HttpPost] + public async Task>> GetUniversityContrasts([FromBody] IdQuery query) + { + return await d_UniversityCollectionServices.GetUniversityContrasts(query); + } + + /// + /// 获取搜索学校 + /// + /// + /// + [HttpGet] + public async Task>> GetUniversitList([FromQuery] NameQuery query) + { + return await d_UniversityServices.GetUniversitList(query); + } + + + /// + /// 报告 获取我喜欢的院校 + /// + /// + /// + [HttpGet] + public async Task>> GetUniversityMap([FromQuery] IdQuery query) + { + return await d_UniversityCollectionServices.GetUniversityMap(query); + } + } +} diff --git a/New_College.Api/Controllers/Front/VipController.cs b/New_College.Api/Controllers/Front/VipController.cs new file mode 100644 index 0000000..ec0374b --- /dev/null +++ b/New_College.Api/Controllers/Front/VipController.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.IServices; +using New_College.Model; +using New_College.Model.ViewModels; + +namespace New_College.Api.Controllers.Front +{ + [Route("api/front/[controller]/[action]")] + [ApiController] + + public class VipController : ControllerBase + { + private readonly IV_VipCardTypeServices v_VipCardTypeServices; + private readonly IV_VipCardInfoServices v_VipCardInfoServices; + public VipController(IV_VipCardTypeServices IV_VipCardTypeServices, + IV_VipCardInfoServices IV_VipCardInfoServices) + { + v_VipCardTypeServices = IV_VipCardTypeServices; + v_VipCardInfoServices = IV_VipCardInfoServices; + } + + /// + /// 获取Vip卡列表 + /// + /// + [HttpGet] + public async Task>> GetVipCardTypeList() + { + var result = await v_VipCardTypeServices.GetVipCardTypeList(); + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = result + }; + } + + /// + /// 绑定卡 + /// + /// + /// + [HttpPost] + [Authorize] + public async Task> BindCardInfo(VipCardQuery query) + { + return await v_VipCardInfoServices.BindCardInfo(query); + } + + /// + /// 获取vip信息 传用户Id + /// + /// + /// + [HttpGet] + [Authorize] + public async Task> GetVipInfo([FromQuery] IdQuery query) + { + return await v_VipCardInfoServices.GetVipInfo(query); + } + } +} diff --git a/New_College.Api/Controllers/Front/VolunteerController.cs b/New_College.Api/Controllers/Front/VolunteerController.cs new file mode 100644 index 0000000..85c210c --- /dev/null +++ b/New_College.Api/Controllers/Front/VolunteerController.cs @@ -0,0 +1,259 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.Model; +using New_College.Model.ViewModels; +using New_College.IServices; + +namespace New_College.Api.Controllers.Front +{ + [Route("api/front/[controller]/[action]")] + [ApiController] + public class VolunteerController : ControllerBase + { + private readonly IT_EnrollmentPlanedescServices t_EnrollmentPlanedescServices; + private readonly ID_MajorClassServices d_MajorClassServices; + public VolunteerController(IT_EnrollmentPlanedescServices IT_EnrollmentPlanedescServices + , ID_MajorClassServices ID_MajorClassServices) + { + t_EnrollmentPlanedescServices = IT_EnrollmentPlanedescServices; + d_MajorClassServices = ID_MajorClassServices; + } + /// + /// 专业分类列表(二级) 传Id 1本科 2 专科 + /// + /// + /// + [HttpGet] + public async Task>> GetMajorClassListByType([FromQuery] IdQuery query) + { + var result = await d_MajorClassServices.GetMajorClassListByType(query); + return new MessageModel>() + { + success = result.Count > 0, + msg = result.Count > 0 ? "获取成功" : "获取失败", + response = result + }; + } + + /// + /// 根据分数获取个性推荐学校 + /// + /// + /// + [HttpGet] + public async Task>> GetRecommendUniversity([FromQuery] RecommendUniversityQuery query) + { + var result = await t_EnrollmentPlanedescServices.GetRecommendUniversity(query); + return new MessageModel>() + { + response = result, + success = true, + msg = "获取成功" + }; + } + + /// + /// 懒人模式 + /// 办学性质 + /// 高校级别 + /// 专业ids + /// + /// + /// + [HttpPost] + public async Task>> GetEnrollmentLazyByPage([FromBody] LazyEnrollmentPlaneQuery query) + { + return await t_EnrollmentPlanedescServices.GetEnrollmentLazyByPage(query); + } + + /// + /// 根据计划Ids 获取招生计划 + /// + /// + /// + [HttpPost] + public async Task>> GetPlanByUniversity([FromBody] PlanDetailQuery query) + { + return await t_EnrollmentPlanedescServices.GetPlanByUniversity(query); + } + + /// + /// 根据年份省份获取批次 + /// + /// + [HttpGet] + public async Task>> GetBatchByAreaAndYear([FromQuery] BatchQuery query) + { + return await t_EnrollmentPlanedescServices.GetBatchByAreaAndYear(query); + } + + /// + /// 冲稳保获取推荐学校专业 + /// + /// + /// + [HttpPost] + public async Task>> GetEnrollmentCWBByPage([FromBody] CWBEnrollmentPlaneQuery query) + { + return await t_EnrollmentPlanedescServices.GetEnrollmentCWBByPage(query); + } + + /// + /// 冲稳保详情 + /// + /// + /// + [HttpPost] + public async Task>> GetCWBUniversityDetail([FromBody] CWBUniversityDetailQuery query) + { + return await t_EnrollmentPlanedescServices.GetCWBUniversityDetail(query); + } + + /// + /// 霍兰德推荐学校专业 + /// + /// + /// + [HttpPost] + public async Task>> GetEnrollmentTagByPage([FromBody] TagEnrollmentPlaneQuery query) + { + return await t_EnrollmentPlanedescServices.GetEnrollmentTagByPage(query); + } + + /// + /// 获取分析结果录取概率 获取之后保存一下 + /// + /// + /// + [HttpGet] + public async Task> GetUniversityProbability([FromQuery] UniversityProbabilityQuery query) + { + return await t_EnrollmentPlanedescServices.GetUniversityProbability(query); + } + + /// + /// 获取概率历史记录列表 + /// + /// + [HttpGet] + public async Task>> GetProbabilityResult([FromQuery] ProbabilityQuery query) + { + return await t_EnrollmentPlanedescServices.GetProbabilityResult(query); + } + + /// + /// 保存志愿表 + /// + /// + /// + [HttpPost] + public async Task> SaveVolunteerTable([FromBody] VolunteerTableQuery query) + { + return await t_EnrollmentPlanedescServices.SaveVolunteerTable(query); + } + + /// + /// 获取个人志愿列表 传Id + /// + /// + /// + [HttpGet] + public async Task>> GetVolunteerTableList([FromQuery] IdQuery query) + { + return await t_EnrollmentPlanedescServices.GetVolunteerTableList(query); + } + + /// + /// 获取志愿表详情 传Id + /// + /// + /// + [HttpGet] + public async Task>> GetVolunteerTableDetail([FromQuery] IdQuery query) + { + return await t_EnrollmentPlanedescServices.GetVolunteerTableDetail(query); + } + + /// + /// 删除志愿表 + /// + /// + /// + [HttpPost] + public async Task> DeleteVolunteerTable([FromBody] IdQuery query) + { + return await t_EnrollmentPlanedescServices.DeleteVolunteerTable(query); + } + + ///// + ///// 保存志愿表 霍兰德专用 弃用 + ///// + ///// + ///// + //[HttpPost] + //public async Task> SaveHollandVolunteer([FromBody] HollandVolunteerTableQuery query) + //{ + // return await t_EnrollmentPlanedescServices.SaveHollandVolunteer(query); + //} + + /// + /// 获取一键生成的志愿表 + /// + /// + /// + [HttpPost] + public async Task>> GetAutoVolunteerTableDetail([FromBody] VolunteerTableQuery query) + { + return await t_EnrollmentPlanedescServices.GetAutoVolunteerTableDetail(query); + } + + /// + /// 获取霍兰德一键生成的志愿表 + /// + /// + /// + [HttpPost] + public async Task>> GetHollandVolunteerTableDetail([FromBody] HollandVolunteerTableQuery query) + { + return await t_EnrollmentPlanedescServices.GetHollandVolunteerTableDetail(query); + } + + + /// + /// 获取喜欢的院校 + /// + /// + /// + [HttpGet] + public async Task>> GetLikeSchoolMajor([FromQuery] IdQuery query) + { + return await t_EnrollmentPlanedescServices.GetLikeSchoolMajor(query); + } + + /// + /// 专业规划 + /// + /// + [HttpGet] + public async Task>> GetMajorPlanClaim([FromQuery] CustomerQuery query) + { + return await t_EnrollmentPlanedescServices.GetMajorPlanClaim(query); + } + + + /// + /// 获取批次 + /// + /// + /// + [HttpPost] + public async Task>> GetBatchByYearArea([FromBody] YearAreaQuery query) + { + return await t_EnrollmentPlanedescServices.GetBatchByYearArea(query); + } + } +} diff --git a/New_College.Api/Controllers/Front/WeixinPayController.cs b/New_College.Api/Controllers/Front/WeixinPayController.cs new file mode 100644 index 0000000..5a256f0 --- /dev/null +++ b/New_College.Api/Controllers/Front/WeixinPayController.cs @@ -0,0 +1,343 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using New_College.Common; +using New_College.IRepository; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; + +namespace New_College.Api.Controllers.Front +{ + [Route("api/front/[controller]/[action]")] + [ApiController] + [Authorize] + public class WeixinPayController : ControllerBase + { + private readonly IV_OrderInfoRepository v_OrderInfoRepository; + private readonly IV_CustomerInfoRepository v_CustomerInfoRepository; + private readonly IV_VipCardInfoRepository v_VipCardInfoRepository; + private readonly IV_VipCardTypeRepository v_VipCardTypeRepository; + + private readonly ILogger logger; + public WeixinPayController(IV_OrderInfoRepository IV_OrderInfoRepository + , IV_CustomerInfoRepository IV_CustomerInfoRepository + , IV_VipCardInfoRepository IV_VipCardInfoRepository + , IV_VipCardTypeRepository IV_VipCardTypeRepository + , ILogger loggers) + { + v_OrderInfoRepository = IV_OrderInfoRepository; + v_CustomerInfoRepository = IV_CustomerInfoRepository; + v_VipCardInfoRepository = IV_VipCardInfoRepository; + v_VipCardTypeRepository = IV_VipCardTypeRepository; + logger = loggers; + } + + /// + /// 下订单 + /// + /// + [HttpPost] + public async Task UnifiedOrder(UnifiedOrderQuery query) + { + var resp = new WeixinPayResult(); + try + { + Random rd = new Random(); + //HttpContext.GetClientUserIp(); + //外部商户订单号 + var payNum = DateTime.Now.ToString("yyyyMMddHHmmss") + rd.Next(0, 1000).ToString().PadLeft(3, '0'); + var data = new WxPayData(); + data.SetValue("body", "壹志愿好帮手VIP购买"); + data.SetValue("out_trade_no", payNum); + data.SetValue("detail", "志愿好帮手VIP卡购买"); + data.SetValue("total_fee", Convert.ToInt32(query.total_fee * 100)); + data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); + //data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss")); + data.SetValue("notify_url", WeixinConfig.NotifyUrl); + //data.SetValue("goods_tag", "test"); + data.SetValue("trade_type", "JSAPI"); + data.SetValue("openid", query.Phone); + //可以将用户Id和订单Id同时封装在attach中 + data.SetValue("attach", string.Format("{0}|{1}", query.Phone, payNum)); + WxPayData result = UnifiedOrder(data); + if (!result.IsSet("appid") || !result.IsSet("prepay_id") || result.GetValue("prepay_id").ToString() == "") + { + resp.err_code_des = result.GetValue("err_code_des").ToString(); + resp.err_code = result.GetValue("err_code").ToString(); + resp.result_code = result.GetValue("result_code").ToString(); + return resp; + } + else + { + resp.nonce_str = result.GetValue("nonce_str").ToString(); + resp.appid = result.GetValue("appid").ToString(); + resp.mchi_id = result.GetValue("mch_id").ToString(); + resp.result_code = result.GetValue("result_code").ToString(); + resp.prepay_id = "prepay_id=" + result.GetValue("prepay_id").ToString(); + //resp.code_url = result.GetValue("code_url").ToString(); + resp.trade_type = result.GetValue("trade_type").ToString(); + var signType = "MD5"; + var timeStamp = ((DateTime.Now.Ticks - TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).Ticks) / 10000).ToString(); + WxPayData applet = new WxPayData(); + applet.SetValue("appId", resp.appid); + applet.SetValue("nonceStr", resp.nonce_str); + applet.SetValue("package", resp.prepay_id); + applet.SetValue("signType", signType); + applet.SetValue("timeStamp", timeStamp); + resp.sign = applet.MakeSign(); + resp.timeStamp = timeStamp; + //NLogHelper.WriteInfo("Signurl" + Newtonsoft.Json.JsonConvert.SerializeObject(resp), DevAuthorNameEnum.Michael, false); + // WebHookHelper.WebHookmarkdownSend("Signurl" + Newtonsoft.Json.JsonConvert.SerializeObject(resp)); + var customer = await v_CustomerInfoRepository.Query(x => x.OpenId == query.Phone && x.IsDelete == false); + if (customer.Count <= 0) + return new WeixinPayResult() { err_code_des = "用户出现错误" }; + //添加一张卡 + var cardtype = await v_VipCardTypeRepository.QueryById(query.CardTypeId); + if (cardtype == null) + return new WeixinPayResult() { err_code_des = "卡出现错误" }; + var code = RadomHelper.GetGuid(); + var addcard = await v_VipCardInfoRepository.Add(new V_VipCardInfo() + { + CardTypeId = query.CardTypeId, + CardTypeName = cardtype.Name, + Code = code, + IsBind = 1, + Money = query.total_fee, + Day = cardtype.Day, + EndTime = DateTime.Now.AddDays(cardtype.Day) + }); + var baseResult = await v_OrderInfoRepository.Add(new V_OrderInfo + { + out_trade_no = payNum, + // PayType = 2, + CardTypeId = query.CardTypeId, + // Status = 1, + CustomerId = customer.FirstOrDefault().Id, + Price = query.total_fee, + PayPrice = query.total_fee, + Name = "壹志愿好帮手VIP购买", + CardNo = code, + CardId = addcard + }); + if (baseResult > 0) + { + //订单号 + applet.SetValue("orderid", baseResult); + resp.orderid = baseResult.ToString(); + } + } + } + catch (Exception ex) + { + //WebHookHelper.WebHookmarkdownSend(ex.ToString()); + + //NLogHelper.WriteError(ex, DevAuthorNameEnum.Michael, false); + } + return resp; + } + + + /// + /// 支付返回值 + /// + /// + [HttpPost] + public async Task PayNotify() + { + logger.LogInformation("开始回调PayNotify"); + + WxPayData res = new WxPayData(); + + //接收从微信后台POST过来的数据 + //转换数据格式并验证签名 + WxPayData data = new WxPayData(); + using (var reader = new StreamReader(Request.Body)) + { + var builder = reader.ReadToEnd(); + //WebHookHelper.WebHookmarkdownSend(builder.ToString()); + try + { + data.FromXml(builder.ToString()); + } + catch (Exception ex) + { + //若签名错误,则立即返回结果给微信支付后台 + + res.SetValue("return_code", "FAIL"); + res.SetValue("return_msg", ex.Message); + // NLogHelper.WriteError("Sign check error : " + res.ToXml(), DevAuthorNameEnum.Michael, false); + //WebHookHelper.WebHookmarkdownSend(string.Format("return_msg:{0}", ex.Message)); + return Content(res.ToXml(), "text/xml"); + } + + }; + // WebHookHelper.WebHookmarkdownSend("Check sign success"); + //检查支付结果中transaction_id是否存在 + if (!data.IsSet("transaction_id")) + { + //若transaction_id不存在,则立即返回结果给微信支付后台 + res.SetValue("return_code", "FAIL"); + res.SetValue("return_msg", "支付结果中微信订单号不存在"); + //WebHookHelper.WebHookmarkdownSend("支付结果中微信订单号不存在"); + return Content(res.ToXml(), "text/xml"); + } + // 执行订单状态操作 + string out_trade_no = data.GetValue("out_trade_no").ToString(); + logger.LogInformation("开始回调PayNotify"+ out_trade_no); + var info = await v_OrderInfoRepository.Query(x => x.out_trade_no == out_trade_no); + if (info.Count <= 0) + { + res.SetValue("return_code", "FAIL"); + res.SetValue("return_msg", "在自有平台未找到该订单号"); + //WebHookHelper.WebHookmarkdownSend("支付结果中微信订单号不存在"); + return Content(res.ToXml(), "text/xml"); + } + var oneinfo = info.FirstOrDefault(); + oneinfo.Status = EnumOrderType.payoff; + var rep = await v_OrderInfoRepository.Update(oneinfo); + if (rep) + { + //修改用户信息 修改为VIp + var customerinfo = await v_CustomerInfoRepository.QueryById(oneinfo.CustomerId); + customerinfo.IsVIP = true; + customerinfo.VipCode = oneinfo.CardNo; + await v_CustomerInfoRepository.Update(customerinfo); + //支付成功后根据用户code找到对应用户修改vip 状态 + res.SetValue("return_code", "SUCCESS"); + res.SetValue("return_msg", "OK"); + } + else + { + // string attach = data.GetValue("attach").ToString(); + // WebHookHelper.WebHookmarkdownSend(attach); + res.SetValue("return_code", "FAIL"); + res.SetValue("return_msg", "在自有平台未找到该订单号"); + } + + return Content(res.ToXml(), "text/xml"); + } + + + /** + * + * 统一下单 + * @param WxPaydata inputObj 提交给统一下单API的参数 + * @param int timeOut 超时时间 + * @throws WePayException + * @return 成功时返回,其他抛异常 + */ + public static WxPayData UnifiedOrder(WxPayData inputObj, int timeOut = 60) + { + string url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; + //检测必填参数 + if (!inputObj.IsSet("out_trade_no")) + { + throw new Exception("缺少统一支付接口必填参数out_trade_no!"); + } + else if (!inputObj.IsSet("body")) + { + throw new Exception("缺少统一支付接口必填参数body!"); + } + else if (!inputObj.IsSet("total_fee")) + { + throw new Exception("缺少统一支付接口必填参数total_fee!"); + } + else if (!inputObj.IsSet("trade_type")) + { + throw new Exception("缺少统一支付接口必填参数trade_type!"); + } + + //关联参数 + if (inputObj.GetValue("trade_type").ToString() == "JSAPI" && !inputObj.IsSet("openid")) + { + throw new Exception("统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!"); + } + if (inputObj.GetValue("trade_type").ToString() == "NATIVE" && !inputObj.IsSet("product_id")) + { + throw new Exception("统一支付接口中,缺少必填参数product_id!trade_type为JSAPI时,product_id为必填参数!"); + } + + //异步通知url未设置,则使用配置文件中的url + if (!inputObj.IsSet("notify_url")) + { + inputObj.SetValue("notify_url", WeixinConfig.NotifyUrl);//异步通知url + } + + inputObj.SetValue("appid", WeixinConfig.Appid);//公众账号ID + inputObj.SetValue("mch_id", WeixinConfig.MCHID);//商户号 + inputObj.SetValue("spbill_create_ip", WePayConfig.IP);//终端ip + inputObj.SetValue("nonce_str", GenerateNonceStr());//随机字符串 + + //签名 + inputObj.SetValue("sign", inputObj.MakeSign()); + string xml = inputObj.ToXml(); + + var start = DateTime.Now; + + // Log.Info("XcxPayApi", "UnfiedOrder request : " + xml); + string response = HttpPost(xml, url, "application/xml", timeOut); + //Log.Info("XcxPayApi", "UnfiedOrder response : " + response); + // WebHookHelper.WebHookmarkdownSend(response); + + var end = DateTime.Now; + int timeCost = (int)((end - start).TotalMilliseconds); + + WxPayData result = new WxPayData(); + result.FromXml(response); + // ReportCostTime(url, timeCost, result);//测速上报网络不好时使用 + return result; + } + /// + /// 生成随机数 + /// + /// + public static string GenerateNonceStr() + { + return Guid.NewGuid().ToString().Replace("-", ""); + } + /// + /// POST请求 + /// + /// + /// + /// application/xml、application/json、application/text、application/x-www-form-urlencoded + /// + /// + /// + public static string HttpPost(string postData, string url, string contentType = null, int timeOut = 30, Dictionary headers = null) + { + postData = postData ?? ""; + + var httpClientHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true + }; + using (HttpClient httpClient = new HttpClient(httpClientHandler)) + { + if (headers != null) + { + foreach (var header in headers) + httpClient.DefaultRequestHeaders.Add(header.Key, header.Value); + } + using (HttpContent client = new StringContent(postData, Encoding.UTF8)) + { + if (contentType != null) + client.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType); + + HttpResponseMessage response = httpClient.PostAsync(url, client).Result; + return response.Content.ReadAsStringAsync().Result; + } + } + } + } +} diff --git a/New_College.Api/Controllers/HealthCheckController.cs b/New_College.Api/Controllers/HealthCheckController.cs new file mode 100644 index 0000000..8d4fc3a --- /dev/null +++ b/New_College.Api/Controllers/HealthCheckController.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Mvc; + +namespace New_College.Controllers +{ + /// + /// 健康检查 + /// + [Route("[controller]")] + [ApiController] + public class HealthCheckController : ControllerBase + { + /// + /// 健康检查接口 + /// + /// + [HttpGet] + public IActionResult Get() + { + return Ok(); + } + } +} \ No newline at end of file diff --git a/New_College.Api/Controllers/ImgController.cs b/New_College.Api/Controllers/ImgController.cs new file mode 100644 index 0000000..54ace19 --- /dev/null +++ b/New_College.Api/Controllers/ImgController.cs @@ -0,0 +1,194 @@ +using System; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using New_College.Model; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.Common; + +namespace New_College.Controllers +{ + /// + /// 图片管理 + /// + [Route("api/[controller]")] + [ApiController] + + public class ImgController : Controller + { + // GET: api/Download + /// + /// 下载图片(支持中文字符) + /// + /// + /// + [HttpGet] + [Authorize] + [Route("/images/Down/Pic")] + public FileStreamResult DownImg([FromServices]IWebHostEnvironment environment) + { + string foldername = ""; + string filepath = Path.Combine(environment.WebRootPath, foldername, "测试下载中文名称的图片.png"); + var stream = System.IO.File.OpenRead(filepath); + string fileExt = ".jpg"; // 这里可以写一个获取文件扩展名的方法,获取扩展名 + //获取文件的ContentType + var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider(); + var memi = provider.Mappings[fileExt]; + var fileName = Path.GetFileName(filepath); + + + return File(stream, memi, fileName); + } + + /// + /// 上传图片,多文件,可以使用 postman 测试, + /// 如果是单文件,可以 参数写 IFormFile file1 + /// + /// + /// + [HttpPost] + [Authorize] + [Route("/images/Upload/Pic")] + public async Task> InsertPicture([FromServices]IWebHostEnvironment environment) + { + var data = new MessageModel(); + string path = string.Empty; + string foldername = "images"; + IFormFileCollection files = null; + + try + { + files = Request.Form.Files; + } + catch (Exception) + { + files = null; + } + + if (files == null || !files.Any()) { data.msg = "请选择上传的文件。"; return data; } + //格式限制 + var allowType = new string[] { "image/jpg", "image/png", "image/jpeg" }; + + string folderpath = Path.Combine(environment.WebRootPath, foldername); + if (!Directory.Exists(folderpath)) + { + Directory.CreateDirectory(folderpath); + } + + if (files.Any(c => allowType.Contains(c.ContentType))) + { + if (files.Sum(c => c.Length) <= 1024 * 1024 * 4) + { + //foreach (var file in files) + var file = files.FirstOrDefault(); + string strpath = Path.Combine(foldername, DateTime.Now.ToString("MMddHHmmss") + file.FileName); + path = Path.Combine(environment.WebRootPath, strpath); + + using (var stream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite)) + { + await file.CopyToAsync(stream); + } + + data = new MessageModel() + { + response = strpath, + msg = "上传成功", + success = true, + }; + return data; + } + else + { + data.msg = "图片过大"; + return data; + } + } + else + + { + data.msg = "图片格式错误"; + return data; + } + } + + + // POST: api/Img + [HttpPost] + public void Post([FromBody] object formdata) + { + } + + // PUT: api/Img/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE: api/ApiWithActions/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + + + /// + /// 上传图片 + /// + /// + /// + [HttpPost("UploadImg")] + public async Task> UploadImg([FromServices] IWebHostEnvironment environment) + { + var data = new MessageModel(); + var file = Request.Form.Files.First(); + if (file == null) { data.msg = "请选择上传的文件。"; return data; } + var path = environment.WebRootPath; + string urlPath = $"/Content/Upload/"; + string DirectoryName = Path.GetDirectoryName(path + urlPath); + if (!Directory.Exists(DirectoryName)) + Directory.CreateDirectory(DirectoryName); + var reportImage = ""; + if (file.Length > 0) + { + var fileName = DateTime.Now.ToString("yyyyMMddHHssfff") + + Path.GetExtension(file.FileName); + using (var stream = new FileStream(path + urlPath + fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite)) + { + await file.CopyToAsync(stream); + } + var newimg = path + urlPath + fileName; + var picfullname = string.Format("{0}{1}", DateTime.Now.ToString("yyyyMMddHHssfff"), ".JPEG"); + reportImage = AliYunOssHelper.UploadFile(picfullname, newimg); + if (string.IsNullOrWhiteSpace(reportImage)) + { + return new MessageModel() + { + response = reportImage, + msg = "上传失败", + success = false, + }; + } + data = new MessageModel() + { + response = reportImage, + msg = "上传成功", + success = true, + }; + if (System.IO.File.Exists(path + urlPath + fileName))//判断文件是否存在bai + { + System.IO.File.Delete(path + urlPath + fileName); + } + return data; + } + else + { + + } + return data; + } + } + +} diff --git a/New_College.Api/Controllers/LoginController.cs b/New_College.Api/Controllers/LoginController.cs new file mode 100644 index 0000000..de3bc1f --- /dev/null +++ b/New_College.Api/Controllers/LoginController.cs @@ -0,0 +1,299 @@ +using System; +using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; +using System.Linq; +using System.Security.Claims; +using System.Threading.Tasks; +using New_College.AuthHelper; +using New_College.AuthHelper.OverWrite; +using New_College.Common.Helper; +using New_College.IServices; +using New_College.Model; +using New_College.Model.ViewModels; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace New_College.Controllers +{ + /// + /// 登录管理【无权限】 + /// + [Produces("application/json")] + [Route("api/Login")] + [AllowAnonymous] + public class LoginController : Controller + { + readonly ISysUserInfoServices _sysUserInfoServices; + readonly IUserRoleServices _userRoleServices; + readonly IRoleServices _roleServices; + readonly PermissionRequirement _requirement; + private readonly IRoleModulePermissionServices _roleModulePermissionServices; + + + /// + /// 构造函数注入 + /// + /// + /// + /// + /// + /// + public LoginController(ISysUserInfoServices sysUserInfoServices, IUserRoleServices userRoleServices, IRoleServices roleServices, PermissionRequirement requirement, IRoleModulePermissionServices roleModulePermissionServices) + { + this._sysUserInfoServices = sysUserInfoServices; + this._userRoleServices = userRoleServices; + this._roleServices = roleServices; + _requirement = requirement; + _roleModulePermissionServices = roleModulePermissionServices; + } + + + #region 获取token的第1种方法 + /// + /// 获取JWT的方法1 + /// + /// + /// + /// + [HttpGet] + [Route("Token")] + public async Task> GetJwtStr(string name, string pass) + { + string jwtStr = string.Empty; + bool suc = false; + //这里就是用户登陆以后,通过数据库去调取数据,分配权限的操作 + + var user = await _sysUserInfoServices.GetUserRoleNameStr(name, MD5Helper.MD5Encrypt32(pass)); + if (user != null) + { + + TokenModelJwt tokenModel = new TokenModelJwt { Uid = 1, Role = user }; + + jwtStr = JwtHelper.IssueJwt(tokenModel); + suc = true; + } + else + { + jwtStr = "login fail!!!"; + } + + return new MessageModel() + { + success = suc, + msg = suc ? "获取成功" : "获取失败", + response = jwtStr + }; + } + + + /// + /// 获取JWT的方法2:给Nuxt提供 + /// + /// + /// + /// + [HttpGet] + [Route("GetTokenNuxt")] + public MessageModel GetJwtStrForNuxt(string name, string pass) + { + string jwtStr = string.Empty; + bool suc = false; + //这里就是用户登陆以后,通过数据库去调取数据,分配权限的操作 + //这里直接写死了 + if (name == "admins" && pass == "admins") + { + TokenModelJwt tokenModel = new TokenModelJwt + { + Uid = 1, + Role = "Admin" + }; + + jwtStr = JwtHelper.IssueJwt(tokenModel); + suc = true; + } + else + { + jwtStr = "login fail!!!"; + } + var result = new + { + data = new { success = suc, token = jwtStr } + }; + + return new MessageModel() + { + success = suc, + msg = suc ? "获取成功" : "获取失败", + response = jwtStr + }; + } + #endregion + + + + /// + /// 获取JWT的方法3:整个系统主要方法 + /// + /// + /// + /// + [HttpGet] + [Route("JWTToken3.0")] + public async Task> GetJwtToken3(string name = "", string pass = "") + { + string jwtStr = string.Empty; + + if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(pass)) + { + return new MessageModel() + { + success = false, + msg = "用户名或密码不能为空", + }; + } + + pass = MD5Helper.MD5Encrypt32(pass); + + var user = await _sysUserInfoServices.Query(d => d.uLoginName == name && d.uLoginPWD == pass && d.tdIsDelete == false); + if (user.Count > 0) + { + var userRoles = await _sysUserInfoServices.GetUserRoleNameStr(name, pass); + //如果是基于用户的授权策略,这里要添加用户;如果是基于角色的授权策略,这里要添加角色 + var claims = new List { + new Claim(ClaimTypes.Name, name), + new Claim(JwtRegisteredClaimNames.Jti, user.FirstOrDefault().uID.ToString()), + new Claim(ClaimTypes.Expiration, DateTime.Now.AddSeconds(_requirement.Expiration.TotalSeconds).ToString()) }; + claims.AddRange(userRoles.Split(',').Select(s => new Claim(ClaimTypes.Role, s))); + + + // ids4和jwt切换 + // jwt + if (!Permissions.IsUseIds4) + { + var data = await _roleModulePermissionServices.RoleModuleMaps(); + var list = (from item in data + where item.IsDeleted == false + orderby item.Id + select new PermissionItem + { + Url = item.Module?.LinkUrl, + Role = item.Role?.Name.ObjToString(), + }).ToList(); + + _requirement.Permissions = list; + } + + var token = JwtToken.BuildJwtToken(claims.ToArray(), _requirement); + return new MessageModel() + { + success = true, + msg = "获取成功", + response = token + }; + } + else + { + return new MessageModel() + { + success = false, + msg = "认证失败", + }; + } + } + + /// + /// 请求刷新Token(以旧换新) + /// + /// + /// + [HttpGet] + [Route("RefreshToken")] + public async Task> RefreshToken(string token = "") + { + string jwtStr = string.Empty; + + if (string.IsNullOrEmpty(token)) + { + return new MessageModel() + { + success = false, + msg = "token无效,请重新登录!", + }; + } + var tokenModel = JwtHelper.SerializeJwt(token); + if (tokenModel != null && tokenModel.Uid > 0) + { + var user = await _sysUserInfoServices.QueryById(tokenModel.Uid); + if (user != null) + { + var userRoles = await _sysUserInfoServices.GetUserRoleNameStr(user.uLoginName, user.uLoginPWD); + //如果是基于用户的授权策略,这里要添加用户;如果是基于角色的授权策略,这里要添加角色 + var claims = new List { + new Claim(ClaimTypes.Name, user.uLoginName), + new Claim(JwtRegisteredClaimNames.Jti, tokenModel.Uid.ObjToString()), + new Claim(ClaimTypes.Expiration, DateTime.Now.AddSeconds(_requirement.Expiration.TotalSeconds).ToString()) }; + claims.AddRange(userRoles.Split(',').Select(s => new Claim(ClaimTypes.Role, s))); + + //用户标识 + var identity = new ClaimsIdentity(JwtBearerDefaults.AuthenticationScheme); + identity.AddClaims(claims); + + var refreshToken = JwtToken.BuildJwtToken(claims.ToArray(), _requirement); + return new MessageModel() + { + success = true, + msg = "获取成功", + response = refreshToken + }; + } + } + + return new MessageModel() + { + success = false, + msg = "认证失败!", + }; + } + + /// + /// 获取JWT的方法4:给 JSONP 测试 + /// + /// + /// + /// + /// + /// + /// + [HttpGet] + [Route("jsonp")] + public void Getjsonp(string callBack, long id = 1, string sub = "Admin", int expiresSliding = 30, int expiresAbsoulute = 30) + { + TokenModelJwt tokenModel = new TokenModelJwt + { + Uid = id, + Role = sub + }; + + string jwtStr = JwtHelper.IssueJwt(tokenModel); + + string response = string.Format("\"value\":\"{0}\"", jwtStr); + string call = callBack + "({" + response + "})"; + Response.WriteAsync(call); + } + + + /// + /// 测试 MD5 加密字符串 + /// + /// + /// + [HttpGet] + [Route("Md5Password")] + public string Md5Password(string password = "") + { + return MD5Helper.MD5Encrypt32(password); + } + } +} \ No newline at end of file diff --git a/New_College.Api/Controllers/ModuleController.cs b/New_College.Api/Controllers/ModuleController.cs new file mode 100644 index 0000000..80c9310 --- /dev/null +++ b/New_College.Api/Controllers/ModuleController.cs @@ -0,0 +1,140 @@ +using System; +using System.Linq.Expressions; +using System.Threading.Tasks; +using New_College.Common.HttpContextUser; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace New_College.Controllers +{ + /// + /// 接口管理 + /// + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize(Permissions.Name)] + public class ModuleController : ControllerBase + { + readonly IModuleServices _moduleServices; + readonly IUser _user; + + + public ModuleController(IModuleServices moduleServices, IUser user) + { + _moduleServices = moduleServices; + _user = user; + } + + /// + /// 获取全部接口api + /// + /// + /// + /// + // GET: api/User + [HttpGet] + public async Task>> Get(int page = 1, string key = "") + { + if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) + { + key = ""; + } + int intPageSize = 50; + + Expression> whereExpression = a => a.IsDeleted != true && (a.Name != null && a.Name.Contains(key)); + + var data = await _moduleServices.QueryPage(whereExpression, page, intPageSize, " Id desc "); + + return new MessageModel>() + { + msg = "获取成功", + success = data.dataCount >= 0, + response = data + }; + + } + + // GET: api/User/5 + [HttpGet("{id}")] + public string Get(string id) + { + return "value"; + } + + /// + /// 添加一条接口信息 + /// + /// + /// + // POST: api/User + [HttpPost] + public async Task> Post([FromBody] Modules module) + { + var data = new MessageModel(); + + module.CreateId = _user.ID; + module.CreateBy = _user.Name; + + var id = (await _moduleServices.Add(module)); + data.success = id > 0; + if (data.success) + { + data.response = id.ObjToString(); + data.msg = "添加成功"; + } + + return data; + } + + /// + /// 更新接口信息 + /// + /// + /// + // PUT: api/User/5 + [HttpPut] + public async Task> Put([FromBody] Modules module) + { + var data = new MessageModel(); + if (module != null && module.Id > 0) + { + data.success = await _moduleServices.Update(module); + if (data.success) + { + data.msg = "更新成功"; + data.response = module?.Id.ObjToString(); + } + } + + return data; + } + + /// + /// 删除一条接口 + /// + /// + /// + // DELETE: api/ApiWithActions/5 + [HttpDelete] + public async Task> Delete(int id) + { + var data = new MessageModel(); + if (id > 0) + { + var userDetail = await _moduleServices.QueryById(id); + userDetail.IsDeleted = true; + data.success = await _moduleServices.Update(userDetail); + if (data.success) + { + data.msg = "删除成功"; + data.response = userDetail?.Id.ObjToString(); + } + } + + return data; + } + } +} diff --git a/New_College.Api/Controllers/MonitorController.cs b/New_College.Api/Controllers/MonitorController.cs new file mode 100644 index 0000000..dae182a --- /dev/null +++ b/New_College.Api/Controllers/MonitorController.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using New_College.Common.Helper; +using New_College.Common.LogHelper; +using New_College.Hubs; +using New_College.Middlewares; +using New_College.Model; +using New_College.Model.ViewModels; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.SignalR; +using Newtonsoft.Json; + +namespace New_College.Controllers +{ + [Route("api/[Controller]/[action]")] + [ApiController] + [AllowAnonymous] + public class MonitorController : Controller + { + private readonly IHubContext _hubContext; + private readonly IWebHostEnvironment _env; + + public MonitorController(IHubContext hubContext, IWebHostEnvironment env) + { + _hubContext = hubContext; + _env = env; + } + + /// + /// 服务器配置信息 + /// + /// + [HttpGet] + public MessageModel Server() + { + return new MessageModel() + { + msg = "获取成功", + success = true, + response = new ServerViewModel() + { + EnvironmentName = _env.EnvironmentName, + OSArchitecture = RuntimeInformation.OSArchitecture.ObjToString(), + ContentRootPath = _env.ContentRootPath, + WebRootPath = _env.WebRootPath, + FrameworkDescription = RuntimeInformation.FrameworkDescription, + MemoryFootprint = (Process.GetCurrentProcess().WorkingSet64 / 1048576).ToString("N2") + " MB", + WorkingTime = DateHelper.TimeSubTract(DateTime.Now, Process.GetCurrentProcess().StartTime) + } + }; + } + + + /// + /// SignalR send data + /// + /// + // GET: api/Logs + [HttpGet] + public MessageModel> Get() + { + + _hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()).Wait(); + + return new MessageModel>() + { + msg = "获取成功", + success = true, + response = null + }; + } + + + + [HttpGet] + public MessageModel GetRequestApiinfoByWeek() + { + return new MessageModel() + { + msg = "获取成功", + success = true, + response = LogLock.RequestApiinfoByWeek() + }; + } + + [HttpGet] + public MessageModel GetAccessApiByDate() + { + return new MessageModel() + { + msg = "获取成功", + success = true, + response = LogLock.AccessApiByDate() + }; + } + + [HttpGet] + public MessageModel GetAccessApiByHour() + { + return new MessageModel() + { + msg = "获取成功", + success = true, + response = LogLock.AccessApiByHour() + }; + } + + [HttpGet] + public MessageModel> GetAccessLogs([FromServices]IWebHostEnvironment environment) + { + var Logs = JsonConvert.DeserializeObject>("[" + LogLock.ReadLog(Path.Combine(environment.ContentRootPath, "Log"), "RecordAccessLogs_", Encoding.UTF8, ReadType.Prefix) + "]"); + + Logs = Logs.Where(d => d.BeginTime.ObjToDate() >= DateTime.Today).OrderByDescending(d => d.BeginTime).Take(50).ToList(); + return new MessageModel>() + { + msg = "获取成功", + success = true, + response = Logs + }; + } + + } + + +} diff --git a/New_College.Api/Controllers/PermissionController.cs b/New_College.Api/Controllers/PermissionController.cs new file mode 100644 index 0000000..4cb0102 --- /dev/null +++ b/New_College.Api/Controllers/PermissionController.cs @@ -0,0 +1,536 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using New_College.AuthHelper; +using New_College.AuthHelper.OverWrite; +using New_College.Common.Helper; +using New_College.Common.HttpContextUser; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace New_College.Controllers +{ + /// + /// 菜单管理 + /// + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize(Permissions.Name)] + public class PermissionController : ControllerBase + { + readonly IPermissionServices _permissionServices; + readonly IModuleServices _moduleServices; + readonly IRoleModulePermissionServices _roleModulePermissionServices; + readonly IUserRoleServices _userRoleServices; + readonly IHttpContextAccessor _httpContext; + readonly IUser _user; + private readonly PermissionRequirement _requirement; + + /// + /// 构造函数 + /// + /// + /// + /// + /// + /// + /// + /// + public PermissionController(IPermissionServices permissionServices, IModuleServices moduleServices, IRoleModulePermissionServices roleModulePermissionServices, IUserRoleServices userRoleServices, IHttpContextAccessor httpContext, IUser user, PermissionRequirement requirement) + { + _permissionServices = permissionServices; + _moduleServices = moduleServices; + _roleModulePermissionServices = roleModulePermissionServices; + _userRoleServices = userRoleServices; + _httpContext = httpContext; + _user = user; + _requirement = requirement; + } + + /// + /// 获取菜单 + /// + /// + /// + /// + // GET: api/User + [HttpGet] + public async Task>> Get(int page = 1, string key = "") + { + PageModel permissions = new PageModel(); + int intPageSize = 50; + if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) + { + key = ""; + } + + #region 舍弃 + //var permissions = await _permissionServices.Query(a => a.IsDeleted != true); + //if (!string.IsNullOrEmpty(key)) + //{ + // permissions = permissions.Where(t => (t.Name != null && t.Name.Contains(key))).ToList(); + //} + ////筛选后的数据总数 + //totalCount = permissions.Count; + ////筛选后的总页数 + //pageCount = (Math.Ceiling(totalCount.ObjToDecimal() / intTotalCount.ObjToDecimal())).ObjToInt(); + //permissions = permissions.OrderByDescending(d => d.Id).Skip((page - 1) * intTotalCount).Take(intTotalCount).ToList(); + #endregion + + + + permissions = await _permissionServices.QueryPage(a => a.IsDeleted != true && (a.Name != null && a.Name.Contains(key)), page, intPageSize, " Id desc "); + + + #region 单独处理 + + var apis = await _moduleServices.Query(d => d.IsDeleted == false); + var permissionsView = permissions.data; + + var permissionAll = await _permissionServices.Query(d => d.IsDeleted != true); + foreach (var item in permissionsView) + { + List pidarr = new List + { + item.Pid + }; + if (item.Pid > 0) + { + pidarr.Add(0); + } + var parent = permissionAll.FirstOrDefault(d => d.Id == item.Pid); + + while (parent != null) + { + pidarr.Add(parent.Id); + parent = permissionAll.FirstOrDefault(d => d.Id == parent.Pid); + } + + + item.PidArr = pidarr.OrderBy(d => d).Distinct().ToList(); + foreach (var pid in item.PidArr) + { + var per = permissionAll.FirstOrDefault(d => d.Id == pid); + item.PnameArr.Add((per != null ? per.Name : "根节点") + "/"); + //var par = Permissions.Where(d => d.Pid == item.Id ).ToList(); + //item.PCodeArr.Add((per != null ? $"/{per.Code}/{item.Code}" : "")); + //if (par.Count == 0 && item.Pid == 0) + //{ + // item.PCodeArr.Add($"/{item.Code}"); + //} + } + + item.MName = apis.FirstOrDefault(d => d.Id == item.Mid)?.LinkUrl; + } + + permissions.data = permissionsView; + + #endregion + + + return new MessageModel>() + { + msg = "获取成功", + success = permissions.dataCount >= 0, + response = permissions + }; + + } + + /// + /// 查询树形 Table + /// + /// 父节点 + /// 关键字 + /// + [HttpGet] + [AllowAnonymous] + public async Task>> GetTreeTable(int f = 0, string key = "") + { + List permissions = new List(); + var apiList = await _moduleServices.Query(d => d.IsDeleted == false); + var permissionsList = await _permissionServices.Query(d => d.IsDeleted == false); + if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) + { + key = ""; + } + + if (key != "") + { + permissions = permissionsList.Where(a => a.Name.Contains(key)).OrderBy(a => a.OrderSort).ToList(); + } + else + { + permissions = permissionsList.Where(a => a.Pid == f).OrderBy(a => a.OrderSort).ToList(); + } + + foreach (var item in permissions) + { + List pidarr = new List { }; + var parent = permissionsList.FirstOrDefault(d => d.Id == item.Pid); + + while (parent != null) + { + pidarr.Add(parent.Id); + parent = permissionsList.FirstOrDefault(d => d.Id == parent.Pid); + } + + //item.PidArr = pidarr.OrderBy(d => d).Distinct().ToList(); + + pidarr.Reverse(); + pidarr.Insert(0, 0); + item.PidArr = pidarr; + + item.MName = apiList.FirstOrDefault(d => d.Id == item.Mid)?.LinkUrl; + item.hasChildren = permissionsList.Where(d => d.Pid == item.Id).Any(); + } + + + return new MessageModel>() + { + msg = "获取成功", + success = permissions.Count >= 0, + response = permissions + }; + } + + // GET: api/User/5 + [HttpGet("{id}")] + public string Get(string id) + { + return "value"; + } + + /// + /// 添加一个菜单 + /// + /// + /// + // POST: api/User + [HttpPost] + public async Task> Post([FromBody] Permission permission) + { + var data = new MessageModel(); + + permission.CreateId = _user.ID; + permission.CreateBy = _user.Name; + + var id = (await _permissionServices.Add(permission)); + data.success = id > 0; + if (data.success) + { + data.response = id.ObjToString(); + data.msg = "添加成功"; + } + + return data; + } + + /// + /// 保存菜单权限分配 + /// + /// + /// + [HttpPost] + public async Task> Assign([FromBody] AssignView assignView) + { + var data = new MessageModel(); + + try + { + if (assignView.rid > 0) + { + data.success = true; + + var roleModulePermissions = await _roleModulePermissionServices.Query(d => d.RoleId == assignView.rid); + + var remove = roleModulePermissions.Where(d => !assignView.pids.Contains(d.PermissionId.ObjToInt())).Select(c => (object)c.Id); + data.success &= remove.Any() ? await _roleModulePermissionServices.DeleteByIds(remove.ToArray()) : true; + + foreach (var item in assignView.pids) + { + var rmpitem = roleModulePermissions.Where(d => d.PermissionId == item); + if (!rmpitem.Any()) + { + var moduleid = (await _permissionServices.Query(p => p.Id == item)).FirstOrDefault()?.Mid; + RoleModulePermission roleModulePermission = new RoleModulePermission() + { + IsDeleted = false, + RoleId = assignView.rid, + ModuleId = moduleid.ObjToInt(), + PermissionId = item, + }; + + + roleModulePermission.CreateId = _user.ID; + roleModulePermission.CreateBy = _user.Name; + + data.success &= (await _roleModulePermissionServices.Add(roleModulePermission)) > 0; + + } + } + + if (data.success) + { + _requirement.Permissions.Clear(); + data.response = ""; + data.msg = "保存成功"; + } + + } + } + catch (Exception) + { + data.success = false; + } + + return data; + } + + + /// + /// 获取菜单树 + /// + /// + /// + /// + [HttpGet] + public async Task> GetPermissionTree(int pid = 0, bool needbtn = false) + { + var data = new MessageModel(); + + var permissions = await _permissionServices.Query(d => d.IsDeleted == false); + var permissionTrees = (from child in permissions + where child.IsDeleted == false + orderby child.Id + select new PermissionTree + { + value = child.Id, + label = child.Name, + Pid = child.Pid, + isbtn = child.IsButton, + order = child.OrderSort, + }).ToList(); + PermissionTree rootRoot = new PermissionTree + { + value = 0, + Pid = 0, + label = "根节点" + }; + + permissionTrees = permissionTrees.OrderBy(d => d.order).ToList(); + + + RecursionHelper.LoopToAppendChildren(permissionTrees, rootRoot, pid, needbtn); + + data.success = true; + if (data.success) + { + data.response = rootRoot; + data.msg = "获取成功"; + } + + return data; + } + + /// + /// 获取路由树 + /// + /// + /// + [HttpGet] + public async Task> GetNavigationBar(int uid) + { + + var data = new MessageModel(); + + var uidInHttpcontext1 = 0; + var roleIds = new List(); + // ids4和jwt切换 + if (Permissions.IsUseIds4) + { + // ids4 + uidInHttpcontext1 = (from item in _httpContext.HttpContext.User.Claims + where item.Type == "sub" + select item.Value).FirstOrDefault().ObjToInt(); + roleIds = (from item in _httpContext.HttpContext.User.Claims + where item.Type == "role" + select item.Value.ObjToInt()).ToList(); + } + else + { + // jwt + uidInHttpcontext1 = ((JwtHelper.SerializeJwt(_httpContext.HttpContext.Request.Headers["Authorization"].ObjToString().Replace("Bearer ", "")))?.Uid).ObjToInt(); + roleIds = (await _userRoleServices.Query(d => d.IsDeleted == false && d.UserId == uid)).Select(d => d.RoleId.ObjToInt()).Distinct().ToList(); + } + + + if (uid > 0 && uid == uidInHttpcontext1) + { + if (roleIds.Any()) + { + var pids = (await _roleModulePermissionServices.Query(d => d.IsDeleted == false && roleIds.Contains(d.RoleId))).Select(d => d.PermissionId.ObjToInt()).Distinct(); + if (pids.Any()) + { + var rolePermissionMoudles = (await _permissionServices.Query(d => pids.Contains(d.Id))).OrderBy(c => c.OrderSort); + var permissionTrees = (from child in rolePermissionMoudles + where child.IsDeleted == false + orderby child.Id + select new NavigationBar + { + id = child.Id, + name = child.Name, + pid = child.Pid, + order = child.OrderSort, + path = child.Code, + iconCls = child.Icon, + Func = child.Func, + IsHide = child.IsHide.ObjToBool(), + IsButton = child.IsButton.ObjToBool(), + meta = new NavigationBarMeta + { + requireAuth = true, + title = child.Name, + NoTabPage = child.IsHide.ObjToBool(), + keepAlive = child.IskeepAlive.ObjToBool() + } + }).ToList(); + + + NavigationBar rootRoot = new NavigationBar() + { + id = 0, + pid = 0, + order = 0, + name = "根节点", + path = "", + iconCls = "", + meta = new NavigationBarMeta(), + + }; + + permissionTrees = permissionTrees.OrderBy(d => d.order).ToList(); + + RecursionHelper.LoopNaviBarAppendChildren(permissionTrees, rootRoot); + + data.success = true; + if (data.success) + { + data.response = rootRoot; + data.msg = "获取成功"; + } + } + } + } + return data; + } + + /// + /// 通过角色获取菜单【无权限】 + /// + /// + /// + [HttpGet] + [AllowAnonymous] + public async Task> GetPermissionIdByRoleId(int rid = 0) + { + var data = new MessageModel(); + + var rmps = await _roleModulePermissionServices.Query(d => d.IsDeleted == false && d.RoleId == rid); + var permissionTrees = (from child in rmps + orderby child.Id + select child.PermissionId.ObjToInt()).ToList(); + + var permissions = await _permissionServices.Query(d => d.IsDeleted == false); + List assignbtns = new List(); + + foreach (var item in permissionTrees) + { + var pername = permissions.FirstOrDefault(d => d.IsButton && d.Id == item)?.Name; + if (!string.IsNullOrEmpty(pername)) + { + //assignbtns.Add(pername + "_" + item); + assignbtns.Add(item.ObjToString()); + } + } + + data.success = true; + if (data.success) + { + data.response = new AssignShow() + { + permissionids = permissionTrees, + assignbtns = assignbtns, + }; + data.msg = "获取成功"; + } + + return data; + } + + /// + /// 更新菜单 + /// + /// + /// + // PUT: api/User/5 + [HttpPut] + public async Task> Put([FromBody] Permission permission) + { + var data = new MessageModel(); + if (permission != null && permission.Id > 0) + { + data.success = await _permissionServices.Update(permission); + if (data.success) + { + data.msg = "更新成功"; + data.response = permission?.Id.ObjToString(); + } + } + + return data; + } + + /// + /// 删除菜单 + /// + /// + /// + // DELETE: api/ApiWithActions/5 + [HttpDelete] + public async Task> Delete(int id) + { + var data = new MessageModel(); + if (id > 0) + { + var userDetail = await _permissionServices.QueryById(id); + userDetail.IsDeleted = true; + data.success = await _permissionServices.Update(userDetail); + if (data.success) + { + data.msg = "删除成功"; + data.response = userDetail?.Id.ObjToString(); + } + } + + return data; + } + } + + public class AssignView + { + public List pids { get; set; } + public int rid { get; set; } + } + public class AssignShow + { + public List permissionids { get; set; } + public List assignbtns { get; set; } + } + +} diff --git a/New_College.Api/Controllers/RoleController.cs b/New_College.Api/Controllers/RoleController.cs new file mode 100644 index 0000000..9931b4c --- /dev/null +++ b/New_College.Api/Controllers/RoleController.cs @@ -0,0 +1,137 @@ +using System.Threading.Tasks; +using New_College.Common.HttpContextUser; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace New_College.Controllers +{ + /// + /// 角色管理 + /// + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize(Permissions.Name)] + public class RoleController : ControllerBase + { + readonly IRoleServices _roleServices; + readonly IUser _user; + + + public RoleController(IRoleServices roleServices, IUser user) + { + _roleServices = roleServices; + _user = user; + } + + /// + /// 获取全部角色 + /// + /// + /// + /// + // GET: api/User + [HttpGet] + public async Task>> Get(int page = 1, string key = "") + { + if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) + { + key = ""; + } + + int intPageSize = 50; + + var data = await _roleServices.QueryPage(a => a.IsDeleted != true && (a.Name != null && a.Name.Contains(key)), page, intPageSize, " Id desc "); + + return new MessageModel>() + { + msg = "获取成功", + success = data.dataCount >= 0, + response = data + }; + + } + + // GET: api/User/5 + [HttpGet("{id}")] + public string Get(string id) + { + return "value"; + } + + /// + /// 添加角色 + /// + /// + /// + // POST: api/User + [HttpPost] + public async Task> Post([FromBody] Role role) + { + var data = new MessageModel(); + + role.CreateId = _user.ID; + role.CreateBy = _user.Name; + + var id = (await _roleServices.Add(role)); + data.success = id > 0; + if (data.success) + { + data.response = id.ObjToString(); + data.msg = "添加成功"; + } + + return data; + } + + /// + /// 更新角色 + /// + /// + /// + // PUT: api/User/5 + [HttpPut] + public async Task> Put([FromBody] Role role) + { + var data = new MessageModel(); + if (role != null && role.Id > 0) + { + data.success = await _roleServices.Update(role); + if (data.success) + { + data.msg = "更新成功"; + data.response = role?.Id.ObjToString(); + } + } + + return data; + } + + /// + /// 删除角色 + /// + /// + /// + // DELETE: api/ApiWithActions/5 + [HttpDelete] + public async Task> Delete(int id) + { + var data = new MessageModel(); + if (id > 0) + { + var userDetail = await _roleServices.QueryById(id); + userDetail.IsDeleted = true; + data.success = await _roleServices.Update(userDetail); + if (data.success) + { + data.msg = "删除成功"; + data.response = userDetail?.Id.ObjToString(); + } + } + + return data; + } + } +} diff --git a/New_College.Api/Controllers/SysRegionController.cs b/New_College.Api/Controllers/SysRegionController.cs new file mode 100644 index 0000000..83f8c38 --- /dev/null +++ b/New_College.Api/Controllers/SysRegionController.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using AutoMapper; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using New_College.Common.HttpContextUser; +using New_College.IRepository.UnitOfWork; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; + +namespace New_College.Api.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class SysRegionController : ControllerBase + { + private readonly IUser _user; + IMapper _mapper; + private readonly IUnitOfWork _unitOfWork; + private readonly ISysRegionServices _regionRepository; + + /// + /// 省市区操作类 + /// + public SysRegionController(ISysRegionServices sysRegionRepository, IUnitOfWork unitOf, IMapper mapper) + { + this._regionRepository = sysRegionRepository; + this._unitOfWork = unitOf; + this._mapper = mapper; + } + + + + + /// + /// 根据ID获取 + /// + /// + /// + [HttpGet] + public async Task> GetSingle(int id) + { + try + { + var regions = (await this._regionRepository.QueryById(id)); + + return new MessageModel() + { + msg = "success", + success = true, + //url = "", + response = regions + }; + } + catch (Exception ex) + { + + return new MessageModel() + { + success = false, + msg = "Error", + status = 500 + }; + } + + } + + + + + + /// + /// 根据level和parentId获取省市区列表信息 + /// + /// + /// + [HttpGet] + public async Task>> GetListByParentId(string Id) + { + try + { + var regionlist = (await _regionRepository.GetListByParentId(Id)); + return new MessageModel>() + { + msg = "success", + success = true, + response = _mapper.Map>(regionlist.ToList()) + }; + } + catch (Exception ex) + { + return new MessageModel>() + { + msg = "error", + success = false + }; + } + } + + + /// + /// 获取省市区 + /// + /// + /// + [HttpGet] + public async Task>> GetRegionList([FromQuery] SysRegionQuery query) + { + try + { + var regionlist = (await _regionRepository.GetRegionList(query)); + return new MessageModel>() + { + msg = "success", + success = true, + response = _mapper.Map>(regionlist.ToList()) + }; + } + catch (Exception ex) + { + return new MessageModel>() + { + msg = "error", + success = false + }; + } + } + } +} diff --git a/New_College.Api/Controllers/TasksQzController.cs b/New_College.Api/Controllers/TasksQzController.cs new file mode 100644 index 0000000..1805808 --- /dev/null +++ b/New_College.Api/Controllers/TasksQzController.cs @@ -0,0 +1,185 @@ +using System; +using System.Linq.Expressions; +using System.Threading.Tasks; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using New_College.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace New_College.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize(Permissions.Name)] + public class TasksQzController : ControllerBase + { + private readonly ITasksQzServices _tasksQzServices; + private readonly ISchedulerCenter _schedulerCenter; + + public TasksQzController(ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter) + { + _tasksQzServices = tasksQzServices; + _schedulerCenter = schedulerCenter; + } + + /// + /// 分页获取 + /// + /// + /// + /// + // GET: api/Buttons/5 + [HttpGet] + public async Task>> Get(int page = 1, string key = "") + { + if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) + { + key = ""; + } + int intPageSize = 50; + + Expression> whereExpression = a => a.IsDelete != true && (a.Name != null && a.Name.Contains(key)); + + var data = await _tasksQzServices.QueryPage(whereExpression, page, intPageSize, " Id desc "); + + return new MessageModel>() + { + msg = "获取成功", + success = data.dataCount >= 0, + response = data + }; + + } + + /// + /// 添加计划任务 + /// + /// + /// + [HttpPost] + public async Task> Post([FromBody] TasksQz tasksQz) + { + var data = new MessageModel(); + + var id = (await _tasksQzServices.Add(tasksQz)); + data.success = id > 0; + if (data.success) + { + data.response = id.ObjToString(); + data.msg = "添加成功"; + } + + return data; + } + + + /// + /// 修改计划任务 + /// + /// + /// + [HttpPut] + public async Task> Put([FromBody] TasksQz tasksQz) + { + var data = new MessageModel(); + if (tasksQz != null && tasksQz.Id > 0) + { + data.success = await _tasksQzServices.Update(tasksQz); + if (data.success) + { + data.msg = "更新成功"; + data.response = tasksQz?.Id.ObjToString(); + } + } + + return data; + } + + /// + /// 启动计划任务 + /// + /// + /// + [HttpGet] + public async Task> StartJob(int jobId) + { + var data = new MessageModel(); + + var model = await _tasksQzServices.QueryById(jobId); + if (model != null) + { + var ResuleModel = await _schedulerCenter.AddScheduleJobAsync(model); + if (ResuleModel.success) + { + model.IsStart = true; + data.success = await _tasksQzServices.Update(model); + } + if (data.success) + { + data.msg = "启动成功"; + data.response = jobId.ObjToString(); + } + } + return data; + + } + /// + /// 停止一个计划任务 + /// + /// + /// + [HttpGet] + public async Task> StopJob(int jobId) + { + var data = new MessageModel(); + + var model = await _tasksQzServices.QueryById(jobId); + if (model != null) + { + var ResuleModel = await _schedulerCenter.StopScheduleJobAsync(model); + if (ResuleModel.success) + { + model.IsStart = false; + data.success = await _tasksQzServices.Update(model); + } + if (data.success) + { + data.msg = "暂停成功"; + data.response = jobId.ObjToString(); + } + } + return data; + + } + /// + /// 重启一个计划任务 + /// + /// + /// + [HttpGet] + public async Task> ReCovery(int jobId) + { + var data = new MessageModel(); + + var model = await _tasksQzServices.QueryById(jobId); + if (model != null) + { + var ResuleModel = await _schedulerCenter.ResumeJob(model); + if (ResuleModel.success) + { + model.IsStart = true; + data.success = await _tasksQzServices.Update(model); + } + if (data.success) + { + data.msg = "重启成功"; + data.response = jobId.ObjToString(); + } + } + return data; + + } + } +} diff --git a/New_College.Api/Controllers/TopicController.cs b/New_College.Api/Controllers/TopicController.cs new file mode 100644 index 0000000..6c14d48 --- /dev/null +++ b/New_College.Api/Controllers/TopicController.cs @@ -0,0 +1,72 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace New_College.Controllers +{ + /// + /// 类别管理【无权限】 + /// + [Route("api/[controller]")] + [ApiController] + [AllowAnonymous] + public class TopicController : ControllerBase + { + readonly ITopicServices _topicServices; + + /// + /// 构造函数 + /// + /// + public TopicController(ITopicServices topicServices) + { + _topicServices = topicServices; + } + + /// + /// 获取Tibug所有分类 + /// + /// + // GET: api/Topic + [HttpGet] + public async Task>> Get() + { + var data = new MessageModel> {response = await _topicServices.GetTopics()}; + if (data.response != null) + { + data.success = true; + data.msg = ""; + } + return data; + } + + // GET: api/Topic/5 + [HttpGet("{id}")] + public string Get(int id) + { + return "value"; + } + + // POST: api/Topic + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT: api/Topic/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE: api/ApiWithActions/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/New_College.Api/Controllers/TopicDetailController.cs b/New_College.Api/Controllers/TopicDetailController.cs new file mode 100644 index 0000000..71ef4a2 --- /dev/null +++ b/New_College.Api/Controllers/TopicDetailController.cs @@ -0,0 +1,178 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using New_College.Common.Helper; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace New_College.Controllers +{ + /// + /// Tibug 管理 + /// + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize(Permissions.Name)] + public class TopicDetailController : ControllerBase + { + readonly ITopicServices _topicServices; + readonly ITopicDetailServices _topicDetailServices; + + /// + /// 构造函数 + /// + /// + /// + public TopicDetailController(ITopicServices topicServices, ITopicDetailServices topicDetailServices) + { + _topicServices = topicServices; + _topicDetailServices = topicDetailServices; + } + + /// + /// 获取Bug数据列表(带分页) + /// 【无权限】 + /// + /// 页数 + /// 专题类型 + /// 关键字 + /// + /// + [HttpGet] + [AllowAnonymous] + public async Task>> Get(int page = 1, string tname = "", string key = "", int intPageSize = 12) + { + int tid = 0; + + if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) + { + key = ""; + } + if (string.IsNullOrEmpty(tname) || string.IsNullOrWhiteSpace(tname)) + { + tname = ""; + } + tname = UnicodeHelper.UnicodeToString(tname); + + if (!string.IsNullOrEmpty(tname)) + { + tid = ((await _topicServices.Query(ts => ts.tName == tname)).FirstOrDefault()?.Id).ObjToInt(); + } + + + var data = await _topicDetailServices.QueryPage(a => !a.tdIsDelete && a.tdSectendDetail == "tbug" && ((tid == 0 && true) || (tid > 0 && a.TopicId == tid)) && ((a.tdName != null && a.tdName.Contains(key)) || (a.tdDetail != null && a.tdDetail.Contains(key))), page, intPageSize, " Id desc "); + + + + return new MessageModel>() + { + msg = "获取成功", + success = data.dataCount >= 0, + response = data + }; + + } + + /// + /// 获取详情【无权限】 + /// + /// + /// + // GET: api/TopicDetail/5 + [HttpGet("{id}")] + [AllowAnonymous] + public async Task> Get(int id) + { + var data = new MessageModel(); + var response = id > 0 ? await _topicDetailServices.QueryById(id) : new TopicDetail(); + data.response = (response?.tdIsDelete).ObjToBool() ? new TopicDetail() : response; + if (data.response != null) + { + data.success = true; + data.msg = ""; + } + + return data; + } + + /// + /// 添加一个 BUG 【无权限】 + /// + /// + /// + // POST: api/TopicDetail + [HttpPost] + [AllowAnonymous] + public async Task> Post([FromBody] TopicDetail topicDetail) + { + var data = new MessageModel(); + + topicDetail.tdCreatetime = DateTime.Now; + topicDetail.tdRead = 0; + topicDetail.tdCommend = 0; + topicDetail.tdGood = 0; + topicDetail.tdTop = 0; + + var id = (await _topicDetailServices.Add(topicDetail)); + data.success = id > 0; + if (data.success) + { + data.response = id.ObjToString(); + data.msg = "添加成功"; + } + + return data; + } + + /// + /// 更新 bug + /// + /// + /// + // PUT: api/TopicDetail/5 + [HttpPut] + public async Task> Update([FromBody] TopicDetail topicDetail) + { + var data = new MessageModel(); + if (topicDetail != null && topicDetail.Id > 0) + { + data.success = await _topicDetailServices.Update(topicDetail); + if (data.success) + { + data.msg = "更新成功"; + data.response = topicDetail?.Id.ObjToString(); + } + } + + return data; + } + + /// + /// 删除 bug + /// + /// + /// + // DELETE: api/ApiWithActions/5 + [HttpDelete] + public async Task> Delete(int id) + { + var data = new MessageModel(); + if (id > 0) + { + var topicDetail = await _topicDetailServices.QueryById(id); + topicDetail.tdIsDelete = true; + data.success = await _topicDetailServices.Update(topicDetail); + if (data.success) + { + data.msg = "删除成功"; + data.response = topicDetail?.Id.ObjToString(); + } + } + + return data; + } + } +} diff --git a/New_College.Api/Controllers/TransactionController.cs b/New_College.Api/Controllers/TransactionController.cs new file mode 100644 index 0000000..9cf473b --- /dev/null +++ b/New_College.Api/Controllers/TransactionController.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using New_College.IRepository.UnitOfWork; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace New_College.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + [AllowAnonymous] + public class TransactionController : ControllerBase + { + private readonly IPasswordLibServices _passwordLibServices; + private readonly IGuestbookServices _guestbookServices; + private readonly IUnitOfWork _unitOfWork; + + + public TransactionController(IUnitOfWork unitOfWork, IPasswordLibServices passwordLibServices, IGuestbookServices guestbookServices) + { + _unitOfWork = unitOfWork; + _passwordLibServices = passwordLibServices; + _guestbookServices = guestbookServices; + } + + // GET: api/Transaction + [HttpGet] + public async Task>> Get() + { + List returnMsg = new List() { }; + try + { + returnMsg.Add($"Begin Transaction"); + + _unitOfWork.BeginTran(); + var passwords = await _passwordLibServices.Query(d => d.IsDeleted == false); + returnMsg.Add($"first time : the count of passwords is :{passwords.Count}"); + + + returnMsg.Add($"insert a data into the table PasswordLib now."); + var insertPassword = await _passwordLibServices.Add(new PasswordLib() + { + IsDeleted = false, + plAccountName = "aaa", + plCreateTime = DateTime.Now + }); + + + passwords = await _passwordLibServices.Query(d => d.IsDeleted == false); + returnMsg.Add($"second time : the count of passwords is :{passwords.Count}"); + returnMsg.Add($" "); + + //...... + + var guestbooks = await _guestbookServices.Query(); + returnMsg.Add($"first time : the count of guestbooks is :{guestbooks.Count}"); + + int ex = 0; + returnMsg.Add($"There's an exception!!"); + returnMsg.Add($" "); + int throwEx = 1 / ex; + + var insertGuestbook = await _guestbookServices.Add(new Guestbook() + { + username = "bbb", + blogId = 1, + createdate = DateTime.Now, + isshow = true + }); + + guestbooks = await _guestbookServices.Query(); + returnMsg.Add($"first time : the count of guestbooks is :{guestbooks.Count}"); + returnMsg.Add($" "); + + _unitOfWork.CommitTran(); + } + catch (Exception) + { + _unitOfWork.RollbackTran(); + var passwords = await _passwordLibServices.Query(); + returnMsg.Add($"third time : the count of passwords is :{passwords.Count}"); + + var guestbooks = await _guestbookServices.Query(); + returnMsg.Add($"third time : the count of guestbooks is :{guestbooks.Count}"); + } + + return new MessageModel>() + { + success = true, + msg = "操作完成", + response = returnMsg + }; + } + + // GET: api/Transaction/5 + [HttpGet("{id}")] + public async Task> Get(int id) + { + return await _guestbookServices.TestTranInRepository(); + } + + // POST: api/Transaction + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT: api/Transaction/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + /// + /// 测试事务在AOP中的使用 + /// + /// + /// + [HttpDelete("{id}")] + public async Task Delete(int id) + { + return await _guestbookServices.TestTranInRepositoryAOP(); + } + } +} diff --git a/New_College.Api/Controllers/UserController.cs b/New_College.Api/Controllers/UserController.cs new file mode 100644 index 0000000..e62a9c7 --- /dev/null +++ b/New_College.Api/Controllers/UserController.cs @@ -0,0 +1,246 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using New_College.AuthHelper.OverWrite; +using New_College.Common.Helper; +using New_College.Common.HttpContextUser; +using New_College.IRepository.UnitOfWork; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace New_College.Controllers +{ + /// + /// 用户管理 + /// + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize(Permissions.Name)] + public class UserController : ControllerBase + { + private readonly IUnitOfWork _unitOfWork; + readonly ISysUserInfoServices _sysUserInfoServices; + readonly IUserRoleServices _userRoleServices; + readonly IRoleServices _roleServices; + private readonly IUser _user; + private readonly ILogger _logger; + + /// + /// 构造函数 + /// + /// + /// + /// + /// + /// + /// + public UserController(IUnitOfWork unitOfWork, ISysUserInfoServices sysUserInfoServices, IUserRoleServices userRoleServices, IRoleServices roleServices, IUser user, ILogger logger) + { + _unitOfWork = unitOfWork; + _sysUserInfoServices = sysUserInfoServices; + _userRoleServices = userRoleServices; + _roleServices = roleServices; + _user = user; + _logger = logger; + } + + /// + /// 获取全部用户 + /// + /// + /// + /// + // GET: api/User + [HttpGet] + public async Task>> Get(int page = 1, string key = "") + { + if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) + { + key = ""; + } + int intPageSize = 50; + + + var data = await _sysUserInfoServices.QueryPage(a => a.tdIsDelete != true && a.uStatus >= 0 && ((a.uLoginName != null && a.uLoginName.Contains(key)) || (a.uRealName != null && a.uRealName.Contains(key))), page, intPageSize, " uID desc "); + + + #region MyRegion + + // 这里可以封装到多表查询,此处简单处理 + var allUserRoles = await _userRoleServices.Query(d => d.IsDeleted == false); + var allRoles = await _roleServices.Query(d => d.IsDeleted == false); + + var sysUserInfos = data.data; + foreach (var item in sysUserInfos) + { + var currentUserRoles = allUserRoles.Where(d => d.UserId == item.uID).Select(d => d.RoleId).ToList(); + item.RIDs = currentUserRoles; + item.RoleNames = allRoles.Where(d => currentUserRoles.Contains(d.Id)).Select(d => d.Name).ToList(); + } + + data.data = sysUserInfos; + #endregion + + + return new MessageModel>() + { + msg = "获取成功", + success = data.dataCount >= 0, + response = data + }; + + } + + // GET: api/User/5 + [HttpGet("{id}")] + [AllowAnonymous] + public string Get(string id) + { + _logger.LogError("test wrong"); + return "value"; + } + + // GET: api/User/5 + /// + /// 获取用户详情根据token + /// 【无权限】 + /// + /// 令牌 + /// + [HttpGet] + [AllowAnonymous] + public async Task> GetInfoByToken(string token) + { + var data = new MessageModel(); + if (!string.IsNullOrEmpty(token)) + { + var tokenModel = JwtHelper.SerializeJwt(token); + if (tokenModel != null && tokenModel.Uid > 0) + { + var userinfo = await _sysUserInfoServices.QueryById(tokenModel.Uid); + if (userinfo != null) + { + data.response = userinfo; + data.success = true; + data.msg = "获取成功"; + } + } + + } + return data; + } + + /// + /// 添加一个用户 + /// + /// + /// + // POST: api/User + [HttpPost] + public async Task> Post([FromBody] sysUserInfo sysUserInfo) + { + var data = new MessageModel(); + + sysUserInfo.uLoginPWD = MD5Helper.MD5Encrypt32(sysUserInfo.uLoginPWD); + sysUserInfo.uRemark = _user.Name; + + var id = await _sysUserInfoServices.Add(sysUserInfo); + data.success = id > 0; + if (data.success) + { + data.response = id.ObjToString(); + data.msg = "添加成功"; + } + + return data; + } + + /// + /// 更新用户与角色 + /// + /// + /// + // PUT: api/User/5 + [HttpPut] + public async Task> Put([FromBody] sysUserInfo sysUserInfo) + { + // 这里使用事务处理 + + var data = new MessageModel(); + try + { + _unitOfWork.BeginTran(); + + if (sysUserInfo != null && sysUserInfo.uID > 0) + { + if (sysUserInfo.RIDs.Count > 0) + { + // 无论 Update Or Add , 先删除当前用户的全部 U_R 关系 + var usreroles = (await _userRoleServices.Query(d => d.UserId == sysUserInfo.uID)).Select(d => d.Id.ToString()).ToArray(); + if (usreroles.Count() > 0) + { + var isAllDeleted = await _userRoleServices.DeleteByIds(usreroles); + } + + // 然后再执行添加操作 + var userRolsAdd = new List(); + sysUserInfo.RIDs.ForEach(rid => + { + userRolsAdd.Add(new UserRole(sysUserInfo.uID, rid)); + }); + + await _userRoleServices.Add(userRolsAdd); + + } + + data.success = await _sysUserInfoServices.Update(sysUserInfo); + + _unitOfWork.CommitTran(); + + if (data.success) + { + data.msg = "更新成功"; + data.response = sysUserInfo?.uID.ObjToString(); + } + } + } + catch (Exception e) + { + _unitOfWork.RollbackTran(); + _logger.LogError(e, e.Message); + } + + return data; + } + + /// + /// 删除用户 + /// + /// + /// + // DELETE: api/ApiWithActions/5 + [HttpDelete] + public async Task> Delete(int id) + { + var data = new MessageModel(); + if (id > 0) + { + var userDetail = await _sysUserInfoServices.QueryById(id); + userDetail.tdIsDelete = true; + data.success = await _sysUserInfoServices.Update(userDetail); + if (data.success) + { + data.msg = "删除成功"; + data.response = userDetail?.uID.ObjToString(); + } + } + + return data; + } + } +} diff --git a/New_College.Api/Controllers/UserRoleController.cs b/New_College.Api/Controllers/UserRoleController.cs new file mode 100644 index 0000000..20201d8 --- /dev/null +++ b/New_College.Api/Controllers/UserRoleController.cs @@ -0,0 +1,92 @@ +using System.Threading.Tasks; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace New_College.Controllers +{ + /// + /// 用户角色关系 + /// + [Produces("application/json")] + [Route("api/[controller]/[action]")] + [ApiController] + [Authorize(Permissions.Name)] + public class UserRoleController : Controller + { + readonly ISysUserInfoServices _sysUserInfoServices; + readonly IUserRoleServices _userRoleServices; + readonly IRoleServices _roleServices; + + /// + /// 构造函数 + /// + /// + /// + /// + public UserRoleController(ISysUserInfoServices sysUserInfoServices, IUserRoleServices userRoleServices, IRoleServices roleServices) + { + this._sysUserInfoServices = sysUserInfoServices; + this._userRoleServices = userRoleServices; + this._roleServices = roleServices; + } + + + + /// + /// 新建用户 + /// + /// + /// + /// + [HttpGet] + public async Task> AddUser(string loginName, string loginPwd) + { + return new MessageModel() + { + success = true, + msg = "添加成功", + response = await _sysUserInfoServices.SaveUserInfo(loginName, loginPwd) + }; + } + + /// + /// 新建Role + /// + /// + /// + [HttpGet] + public async Task> AddRole(string roleName) + { + return new MessageModel() + { + success = true, + msg = "添加成功", + response = await _roleServices.SaveRole(roleName) + }; + } + + /// + /// 新建用户角色关系 + /// + /// + /// + /// + [HttpGet] + public async Task> AddUserRole(int uid, int rid) + { + return new MessageModel() + { + success = true, + msg = "添加成功", + response = await _userRoleServices.SaveUserRole(uid, rid) + }; + } + + + + + } +} diff --git a/New_College.Api/Controllers/ValuesController.cs b/New_College.Api/Controllers/ValuesController.cs new file mode 100644 index 0000000..68145f4 --- /dev/null +++ b/New_College.Api/Controllers/ValuesController.cs @@ -0,0 +1,300 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Threading.Tasks; +using AutoMapper; +using New_College.Common.HttpContextUser; +using New_College.Common.HttpRestSharp; +using New_College.Common.WebApiClients.HttpApis; +using New_College.Filter; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace New_College.Controllers +{ + /// + /// Values控制器 + /// + [Route("api/[controller]")] + [ApiController] + //[Authorize] + //[Authorize(Roles = "Admin,Client")] + //[Authorize(Policy = "SystemOrAdmin")] + //[Authorize(PermissionNames.Permission)] + [Authorize] + public class ValuesController : ControllerBase + { + private IMapper _mapper; + private readonly IAdvertisementServices _advertisementServices; + private readonly Love _love; + private readonly IRoleModulePermissionServices _roleModulePermissionServices; + private readonly IUser _user; + private readonly IPasswordLibServices _passwordLibServices; + private readonly IBlogApi _blogApi; + private readonly IDoubanApi _doubanApi; + readonly IBlogArticleServices _blogArticleServices; + + /// + /// ValuesController + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public ValuesController(IBlogArticleServices blogArticleServices, IMapper mapper, IAdvertisementServices advertisementServices, Love love, IRoleModulePermissionServices roleModulePermissionServices, IUser user, IPasswordLibServices passwordLibServices, IBlogApi blogApi, IDoubanApi doubanApi) + { + // 测试 Authorize 和 mapper + _mapper = mapper; + _advertisementServices = advertisementServices; + _love = love; + _roleModulePermissionServices = roleModulePermissionServices; + // 测试 Httpcontext + _user = user; + // 测试多库 + _passwordLibServices = passwordLibServices; + // 测试http请求 + _blogApi = blogApi; + _doubanApi = doubanApi; + // 测试AOP加载顺序,配合 return + _blogArticleServices = blogArticleServices; + } + /// + /// Get方法 + /// + /// + // GET api/values + [HttpGet] + [AllowAnonymous] + public async Task> Get() + { + var data = new MessageModel(); + + /* + * 测试 sql 查询 + */ + var queryBySql = await _blogArticleServices.QuerySql("SELECT bsubmitter,btitle,bcontent,bCreateTime FROM BlogArticle WHERE bID>5"); + + + /* + * 测试 sql 更新 + * + * 【SQL参数】:@bID:5 + * @bsubmitter:laozhang619 + * @IsDeleted:False + * 【SQL语句】:UPDATE `BlogArticle` SET + * `bsubmitter`=@bsubmitter,`IsDeleted`=@IsDeleted WHERE `bID`=@bID + */ + var updateSql = await _blogArticleServices.Update(new { bsubmitter = $"laozhang{DateTime.Now.Millisecond}", IsDeleted = false, bID = 5 }); + + + // 测试模拟异常,全局异常过滤器拦截 + var i = 0; + var d = 3 / i; + + + // 测试 AOP 缓存 + var blogArticles = await _blogArticleServices.GetBlogs(); + + + // 测试多表联查 + var roleModulePermissions = await _roleModulePermissionServices.QueryMuchTable(); + + + // 测试多个异步执行时间 + var roleModuleTask = _roleModulePermissionServices.Query(); + var listTask = _advertisementServices.Query(); + var ad = await roleModuleTask; + var list = await listTask; + + + // 测试service层返回异常 + _advertisementServices.ReturnExp(); + + Love love = null; + love.SayLoveU(); + + return data; + } + /// + /// Get(int id)方法 + /// + /// + /// + // GET api/values/5 + [HttpGet("{id}")] + [AllowAnonymous] + //[TypeFilter(typeof(DeleteSubscriptionCache),Arguments =new object[] { "1"})] + [TypeFilter(typeof(UseServiceDIAttribute), Arguments = new object[] { "laozhang" })] + public ActionResult Get(int id) + { + var loveu = _love.SayLoveU(); + + return "value"; + } + + /// + /// 测试参数是必填项 + /// + /// + /// + [HttpGet] + [Route("/api/values/RequiredPara")] + public string RequiredP([Required]string id) + { + return id; + } + + + /// + /// 通过 HttpContext 获取用户信息 + /// + /// 声明类型,默认 jti + /// + [HttpGet] + [Route("/api/values/UserInfo")] + public MessageModel> GetUserInfo(string ClaimType = "jti") + { + var getUserInfoByToken = _user.GetUserInfoFromToken(ClaimType); + return new MessageModel>() + { + success = _user.IsAuthenticated(), + msg = _user.IsAuthenticated() ? _user.Name.ObjToString() : "未登录", + response = _user.GetClaimValueByType(ClaimType) + }; + } + + /// + /// to redirect by route template name. + /// + [HttpGet("/api/custom/go-destination")] + [AllowAnonymous] + public void Source() + { + var url = Url.RouteUrl("Destination_Route"); + Response.Redirect(url); + } + + /// + /// route with template name. + /// + /// + [HttpGet("/api/custom/destination", Name = "Destination_Route")] + [AllowAnonymous] + public string Destination() + { + return "555"; + } + + + /// + /// 测试 post 一个对象 + 独立参数 + /// + /// model实体类参数 + /// 独立参数 + [HttpPost] + [AllowAnonymous] + public object Post([FromBody] BlogArticle blogArticle, int id) + { + return Ok(new { success = true, data = blogArticle, id = id }); + } + + + /// + /// 测试 post 参数 + /// + /// + /// + [HttpPost] + [Route("TestPostPara")] + [AllowAnonymous] + public object TestPostPara(string name) + { + return Ok(new { success = true, name = name }); + } + + /// + /// 测试http请求 RestSharp Get + /// + /// + [HttpGet("RestsharpGet")] + [AllowAnonymous] + public TestRestSharpGetDto RestsharpGet() + { + return HttpHelper.GetApi("http://apk.neters.club/", "api/Blog/DetailNuxtNoPer", "id=1"); + } + /// + /// 测试http请求 RestSharp Post + /// + /// + [HttpGet("RestsharpPost")] + [AllowAnonymous] + public TestRestSharpPostDto RestsharpPost() + { + return HttpHelper.PostApi("http://apk.neters.club/api/Values/TestPostPara?name=老张", new { age = 18 }); + } + + /// + /// 测试多库连接 + /// + /// + [HttpGet("TestMutiDBAPI")] + [AllowAnonymous] + public async Task TestMutiDBAPI() + { + // 从主库(Sqlite)中,操作blogs + var blogs = await _blogArticleServices.Query(d => d.bID == 1); + + // 从从库(Sqlserver)中,获取pwds + var pwds = await _passwordLibServices.Query(d => d.PLID > 0); + + return new + { + blogs, + pwds + }; + } + + /// + /// 测试http请求 WebApiClient Get + /// + /// + [HttpGet("WebApiClientGetAsync")] + [AllowAnonymous] + public async Task WebApiClientGetAsync() + { + int id = 1; + string isbn = "9787544270878"; + var doubanVideoDetail = await _doubanApi.VideoDetailAsync(isbn); + return await _blogApi.DetailNuxtNoPerAsync(id); + } + + /// + /// Put方法 + /// + /// + /// + // PUT api/values/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + /// + /// Delete方法 + /// + /// + // DELETE api/values/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/New_College.Api/Controllers/v1/ApbController.cs b/New_College.Api/Controllers/v1/ApbController.cs new file mode 100644 index 0000000..c9fb8e8 --- /dev/null +++ b/New_College.Api/Controllers/v1/ApbController.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using New_College.SwaggerHelper; +using Microsoft.AspNetCore.Mvc; +using static New_College.Extensions.CustomApiVersion; + +namespace New_College.Controllers.v1 +{ + [Route("api/[controller]")] + [ApiController] + public class ApbController : ControllerBase + { + + + /************************************************/ + // 如果不需要使用Http协议带名称的,比如这种 [HttpGet] + // 就可以按照下边的写法去写,在方法上直接加特性 [CustomRoute(ApiVersions.v1, "apbs")] + // 反之,如果你需要http协议带名称,请看 V2 文件夹的方法 + /************************************************/ + + [HttpGet] + [CustomRoute(ApiVersions.V1, "apbs")] + public IEnumerable Get() + { + return new string[] { "第一版的 apbs" }; + } + + + } +} diff --git a/New_College.Api/Controllers/v2/ApbController.cs b/New_College.Api/Controllers/v2/ApbController.cs new file mode 100644 index 0000000..a3162d7 --- /dev/null +++ b/New_College.Api/Controllers/v2/ApbController.cs @@ -0,0 +1,32 @@ +using New_College.SwaggerHelper; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using static New_College.Extensions.CustomApiVersion; + +namespace New_College.Controllers.v2 +{ + [CustomRoute(ApiVersions.V2)] + //[Route("api/[controller]")] + [ApiController] + [Authorize(Permissions.Name)] + public class ApbController : ControllerBase + { + + + /************************************************/ + // 如果需要使用Http协议带名称的,比如这种 [HttpGet("apbs")] + // 目前只能把[CustomRoute(ApiVersions.v2)] 提到 controller 的上边,做controller的特性 + // 并且去掉//[Route("api/[controller]")]路由特性,否则会有两个接口 + /************************************************/ + + + [HttpGet("apbs")] + public IEnumerable Get() + { + return new string[] { "第二版的 apbs" }; + } + + + } +} diff --git a/New_College.Api/Dockerfile b/New_College.Api/Dockerfile new file mode 100644 index 0000000..37e0a50 --- /dev/null +++ b/New_College.Api/Dockerfile @@ -0,0 +1,36 @@ +FROM swr.cn-south-1.myhuaweicloud.com/mcr/aspnet:3.1-alpine +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +RUN echo 'Asia/Shanghai' >/etc/timezone + +#RUN apk add --no-cache ca-certificates python3 bash openssh git openssl-dev uwsgi uwsgi-python3 +#RUN apk add --no-cache --virtual .build-deps python3-dev gcc musl-dev libffi-dev make \ + #&& pip3 install --no-cache-dir --trusted-host mirrors.aliyun.com -i http://mirrors.aliyun.com/pypi/simple/ \ + #pymysql==0.8.1 \ + #Flask==1.0.2 \ + #Flask-RESTful==0.3.6 \ + #Flask-Script==2.0.6 \ + #Flask-SQLAlchemy==2.3.2 \ + #Flask-WTF==0.14.2 \ + #SQLAlchemy==1.2.7 \ + #simplejson==3.16.0 \ + #six==1.11.0 \ + #celery==4.2.1 \ + #xlrd==1.1.0 \ + #xlwt==1.3.0 \ + #msgpack==0.5.0 \ + #&& apk del .build-deps +# +#RUN git clone https://github.com/Supervisor/supervisor.git \ + #&& cd supervisor \ + #&& python3 setup.py install \ + #&& cd .. \ + #&& rm -rf supervisor \ + #&& cd /etc/ \ + #&& echo_supervisord_conf > supervisord.conf \ + #&& echo '[include]' >> supervisord.conf \ + #&& echo 'files = /code/supervisor/*.ini' >> supervisord.conf \ + #&& supervisord -c /etc/supervisord.conf +WORKDIR /app +COPY . . +EXPOSE 8083 +ENTRYPOINT ["dotnet", "New_College.Api.dll","-b","0.0.0.0"] \ No newline at end of file diff --git a/New_College.Api/Filter/CustomRouteAttribute.cs b/New_College.Api/Filter/CustomRouteAttribute.cs new file mode 100644 index 0000000..b8d1681 --- /dev/null +++ b/New_College.Api/Filter/CustomRouteAttribute.cs @@ -0,0 +1,37 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ApiExplorer; +using System; +using static New_College.Extensions.CustomApiVersion; + +namespace New_College.SwaggerHelper +{ + /// + /// 自定义路由 /api/{version}/[controler]/[action] + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] + public class CustomRouteAttribute : RouteAttribute, IApiDescriptionGroupNameProvider + { + + /// + /// 分组名称,是来实现接口 IApiDescriptionGroupNameProvider + /// + public string GroupName { get; set; } + + /// + /// 自定义路由构造函数,继承基类路由 + /// + /// + public CustomRouteAttribute(string actionName = "[action]") : base("/api/{version}/[controller]/" + actionName) + { + } + /// + /// 自定义版本+路由构造函数,继承基类路由 + /// + /// + /// + public CustomRouteAttribute(ApiVersions version, string actionName = "") : base($"/api/{version.ToString()}/[controller]/{actionName}") + { + GroupName = version.ToString(); + } + } +} diff --git a/New_College.Api/Filter/GlobalAuthorizeFilter.cs b/New_College.Api/Filter/GlobalAuthorizeFilter.cs new file mode 100644 index 0000000..7bb6cce --- /dev/null +++ b/New_College.Api/Filter/GlobalAuthorizeFilter.cs @@ -0,0 +1,56 @@ +using Microsoft.AspNetCore.Mvc.ApplicationModels; +using Microsoft.AspNetCore.Mvc.Authorization; +using Microsoft.AspNetCore.Mvc.Filters; +using System.Linq; +using System.Threading.Tasks; + +namespace New_College.Filter +{ + /// + /// Summary:全局路由权限公约 + /// Remarks:目的是针对不同的路由,采用不同的授权过滤器 + /// 如果 controller 上不加 [Authorize] 特性,默认都是 Permission 策略 + /// 否则,如果想特例其他授权机制的话,需要在 controller 上带上 [Authorize],然后再action上自定义授权即可,比如 [Authorize(Roles = "Admin")] + /// + public class GlobalRouteAuthorizeConvention : IApplicationModelConvention + { + public void Apply(ApplicationModel application) + { + foreach (var c in application.Controllers) + { + if (!c.Filters.Any(e => e is AuthorizeFilter)) + { + // 没有写特性,就用全局的 Permission 授权 + c.Filters.Add(new AuthorizeFilter(Permissions.Name)); + } + else { + // 写了特性,[Authorize] 或 [AllowAnonymous] ,根据情况进行权限认证 + } + + } + } + } + + /// + /// 全局权限过滤器【无效】 + /// + public class GlobalAuthorizeFilter : AuthorizeFilter + { + + public override Task OnAuthorizationAsync(AuthorizationFilterContext context) + { + if (context.Filters.Any(item => item is IAsyncAuthorizationFilter && item != this)) + { + return Task.FromResult(0); + } + + + return base.OnAuthorizationAsync(context); + + + } + } + + + +} diff --git a/New_College.Api/Filter/GlobalExceptionFilter.cs b/New_College.Api/Filter/GlobalExceptionFilter.cs new file mode 100644 index 0000000..be64f51 --- /dev/null +++ b/New_College.Api/Filter/GlobalExceptionFilter.cs @@ -0,0 +1,90 @@ +using New_College.Common.LogHelper; +using New_College.Hubs; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.SignalR; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using StackExchange.Profiling; +using System; + +namespace New_College.Filter +{ + /// + /// 全局异常错误日志 + /// + public class GlobalExceptionsFilter : IExceptionFilter + { + private readonly IWebHostEnvironment _env; + private readonly IHubContext _hubContext; + private readonly ILogger _loggerHelper; + + public GlobalExceptionsFilter(IWebHostEnvironment env, ILogger loggerHelper, IHubContext hubContext) + { + _env = env; + _loggerHelper = loggerHelper; + _hubContext = hubContext; + } + + public void OnException(ExceptionContext context) + { + var json = new JsonErrorResponse(); + + json.Message = context.Exception.Message;//错误信息 + var errorAudit = "Unable to resolve service for"; + if (!string.IsNullOrEmpty(json.Message)&& json.Message.Contains(errorAudit)) + { + json.Message = json.Message.Replace(errorAudit, $"(若新添加服务,需要重新编译项目){errorAudit}"); + } + if (_env.IsDevelopment()) + { + json.DevelopmentMessage = context.Exception.StackTrace;//堆栈信息 + } + context.Result = new InternalServerErrorObjectResult(json); + + MiniProfiler.Current.CustomTiming("Errors:", json.Message); + + + //采用log4net 进行错误日志记录 + _loggerHelper.LogError(json.Message + WriteLog(json.Message, context.Exception)); + + _hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()).Wait(); + + } + + /// + /// 自定义返回格式 + /// + /// + /// + /// + public string WriteLog(string throwMsg, Exception ex) + { + return string.Format("\r\n【自定义错误】:{0} \r\n【异常类型】:{1} \r\n【异常信息】:{2} \r\n【堆栈调用】:{3}", new object[] { throwMsg, + ex.GetType().Name, ex.Message, ex.StackTrace }); + } + + } + public class InternalServerErrorObjectResult : ObjectResult + { + public InternalServerErrorObjectResult(object value) : base(value) + { + StatusCode = StatusCodes.Status500InternalServerError; + } + } + //返回错误信息 + public class JsonErrorResponse + { + /// + /// 生产环境的消息 + /// + public string Message { get; set; } + /// + /// 开发环境的消息 + /// + public string DevelopmentMessage { get; set; } + } + +} diff --git a/New_College.Api/Filter/GlobalRoutePrefixFilter.cs b/New_College.Api/Filter/GlobalRoutePrefixFilter.cs new file mode 100644 index 0000000..9dd89e5 --- /dev/null +++ b/New_College.Api/Filter/GlobalRoutePrefixFilter.cs @@ -0,0 +1,51 @@ +using Microsoft.AspNetCore.Mvc.ApplicationModels; +using Microsoft.AspNetCore.Mvc.Routing; +using System.Linq; + +namespace New_College.Filter +{ + /// + /// 全局路由前缀公约 + /// + public class GlobalRoutePrefixFilter : IApplicationModelConvention + { + private readonly AttributeRouteModel _centralPrefix; + + public GlobalRoutePrefixFilter(IRouteTemplateProvider routeTemplateProvider) + { + _centralPrefix = new AttributeRouteModel(routeTemplateProvider); + } + + //接口的Apply方法 + public void Apply(ApplicationModel application) + { + //遍历所有的 Controller + foreach (var controller in application.Controllers) + { + // 已经标记了 RouteAttribute 的 Controller + var matchedSelectors = controller.Selectors.Where(x => x.AttributeRouteModel != null).ToList(); + if (matchedSelectors.Any()) + { + foreach (var selectorModel in matchedSelectors) + { + // 在 当前路由上 再 添加一个 路由前缀 + selectorModel.AttributeRouteModel = AttributeRouteModel.CombineAttributeRouteModel(_centralPrefix, + selectorModel.AttributeRouteModel); + } + } + + // 没有标记 RouteAttribute 的 Controller + var unmatchedSelectors = controller.Selectors.Where(x => x.AttributeRouteModel == null).ToList(); + if (unmatchedSelectors.Any()) + { + foreach (var selectorModel in unmatchedSelectors) + { + // 添加一个 路由前缀 + selectorModel.AttributeRouteModel = _centralPrefix; + } + } + } + } + } + +} diff --git a/New_College.Api/Filter/UseServiceDIAttribute.cs b/New_College.Api/Filter/UseServiceDIAttribute.cs new file mode 100644 index 0000000..403370f --- /dev/null +++ b/New_College.Api/Filter/UseServiceDIAttribute.cs @@ -0,0 +1,42 @@ +using New_College.IServices; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.Extensions.Logging; +using System; + +namespace New_College.Filter +{ + public class UseServiceDIAttribute : ActionFilterAttribute + { + + protected readonly ILogger _logger; + private readonly IBlogArticleServices _blogArticleServices; + private readonly string _name; + + public UseServiceDIAttribute(ILogger logger, IBlogArticleServices blogArticleServices,string Name="") + { + _logger = logger; + _blogArticleServices = blogArticleServices; + _name = Name; + } + + + public override void OnActionExecuted(ActionExecutedContext context) + { + //var dd =await _blogArticleServices.Query(); + base.OnActionExecuted(context); + DeleteSubscriptionFiles(); + } + + private void DeleteSubscriptionFiles() + { + try + { + // ... + } + catch (Exception e) + { + _logger.LogError(e, "Error Delete Subscription Files"); + } + } + } +} diff --git a/New_College.Api/Log4net.config b/New_College.Api/Log4net.config new file mode 100644 index 0000000..67beb3d --- /dev/null +++ b/New_College.Api/Log4net.config @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/New_College.Api/New_College.Api.csproj b/New_College.Api/New_College.Api.csproj new file mode 100644 index 0000000..cc53dd2 --- /dev/null +++ b/New_College.Api/New_College.Api.csproj @@ -0,0 +1,93 @@ + + + + + Exe + + netcoreapp3.1 + + OutOfProcess + Linux + 9dd21652-c528-44ce-9a01-f33c5d3edab8 + + + + ..\New_College.Api\New_College.xml + 1701;1702;1591 + + + + ..\New_College\New_College.xml + 1701;1702;1591 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Always + + + + + + Always + + + + + + diff --git a/New_College.Api/New_College.Model.xml b/New_College.Api/New_College.Model.xml new file mode 100644 index 0000000..8880d0d --- /dev/null +++ b/New_College.Api/New_College.Model.xml @@ -0,0 +1,5198 @@ + + + + New_College.Model + + + + + 这是爱 + + + + + id + + + + + 姓名 + + + + + 年龄 + + + + + 通用返回信息类 + + + + + 状态码 + + + + + 操作是否成功 + + + + + 返回信息 + + + + + 返回数据集合 + + + + + 广告图片 + + + + + 广告标题 + + + + + 广告链接 + + + + + 备注 + + + + + 海报管理 + + + + + banner name + + + + + 图片地址 + + + + + 要去的地址 + + + + + banner 0,不展示,1展示是否展示 + + + + + 海报位置:0 首页banner + + + + + 博客文章 + + + + + 主键 + + 这里之所以没用RootEntity,是想保持和之前的数据库一致,主键是bID,不是Id + + + + 创建人 + + + + + 标题blog + + + + + 类别 + + + + + 内容 + + + + + 访问量 + + + + + 评论数量 + + + + + 修改时间 + + + + + 创建时间 + + + + + 备注 + + + + + 逻辑删除 + + + + + 招生简章 + + + + + 院校Id + + + + + 发布时间 + + + + + 标题 + + + + + 文章内容 + + + + + 专业二级分类id + + + + + 专业名称 + + + + + 教育部专业编号 + + + + + 热度 + + + + + 专业分类 1文科 2理科 3不区分 + + + + + + + + + + + + + + + 本科/专科大类 1本科 2 专科 + + + + + 专业类型名称 + + + + + 专业一级分类id + + + + + 院校id + + + + + 专业id + + + + + 专业主修课程 + + + + + 专业前景 + + + + + 专业介绍 + + + + + 相关技能 + + + + + 考研方向 + + + + + 专业ID + + + + + 职业ID + + + + + 职业id + + + + + 标签 + + + + + 院校id + + + + + 专业id + + + + + 是否为特殊专业,0为不是,1为是 + + + + + 专业名称 + + + + + 就业概况-名次 + + + + + 就业概况-名次描述 + + + + + 就业最多地区 + + + + + 就业最多行业 + + + + + 就业行业分布 + + + + + 就业行业分布比例 + + + + + 就业地区分布 + + + + + 就业地区分布比例 + + + + + 工资情况 + + + + + 工资比例 + + + + + 经验情况 + + + + + 经验比例 + + + + + 学历要求 + + + + + 学历要求 + + + + + 就业方向 + + + + + 从事岗位 + + + + + 平均工资 + + + + + 工作年限 + + + + + 工作年限工资 + + + + + 专业Id + + + + + 专业名称 + + + + + 薪资 + + + + + 职业id + + + + + 标签 + + + + + 职业分类id + + + + + 职业名称 + + + + + 职业介绍 + + + + + 是否推荐,0为不推荐,1为推荐 + + + + + 分类名称 + + + + + 分类等级 + + + + + 省id + + + + + 省name + + + + + 排名 + + + + + 创办时间 + + + + + 办学性质 1、公立,2、私立 + + + + + 隶属于 1、教育部,2、省政府, 3 其他部委,4 军校 + + + + + 教育行政主管部门名称 + + + + + 学科层次 1、本科,2、专科 + + + + + 是否985 0、否,1、是 + + + + + 是否211 0、否,1、是 + + + + + 是否双一流 0、否,1、是 + + + + + 院士数 + + + + + 博士数 + + + + + 硕士数 + + + + + 大学类型 0综合,1理工类,2医学类... + + + + + logo + + + + + 院校官网 + + + + + 院校简介 + + + + + 院校收藏和对比 + + + + + 用户Id + + + + + 院校Id + + + + + 1收藏 2对比 + + + + + 院校Id + + + + + 院校图片列表地址 + + + + + 院校名称 + + + + + 类型(0,校友会 1,武书连 2,软科 3,QS 4,U.S.News) + + + + + 年份 + + + + + 排名 + + + + + 留言表 + + + + 博客ID + + + + + 创建时间 + + + + + 手机 + + + + + qq + + + + + 留言内容 + + + + + ip地址 + + + + + 是否显示在前台,0否1是 + + + + + + 接口API地址信息表 + + + + + ID + + + + + 获取或设置是否禁用,逻辑上的删除,非物理删除 + + + + + 父ID + + + + + 名称 + + + + + 菜单链接地址 + + + + + 区域名称 + + + + + 控制器名称 + + + + + Action名称 + + + + + 图标 + + + + + 菜单编号 + + + + + 排序 + + + + + /描述 + + + + + 是否是右侧菜单 + + + + + 是否激活 + + + + + 菜单与按钮关系表 + + + + + 获取或设置是否禁用,逻辑上的删除,非物理删除 + + + + + 菜单ID + + + + + 按钮ID + + + + + 接口API地址信息表 + + + + + ID + + + + + 获取或设置是否禁用,逻辑上的删除,非物理删除 + + + + + 父ID + + + + + 名称 + + + + + 菜单链接地址 + + + + + 区域名称 + + + + + 控制器名称 + + + + + Action名称 + + + + + 图标 + + + + + 菜单编号 + + + + + 排序 + + + + + /描述 + + + + + 是否是右侧菜单 + + + + + 是否激活 + + + + + 创建ID + + + + + 创建者 + + + + + 创建时间 + + + + + 修改ID + + + + + 修改者 + + + + + 修改时间 + + + + + 产品教程,赚钱攻略,操作指南 + + + + + 素材库 + + + + + 素材封面 + + + + + 素材内容 + + + + + 日志记录 + + + + + 区域名 + + + + + 区域控制器名 + + + + + Action名称 + + + + + IP地址 + + + + + 描述 + + + + + 登录时间 + + + + + 登录名称 + + + + + 用户ID + + + + + 密码库表 + + + + + 获取或设置是否禁用,逻辑上的删除,非物理删除 + + + + + 路由菜单表 + + + + + ID + + + + + 菜单执行Action名 + + + + + 菜单显示名(如用户页、编辑(按钮)、删除(按钮)) + + + + + 是否是按钮 + + + + + 组件类型(0,为button或菜单,1为下拉框,2...) + + + + + 是否是隐藏菜单 + + + + + 是否keepAlive + + + + + 按钮事件 + + + + + 上一级菜单(0表示上一级无菜单) + + + + + 接口api + + + + + 排序 + + + + + 菜单图标 + + + + + 菜单描述 + + + + + 激活状态 + + + + + 创建ID + + + + + 创建者 + + + + + 创建时间 + + + + + 修改ID + + + + + 修改者 + + + + + 修改时间 + + + + + 获取或设置是否禁用,逻辑上的删除,非物理删除 + + + + + 角色表 + + + + + ID + + + + + 获取或设置是否禁用,逻辑上的删除,非物理删除 + + + + + 角色名 + + + + + 描述 + + + + + 排序 + + + + + 是否激活 + + + + + 创建ID + + + + + 创建者 + + + + + 创建时间 + + + + + 修改ID + + + + + 修改者 + + + + + 修改时间 + + + + + 按钮跟权限关联表 + + + + + ID + + + + + 获取或设置是否禁用,逻辑上的删除,非物理删除 + + + + + 角色ID + + + + + 菜单ID + + + + + api ID + + + + + 创建ID + + + + + 创建者 + + + + + 创建时间 + + + + + 修改ID + + + + + 修改者 + + + + + 修改时间 + + + + + 带创建人BaseModel + + + + + ID + + + + + 排序 + + + + + 创建ID + + + + + 创建者 + + + + + 创建时间 + + + + + 修改ID + + + + + 修改者 + + + + + 修改时间 + + + + + 是否删除 + + + + + 不带创建人BaseModel + + + + + ID + + + + + 排序 + + + + + 创建时间 + + + + + + 是否删除 + + + + + 省市区 + + + + + 主键ID + + + + + 用户信息表 + + + + + 用户ID + + + + + 登录账号 + + + + + 登录密码 + + + + + 真实姓名 + + + + + 状态 + + + + + 备注 + + + + + 创建时间 + + + + + 更新时间 + + + + + 最后登录时间 + + + + + 错误次数 + + + + + 登录账号 + + + + + 任务计划表 + + + + + 任务名称 + + + + + 任务分组 + + + + + 任务运行时间表达式 + + + + + 任务所在DLL对应的程序集名称 + + + + + 任务所在类 + + + + + 任务描述 + + + + + 执行次数 + + + + + 开始时间 + + + + + 结束时间 + + + + + 触发器类型(0、simple 1、cron) + + + + + 执行间隔时间, 秒为单位 + + + + + 是否启动 + + + + + 执行传参 + + + + + 测评分类表 + + + + + 分类名称 + + + + + 解释 + + + + + 解释详情 + + + + + Vip卡类型 + + + + + 测评分类Id + + + + + 周期名称 + + + + + 个性倾向结果表 + + + + + 学生Id + + + + + 周期Id + + + + + 年级名称 + + + + + 班级名称 + + + + + 喜欢的学科 + + + + + + + + + + 是否出国留学 + + + + + 结果 + + + + + Tag标签 + + + + + 自选标签 + + + + + 标签 + + + + + 适合的领域 + + + + + 性格特征解读 + + + + + 优势 + + + + + 劣势 + + + + + 偏好的活动特质 + + + + + 可能存在的盲点 + + + + + 建议 + + + + + 测评结果表 生涯能力和心理测量 + + + + + 学生Id + + + + + 周期Id + + + + + 年级名称 + + + + + 班级名称 + + + + + 分类Id + + + + + 结果 + + + + + 是否打开 + + + + + 问题表 + + + + + 问题分类Id + + + + + 问题类型Id + + + + + 问题 + + + + + 问题类型 + + + + + 问题Tag + + + + + 版本 + + + + + 正反记分 1是正向记分 0是反向记分 + + + + + 问题类型表 + + + + + 问题类型 + + + + + 分类Id + + + + + Tibug 类别 + + + + + Tibug 博文 + + + + + 省份id + + + + + 省份名称 + + + + + 学界 + + + + + 分数 + + + + + 类型 + + + + + 批次名称 + + + + + 批次表 + + + + + 省份ID + + + + + 省份名称 + + + + + 批次名称 + + + + + 年份 + + + + + 省份id + + + + + 省份名称 + + + + + 年份 + + + + + 本科1,专科0,其他-1 + + + + + 文理 不分文理 + + + + + 计划名称 + + + + + 省份Id + + + + + 年份 + + + + + 招生计划id + + + + + 招生计划批次id + + + + + 招生院校id + + + + + 选科限制:新高考(物理,化学,生物),老高考(无);新高考省份:江苏 湖北 福建 辽宁 广东 重庆 河北 湖南 + + + + + 计划招生数 + + + + + 专业学费 + + + + + 语言限制-------------------------------------- + + + + + 标签匹配 + + + + + 分数线 + + + + + 备注 + + + + + 专业学年制(4年,3年) + + + + + 专业ID -------------------------------------- + + + + + 专业名称-》招生计划名称 + + + + + 专业平均分 + + + + + 位次 + + + + + 招生计划Id + + + + + 省份Id + + + + + 类型 不分文理(0),理工类(1),文史类(2),default(1) + + + + + 档位名称 + + + + + 最高分 + + + + + 最低分 + + + + + 计划名称 + + + + + 标签 + + + + + 省份Id + + + + + 省份名称 + + + + + 年份 + + + + + 满分 + + + + + 用户跟角色关联表 + + + + + 获取或设置是否禁用,逻辑上的删除,非物理删除 + + + + + 用户ID + + + + + 角色ID + + + + + 概率历史 + + + + + 用户Id + + + + + 院校Id + + + + + 概率 + + + + + 预估分数 + + + + + 区域Id + + + + + 年份 + + + + + 志愿Table + + + + + 用户ID + + + + + 志愿表名称 + + + + + 志愿表详情 + + + + + 志愿表Id + + + + + 院校Id + + + + + 院校名称 + + + + + 院校编码 + + + + + 招生计划Id列表逗号隔开 + + + + + 用户头像 + + + + + 用户code + + + + + 小程序openid + + + + + 用户名 + + + + + 性别 1男 2女 + + + + + 电话 + + + + + 用户密码 + + + + + 密码混合验证字段 + + + + + 学生所在学校 + + + + + 学生所在班级 + + + + + 用户类型 + + + + + 省市区id + + + + + 省市区名称 + + + + + 状态:0、未启用,1、启用,2、禁用 + + + + + 学生数据是否初始化(省份,选科等) + + + + + 0(新高考),1(文科,理科) + + + + + 选科文字展示 + + + + + 考生预计分数 + + + + + 是否为VIP + + + + + 是否更新分数 + + + + + 年份 + + + + + 省份id + + + + + 标题 + + + + + 图片 + + + + + 政策内容 + + + + + 此表用户绑定后添加和直接购买 + + + + + 1支付宝支付 0微信支付 + + + + + 状态 + + + + + 价格 + + + + + 实付款 + + + + + 卡Id + + + + + 卡号 + + + + + 卡类型Id + + + + + 用户Id + + + + + + + + + + + + + + + 订单号 + + + + + 用户Id + + + + + 逗号隔开 + + + + + 状态1初选 + 状态2是结束 + 重新选择的时候修改为1 + + + + + 账号 key + + + + + 是否一绑定 + + + + + 天数 + + + + + 金额 + + + + + 卡类型Id + + + + + 卡类型 + + + + + 卡类型名称 + + + + + 金额 + + + + + + + + + + 天数 + + + + + 介绍 + + + + + 通用分页信息类 + + + + + 当前页标 + + + + + 总页数 + + + + + 数据总数 + + + + + 每页大小 + + + + + 返回数据 + + + + + 用户头像 + + + + + 首次注册时传此值 + + + + + 退出重新登录时传此值 + + + + + 无权限 + + + + + 找不到指定资源 + + + + + 找不到指定资源 + + + + + 异步添加种子数据 + + + + + + + + 生成Controller层 + + sqlsugar实例 + 数据库链接ID + 数据库表名数组,默认空,生成所有表 + + + + + + 生成Model层 + + sqlsugar实例 + 数据库链接ID + 数据库表名数组,默认空,生成所有表 + + + + + + 生成IRepository层 + + sqlsugar实例 + 数据库链接ID + + 数据库表名数组,默认空,生成所有表 + + + + + 生成 IService 层 + + sqlsugar实例 + 数据库链接ID + + 数据库表名数组,默认空,生成所有表 + + + + + 生成 Repository 层 + + sqlsugar实例 + 数据库链接ID + + 数据库表名数组,默认空,生成所有表 + + + + + 生成 Service 层 + + sqlsugar实例 + 数据库链接ID + + 数据库表名数组,默认空,生成所有表 + + + + + 功能描述:根据数据库表生产Controller层 + 作  者:New_College + + + 数据库链接ID + 实体类存放路径 + 命名空间 + 生产指定的表 + 实现接口 + + 是否序列化 + + + + 功能描述:根据数据库表生产Model层 + 作  者:New_College + + + 数据库链接ID + 实体类存放路径 + 命名空间 + 生产指定的表 + 实现接口 + + 是否序列化 + + + + 功能描述:根据数据库表生产IRepository层 + 作  者:New_College + + + 数据库链接ID + 实体类存放路径 + 命名空间 + 生产指定的表 + 实现接口 + + + + + 功能描述:根据数据库表生产IServices层 + 作  者:New_College + + + 数据库链接ID + 实体类存放路径 + 命名空间 + 生产指定的表 + 实现接口 + + + + + 功能描述:根据数据库表生产 Repository 层 + 作  者:New_College + + + 数据库链接ID + 实体类存放路径 + 命名空间 + 生产指定的表 + 实现接口 + + + + + 功能描述:根据数据库表生产 Services 层 + 作  者:New_College + + + 数据库链接ID + 实体类存放路径 + 命名空间 + 生产指定的表 + 实现接口 + + + + + 根据模板内容批量生成文件 + + 类文件字符串list + 生成路径 + 文件名格式模板 + + + + 连接字符串 + New_College + + + + + 连接字符串 + New_College + + + + + 数据库类型 + New_College + + + + + 数据连接对象 + New_College + + + + + 数据库上下文实例(自动关闭连接) + New_College + + + + + 功能描述:构造函数 + 作  者:New_College + + + + + 功能描述:获取数据库处理对象 + 作  者:New_College + + 返回值 + + + + 功能描述:获取数据库处理对象 + 作  者:New_College + + db + 返回值 + + + + 功能描述:根据实体类生成数据库表 + 作  者:New_College + + 是否备份表 + 指定的实体 + + + + 功能描述:根据实体类生成数据库表 + 作  者:New_College + + 是否备份表 + 指定的实体 + + + + 功能描述:获得一个DbContext + 作  者:New_College + + + + + + 功能描述:设置初始化参数 + 作  者:New_College + + 连接字符串 + 数据库类型 + + + + 功能描述:创建一个链接配置 + 作  者:New_College + + 是否自动关闭连接 + 是否夸类事务 + ConnectionConfig + + + + 功能描述:获取一个自定义的DB + 作  者:New_College + + config + 返回值 + + + + 功能描述:获取一个自定义的数据库处理对象 + 作  者:New_College + + sugarClient + 返回值 + + + + 功能描述:获取一个自定义的数据库处理对象 + 作  者:New_College + + config + 返回值 + + + + 表格数据,支持分页 + + + + + 返回编码 + + + + + 返回信息 + + + + + 记录总数 + + + + + 返回数据集 + + + + + 广告类 + + + + + 分类ID + + + + + 创建时间 + + + + + 广告图片 + + + + + 广告标题 + + + + + 广告链接 + + + + + 备注 + + + + + 微信小程序配置 + + + + + 绑定支付的APPID(必须配置) + + + + + 公众账号secert + + + + + 商户号(必填) + + + + + 商户支付密钥 + + + + + 支付结果回调URL + + + + + + + + + + 本科/专科大类 1本科 2 专科 + + + + + 博客信息展示类 + + + + + + + + + 创建人 + + + + + 博客标题 + + + + + 摘要 + + + + + + 上一篇 + + + + + 上一篇id + + + + + 下一篇 + + + + + 下一篇id + + + + 类别 + + + + + 内容 + + + + + + 访问量 + + + + + 评论数量 + + + + 修改时间 + + + + + + 创建时间 + + + + 备注 + + + + + + 留言信息展示类 + + + + 留言表 + + + + + 博客ID + + + + + 创建时间 + + + + + 手机 + + + + + qq + + + + + 留言内容 + + + + + ip地址 + + + + + 是否显示在前台,0否1是 + + + + + + 测评类型 + + + + + + + + + + 纬度Id + + + + + 用户Id + + + + + 不传就不修改密码 + + + + + 用户头像 + + + + + 用户名 + + + + + 性别 1男 2女 + + + + + 0(新高考),1,文科,2 理科 + + + + + 选科文字展示 + + + + + 更新信息query + + + + + 省市区id + + + + + 省市区名称 + + + + + 0(新高考),1,文科,2 理科 + + + + + 选科文字展示 + + + + + 考生预计分数 + + + + + + + + + + 省市区id + + + + + 省市区名称 + + + + + 年份 + + + + + + + + + + + + + + + + + + + + 图片 + + + + + 办学层次 本科/专科大类 1本科 2 专科 + + + + + 专业基础查询 + + + + + 学科层次 + + + + + 省市区名称 + + + + + 办学性质 + + + + + 学校类型 + + + + + 是否985 0、否,1、是 + + + + + 是否211 0、否,1、是 + + + + + 是否双一流 0、否,1、是 + + + + + 选科 物化生 中文逗号(,)隔开 + + + + + 高考年份 + + + + + 省市区名称 + + + + + 省份Id + + + + + 分数 + + + + + 专业分类 1文科 2理科 3不区分 + + + + + 教育部专业编号 + + + + + 专业名称 + + + + + 是否前10个 1是2不是 + + + + + 霍兰德标签 + + + + + 选科 物化生 中文逗号(,)隔开 + + + + + 高考年份 + + + + + 省市区名称 + + + + + 省份Id + + + + + 分数 + + + + + 类型 1本科 2专科 + + + + + 1支付宝支付 2微信支付 + + + + + 1支付宝支付 2微信支付 + + + + + 状态 1待支付 2已支付 + + + + + 状态 1待支付 2已支付 + + + + + 价格 + + + + + 实付款 + + + + + 卡Id + + + + + 卡号 + + + + + 卡类型Id + + + + + 卡类型名字 + + + + + 用户Id + + + + + 用户名 + + + + + 名字 + + + + + out_trade_no + + + + + 订单号 + + + + + 电话 + + + + + 根据卡号查询 + + + + + 根据VIP类别查询 + + + + + 根据支付方式查询 + + + + + 根据支付状态查询 + + + + + 根据手机号查询 + + + + + 根据out_trade_no号查询 + + + + + 微信浏览器(标价金额) + + + + + trade_type=JSAPI时(即JSAPI支付),此参数必传,此参数为微信用户在商户对应appid下的唯一标识。openid如何获取,可参考【获取openid】。企业号请使用【企业号OAuth2.0接口】获取企业号内成员userid,再调用【企业号userid转openid接口】进行转换 + + + + + 系统生成订单号 + + + + + 招生计划Ids + + + + + 高考年份 + + + + + 专业Ids + + + + + + + + + + 省份Id + + + + + 生涯能力提交 + + + + + 学科探索传入 + + + + + 学生发展 + + + + + 学科探索query + + + + + 生涯能力json + + + + + 学生发展 + + + + + 霍兰德如果不传周期Id的话就获取最新的 + + + + + 学科层次 + + + + + 省市区名称 + + + + + 办学性质 + + + + + 学校类型 + + + + + 是否985 0、否,1、是 + + + + + 是否211 0、否,1、是 + + + + + 是否双一流 0、否,1、是 + + + + + 录取概率传入 + + + + + 用户Id + + + + + 分数 + + + + + 院校Id + + + + + 省份名称 + + + + + 省份Id + + + + + 年份 + + + + + 用户Id + + + + + 逗号隔开 + + + + + 第三部传1 第五步选择传2 + + + + + 年份 + + + + + 省份Id + + + + + 标签 + + + + + 用户Id + + + + + 第四步选的专业名称 + + + + + 第四步选科 + + + + + 年份 + + + + + 省份Id + + + + + 标签 + + + + + 年份 + + + + + 省份Id + + + + + 省份名称 + + + + + 传0位获取省 传其他Code为获取下级数据 + + + + + 检索省份 + + + + + 科目 物化生政史地 传的话都好隔开 中文逗号 + + + + + 高考年份 + + + + + 学生预估分数 + + + + + 省市区名称 + + + + + 省份Id + + + + + 霍兰德标签 + + + + + 1专业到学校 2学校到专业 + + + + + 批次Id + + + + + 懒人模式Query + + + + + 高考年份 + + + + + 学生预估分数 + + + + + 省市区名称 + + + + + 省份Id + + + + + 办学性质1、公立,2、私立 + + + + + 省份 名称 + + + + + 专业Ids最多三个 + + + + + 冲稳保Query + + + + + 高考年份 + + + + + 批次Id + + + + + 学生预估分数 + + + + + 学校省份 + + + + + 省市区名称 + + + + + 省份Id + + + + + 办学性质1、公立,2、私立 + + + + + 高校级别 985传1 211传2 双一流传3 其他传0或者不传 + + + + + 专业Ids + + + + + dto query + + + + + 用户Id + + + + + 1收藏 2对比 + + + + + 添加Query + + + + + 用户Id + + + + + 1收藏 2对比 + + + + + 院校Id + + + + + 学科层次 + + + + + 省市区名称 + + + + + 办学性质 + + + + + 用户id + + + + + 学校类型 + + + + + 是否985 0、否,1、是 + + + + + 是否211 0、否,1、是 + + + + + 是否双一流 0、否,1、是 + + + + + 院校类型 (0,校友会 1,武书连 2,软科 3,QS 4,U.S.News) + + + + + 编号id + + + + + 账号 key + + + + + vip 卡类别id + + + + + 编号id + + + + + 账号 key + + + + + 卡片类别 + + + + + 是否绑定 + + + + + 卡类型名称 + + + + + 金额 + + + + + 天数 + + + + + vip卡类型id + + + + + 头部 + + + + + 长度 + + + + + 数量 + + + + + 用户Id + + + + + 省份Id + + + + + 省份Name + + + + + 年份 + + + + + 分数 + + + + + 霍兰德推荐专业学校信息 + + + + + 霍兰德推荐专业学校信息 + + + + + 计划名称 + + + + + 院校信息 + + + + + 院校信息 + + + + + 院校Id + + + + + 院校名称 + + + + + 创建者Ip + + + + + 后端域名 + + + + + 用户Id + + + + + 卡类型Id + + + + + 金额 + + + + + 回调地址 + + + + + 订单号 + + + + + 金额 + + + + + 后端IP + + + + + 项目编号 + + + + + 通知时间 + + + + + 通知的类型 + + + + + 通知校验ID + + + + + 开发者的app_id + + + + + 编码格式 + + + + + 接口版本 + + + + + 签名类型 + + + + + 签名 + + + + + 支付宝交易号 + + + + + 商户订单号 + + + + + 商户业务号 + + + + + 买家支付宝用户号 + + + + + 买家支付宝账号 + + + + + 卖家支付宝用户号 + + + + + 卖家支付宝账号 + + + + + 交易状态 + + + + + 订单金额 + + + + + 实收金额 + + + + + 付款金额 + + + + + 标题 + + + + + 描述 + + + + + 交易创建时间 + + + + + 交易付款时间 + + + + + 交易结束时间 + + + + + 试题编号 + + + + + 问题typeid + + + + + 问题 + + + + + 标签 + + + + + 问题类型 + + + + + 是否正反记分 + + + + + 试题编号 + + + + + 试题 + + + + + 选项 + + + + + A或者B + + + + + 选项内容 + + + + + 选项标签 + + + + + 测试次数 + + + + + 周期Id + + + + + 上次测试时间 + + + + + 订单ID + + + + + 交易号 + + + + + 订单状态 + + + + + 创建时间 + + + + + 返回状态1成功 2验证码错误 3失败 + + + + + 小程序openid + + + + + 用户头像 + + + + + 用户名 + + + + + 性别 1男 2女 + + + + + 省市区id + + + + + 省市区名称 + + + + + 学生数据是否初始化(省份,选科等) + + + + + 0(新高考),1(文科,理科) + + + + + 选科文字展示 + + + + + 考生预计分数 + + + + + 是否为VIP + + + + + 学届 + + + + + 编号id + + + + + 用户名 + + + + + 电话 + + + + + 住址 + + + + + Vip账号 + + + + + 0(新高考),1(文科,理科) + + + + + 选科文字展示 + + + + + 考生预计分数 + + + + + 根据用户名查询 + + + + + 根据选科查询 + + + + + 根据电话查询 + + + + + 主键 + + + + + 招生标题 + + + + + 主键 + + + + + 招生标题 + + + + + 发布时间 + + + + + 文章内容 + + + + + 省份名称 + + + + + 标题 + + + + + 修改时间 + + + + + 省份id + + + + + 标题 + + + + + 图片 + + + + + 政策内容 + + + + + + + + + + 标题 + + + + + 图片 + + + + + 政策内容 + + + + + 大类名称 + + + + + 专业科目信息 + + + + + 专业科目信息 + + + + + 专业名称 + + + + + 科目要求 + + + + + 专业介绍 + + + + + 专业简介 + + + + + 主要课程 + + + + + 考研方向 + + + + + 就业方向 + + + + + 专业ID + + + + + 学校ID + + + + + 学校名称 + + + + + 学校类型/公立/私立 + + + + + 985/211 + + + + + 双一流 + + + + + 就业前景 + + + + + 职业分布 + + + + + 行业分布 + + + + + 地区分布 + + + + + 工资分布 + + + + + 名称 + + + + + 分布比例 + + + + + 备注 + + + + + 专业名称 + + + + + 薪资 + + + + + 上级名称 + + + + + 本科还是专科 + + + + + 主键id + + + + + 职业名称 + + + + + 职业 + + + + + 主键id + + + + + 职业名称 + + + + + 排序 + + + + + 职业介绍 + + + + + 院校名称 + + + + + 院校Id + + + + + 概率 + + + + + 预估分数 + + + + + 年份 + + + + + 省份Id + + + + + Id + + + + + 周期Id + + + + + 周期名称 + + + + + 测评时间 + + + + + 生涯能力反回结果 + + + + + 能力评估 + + + + + 变化反馈 + + + + + 分数 + + + + + namevalue + + + + + 推荐选科 + + + + + 学科兴趣 + + + + + 学科能力 + + + + + + + + + + 测评结果 + + + + + 标签 + + + + + 适合的领域 + + + + + 性格特征解读 + + + + + 优势 + + + + + 劣势 + + + + + 偏好的活动特质 + + + + + 可能存在的盲点 + + + + + 建议 + + + + + 推荐选科 + + + + + 霍兰德 + + + + + 学科探索 + + + + + 自选结果 + + + + + uni 专业列表 + + + + + uni二级专业列表 + + + + + 院校Id + + + + + 名称 + + + + + 是否985 + + + + + 是否211 + + + + + 是否双一流 + + + + + 学校logo + + + + + 是否加入对比 0就是没有 + + + + + 是否收藏 + + + + + 名称 + + + + + 排名 + + + + + 是否985 + + + + + 是否211 + + + + + 是否双一流 + + + + + 省市区名称 + + + + + 办学性质 + + + + + 隶属于 + + + + + 学科层次 + + + + + 学校类型 + + + + + 创办时间 + + + + + 院士数 + + + + + 博士数 + + + + + 硕士数 + + + + + 主键id + + + + + 名称 + + + + + 排名 + + + + + 是否985 + + + + + 是否211 + + + + + 是否双一流 + + + + + 学校logo + + + + + 学校简介 + + + + + 省市区名称 + + + + + 办学性质 + + + + + 隶属于 + + + + + 学科层次 + + + + + 学校类型 + + + + + 创办时间 + + + + + 院士数 + + + + + 博士数 + + + + + 硕士数 + + + + + 是否收藏 + + + + + 是否对比 + + + + + 是否分数接近 + + + + + 院校图片json + + + + + 长学校id + + + + + + + + + + -1代表 id为空 -2代表院校为空 + + + + + 特色专业 + + + + + 毕业生省份流向 + + + + + 相关专业 + + + + + 毕业生省份流向 + + + + + 院校招生计划 + + + + + 院校名称 + + + + + 排名 最新 + + + + + 录取概率分析结果 + + + + + 是否985 + + + + + 是否211 + + + + + 是否双一流 + + + + + 学校logo + + + + + 名称 + + + + + 省市区名称 + + + + + 学科层次 + + + + + 办学性质 + + + + + 隶属于 + + + + + 排行 + + + + + 概率 + + + + + 预估分数 + + + + + 历年最低分 + + + + + 建议 + + + + + 历年最低分 + + + + + 年份 + + + + + 批次名称 + + + + + 最低分 + + + + + 编号id + + + + + 账号 key + + + + + 是否一绑定 + + + + + 是否一绑定 + + + + + vip 天数 + + + + + vip 金额 + + + + + vip 卡类别名字 + + + + + 卡类型Id + + + + + 卡类型名称 + + + + + 金额 + + + + + 天数 + + + + + 是否是Vip + + + + + 卡类型Id + + + + + 卡类型名称 + + + + + 卡号 + + + + + 到期时间 + + + + + 志愿填报推荐一级懒人专用 + + + + + 排名 + + + + + 是否211 + + + + + 是否双一流 + + + + + 行政名称 + + + + + 志愿填报推荐一级 + + + + + 冲稳保 类型 + + + + + 排名 + + + + + 是否211 + + + + + 是否双一流 + + + + + 对应的Ids + + + + + 对应专业数 + + + + + 点开学校 展示专业 + + + + + 冲稳保返回 + + + + + 霍兰德获取推荐专业 + + + + + Id + + + + + 名称 + + + + + 颜色 + + + + + 对应信息 + + + + + 专用 + + + + + Id + + + + + 名称 + + + + + 颜色 + + + + + 学校信息 + + + + + 院校Id + + + + + 院校名称 + + + + + 是否211 + + + + + 是否双一流 + + + + + 志愿表详情 + + + + + 志愿列表 + + + + + 名称 + + + + + 排名 + + + + + 是否985 + + + + + 是否211 + + + + + 是否双一流 + + + + + 学校logo + + + + + + + + + + 服务器VM + + + + + 环境变量 + + + + + 系统架构 + + + + + ContentRootPath + + + + + WebRootPath + + + + + .NET Core版本 + + + + + 内存占用 + + + + + 启动时间 + + + + + 菜单展示model + + + + + 用来测试 RestSharp Get 请求 + + + + + + + + + + + + + + + 用来测试 RestSharp Post 请求 + + + + + 留言排名展示类 + + + + 博客ID + + + + + + 评论数量 + + + + 博客标题 + + + + + diff --git a/New_College.Api/New_College.xml b/New_College.Api/New_College.xml new file mode 100644 index 0000000..6a4a1b0 --- /dev/null +++ b/New_College.Api/New_College.xml @@ -0,0 +1,1469 @@ + + + + New_College.Api + + + + + 获取分页 + + + + + + + 获取分页 + + + + + + + 获取单个 + + + + + + + 添加 + + + + + + + 修改 + + + + + + + 删除 + + + + + + + 获取分页 + + + + + + + 获取分页 + + + + + + + 生成卡信息 + + + + + + + 获取分页 + + + + + + + 获取单个 + + + + + + + 添加 + + + + + + + 修改 + + + + + + + 删除 + + + + + + + 获取vipcardTypeList + + + + + + 获取微信openid + + + + + + + 解密手机号同时保存用户信息 + + + + + + + 用户获取用户信息有OpenId 调用此接口 + + + + + + + 更改分数 + + + + + + + 完善用户信息 + + + + + + + 根绝Id获取用户信息 + + + + + + + 获取考试时间 + + + + + + + 获取院校库 + + + + + + + 专业库 一级二级列表 + + + + + + + 获取推荐职业 + + + + + + 职业库 一级二级列表 + + + + + + 获取职业第三级 + + + + + + + 院校详情 + + + + + + + 获取专业介绍 + + + + + + + 相关院校 + + + + + + + 获取专业就业前景 + + + + + + + 获取第三级 + + + + + + + 根据标签推荐专业 + + + + + + + 获取职业详情-职业介绍 + + + + + + 院校相关专业专用 + + + + + + + 查学校省份的 年份批次 + + + + + + + 获取招生计划 院校详情 + + + + + + + 获取院校排名 + + + + + + + 专业搜索 + + + + + + + 获取招生简章列表 + + + + + + + 获取招生简介详情 + + + + + + + 获取高薪推荐 + + + + + + 下订单 + + + + + + 获取省市区 + + + + + + + 获取分类 根绝type + + + + + + 获取个人某个维度测评结果 + + + + + + + 获取测评状态 + + + + + + + 获取问题 + + + + + + + 获取mbti试题 + + + + + + 提交 + + + + + + 提交 霍兰德和MBTI + + + + + + + 获取学生发展 + + + + + + + 获取霍兰德测评结果 + + + + + + + 获取MBTI测评结果 + + + + + + + 学科探索 结果 + + + + + + + 传入用户Id 获取霍兰德测评状态 + + + + + + + 传入用户Id 获取学科探索测评状态 + + + + + + + 获取我的自选科目 + + + + + + + 保存我的选科 + + + + + + + 根据标签推荐选科 + + + + + + + 获取测评最新周期Id + + + + + + + 获取三种推荐选科 + + + + + + + 根绝霍兰德获取推荐选科 + + + + + + + 获取收藏和对比 + + + + + + + 删除 + + + + + + + 添加收藏、对比 + + + + + + + 获取院校对比结果 传Ids + + + + + + 获取搜索学校 + + + + + + + 报告 获取我喜欢的院校 + + + + + + + 获取Vip卡列表 + + + + + + 绑定卡 + + + + + + + 获取vip信息 传用户Id + + + + + + + 专业分类列表(二级) 传Id 1本科 2 专科 + + + + + + + 根据分数获取个性推荐学校 + + + + + + + 懒人模式 + 办学性质 + 高校级别 + 专业ids + + + + + + + 根据计划Ids 获取招生计划 + + + + + + + 根据年份省份获取批次 + + + + + + 冲稳保获取推荐学校专业 + + + + + + + 冲稳保详情 + + + + + + + 霍兰德推荐学校专业 + + + + + + + 获取分析结果录取概率 获取之后保存一下 + + + + + + + 获取概率历史记录列表 + + + + + + 保存志愿表 + + + + + + + 获取个人志愿列表 传Id + + + + + + + 获取志愿表详情 传Id + + + + + + + 删除志愿表 + + + + + + + 获取一键生成的志愿表 + + + + + + + 获取霍兰德一键生成的志愿表 + + + + + + + 获取喜欢的院校 + + + + + + + 专业规划 + + + + + + 获取批次 + + + + + + + 下订单 + + + + + + 支付返回值 + + + + + + 统一下单 + @param WxPaydata inputObj 提交给统一下单API的参数 + @param int timeOut 超时时间 + @throws WePayException + @return 成功时返回,其他抛异常 + + + + 生成随机数 + + + + + + POST请求 + + + + application/xml、application/json、application/text、application/x-www-form-urlencoded + + + + + + + 省市区操作类 + + + + + 根据ID获取 + + + + + + + 根据level和parentId获取省市区列表信息 + + + + + + + 获取省市区 + + + + + + + 博客管理 + + + + + 构造函数 + + + + + + + 获取博客列表【无权限】 + + + + + + + + + + 获取博客详情 + + + + + + + 获取详情【无权限】 + + + + + + + 获取博客测试信息 v2版本 + + + + + + 添加博客【无权限】 + + + + + + + + + + + + + + 更新博客信息 + + + + + + + 删除博客 + + + + + + + apache jemeter 压力测试 + 更新接口 + + + + + + 构造函数 + + + + + 获取 整体框架 文件 + + + + + + 根据数据库表名 生成整体框架 + 仅针对通过CodeFirst生成表的情况 + + 数据库链接名称 + 需要生成的表名 + + + + + DbFrist 根据数据库表名 生成整体框架,包含Model层 + + 数据库链接名称 + 需要生成的表名 + + + + + 获取权限部分Map数据(从库) + 迁移到新库(主库) + + + + + + 权限数据库导出tsv + + + + + + 健康检查 + + + + + 健康检查接口 + + + + + + 图片管理 + + + + + 下载图片(支持中文字符) + + + + + + + 上传图片,多文件,可以使用 postman 测试, + 如果是单文件,可以 参数写 IFormFile file1 + + + + + + + 上传图片 + + + + + + + 登录管理【无权限】 + + + + + 构造函数注入 + + + + + + + + + + 获取JWT的方法1 + + + + + + + + 获取JWT的方法2:给Nuxt提供 + + + + + + + + 获取JWT的方法3:整个系统主要方法 + + + + + + + + 请求刷新Token(以旧换新) + + + + + + + 获取JWT的方法4:给 JSONP 测试 + + + + + + + + + + + 测试 MD5 加密字符串 + + + + + + + 接口管理 + + + + + 获取全部接口api + + + + + + + + 添加一条接口信息 + + + + + + + 更新接口信息 + + + + + + + 删除一条接口 + + + + + + + 服务器配置信息 + + + + + + SignalR send data + + + + + + 菜单管理 + + + + + 构造函数 + + + + + + + + + + + + 获取菜单 + + + + + + + + 查询树形 Table + + 父节点 + 关键字 + + + + + 添加一个菜单 + + + + + + + 保存菜单权限分配 + + + + + + + 获取菜单树 + + + + + + + + 获取路由树 + + + + + + + 通过角色获取菜单【无权限】 + + + + + + + 更新菜单 + + + + + + + 删除菜单 + + + + + + + 角色管理 + + + + + 获取全部角色 + + + + + + + + 添加角色 + + + + + + + 更新角色 + + + + + + + 删除角色 + + + + + + + 分页获取 + + + + + + + + 添加计划任务 + + + + + + + 修改计划任务 + + + + + + + 启动计划任务 + + + + + + + 停止一个计划任务 + + + + + + + 重启一个计划任务 + + + + + + + 类别管理【无权限】 + + + + + 构造函数 + + + + + + 获取Tibug所有分类 + + + + + + Tibug 管理 + + + + + 构造函数 + + + + + + + 获取Bug数据列表(带分页) + 【无权限】 + + 页数 + 专题类型 + 关键字 + + + + + + 获取详情【无权限】 + + + + + + + 添加一个 BUG 【无权限】 + + + + + + + 更新 bug + + + + + + + 删除 bug + + + + + + + 测试事务在AOP中的使用 + + + + + + + 用户管理 + + + + + 构造函数 + + + + + + + + + + + 获取全部用户 + + + + + + + + 获取用户详情根据token + 【无权限】 + + 令牌 + + + + + 添加一个用户 + + + + + + + 更新用户与角色 + + + + + + + 删除用户 + + + + + + + 用户角色关系 + + + + + 构造函数 + + + + + + + + 新建用户 + + + + + + + + 新建Role + + + + + + + 新建用户角色关系 + + + + + + + + Values控制器 + + + + + ValuesController + + + + + + + + + + + + + + Get方法 + + + + + + Get(int id)方法 + + + + + + + 测试参数是必填项 + + + + + + + 通过 HttpContext 获取用户信息 + + 声明类型,默认 jti + + + + + to redirect by route template name. + + + + + route with template name. + + + + + + 测试 post 一个对象 + 独立参数 + + model实体类参数 + 独立参数 + + + + 测试 post 参数 + + + + + + + 测试http请求 RestSharp Get + + + + + + 测试http请求 RestSharp Post + + + + + + 测试多库连接 + + + + + + 测试http请求 WebApiClient Get + + + + + + Put方法 + + + + + + + Delete方法 + + + + + + 自定义路由 /api/{version}/[controler]/[action] + + + + + 分组名称,是来实现接口 IApiDescriptionGroupNameProvider + + + + + 自定义路由构造函数,继承基类路由 + + + + + + 自定义版本+路由构造函数,继承基类路由 + + + + + + + Summary:全局路由权限公约 + Remarks:目的是针对不同的路由,采用不同的授权过滤器 + 如果 controller 上不加 [Authorize] 特性,默认都是 Permission 策略 + 否则,如果想特例其他授权机制的话,需要在 controller 上带上 [Authorize],然后再action上自定义授权即可,比如 [Authorize(Roles = "Admin")] + + + + + 全局权限过滤器【无效】 + + + + + 全局异常错误日志 + + + + + 自定义返回格式 + + + + + + + + 生产环境的消息 + + + + + 开发环境的消息 + + + + + 全局路由前缀公约 + + + + + 加载配置文件,构建IConfigurationRoot + + + + + 获取配置文件中的内容,继承自IConfiguration + + + + diff --git a/New_College.Api/Program.cs b/New_College.Api/Program.cs new file mode 100644 index 0000000..8ff2f9d --- /dev/null +++ b/New_College.Api/Program.cs @@ -0,0 +1,63 @@ +using Autofac.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System.IO; + +namespace New_College +{ + public class Program + { + /// + /// 加载配置文件,构建IConfigurationRoot + /// + private static readonly IConfigurationBuilder ConfigurationBuilder = new ConfigurationBuilder(); + /// + /// 获取配置文件中的内容,继承自IConfiguration + /// + private static IConfigurationRoot _configuration; + + public static void Main(string[] args) + { + _configuration = ConfigurationBuilder + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile(cfg => + { + cfg.Path = "appsettings.json"; + cfg.ReloadOnChange = true; + cfg.Optional = false; + }) + //Build方法的调用要在AddJsonFile之后,否则生成的IConfigurationRoot实例的 + //Providers属性不包含任何元素而导致无法读取文件中的信息 + .Build(); + + var url = _configuration.GetSection("urls"); + //初始化默认主机Builder + Host.CreateDefaultBuilder(args) + .UseServiceProviderFactory(new AutofacServiceProviderFactory()) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder + .UseStartup() + .UseUrls(url.Value) + .ConfigureLogging((hostingContext, builder) => + { + //过滤掉系统默认的一些日志 + builder.AddFilter("System", LogLevel.Error); + builder.AddFilter("Microsoft", LogLevel.Error); + builder.AddFilter("New_College.AuthHelper.ApiResponseHandler", LogLevel.Error); + + //可配置文件 + var path = Path.Combine(Directory.GetCurrentDirectory(), "Log4net.config"); + builder.AddLog4Net(path); + }); + }) + // 生成承载 web 应用程序的 Microsoft.AspNetCore.Hosting.IWebHost。Build是WebHostBuilder最终的目的,将返回一个构造的WebHost,最终生成宿主。 + .Build() + // 运行 web 应用程序并阻止调用线程, 直到主机关闭。 + // ※※※※ 有异常,查看 Log 文件夹下的异常日志 ※※※※ + .Run(); + } + } +} diff --git a/New_College.Api/Properties/launchSettings.json b/New_College.Api/Properties/launchSettings.json new file mode 100644 index 0000000..de44141 --- /dev/null +++ b/New_College.Api/Properties/launchSettings.json @@ -0,0 +1,34 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:60716", + "sslPort": 0 + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "New_College": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:8083" + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "publishAllPorts": true + } + } +} \ No newline at end of file diff --git a/New_College.Api/Startup.cs b/New_College.Api/Startup.cs new file mode 100644 index 0000000..9e494b8 --- /dev/null +++ b/New_College.Api/Startup.cs @@ -0,0 +1,226 @@ +using Autofac; +using New_College.Common; +using New_College.Common.LogHelper; +using New_College.Extensions; +using New_College.Filter; +using New_College.Hubs; +using New_College.IServices; +using New_College.Middlewares; +using New_College.Model.Seed; +using New_College.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Server.Kestrel.Core; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using System.Reflection; +using New_College.Model.ViewModels; +using Essensoft.AspNetCore.Payment.WeChatPay; +using Essensoft.AspNetCore.Payment.Alipay; + +namespace New_College +{ + public class Startup + { + + private IServiceCollection _services; + + public Startup(IConfiguration configuration, IWebHostEnvironment env) + { + Configuration = configuration; + Env = env; + } + + public IConfiguration Configuration { get; } + public IWebHostEnvironment Env { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + // 以下code可能与文章中不一样,对代码做了封装,具体查看右侧 Extensions 文件夹. + services.AddSingleton(); + services.AddSingleton(new Appsettings(Configuration)); + services.AddSingleton(new LogLock(Env.ContentRootPath)); + + Permissions.IsUseIds4 = Appsettings.app(new string[] { "Startup", "IdentityServer4", "Enabled" }).ObjToBool(); + //短信配置 + AliyunSmsSenderConfig.accessKeyId = Appsettings.app(new string[] { "AliyunSmsSenderConfig", "accessKeyId" }).ObjToString(); + AliyunSmsSenderConfig.accessKeySecret = Appsettings.app(new string[] { "AliyunSmsSenderConfig", "accessKeySecret" }).ObjToString(); + + WeixinConfig.Appid = Appsettings.app(new string[] { "Weixin", "Appid" }).ObjToString(); + WeixinConfig.Secret = Appsettings.app(new string[] { "Weixin", "Secret" }).ObjToString(); + WeixinConfig.MCHID = Appsettings.app(new string[] { "Weixin", "MCHID" }).ObjToString(); + WeixinConfig.KEY = Appsettings.app(new string[] { "Weixin", "KEY" }).ObjToString(); + WeixinConfig.NotifyUrl = Appsettings.app(new string[] { "Weixin", "NotifyUrl" }).ObjToString(); + + //阿里云oss配置 + AliYunOssConfig.wendpoint = Appsettings.app(new string[] { "AliYunOss", "wendpoint" }).ObjToString(); + AliYunOssConfig.accessKeyId = Appsettings.app(new string[] { "AliYunOss", "accessKeyId" }).ObjToString(); + AliYunOssConfig.accessKeySecret = Appsettings.app(new string[] { "AliYunOss", "accessKeySecret" }).ObjToString(); + AliYunOssConfig.bucket = Appsettings.app(new string[] { "AliYunOss", "bucket" }).ObjToString(); + AliYunOssConfig.endpoint = Appsettings.app(new string[] { "AliYunOss", "endpoint" }).ObjToString(); + + ////微信app支付 + //WeiXinPayConfig.NotifyUrl= Appsettings.app(new string[] { "WeChatPay", "NotifyUrl" }).ObjToString(); + //WeiXinPayConfig.APP_ID= Appsettings.app(new string[] { "WeChatPay", "AppId" }).ObjToString(); + //WeiXinPayConfig.MCHID= Appsettings.app(new string[] { "WeChatPay", "MchId" }).ObjToString(); + ////支付宝app支付 + //AliPayConfig.APP_ID = Appsettings.app(new string[] { "Alipay", "AppId" }).ObjToString(); + //AliPayConfig.APP_PRIVATE_KEY = Appsettings.app(new string[] { "Alipay", "AppPrivateKey" }).ObjToString(); + //AliPayConfig.ALIPAY_PUBLIC_KEY = Appsettings.app(new string[] { "Alipay", "AlipayPublicKey" }).ObjToString(); + //AliPayConfig.CHARSET = Appsettings.app(new string[] { "Alipay", "CHARSET" }).ObjToString(); + //AliPayConfig.NotifyUrl = Appsettings.app(new string[] { "Alipay", "NotifyUrl" }).ObjToString(); + //支付信息传入 + //PayInfoQuery.CreateIp= Appsettings.app(new string[] { "PayInfoQuery", "CreateIp" }).ObjToString(); + //PayInfoQuery.ApiUrl= Appsettings.app(new string[] { "PayInfoQuery", "ApiUrl" }).ObjToString(); + + //支付注入 + //services.AddAlipay(); + //services.AddWeChatPay(); + + //services.Configure(Configuration.GetSection("WeChatPay")); + //services.Configure(Configuration.GetSection("Alipay")); + + + + services.AddMemoryCacheSetup(); + services.AddSqlsugarSetup(); + services.AddDbSetup(); + services.AddAutoMapperSetup(); + services.AddCorsSetup(); + services.AddMiniProfilerSetup(); + services.AddSwaggerSetup(); + services.AddJobSetup(); + services.AddHttpContextSetup(); + services.AddAppConfigSetup(); + services.AddHttpApi(); + + // 授权+认证 (jwt or ids4) + services.AddAuthorizationSetup(); + if (Permissions.IsUseIds4) + { + services.AddAuthentication_Ids4Setup(); + } + else + { + services.AddAuthentication_JWTSetup(); + } + + services.AddIpPolicyRateLimitSetup(Configuration); + + services.AddSignalR().AddNewtonsoftJsonProtocol(); + + services.AddScoped(); + + services.Configure(x => x.AllowSynchronousIO = true) + .Configure(x => x.AllowSynchronousIO = true); + + services.AddControllers(o => + { + // 全局异常过滤 + o.Filters.Add(typeof(GlobalExceptionsFilter)); + // 全局路由权限公约 + //o.Conventions.Insert(0, new GlobalRouteAuthorizeConvention()); + // 全局路由前缀,统一修改路由 + o.Conventions.Insert(0, new GlobalRoutePrefixFilter(new RouteAttribute(RoutePrefix.Name))); + }) + //全局配置Json序列化处理 + .AddNewtonsoftJson(options => + { + //忽略循环引用 + options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; + //不使用驼峰样式的key + options.SerializerSettings.ContractResolver = new DefaultContractResolver(); + //设置时间格式 + //options.SerializerSettings.DateFormatString = "yyyy-MM-dd"; + }); + + _services = services; + } + + // 注意在Program.CreateHostBuilder,添加Autofac服务工厂 + public void ConfigureContainer(ContainerBuilder builder) + { + builder.RegisterModule(new AutofacModuleRegister()); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, MyContext myContext, ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter, IHostApplicationLifetime lifetime) + { + // Ip限流,尽量放管道外层 + //app.UseIpLimitMildd(); + // 记录请求与返回数据 + app.UseReuestResponseLog(); + // signalr + app.UseSignalRSendMildd(); + // 记录ip请求 + app.UseIPLogMildd(); + // 查看注入的所有服务 + app.UseAllServicesMildd(_services); + + if (env.IsDevelopment()) + { + // 在开发环境中,使用异常页面,这样可以暴露错误堆栈信息,所以不要放在生产环境。 + app.UseDeveloperExceptionPage(); + } + else + { + app.UseExceptionHandler("/Error"); + // 在非开发环境中,使用HTTP严格安全传输(or HSTS) 对于保护web安全是非常重要的。 + // 强制实施 HTTPS 在 ASP.NET Core,配合 app.UseHttpsRedirection + //app.UseHsts(); + } + + // 封装Swagger展示 + app.UseSwaggerMildd(() => GetType().GetTypeInfo().Assembly.GetManifestResourceStream("New_College.Api.index.html")); + + // ↓↓↓↓↓↓ 注意下边这些中间件的顺序,很重要 ↓↓↓↓↓↓ + + // CORS跨域 + app.UseCors(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" })); + // 跳转https + //app.UseHttpsRedirection(); + // 使用静态文件 + app.UseStaticFiles(); + // 使用cookie + app.UseCookiePolicy(); + // 返回错误码 + app.UseStatusCodePages(); + // Routing + app.UseRouting(); + // 这种自定义授权中间件,可以尝试,但不推荐 + // app.UseJwtTokenAuth(); + // 先开启认证 + app.UseAuthentication(); + // 然后是授权中间件 + app.UseAuthorization(); + // 开启异常中间件,要放到最后 + //app.UseExceptionHandlerMidd(); + // 性能分析 + app.UseMiniProfiler(); + // 用户访问记录 + app.UseRecordAccessLogsMildd(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllerRoute( + name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}"); + + endpoints.MapHub("/api2/chatHub"); + }); + + // 生成种子数据 + app.UseSeedDataMildd(myContext, Env.WebRootPath); + // 开启QuartzNetJob调度服务 + app.UseQuartzJobMildd(tasksQzServices, schedulerCenter); + //服务注册 + app.UseConsulMildd(Configuration, lifetime); + } + + } +} diff --git a/New_College.Api/appsettings.Development.json b/New_College.Api/appsettings.Development.json new file mode 100644 index 0000000..e203e94 --- /dev/null +++ b/New_College.Api/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/New_College.Api/appsettings.json b/New_College.Api/appsettings.json new file mode 100644 index 0000000..5ce9ebb --- /dev/null +++ b/New_College.Api/appsettings.json @@ -0,0 +1,210 @@ +{ + "Weixin": { + "Appid": "wx6d433f70416c37d4", + "Secret": "d7cb43cd2546f04f87c04d6ffd5fa9be", + //MCHID + "MCHID": "1600580140", + //MCHKey + "KEY": "sa6328ahwqiuyoa923zaswq7ed021mns", + //NotifyUrl + "NotifyUrl": "http://*:8082/api/WeixinPay/PayNotify" + }, + "Logging": { + "IncludeScopes": false, + "Debug": { + "LogLevel": { + "Default": "Warning" + } + }, + "Console": { + "LogLevel": { + "Default": "Warning", + "Microsoft.Hosting.Lifetime": "Debug" + } + }, + "Log4Net": { + "Name": "New_College" + } + }, + "urls": "http://*:8083", // IIS 部署,注释掉 + "AllowedHosts": "*", + "AppSettings": { + "RedisCachingAOP": { + "Enabled": true, + "ConnectionString": "127.0.0.1:6379", + "Password": "Vs_.127134" + }, + "MemoryCachingAOP": { + "Enabled": true + }, + "LogAOP": { + "Enabled": false + }, + "TranAOP": { + "Enabled": false + }, + "SqlAOP": { + "Enabled": false + }, + "Date": "2018-08-28", + "SeedDBEnabled": true, //只生成表结构 + "SeedDBDataEnabled": true, //生成表,并初始化数据 + "Author": "New_College" + }, + + // 请配置MainDB为你想要的主库的ConnId值,并设置对应的Enabled为true; + // *** 单库操作,把 MutiDBEnabled 设为false ***; + // *** 多库操作,把 MutiDBEnabled 设为true,其他的从库Enabled也为true **; + // 具体配置看视频:https://www.bilibili.com/video/BV1BJ411B7mn?p=6 + + "MainDB": "WMBLOG_MYSQL", //当前项目的主库,所对应的连接字符串的Enabled必须为true + "MutiDBEnabled": false, //是否开启多库模式 + "CQRSEnabled": false, //是否开启读写分离模式,必须是单库模式,且数据库类型一致,比如都是SqlServer + "DBS": [ + /* + 对应下边的 DBType + MySql = 0, + SqlServer = 1, + Sqlite = 2, + Oracle = 3, + PostgreSQL = 4 + */ + { + "ConnId": "WMBLOG_SQLITE", + "DBType": 2, + "Enabled": false, + "HitRate": 50, // 值越大,优先级越高 + "Connection": "WMBlog.db" //sqlite只写数据库名就行 + }, + { + "ConnId": "WMBLOG_MSSQL_1", + "DBType": 1, + "Enabled": false, + "HitRate": 40, + "Connection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=WMBLOG_MSSQL_1;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + "ProviderName": "System.Data.SqlClient" + }, + { + "ConnId": "WMBLOG_MSSQL_2", + "DBType": 1, + "Enabled": false, + "HitRate": 30, + "Connection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=WMBLOG_MSSQL_2;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + "ProviderName": "System.Data.SqlClient" + }, + { + "ConnId": "WMBLOG_MYSQL", + "DBType": 0, + "Enabled": true, + "HitRate": 20, + "Connection": "Server=47.103.130.88; Port=3306;SslMode=None;Database=new_college; Uid=root; Pwd=Vs..127134;CharSet=utf8mb4" + }, + { + "ConnId": "WMBLOG_ORACLE", + "DBType": 3, + "Enabled": false, + "HitRate": 10, + "Connection": "Provider=OraOLEDB.Oracle; Data Source=WMBlogDB; User Id=sss; Password=789;", + "OracleConnection_other1": "User ID=sss;Password=789;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.8.65)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME = orcl)))" + } + ], + "Audience": { + "Secret": "sdfsdfsrty45634kkhllghtdgdfss345t678fs", //不要太短,16位+ + "SecretFile": "C:\\my-file\\new_college.audience.secret.txt", //安全。内容就是Secret + "Issuer": "New_College", + "Audience": "wr" + }, + "Startup": { + "Cors": { + "PolicyName": "CorsIpAccess", //策略名称 + "EnableAllIPs": true, //是否应用所有的IP + // 支持多个域名端口,注意端口号后不要带/斜杆:比如localhost:8000/,是错的 + // 注意,http://127.0.0.1:1818 和 http://localhost:1818 是不一样的 + "IPs": "http://127.0.0.1:2364,http://localhost:2364,http://127.0.0.1:6391,http://localhost:6391,http://127.0.0.1:8080,http://localhost:8080,http://web.riyuemedia.cn,https://payment.riyuemedia.cn" + }, + "AppConfigAlert": { + "Enabled": true + }, + "ApiName": "New_College", + "IdentityServer4": { + "Enabled": false, // 这里默认是false,表示使用jwt,如果设置为true,则表示系统使用Ids4模式 + "AuthorizationUrl": "https://ids.neters.club", // 认证中心域名 + "ApiName": "new_college.api" // 资源服务器 + } + }, + "Middleware": { + "RequestResponseLog": { + "Enabled": false + }, + "IPLog": { + "Enabled": true + }, + "RecordAccessLogs": { + "Enabled": true + }, + "SignalR": { + "Enabled": false + }, + "QuartzNetJob": { + "Enabled": true + }, + "Consul": { + "Enabled": false + }, + "IpRateLimit": { + "Enabled": true + } + }, + "IpRateLimiting": { + "EnableEndpointRateLimiting": true, //False: globally executed, true: executed for each + "StackBlockedRequests": false, //False: Number of rejections should be recorded on another counter + "RealIpHeader": "X-Real-IP", + "ClientIdHeader": "X-ClientId", + "IpWhitelist": [], //ip访问白名单 + "EndpointWhitelist": [ "get:/api/xxx", "*:/api/yyy" ], + "ClientWhitelist": [ "dev-client-1", "dev-client-2" ], + "HttpStatusCode": 429, //返回状态码 + "GeneralRules": [ //api规则,结尾一定要带* + { + "Endpoint": "*:/api/blog*", + "Period": "1m", + "Limit": 20000 + }, + { + "Endpoint": "*/api/*", + "Period": "1s", + "Limit": 3000 + }, + { + "Endpoint": "*/api/*", + "Period": "1m", + "Limit": 300000 + }, + { + "Endpoint": "*/api/*", + "Period": "12h", + "Limit": 5000000 + } + ] + + }, + "ConsulSetting": { + "ServiceName": "BlogCoreService", + "ServiceIP": "localhost", + "ServicePort": "8081", + "ServiceHealthCheck": "/healthcheck", + "ConsulAddress": "http://localhost:8500" + }, + "AliyunSmsSenderConfig": { + "accessKeyId": "LTAI4GK6SGUmMX3J9Wyzyt6C", + "accessKeySecret": "vTUjL4so42kiuctWEb6WoaxtXs3MLS" + }, + + "AliYunOss": { + "wendpoint": "http://yrtsedu.oss-cn-shanghai.aliyuncs.com/", + "accessKeyId": "LTAI4GBVp1V6CVGpuHdznRLw", + "accessKeySecret": "JVcuywn3ZU5dhFEgvcfzIxoMRm0qVs", + "bucket": "yrtsedu", + "endpoint": "http://oss-cn-shanghai.aliyuncs.com" + } +} diff --git a/New_College.Api/index.html b/New_College.Api/index.html new file mode 100644 index 0000000..6a88948 --- /dev/null +++ b/New_College.Api/index.html @@ -0,0 +1,137 @@ + + + + + + + + + + + %(DocumentTitle) + + + + + + + %(HeadContent) + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + diff --git a/New_College.Api/wwwroot/BlogCore.Data.json/BlogArticle.tsv b/New_College.Api/wwwroot/BlogCore.Data.json/BlogArticle.tsv new file mode 100644 index 0000000..2bd7067 --- /dev/null +++ b/New_College.Api/wwwroot/BlogCore.Data.json/BlogArticle.tsv @@ -0,0 +1,15 @@ +[ + { + "bID": 1, + "bsubmitter": "admin", + "btitle": "测试数据:IIS new add website ,some wrong:The requested page cannot be accessed because the related configuration data for the page is invalid.", + "bcategory": "技术博文", + "bcontent": "

问题:

The requested page cannot be accessed because the related configuration data for the page is invalid.

HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:

Module IIS Web Core

Notification Unknown

Handler Not yet determined

Error Code 0x80070003

Config Error Cannot read configuration file

Config File \\?\\D:\\Projects\\...\\web.config

Requested URL http:// localhost:8080/

Physical Path

Logon Method Not yet determined

Logon User Not yet determined

Request Tracing Directory C:\\Users\\...\\TraceLogFiles\\

Config Source:

Answer:

1,find the site's application pools

2,\"Advanced Settings\" ==> Indentity ==>  Custom account



", + "btraffic": 127, + "bcommentNum": 1, + "bUpdateTime": "\/Date(1546272000000+0800)\/", + "bCreateTime": "\/Date(1546272000000+0800)\/", + "bRemark": null, + "IsDeleted": "0" + } +] diff --git a/New_College.Api/wwwroot/BlogCore.Data.json/Modules.tsv b/New_College.Api/wwwroot/BlogCore.Data.json/Modules.tsv new file mode 100644 index 0000000..446327d --- /dev/null +++ b/New_College.Api/wwwroot/BlogCore.Data.json/Modules.tsv @@ -0,0 +1,926 @@ +[ + { + "IsDeleted": "0", + "ParentId": null, + "Name": "values接口", + "LinkUrl": "\/api\/values", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 1, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 1 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "claims的接口", + "LinkUrl": "\/api\/claims", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 1, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 2 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "UserRole接口", + "LinkUrl": "\/api\/UserRole", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 1, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 3 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": null, + "LinkUrl": "\/api\/v2\/Apb\/apbs", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 1, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 4 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "修改 tibug 文章", + "LinkUrl": "\/api\/TopicDetail\/update", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 1, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 5 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "删除tibug文章", + "LinkUrl": "\/api\/TopicDetail\/delete", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 1, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 6 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "获取用户", + "LinkUrl": "\/api\/user\/get", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 1, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 7 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "获取用户详情", + "LinkUrl": "\/api\/user\/get\/\\d+", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 1, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 8 + }, + { + "IsDeleted": "1", + "ParentId": null, + "Name": "角色接口", + "LinkUrl": "\/api\/role", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 9 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "添加用户", + "LinkUrl": "\/api\/user\/post", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 10 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "删除用户", + "LinkUrl": "\/api\/user\/delete", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 11 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "修改用户", + "LinkUrl": "\/api\/user\/put", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 12 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "获取api接口", + "LinkUrl": "\/api\/module\/get", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 13 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "删除api接口", + "LinkUrl": "\/api\/module\/delete", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 14 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "修改api接口", + "LinkUrl": "\/api\/module\/put", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 15 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "添加api接口", + "LinkUrl": "\/api\/module\/post", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 16 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "获取菜单", + "LinkUrl": "\/api\/permission\/get", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 17 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "删除菜单", + "LinkUrl": "\/api\/permission\/delete", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 18 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "修改菜单", + "LinkUrl": "\/api\/permission\/put", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 19 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "添加菜单", + "LinkUrl": "\/api\/permission\/post", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 20 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "获取菜单树", + "LinkUrl": "\/api\/permission\/getpermissiontree", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 21 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "获取角色", + "LinkUrl": "\/api\/role\/get", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 22 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "删除角色", + "LinkUrl": "\/api\/role\/delete", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 23 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "修改角色", + "LinkUrl": "\/api\/role\/put", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 24 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "添加角色", + "LinkUrl": "\/api\/role\/post", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 25 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "获取bug", + "LinkUrl": "\/api\/TopicDetail\/Get", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 26 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "获取博客", + "LinkUrl": "\/api\/Blog", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 27 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "保存分配", + "LinkUrl": "\/api\/permission\/Assign", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 28 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "Get导航条", + "LinkUrl": "\/api\/permission\/GetNavigationBar", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 29 + }, + { + "IsDeleted": "1", + "ParentId": null, + "Name": "test", + "LinkUrl": "\/api\/Blog\/delete1", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 30 + }, + { + "IsDeleted": "1", + "ParentId": null, + "Name": "test", + "LinkUrl": "\/api\/Blog\/delete2", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 31 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "删除博客", + "LinkUrl": "\/api\/Blog\/delete", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 32 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "获取全部日志", + "LinkUrl": "\/api\/Monitor\/get", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 33 + }, + { + "IsDeleted": "1", + "ParentId": null, + "Name": "Agent -测试- 快速添加接口权限", + "LinkUrl": "\/api\/Agent\/get", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 34 + }, + { + "IsDeleted": "1", + "ParentId": null, + "Name": "test", + "LinkUrl": "\/api\/test\/get", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 35 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "Department - 测试新建api - 部门管控", + "LinkUrl": "\/api\/Department\/get", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 36 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "获取任务调取分页", + "LinkUrl": "\/api\/TasksQz\/get", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 37 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "添加任务", + "LinkUrl": "\/api\/TasksQz\/Post", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 38 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "编辑任务", + "LinkUrl": "\/api\/TasksQz\/put", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 39 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "开启任务", + "LinkUrl": "\/api\/TasksQz\/StartJob", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 40 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "停止任务", + "LinkUrl": "\/api\/TasksQz\/StopJob", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 41 + }, + { + "IsDeleted": "0", + "ParentId": null, + "Name": "重启任务", + "LinkUrl": "\/api\/TasksQz\/ReCovery", + "Area": null, + "Controller": null, + "Action": null, + "Icon": null, + "Code": null, + "OrderSort": 0, + "Description": null, + "IsMenu": "0", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 42 + } +] diff --git a/New_College.Api/wwwroot/BlogCore.Data.json/Permission.tsv b/New_College.Api/wwwroot/BlogCore.Data.json/Permission.tsv new file mode 100644 index 0000000..d3f1ef1 --- /dev/null +++ b/New_College.Api/wwwroot/BlogCore.Data.json/Permission.tsv @@ -0,0 +1,1670 @@ +[ + { + "Code": "\/", + "Name": "QQ欢迎页", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": "fa-qq", + "Description": "33", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 1, + "IsHide": "0" + }, + { + "Code": "-", + "Name": "用户角色管理", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": "fa-users", + "Description": "11", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 2, + "IsHide": "0" + }, + { + "Code": "\/User\/Roles", + "Name": "角色管理", + "IsButton": "0", + "Pid": 2, + "Mid": 22, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 3, + "IsHide": "0" + }, + { + "Code": "\/User\/Users", + "Name": "用户管理", + "IsButton": "0", + "Pid": 2, + "Mid": 7, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 4, + "IsHide": "0" + }, + { + "Code": "-", + "Name": "菜单权限管理", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": "fa-sitemap", + "Description": null, + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 5, + "IsHide": "0" + }, + { + "Code": "\/Permission\/Module", + "Name": "接口管理", + "IsButton": "0", + "Pid": 5, + "Mid": 13, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 6, + "IsHide": "0" + }, + { + "Code": "\/Permission\/Permission", + "Name": "菜单管理", + "IsButton": "0", + "Pid": 5, + "Mid": 17, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 7, + "IsHide": "0" + }, + { + "Code": "\/Thanks", + "Name": "致谢页", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 5, + "Icon": "fa-star ", + "Description": null, + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 8, + "IsHide": "0" + }, + { + "Code": "无", + "Name": "查询", + "IsButton": "1", + "Pid": 4, + "Mid": 7, + "OrderSort": 0, + "Icon": null, + "Description": "这个用户页的查询按钮", + "Enabled": "1", + "Func": "getUsers", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 9, + "IsHide": "0" + }, + { + "Code": "-", + "Name": "报表管理", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": "fa-line-chart", + "Description": null, + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 10, + "IsHide": "0" + }, + { + "Code": "\/Form\/Charts", + "Name": "图表", + "IsButton": "0", + "Pid": 10, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 11, + "IsHide": "0" + }, + { + "Code": "\/Form\/Form", + "Name": "表单", + "IsButton": "0", + "Pid": 10, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 12, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "新增", + "IsButton": "1", + "Pid": 4, + "Mid": 10, + "OrderSort": 0, + "Icon": null, + "Description": "新增用户", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "Func": "handleAdd", + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 13, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "编辑", + "IsButton": "1", + "Pid": 4, + "Mid": 12, + "OrderSort": 0, + "Icon": null, + "Description": "编辑用户", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "Func": "handleEdit", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 14, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "删除", + "IsButton": "1", + "Pid": 4, + "Mid": 11, + "OrderSort": 0, + "Icon": null, + "Description": "删除用户", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "Func": "handleDel", + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 15, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "查询", + "IsButton": "1", + "Pid": 3, + "Mid": 22, + "OrderSort": 0, + "Icon": null, + "Description": "查询 角色", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Func": "getRoles", + "IsDeleted": "0", + "Id": 16, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "新增", + "IsButton": "1", + "Pid": 3, + "Mid": 25, + "OrderSort": 0, + "Icon": null, + "Description": "新增 角色", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Func": "handleAdd", + "IsDeleted": "0", + "Id": 17, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "编辑", + "IsButton": "1", + "Pid": 3, + "Mid": 24, + "OrderSort": 0, + "Icon": null, + "Description": "编辑角色", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Func": "handleEdit", + "IsDeleted": "0", + "Id": 18, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "删除", + "IsButton": "1", + "Pid": 3, + "Mid": 23, + "OrderSort": 0, + "Icon": null, + "Description": "删除角色", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Func": "handleDel", + "IsDeleted": "0", + "Id": 19, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "查询", + "IsButton": "1", + "Pid": 6, + "Mid": 13, + "OrderSort": 0, + "Icon": null, + "Description": "查询 接口", + "Func": "getModules", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 20, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "新增", + "IsButton": "1", + "Pid": 6, + "Mid": 16, + "OrderSort": 0, + "Icon": null, + "Description": "新增 接口", + "Enabled": "1", + "Func": "handleAdd", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 21, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "编辑", + "IsButton": "1", + "Pid": 6, + "Mid": 15, + "OrderSort": 0, + "Icon": null, + "Description": "编辑 接口", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "Func": "handleEdit", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 22, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "删除", + "IsButton": "1", + "Pid": 6, + "Mid": 14, + "OrderSort": 0, + "Icon": null, + "Description": "删除接口", + "Enabled": "1", + "CreateId": 18, + "Func": "handleDel", + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 23, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "查询", + "IsButton": "1", + "Pid": 7, + "Mid": 17, + "OrderSort": 0, + "Icon": null, + "Description": "查询 菜单", + "Func": "getPermissions", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 24, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "新增", + "IsButton": "1", + "Pid": 7, + "Mid": 20, + "OrderSort": 0, + "Icon": null, + "Description": "新增菜单", + "Enabled": "1", + "Func": "handleAdd", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 25, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "编辑", + "IsButton": "1", + "Pid": 7, + "Mid": 19, + "OrderSort": 0, + "Icon": null, + "Description": "编辑菜单", + "Enabled": "1", + "Func": "handleEdit", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 26, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "删除", + "IsButton": "1", + "Pid": 7, + "Mid": 18, + "OrderSort": 0, + "Icon": null, + "Description": "删除 菜单", + "Enabled": "1", + "CreateId": 18, + "Func": "handleDel", + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 27, + "IsHide": "0" + }, + { + "Code": "\/Tibug\/Bugs", + "Name": "TiBug", + "IsButton": "0", + "Pid": 42, + "Mid": 26, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 28, + "IsHide": "0" + }, + { + "Code": "-", + "Name": "博客管理", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": "fa-file-word-o", + "Description": null, + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 29, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "编辑", + "IsButton": "1", + "Pid": 28, + "Mid": 5, + "OrderSort": 0, + "Icon": null, + "Description": "编辑 tibug ", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "Func": "handleEdit", + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 30, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "删除", + "IsButton": "1", + "Pid": 28, + "Mid": 6, + "OrderSort": 0, + "Icon": null, + "Description": "删除 tibug", + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "Func": "handleDel", + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 31, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "查询", + "IsButton": "1", + "Pid": 28, + "Mid": 26, + "OrderSort": 0, + "Icon": null, + "Description": "查询 tibug", + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "Func": "getBugs", + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 32, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "菜单树", + "IsButton": "1", + "Pid": 7, + "Mid": 21, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 33, + "IsHide": "1" + }, + { + "Code": "\/Permission\/Assign", + "Name": "权限分配", + "IsButton": "0", + "Pid": 5, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 34, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "保存权限", + "IsButton": "1", + "Pid": 34, + "Mid": 28, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 35, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "左侧导航", + "IsButton": "1", + "Pid": 7, + "Mid": 29, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 36, + "IsHide": "1" + }, + { + "Code": "-", + "Name": "测试页面管理", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": "fa-flask", + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 37, + "IsHide": "0" + }, + { + "Code": "\/TestShow\/TestOne", + "Name": "测试页面1", + "IsButton": "0", + "Pid": 37, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 38, + "IsHide": "0" + }, + { + "Code": "\/TestShow\/TestTwo", + "Name": "测试页面2", + "IsButton": "0", + "Pid": 37, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 39, + "IsHide": "0" + }, + { + "Code": "\/I18n\/index", + "Name": "国际化", + "IsButton": "0", + "Pid": 41, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 40, + "IsHide": "0" + }, + { + "Code": "-", + "Name": "多语言管理", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": "fa-language", + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 41, + "IsHide": "0" + }, + { + "Code": "-", + "Name": "问题管理", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": "fa-bug", + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 42, + "IsHide": "0" + }, + { + "Code": "\/Blog\/Blogs", + "Name": "博客", + "IsButton": "0", + "Pid": 29, + "Mid": 27, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 43, + "IsHide": "0" + }, + { + "Code": "-", + "Name": "多级路由", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": "fa-sort-amount-asc", + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 44, + "IsHide": "0" + }, + { + "Code": "-", + "Name": "Menu-1", + "IsButton": "0", + "Pid": 44, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 45, + "IsHide": "0" + }, + { + "Code": "\/Recursion\/Menu_1\/Menu_1_2", + "Name": "Menu-1-2", + "IsButton": "0", + "Pid": 45, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 46, + "IsHide": "0" + }, + { + "Code": "-", + "Name": "Menu-1-1", + "IsButton": "0", + "Pid": 45, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 47, + "IsHide": "0" + }, + { + "Code": "\/Recursion\/Menu_1\/Menu_1_1\/Menu_1_1_1", + "Name": "Menu-1-1-1", + "IsButton": "0", + "Pid": 47, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 48, + "IsHide": "0" + }, + { + "Code": "\/Recursion\/Menu_1\/Menu_1_1\/Menu_1_1_2", + "Name": "Menu-1-1-2", + "IsButton": "0", + "Pid": 47, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 49, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 50, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 51, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 52, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 53, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 54, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 55, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 56, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 57, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 58, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 59, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 60, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 61, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 62, + "IsHide": "0" + }, + { + "Code": "s", + "Name": "s", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "0", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 63, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "删除", + "IsButton": "1", + "Pid": 43, + "Mid": 32, + "OrderSort": 0, + "Icon": null, + "Description": "删除博客按钮", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "Func": "handleDel", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 64, + "IsHide": "0" + }, + { + "Code": "-", + "Name": "日志管理", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 0, + "Icon": "fa-diamond", + "Description": null, + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 65, + "IsHide": "0" + }, + { + "Code": "\/Logs\/Index", + "Name": "全部日志", + "IsButton": "0", + "Pid": 65, + "Mid": 33, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 66, + "IsHide": "0" + }, + { + "Code": "\/Blog\/Detail\/:id", + "Name": "博客详情", + "IsButton": "0", + "Pid": 29, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 67, + "IsHide": "1" + }, + { + "Code": "-", + "Name": "系统管理", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 1, + "Icon": "el-icon-s-operation", + "Description": null, + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 68, + "IsHide": "0" + }, + { + "Code": "\/System\/My", + "Name": "个人中心", + "IsButton": "0", + "Pid": 68, + "Mid": 0, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 69, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "查询", + "IsButton": "1", + "Pid": 69, + "Mid": 34, + "OrderSort": 0, + "Icon": null, + "Description": "Agent 代理的查询接口", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 70, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "查询", + "IsButton": "1", + "Pid": 69, + "Mid": 35, + "OrderSort": 0, + "Icon": null, + "Description": "查询 部门 Department get", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "1", + "Id": 71, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "查询", + "IsButton": "1", + "Pid": 69, + "Mid": 36, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 72, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "查询", + "IsButton": "1", + "Pid": 43, + "Mid": 27, + "OrderSort": 0, + "Icon": null, + "Description": "查询博客按钮", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "Func": "getBlogs", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 73, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "编辑", + "IsButton": "1", + "Pid": 43, + "Mid": 27, + "OrderSort": 0, + "Icon": null, + "Description": "编辑博客按钮", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "Func": "handleEdit", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 74, + "IsHide": "0" + }, + { + "Code": "-", + "Name": "任务调度", + "IsButton": "0", + "Pid": 0, + "Mid": 0, + "OrderSort": 1, + "Icon": "fa-history", + "Description": null, + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 75, + "IsHide": "0" + }, + { + "Code": "\/Task\/QuartzJob", + "Name": "任务列表", + "IsButton": "0", + "Pid": 75, + "Mid": 37, + "OrderSort": 0, + "Icon": null, + "Description": null, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 76, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "查询", + "IsButton": "1", + "Pid": 76, + "Mid": 37, + "OrderSort": 0, + "Icon": null, + "Description": "查询任务按钮", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "Func": "getTasks", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 77, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "添加", + "IsButton": "1", + "Pid": 76, + "Mid": 38, + "OrderSort": 0, + "Icon": null, + "Description": "添加任务按钮", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "Func": "handleAdd", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 78, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "编辑", + "IsButton": "1", + "Pid": 76, + "Mid": 39, + "OrderSort": 0, + "Icon": null, + "Description": "编辑任务按钮", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "Func": "handleEdit", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 79, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "开启", + "IsButton": "1", + "Pid": 76, + "Mid": 40, + "OrderSort": 0, + "Icon": null, + "Description": "开启任务按钮", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "Func": "handleStartJob", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 80, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "暂停", + "IsButton": "1", + "Pid": 76, + "Mid": 41, + "OrderSort": 0, + "Icon": null, + "Description": "暂停任务按钮", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "Func": "handleStopJob", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 81, + "IsHide": "0" + }, + { + "Code": " ", + "Name": "重启", + "IsButton": "1", + "Pid": 76, + "Mid": 42, + "OrderSort": 0, + "Icon": null, + "Description": "重启任务按钮", + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "Func": "handleReCoveryJob", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "IsDeleted": "0", + "Id": 82, + "IsHide": "0" + } +] diff --git a/New_College.Api/wwwroot/BlogCore.Data.json/Role.tsv b/New_College.Api/wwwroot/BlogCore.Data.json/Role.tsv new file mode 100644 index 0000000..510cbb1 --- /dev/null +++ b/New_College.Api/wwwroot/BlogCore.Data.json/Role.tsv @@ -0,0 +1,408 @@ +[ + { + "IsDeleted": "0", + "Name": "Admin", + "Description": "普通管理", + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 1 + }, + { + "IsDeleted": "0", + "Name": "System", + "Description": "系统管理", + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 2 + }, + { + "IsDeleted": "0", + "Name": "Tibug", + "Description": "tibug系统管理", + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 3 + }, + { + "IsDeleted": "0", + "Name": "SuperAdmin", + "Description": "超级管理", + "OrderSort": 0, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "blogadmin", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 4 + }, + { + "IsDeleted": "1", + "Name": "AdminTest", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": 18, + "CreateBy": "提bug账号", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 5 + }, + { + "IsDeleted": "0", + "Name": "AdminTest", + "Description": "测试管理", + "OrderSort": 1, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 6 + }, + { + "IsDeleted": "0", + "Name": "AdminTest2", + "Description": "测试管理2", + "OrderSort": 1, + "Enabled": "1", + "CreateId": 23, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 7 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 8 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 9 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 10 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 11 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 12 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 13 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 14 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 15 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 16 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 17 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 18 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 19 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 20 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 21 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 22 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 23 + }, + { + "IsDeleted": "1", + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 24 + }, + { + "IsDeleted": null, + "Name": "sss", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 25 + }, + { + "IsDeleted": null, + "Name": "213", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 26 + }, + { + "IsDeleted": null, + "Name": "抬头填", + "Description": null, + "OrderSort": 1, + "Enabled": "1", + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 27 + }, + { + "IsDeleted": "0", + "Name": "hello1", + "Description": "测试 常用 get post put 请求", + "OrderSort": 1, + "Enabled": "1", + "CreateId": 12, + "CreateBy": "后台总管理员", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 28 + }, + { + "IsDeleted": "1", + "Name": "55", + "Description": "555", + "OrderSort": 1, + "Enabled": "0", + "CreateId": 39, + "CreateBy": "Kawhi", + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 29 + } +] diff --git a/New_College.Api/wwwroot/BlogCore.Data.json/RoleModulePermission.tsv b/New_College.Api/wwwroot/BlogCore.Data.json/RoleModulePermission.tsv new file mode 100644 index 0000000..bb624d0 --- /dev/null +++ b/New_College.Api/wwwroot/BlogCore.Data.json/RoleModulePermission.tsv @@ -0,0 +1,1562 @@ +[ + { + "IsDeleted": "0", + "RoleId": 1, + "ModuleId": 1, + "PermissionId": null, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 1 + }, + { + "IsDeleted": "0", + "RoleId": 1, + "ModuleId": 2, + "PermissionId": null, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 2 + }, + { + "IsDeleted": "0", + "RoleId": 1, + "ModuleId": 3, + "PermissionId": null, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 3 + }, + { + "IsDeleted": "0", + "RoleId": 1, + "ModuleId": 4, + "PermissionId": null, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 4 + }, + { + "IsDeleted": "0", + "RoleId": 2, + "ModuleId": 4, + "PermissionId": null, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 5 + }, + { + "IsDeleted": "0", + "RoleId": 3, + "ModuleId": 5, + "PermissionId": 30, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 6 + }, + { + "IsDeleted": "0", + "RoleId": 3, + "ModuleId": 6, + "PermissionId": 31, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 7 + }, + { + "IsDeleted": "0", + "RoleId": 3, + "ModuleId": 7, + "PermissionId": 9, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 8 + }, + { + "IsDeleted": "0", + "RoleId": 3, + "ModuleId": 26, + "PermissionId": 28, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 9 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 7, + "PermissionId": 3, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 10 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 7, + "PermissionId": 9, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 11 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 10, + "PermissionId": 13, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 12 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 12, + "PermissionId": 14, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 13 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 11, + "PermissionId": 15, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 14 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 2, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 15 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 22, + "PermissionId": 4, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 16 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 22, + "PermissionId": 16, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 17 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 25, + "PermissionId": 17, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 18 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 24, + "PermissionId": 18, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 19 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 23, + "PermissionId": 19, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 20 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 1, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 21 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 5, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 22 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 13, + "PermissionId": 6, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 23 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 13, + "PermissionId": 20, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 24 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 16, + "PermissionId": 21, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 25 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 15, + "PermissionId": 22, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 26 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 14, + "PermissionId": 23, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 27 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 17, + "PermissionId": 7, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 28 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 17, + "PermissionId": 24, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 29 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 20, + "PermissionId": 25, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 30 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 19, + "PermissionId": 26, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 31 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 18, + "PermissionId": 27, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 32 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 8, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 33 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 10, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 34 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 11, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 35 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 12, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 36 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 26, + "PermissionId": 28, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 37 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 5, + "PermissionId": 30, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 38 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 6, + "PermissionId": 31, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 39 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 27, + "PermissionId": 29, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 40 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 26, + "PermissionId": 32, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 41 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 1, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 42 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 8, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 43 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 10, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 44 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 11, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 45 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 12, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 46 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 27, + "PermissionId": 29, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 47 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 2, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 48 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 7, + "PermissionId": 3, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 49 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 22, + "PermissionId": 4, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 50 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 5, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 51 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 13, + "PermissionId": 6, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 52 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 17, + "PermissionId": 7, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 53 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 26, + "PermissionId": 28, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 54 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 28, + "PermissionId": 34, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 55 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 21, + "PermissionId": 33, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 56 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 7, + "PermissionId": 9, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 57 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 22, + "PermissionId": 16, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 58 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 13, + "PermissionId": 20, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 59 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 17, + "PermissionId": 24, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 60 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 26, + "PermissionId": 32, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 61 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 28, + "PermissionId": 35, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 62 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 21, + "PermissionId": 33, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 63 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 29, + "PermissionId": 36, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 64 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 34, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 65 + }, + { + "IsDeleted": "0", + "RoleId": 7, + "ModuleId": 0, + "PermissionId": 1, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 66 + }, + { + "IsDeleted": "0", + "RoleId": 7, + "ModuleId": 0, + "PermissionId": 2, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 67 + }, + { + "IsDeleted": "0", + "RoleId": 7, + "ModuleId": 7, + "PermissionId": 4, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 68 + }, + { + "IsDeleted": "0", + "RoleId": 7, + "ModuleId": 0, + "PermissionId": 10, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 69 + }, + { + "IsDeleted": "0", + "RoleId": 7, + "ModuleId": 0, + "PermissionId": 12, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 70 + }, + { + "IsDeleted": "0", + "RoleId": 7, + "ModuleId": 0, + "PermissionId": 8, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 71 + }, + { + "IsDeleted": "0", + "RoleId": 7, + "ModuleId": 22, + "PermissionId": 16, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 72 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 37, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 73 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 38, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 74 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 39, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 75 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 40, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 76 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 40, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 77 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 37, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 78 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 38, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 79 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 39, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 80 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 41, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 81 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 41, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 82 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 42, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 83 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 42, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 84 + }, + { + "IsDeleted": "0", + "RoleId": 3, + "ModuleId": 0, + "PermissionId": 42, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 85 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 43, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 86 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 43, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 87 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 44, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 88 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 45, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 89 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 46, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 90 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 47, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 91 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 48, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 92 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 32, + "PermissionId": 64, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 128 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 65, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 129 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 33, + "PermissionId": 66, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 130 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 65, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 131 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 33, + "PermissionId": 66, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 132 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 67, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 133 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 67, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 134 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 68, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 135 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 0, + "PermissionId": 69, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 136 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 68, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 137 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 0, + "PermissionId": 69, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 138 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 29, + "PermissionId": 36, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 139 + }, + { + "IsDeleted": "0", + "RoleId": 7, + "ModuleId": 29, + "PermissionId": 36, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 140 + }, + { + "IsDeleted": "0", + "RoleId": 7, + "ModuleId": 27, + "PermissionId": 33, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 141 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 36, + "PermissionId": 72, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 144 + }, + { + "IsDeleted": "0", + "RoleId": 28, + "ModuleId": 0, + "PermissionId": 1, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 145 + }, + { + "IsDeleted": "0", + "RoleId": 28, + "ModuleId": 0, + "PermissionId": 2, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 146 + }, + { + "IsDeleted": "0", + "RoleId": 28, + "ModuleId": 22, + "PermissionId": 3, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 147 + }, + { + "IsDeleted": "0", + "RoleId": 28, + "ModuleId": 7, + "PermissionId": 4, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 148 + }, + { + "IsDeleted": "0", + "RoleId": 28, + "ModuleId": 22, + "PermissionId": 16, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 149 + }, + { + "IsDeleted": "0", + "RoleId": 28, + "ModuleId": 7, + "PermissionId": 9, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 150 + }, + { + "IsDeleted": "0", + "RoleId": 28, + "ModuleId": 25, + "PermissionId": 17, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 151 + }, + { + "IsDeleted": "0", + "RoleId": 28, + "ModuleId": 10, + "PermissionId": 13, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 152 + }, + { + "IsDeleted": "0", + "RoleId": 28, + "ModuleId": 21, + "PermissionId": 33, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 153 + }, + { + "IsDeleted": "0", + "RoleId": 28, + "ModuleId": 29, + "PermissionId": 36, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 154 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 32, + "PermissionId": 73, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 155 + }, + { + "IsDeleted": "0", + "RoleId": 6, + "ModuleId": 32, + "PermissionId": 73, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 156 + }, + { + "IsDeleted": "0", + "RoleId": 4, + "ModuleId": 27, + "PermissionId": 74, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 157 + } +] diff --git a/New_College.Api/wwwroot/BlogCore.Data.json/TasksQz.tsv b/New_College.Api/wwwroot/BlogCore.Data.json/TasksQz.tsv new file mode 100644 index 0000000..bcf4608 --- /dev/null +++ b/New_College.Api/wwwroot/BlogCore.Data.json/TasksQz.tsv @@ -0,0 +1,20 @@ +[ + { + "Name": "博客管理", + "JobGroup": "博客测试组", + "TriggerType": 1, + "Cron": "0 */1 * * * ?", + "AssemblyName": "New_College.Tasks", + "ClassName": "Job_Blogs_Quartz", + "Remark": "", + "RunTimes": 0, + "BeginTime": "\/Date(1546272000000+0800)\/", + "EndTime": "\/Date(1640966400000+0800)\/", + "IntervalSecond": 0, + "IsStart": true, + "JobParams": "1", + "IsDeleted": false, + "CreateTime": "\/Date(1546272000000+0800)\/", + "Id": 1 + } +] diff --git a/New_College.Api/wwwroot/BlogCore.Data.json/Topic.tsv b/New_College.Api/wwwroot/BlogCore.Data.json/Topic.tsv new file mode 100644 index 0000000..ef96b80 --- /dev/null +++ b/New_College.Api/wwwroot/BlogCore.Data.json/Topic.tsv @@ -0,0 +1,16 @@ +[ + { + "tLogo": "\/Upload\/20180626\/95445c8e288e47e3af7a180b8a4cc0c7.jpg", + "tName": "《罗马人的故事》", + "tDetail": "这是一个荡气回肠的故事", + "tAuthor": "Laozhang", + "tSectendDetail": null, + "tIsDelete": "0", + "tRead": 0, + "tCommend": 0, + "tGood": 0, + "tCreatetime": "\/Date(1546272000000+0800)\/", + "tUpdatetime": "\/Date(1546272000000+0800)\/", + "Id": 1 + } +] diff --git a/New_College.Api/wwwroot/BlogCore.Data.json/TopicDetail.tsv b/New_College.Api/wwwroot/BlogCore.Data.json/TopicDetail.tsv new file mode 100644 index 0000000..895ebed --- /dev/null +++ b/New_College.Api/wwwroot/BlogCore.Data.json/TopicDetail.tsv @@ -0,0 +1,19 @@ +[ + { + "TopicId": 1, + "tdLogo": null, + "tdName": "第一章 罗马的诞生 第一节 传说的年代", + "tdContent": "

第一节 传说的年代<\/p>

每个民族都有自己的神话传说。大概希望知道本民族的来源是个很自然的愿望吧。但这是一个难题,因为这几乎不可能用科学的方法来解释清楚。不过所有的民族都没有这样的奢求。他们只要有一个具有一定的条理性,而又能振奋其民族精神的浪漫故事就行,别抬杠,象柏杨那样将中国的三皇五帝都来个科学分析,来评论他们的执政之优劣是大可不必的。<\/p>

对於罗马人,他们有一个和特洛伊城的陷落相关的传说。<\/p>

位於小亚细亚西岸的繁荣的城市特洛伊,在遭受了阿加美农统帅的希腊联军的十年围攻之後,仍未陷落。希腊联军於是留下一个巨大的木马後假装撤兵。特洛伊人以为那是希腊联军留给自己的礼物,就将它拉入城内。<\/p>

当庆祝胜利的狂欢结束,特洛伊人满怀对明日的和平生活的希望熟睡後,藏在木马内的希腊士兵一个又一个地爬了出来。就在这天夜里,特洛伊城便在火光和叫喊中陷落了。全城遭到大屠杀 ,幸免於死的人全都沦为奴隶。混乱之中只有特洛伊国王的驸马阿伊尼阿斯带着老父,儿子等数人在女神维娜斯的帮助下成功地逃了出来。这驸马爷乃是女神维娜斯与凡人男子之间的儿子,女神维娜斯不忍心看着自己的儿子被希腊士兵屠杀 。<\/p>

这阿驸马一行人分乘几条船,离开了火光冲天的特洛伊城。在女神维娜斯的指引下,浪迹地中海,最後在意大利西岸登陆。当地的国王看上了阿伊尼阿斯并把自己的女儿嫁给了他。他又是驸马了,与他的新妻过起了幸福的生活。难民们也安定了下来。<\/p>

阿伊尼阿斯死後,跟随他逃难来的儿子继承了王位。新王在位三十年後,离开了这块地方,到台伯河(Tiber)下游建了一个新城亚尔巴龙迦城。这便是罗马城的前身了。<\/p>

罗马人自古相信罗马城是公元前731年4月21日由罗莫路和勒莫(Romulus and Remus)建设的。而这两个孪生兄弟是从特洛伊逃出的阿伊尼阿斯的子孙。後来,罗马人接触了希腊文化後才知道特洛伊的陷落是在公元前十三世纪,老早的事了。罗马人好象并没有对这段空白有任何烦恼,随手编出一串传说,把那空白给填补了。反正传说这事荒唐一点的更受欢迎。经过了一堆搞不清谁是谁的王的统治,出现了一个什麽王的公主。<\/p>

公主的叔父在篡夺了王位後,为了防止公主结婚生子威胁自己的王位,便任命未婚的公主为巫女。这是主管祭神的职位,象修女一样不得结婚。<\/p>

不巧一日这美丽的公主在祭事的空余,来到小河边午睡。也是合当有事,被过往的战神玛尔斯(Mars)一见钟情。这玛尔斯本是靠挑起战争混饭吃的,但也常勾引 良家妇女。这天战神也没错过机会,立刻由天而降,与公主一试云雨。据说战神的技术特神,公主还没来得及醒便完事升天去了。後来公主生了一双胞胎,起名罗莫路和勒莫。<\/p>

叔父闻知此事大怒,将公主投入大牢,又把那双胞胎放在篮子里抛入台伯河,指望那篮子漂入大海将那双胞胎淹死。类似的故事在旧约圣经里也有,那是关於摩西的事,好象这类传说在当地十分流行。<\/p>

再说那兄弟俩的篮子被河口附近茂密的灌木丛钩住而停了下来,俩人哭声引来的一只过路的母狼。意大利的狼都带点慈悲心,不但没吃了俩人当点心,还用自己的奶去喂他们,这才救了俩小命。<\/p>

不过,总是由狼养活也没法交 待,於是又一日一放羊的在这地盘上溜哒,发现了兄弟俩,将他们抱了回去扶养成人 。据说现在这一带仍有许多放羊的。<\/p>

兄弟俩长大後成了这一带放羊人的头,在与别的放羊人的圈子的打斗中不断地扩展自己的势力范围。圈子大了,情报也就多了,终于有一天,罗莫路和勒莫知道了自己身事。<\/p>

兄弟俩就带着手下的放羊人呼啸着去打破了亚尔巴龙迦城,杀了那国王,将王位又交 还给了自己祖父。他们的母亲似乎已经死在了大牢里。但兄弟俩也没在亚尔巴龙迦城多住,他们认为亚尔巴龙迦城位於山地,虽然易守难攻,却不利发展。加上兄弟俩是在台伯河的下游长大的,所以便回到原地,建了个新城。除了手下的放羊人又加上了附近的放羊人和农民。<\/p>

消灭了共同的敌人後,兄弟俩的关系开始恶化。有人说是为了新城的命名,有人说是为了新城的城址,也有人说是为了争夺王位。兄弟俩於是分割统治,各占一小山包。但纷争又开始了,勒莫跳过了罗莫路为表示势力范围而挖的沟。对於这种侵犯他人权力的行为,罗莫路大义灭亲地在自己兄弟的後脑上重重地来了一锄头,勒莫便被灭了。<\/p>

<\/p>

於是这城便以罗莫路的名字命名为罗马,这就是公元前731年4月21日的事了,到现在这天仍是意大利的节日,罗马人会欢天喜地的庆祝罗莫路杀了自己的…不,是庆祝罗马建城。王位当然也得由罗莫路来坐,一切问题都没了。这时四年一度的奥林匹克运动会在希腊已经开了六回,罗马也从传说的时代走出,近入了历史时代。<\/p>


<\/p>", + "tdDetail": "标题", + "tdSectendDetail": null, + "tdIsDelete": "0", + "tdRead": 8, + "tdCommend": 0, + "tdGood": 0, + "tdCreatetime": "\/Date(1546272000000+0800)\/", + "tdUpdatetime": "\/Date(1546272000000+0800)\/", + "tdTop": 0, + "tdAuthor": null, + "Id": 1 + } +] diff --git a/New_College.Api/wwwroot/BlogCore.Data.json/UserRole.tsv b/New_College.Api/wwwroot/BlogCore.Data.json/UserRole.tsv new file mode 100644 index 0000000..a15e04a --- /dev/null +++ b/New_College.Api/wwwroot/BlogCore.Data.json/UserRole.tsv @@ -0,0 +1,134 @@ +[ + { + "IsDeleted": "0", + "UserId": 4, + "RoleId": 1, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 1 + }, + { + "IsDeleted": "0", + "UserId": 3, + "RoleId": 2, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 2 + }, + { + "IsDeleted": "0", + "UserId": 7, + "RoleId": 3, + "CreateId": null, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 3 + }, + { + "IsDeleted": "0", + "UserId": 12, + "RoleId": 4, + "CreateId": 23, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 4 + }, + { + "IsDeleted": "0", + "UserId": 1, + "RoleId": 2, + "CreateId": 1, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 5 + }, + { + "IsDeleted": "0", + "UserId": 1, + "RoleId": 1, + "CreateId": 1, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 6 + }, + { + "IsDeleted": "0", + "UserId": 2, + "RoleId": 1, + "CreateId": 13, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 7 + }, + { + "IsDeleted": "0", + "UserId": 8, + "RoleId": 6, + "CreateId": 19, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 8 + }, + { + "IsDeleted": "0", + "UserId": 13, + "RoleId": 7, + "CreateId": 24, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": "\/Date(1546272000000+0800)\/", + "Id": 9 + }, + { + "IsDeleted": "0", + "UserId": 0, + "RoleId": 0, + "CreateId": 0, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": null, + "Id": 10 + }, + { + "IsDeleted": "0", + "UserId": 39, + "RoleId": 28, + "CreateId": 39, + "CreateBy": null, + "CreateTime": "\/Date(1546272000000+0800)\/", + "ModifyId": null, + "ModifyBy": null, + "ModifyTime": null, + "Id": 11 + } +] diff --git a/New_College.Api/wwwroot/BlogCore.Data.json/sysUserInfo.tsv b/New_College.Api/wwwroot/BlogCore.Data.json/sysUserInfo.tsv new file mode 100644 index 0000000..c752a1e --- /dev/null +++ b/New_College.Api/wwwroot/BlogCore.Data.json/sysUserInfo.tsv @@ -0,0 +1,704 @@ +[ + { + "uID": 1, + "uLoginName": "laozhang", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "老张", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": "老张的哲学", + "sex": 1, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "0" + }, + { + "uID": 2, + "uLoginName": "laoli", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "laoli", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 1, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "0" + }, + { + "uID": 3, + "uLoginName": "user", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "userli", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": "广告", + "sex": 1, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "0" + }, + { + "uID": 4, + "uLoginName": "admins", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "0" + }, + { + "uID": 5, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 6, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 7, + "uLoginName": "tibug", + "uLoginPWD": "BB1C0516F0F4469549CD4A95833A78E5", + "uRealName": "提bug账号", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 1, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "0" + }, + { + "uID": 8, + "uLoginName": "test", + "uLoginPWD": "098F6BCD4621D373CADE4E832627B4F6", + "uRealName": "后台测试1号", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": "测试是", + "sex": 1, + "age": 3, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "0" + }, + { + "uID": 9, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 10, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 11, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 12, + "uLoginName": "blogadmin", + "uLoginPWD": "3FACF26687DAB7254848976256EDB56F", + "uRealName": "后台总管理员", + "uStatus": 0, + "uRemark": "t15", + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 1, + "age": 10, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "0" + }, + { + "uID": 13, + "uLoginName": "test2", + "uLoginPWD": "AD0234829205B9033196BA818F7A872B", + "uRealName": "后台测试2号", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 12, + "birth": "\/Date(1546272000000+0800)\/", + "addr": "北京市", + "tdIsDelete": "0" + }, + { + "uID": 14, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 15, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 16, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 17, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 18, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 19, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 20, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 21, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 22, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 23, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 24, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 25, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 26, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 27, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 28, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 29, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 30, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 31, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 32, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 33, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 34, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 35, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 36, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 37, + "uLoginName": "xx", + "uLoginPWD": "2AEFC34200A294A3CC7DB81B43A81873", + "uRealName": "admins", + "uStatus": 0, + "uRemark": null, + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 0, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 38, + "uLoginName": "99", + "uLoginPWD": "AC627AB1CCBDB62EC96E702F7F6425B", + "uRealName": "99", + "uStatus": 0, + "uRemark": "blogadmin", + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": -1, + "age": 0, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "1" + }, + { + "uID": 39, + "uLoginName": "Kawhi", + "uLoginPWD": "96FEE3FD714358658BFB881A4E1642BE", + "uRealName": "Kawhi 测试员", + "uStatus": 0, + "uRemark": "blogadmin", + "uCreateTime": "\/Date(1546272000000+0800)\/", + "uUpdateTime": "\/Date(1546272000000+0800)\/", + "uLastErrTime": "\/Date(1546272000000+0800)\/", + "uErrorCount": 0, + "name": null, + "sex": 1, + "age": 18, + "birth": "\/Date(1546272000000+0800)\/", + "addr": null, + "tdIsDelete": "0" + } +] diff --git a/New_College.Api/wwwroot/CorsPost.html b/New_College.Api/wwwroot/CorsPost.html new file mode 100644 index 0000000..422061b --- /dev/null +++ b/New_College.Api/wwwroot/CorsPost.html @@ -0,0 +1,100 @@ + + + + + New_College + + + + + + +

通过JsonP实现跨域请求

+ + +
+
+
+ +

添加请求头实现跨域

+ 无 +
+ + +

通过CORS实现跨域请求,另需要在服务器段配置CORE

+ + +
+
+
+ + +
+
+
+ + \ No newline at end of file diff --git a/New_College.Api/wwwroot/JMeterTest.png b/New_College.Api/wwwroot/JMeterTest.png new file mode 100644 index 0000000..78f42c7 Binary files /dev/null and b/New_College.Api/wwwroot/JMeterTest.png differ diff --git a/New_College.Api/wwwroot/MVP_Logo_Horizontal_Preferred_Cyan300_CMYK_72ppi.png b/New_College.Api/wwwroot/MVP_Logo_Horizontal_Preferred_Cyan300_CMYK_72ppi.png new file mode 100644 index 0000000..0315b2e Binary files /dev/null and b/New_College.Api/wwwroot/MVP_Logo_Horizontal_Preferred_Cyan300_CMYK_72ppi.png differ diff --git a/New_College.Api/wwwroot/NoInterAutofacIOC.rar b/New_College.Api/wwwroot/NoInterAutofacIOC.rar new file mode 100644 index 0000000..261036d Binary files /dev/null and b/New_College.Api/wwwroot/NoInterAutofacIOC.rar differ diff --git a/New_College.Api/wwwroot/QQGroup.png b/New_College.Api/wwwroot/QQGroup.png new file mode 100644 index 0000000..413d799 Binary files /dev/null and b/New_College.Api/wwwroot/QQGroup.png differ diff --git a/New_College.Api/wwwroot/index.html b/New_College.Api/wwwroot/index.html new file mode 100644 index 0000000..cf47942 --- /dev/null +++ b/New_College.Api/wwwroot/index.html @@ -0,0 +1,42 @@ + + + + + 默认首页 + + + + + +
+
+ + +
+ + \ No newline at end of file diff --git a/New_College.Api/wwwroot/laozhangisphigood.jpg b/New_College.Api/wwwroot/laozhangisphigood.jpg new file mode 100644 index 0000000..d007244 Binary files /dev/null and b/New_College.Api/wwwroot/laozhangisphigood.jpg differ diff --git a/New_College.Api/wwwroot/logo.jpg.jpg b/New_College.Api/wwwroot/logo.jpg.jpg new file mode 100644 index 0000000..d3ff6a7 Binary files /dev/null and b/New_College.Api/wwwroot/logo.jpg.jpg differ diff --git a/New_College.Api/wwwroot/logo.png.png b/New_College.Api/wwwroot/logo.png.png new file mode 100644 index 0000000..19eea58 Binary files /dev/null and b/New_College.Api/wwwroot/logo.png.png differ diff --git a/New_College.Api/wwwroot/logo/favicon-32x32.png b/New_College.Api/wwwroot/logo/favicon-32x32.png new file mode 100644 index 0000000..68062fe Binary files /dev/null and b/New_College.Api/wwwroot/logo/favicon-32x32.png differ diff --git a/New_College.Api/wwwroot/logocore.png b/New_College.Api/wwwroot/logocore.png new file mode 100644 index 0000000..8027e5e Binary files /dev/null and b/New_College.Api/wwwroot/logocore.png differ diff --git a/New_College.Api/wwwroot/operateFlow.gif b/New_College.Api/wwwroot/operateFlow.gif new file mode 100644 index 0000000..d7ae688 Binary files /dev/null and b/New_College.Api/wwwroot/operateFlow.gif differ diff --git a/New_College.Api/wwwroot/web.config b/New_College.Api/wwwroot/web.config new file mode 100644 index 0000000..29cf4ac --- /dev/null +++ b/New_College.Api/wwwroot/web.config @@ -0,0 +1,3 @@ + + + diff --git a/New_College.Build.bat b/New_College.Build.bat new file mode 100644 index 0000000..ed06825 --- /dev/null +++ b/New_College.Build.bat @@ -0,0 +1,21 @@ +git pull + + +@echo off +for /f "tokens=5" %%i in ('netstat -aon ^| findstr ":8081"') do ( + set n=%%i +) +taskkill /f /pid %n% + + + + +dotnet build + +cd New_College.Api + + + +dotnet run + +cmd \ No newline at end of file diff --git a/New_College.Common/Attribute/CachingAttribute.cs b/New_College.Common/Attribute/CachingAttribute.cs new file mode 100644 index 0000000..c34f15d --- /dev/null +++ b/New_College.Common/Attribute/CachingAttribute.cs @@ -0,0 +1,17 @@ +using System; + +namespace New_College.Common +{ + /// + /// 这个Attribute就是使用时候的验证,把它添加到要缓存数据的方法中,即可完成缓存的操作。 + /// + [AttributeUsage(AttributeTargets.Method, Inherited = true)] + public class CachingAttribute : Attribute + { + /// + /// 缓存绝对过期时间(分钟) + /// + public int AbsoluteExpiration { get; set; } = 30; + + } +} diff --git a/New_College.Common/Attribute/UseTranAttribute.cs b/New_College.Common/Attribute/UseTranAttribute.cs new file mode 100644 index 0000000..b523026 --- /dev/null +++ b/New_College.Common/Attribute/UseTranAttribute.cs @@ -0,0 +1,13 @@ +using System; + +namespace New_College.Common +{ + /// + /// 这个Attribute就是使用时候的验证,把它添加到需要执行事务的方法中,即可完成事务的操作。 + /// + [AttributeUsage(AttributeTargets.Method, Inherited = true)] + public class UseTranAttribute : Attribute + { + + } +} diff --git a/New_College.Common/DB/AppSecretConfig.cs b/New_College.Common/DB/AppSecretConfig.cs new file mode 100644 index 0000000..a68da87 --- /dev/null +++ b/New_College.Common/DB/AppSecretConfig.cs @@ -0,0 +1,47 @@ +using System.IO; + +namespace New_College.Common.AppConfig +{ + public class AppSecretConfig + { + private static string Audience_Secret = Appsettings.app(new string[] { "Audience", "Secret" }); + private static string Audience_Secret_File = Appsettings.app(new string[] { "Audience", "SecretFile" }); + + + public static string Audience_Secret_String => InitAudience_Secret(); + + + private static string InitAudience_Secret() + { + var securityString = DifDBConnOfSecurity(Audience_Secret_File); + if (!string.IsNullOrEmpty(Audience_Secret_File)&& !string.IsNullOrEmpty(securityString)) + { + return securityString; + } + else + { + return Audience_Secret; + } + + } + + private static string DifDBConnOfSecurity(params string[] conn) + { + foreach (var item in conn) + { + try + { + if (File.Exists(item)) + { + return File.ReadAllText(item).Trim(); + } + } + catch (System.Exception) { } + } + + return ""; + } + + } + +} diff --git a/New_College.Common/DB/BaseDBConfig.cs b/New_College.Common/DB/BaseDBConfig.cs new file mode 100644 index 0000000..3a6baa8 --- /dev/null +++ b/New_College.Common/DB/BaseDBConfig.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace New_College.Common.DB +{ + public class BaseDBConfig + { + /* 之前的单库操作已经删除,如果想要之前的代码,可以查看我的GitHub的历史记录 + * 目前是多库操作,默认加载的是appsettings.json设置为true的第一个db连接。 + */ + public static (List, List) MutiConnectionString => MutiInitConn(); + private static string DifDBConnOfSecurity(params string[] conn) + { + foreach (var item in conn) + { + try + { + if (File.Exists(item)) + { + return File.ReadAllText(item).Trim(); + } + } + catch (System.Exception) { } + } + + return conn[conn.Length - 1]; + } + + + public static (List, List) MutiInitConn() + { + List listdatabase = Appsettings.app("DBS") + .Where(i => i.Enabled).ToList(); + foreach (var i in listdatabase) + { + SpecialDbString(i); + } + List listdatabaseSimpleDB = new List();//单库 + List listdatabaseSlaveDB = new List();//从库 + + // 单库,且不开启读写分离,只保留一个 + if (!Appsettings.app(new string[] { "CQRSEnabled" }).ObjToBool() && !Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) + { + if (listdatabase.Count == 1) + { + return (listdatabase, listdatabaseSlaveDB); + } + else + { + var dbFirst = listdatabase.FirstOrDefault(d => d.ConnId == Appsettings.app(new string[] { "MainDB" }).ObjToString()); + if (dbFirst == null) + { + dbFirst = listdatabase.FirstOrDefault(); + } + listdatabaseSimpleDB.Add(dbFirst); + return (listdatabaseSimpleDB, listdatabaseSlaveDB); + } + } + + + // 读写分离,且必须是单库模式,获取从库 + if (Appsettings.app(new string[] { "CQRSEnabled" }).ObjToBool() && !Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) + { + if (listdatabase.Count > 1) + { + listdatabaseSlaveDB = listdatabase.Where(d => d.ConnId != Appsettings.app(new string[] { "MainDB" }).ObjToString()).ToList(); + } + } + + + + return (listdatabase, listdatabaseSlaveDB); + //} + } + + private static MutiDBOperate SpecialDbString(MutiDBOperate mutiDBOperate) + { + if (mutiDBOperate.DbType == DataBaseType.Sqlite) + { + mutiDBOperate.Connection = $"DataSource=" + Path.Combine(Environment.CurrentDirectory, mutiDBOperate.Connection); + } + //else if (mutiDBOperate.DbType == DataBaseType.SqlServer) + //{ + // mutiDBOperate.Conn = DifDBConnOfSecurity(@"D:\my-file\dbCountPsw1.txt", @"c:\my-file\dbCountPsw1.txt", mutiDBOperate.Conn); + //} + else if (mutiDBOperate.DbType == DataBaseType.MySql) + { + mutiDBOperate.Connection = DifDBConnOfSecurity(@"D:\my-file\dbCountPsw1_MySqlConn.txt", @"c:\my-file\dbCountPsw1_MySqlConn.txt", mutiDBOperate.Connection); + } + else if (mutiDBOperate.DbType == DataBaseType.Oracle) + { + mutiDBOperate.Connection = DifDBConnOfSecurity(@"D:\my-file\dbCountPsw1_OracleConn.txt", @"c:\my-file\dbCountPsw1_OracleConn.txt", mutiDBOperate.Connection); + } + + return mutiDBOperate; + } + } + + + public enum DataBaseType + { + MySql = 0, + SqlServer = 1, + Sqlite = 2, + Oracle = 3, + PostgreSQL = 4 + } + public class MutiDBOperate + { + /// + /// 连接启用开关 + /// + public bool Enabled { get; set; } + /// + /// 连接ID + /// + public string ConnId { get; set; } + /// + /// 从库执行级别,越大越先执行 + /// + public int HitRate { get; set; } + /// + /// 连接字符串 + /// + public string Connection { get; set; } + /// + /// 数据库类型 + /// + public DataBaseType DbType { get; set; } + } +} \ No newline at end of file diff --git a/New_College.Common/DB/MainDb.cs b/New_College.Common/DB/MainDb.cs new file mode 100644 index 0000000..5fff1fe --- /dev/null +++ b/New_College.Common/DB/MainDb.cs @@ -0,0 +1,7 @@ +namespace New_College.Common.DB +{ + public static class MainDb + { + public static string CurrentDbConnId = "1"; + } +} diff --git a/New_College.Common/Enum/EnumHelper.cs b/New_College.Common/Enum/EnumHelper.cs new file mode 100644 index 0000000..b07e645 --- /dev/null +++ b/New_College.Common/Enum/EnumHelper.cs @@ -0,0 +1,210 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace New_College.Common +{ + public enum CustomerTypeEnum + { + /// + /// 普通用户 + /// + [Description("普通用户")] + General = 0, + /// + /// 个人代理 + /// + [Description("个人代理")] + PersonalAgency = 1, + /// + /// 机构代理 + /// + [Description("机构代理")] + Agency = 2 + + } + + /// + /// 卡类型 + /// + public enum CardTypeEnum + { + /// + /// 志愿填报卡 + /// + [Description("志愿填报卡")] + volunteerCard=0, + /// + /// 选科指导卡 + /// + [Description("选科指导卡")] + selectSubjectGuideCard=1, + /// + /// 生涯发展卡 + /// + [Description("生涯发展卡")] + development=2 + } + + + /// + /// 办学层次 + /// + public enum EnumSchoolLevel + { + /// + /// 本科 + /// + RegularCollegeCourse = 1, + /// + /// 专科 + /// + Specialist = 2 + } + /// + /// 办学类别 + /// + public enum EnumUniversityType + { + /// + /// 综合 + /// + [Description("综合")] + Comprehensive = 0, + /// + /// 理工 + /// + [Description("理工")] + Engineering = 1, + /// + /// 财经 + /// + [Description("财经")] + Finance = 2, + /// + /// 农林 + /// + [Description("农林")] + Farming = 3, + /// + /// 医药 + /// + [Description("医药")] + Medical = 4, + /// + /// 师范 + /// + [Description("师范")] + Normal = 5, + /// + /// 体育 + /// + [Description("体育")] + Sports = 6, + /// + /// 省属 + /// + [Description("省属")] + Provincial = 7, + /// + /// 政法 + /// + [Description("政法")] + Politics = 8, + /// + /// 艺术 + /// + [Description("艺术")] + Art = 9, + /// + /// 民族 + /// + [Description("民族")] + Nation = 10, + /// + /// 军事 + /// + [Description("军事")] + Military = 11, + /// + /// 语言 + /// + [Description("语言")] + Language = 12, + /// + /// 其它 + /// + [Description("其它")] + Other = 13, + } + + /// + /// 订单类型 + /// + public enum EnumOrderType + { + /// + ///取消订单 + /// + [Description("取消")] + Cancel = -1, + /// + /// 待支付 + /// + [Description("待支付")] + payment = 0, + /// + /// 支付完成 + /// + [Description("支付完成")] + payoff = 1, + /// + /// 已发货 + /// + [Description("已发货")] + Delivered = 2, + /// + /// 已收货 + /// + [Description("已收货")] + Received = 3 + } + + + + /// + /// 支付方式 + /// + public enum EnumPayType + { + /// + /// 微信 + /// + [Description("微信")] + WeiPay = 0, + /// + /// 支付宝 + /// + [Description("支付宝")] + AliPay = 1, + /// + /// IOS支付 + /// + [Description("IOS支付")] + IOSPay = 2 + } + + public enum EnumTagColor + { + + [Description("深蓝")] + a = 0, + [Description("中等蓝")] + b = 1, + [Description("浅蓝")] + c = 2, + [Description("淡蓝")] + d = 3 + } +} diff --git a/New_College.Common/Excel/ExcelUtil.cs b/New_College.Common/Excel/ExcelUtil.cs new file mode 100644 index 0000000..d220b5f --- /dev/null +++ b/New_College.Common/Excel/ExcelUtil.cs @@ -0,0 +1,143 @@ +using NPOI.SS.UserModel; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Text; + +namespace New_College.Common.Excel +{ + public class ExcelUtil + { + /// + /// 读取Excel多Sheet数据 + /// + /// 文件路径 + /// Sheet名 + /// + public static DataSet ReadExcelToDataSet(string filePath, string sheetName = null) + { + if (!File.Exists(filePath)) + { + // LogUtil.Debug($"未找到文件{filePath}"); + return null; + } + //获取文件信息 + FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); + IWorkbook workbook = WorkbookFactory.Create(fs); + //获取sheet信息 + ISheet sheet = null; + DataSet ds = new DataSet(); + if (!string.IsNullOrEmpty(sheetName)) + { + sheet = workbook.GetSheet(sheetName); + if (sheet == null) + { + // LogUtil.Debug($"{filePath}未找到sheet:{sheetName}"); + return null; + } + DataTable dt = ReadExcelFunc(workbook, sheet); + ds.Tables.Add(dt); + } + else + { + //遍历获取所有数据 + int sheetCount = workbook.NumberOfSheets; + for (int i = 0; i < sheetCount; i++) + { + sheet = workbook.GetSheetAt(i); + if (sheet != null) + { + DataTable dt = ReadExcelFunc(workbook, sheet); + ds.Tables.Add(dt); + } + } + } + fs.Close(); + fs.Dispose(); + return ds; + } + + /// + /// 读取Excel信息 + /// + /// 工作区 + /// sheet + /// + private static DataTable ReadExcelFunc(IWorkbook workbook, ISheet sheet) + { + DataTable dt = new DataTable(); + //获取列信息 + IRow cells = sheet.GetRow(sheet.FirstRowNum); + int cellsCount = cells.PhysicalNumberOfCells; + int emptyCount = 0; + int cellIndex = sheet.FirstRowNum; + List listColumns = new List(); + bool isFindColumn = false; + while (!isFindColumn) + { + emptyCount = 0; + listColumns.Clear(); + for (int i = 0; i < cellsCount; i++) + { + if (string.IsNullOrEmpty(cells.GetCell(i).StringCellValue)) + { + emptyCount++; + } + listColumns.Add(cells.GetCell(i).StringCellValue); + } + //这里根据逻辑需要,空列超过多少判断 + if (emptyCount == 0) + { + isFindColumn = true; + } + //cellIndex++; + cells = sheet.GetRow(cellIndex); + } + + foreach (string columnName in listColumns) + { + if (dt.Columns.Contains(columnName)) + { + //如果允许有重复列名,自己做处理 + continue; + } + dt.Columns.Add(columnName, typeof(string)); + } + //开始获取数据 + int rowsCount = sheet.PhysicalNumberOfRows; + cellIndex += 1; + DataRow dr = null; + for (int i = cellIndex; i < rowsCount; i++) + { + cells = sheet.GetRow(i); + dr = dt.NewRow(); + for (int j = 0; j < dt.Columns.Count; j++) + { + var zz = cells.GetCell(j); + if (zz == null) + { + dr[j] = ""; + continue; + } + var cc = zz.CellType; + //这里可以判断数据类型 + switch (cc) + { + case CellType.String: + dr[j] = cells.GetCell(j).StringCellValue; + break; + case CellType.Numeric: + dr[j] = cells.GetCell(j).NumericCellValue.ToString(); + break; + case CellType.Unknown: + dr[j] = cells.GetCell(j).StringCellValue; + break; + } + } + dt.Rows.Add(dr); + } + return dt; + } + } +} diff --git a/New_College.Common/GlobalVar/AliYunOssConfig.cs b/New_College.Common/GlobalVar/AliYunOssConfig.cs new file mode 100644 index 0000000..8f37601 --- /dev/null +++ b/New_College.Common/GlobalVar/AliYunOssConfig.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College +{ + public static class AliYunOssConfig + { + public static string wendpoint { get; set; } + + public static string bucket { get; set; } + + public static string accessKeyId { get; set; } + + public static string accessKeySecret { get; set; } + + public static string endpoint { get; set; } + } +} diff --git a/New_College.Common/GlobalVar/GlobalVars.cs b/New_College.Common/GlobalVar/GlobalVars.cs new file mode 100644 index 0000000..38c0086 --- /dev/null +++ b/New_College.Common/GlobalVar/GlobalVars.cs @@ -0,0 +1,29 @@ +namespace New_College +{ + /// + /// 权限变量配置 + /// + public static class Permissions + { + public const string Name = "Permission"; + + /// + /// 当前项目是否启用IDS4权限方案 + /// true:表示启动IDS4 + /// false:表示使用JWT + public static bool IsUseIds4 = false; + } + + /// + /// 路由变量前缀配置 + /// + public static class RoutePrefix + { + /// + /// 前缀名 + /// 如果不需要,尽量留空,不要修改 + /// 除非一定要在所有的 api 前统一加上特定前缀 + /// + public const string Name = ""; + } +} diff --git a/New_College.Common/GlobalVar/WeiXinConfig.cs b/New_College.Common/GlobalVar/WeiXinConfig.cs new file mode 100644 index 0000000..8af3a8f --- /dev/null +++ b/New_College.Common/GlobalVar/WeiXinConfig.cs @@ -0,0 +1,35 @@ +namespace New_College +{ + + public static class WeixinConfig + { + /// + /// 微信appid + /// + public static string Appid { get; set; } + + /// + /// 微信安全码 + /// + public static string Secret { get; set; } + + /// + /// 商户ID + /// + public static string MCHID { get; set; } + + /// + /// 商户key + /// + public static string KEY { get; set; } + + /// + /// 支付回调URL + /// + public static string NotifyUrl { get; set; } + + } + + + +} \ No newline at end of file diff --git a/New_College.Common/Helper/AliYunOssHelper.cs b/New_College.Common/Helper/AliYunOssHelper.cs new file mode 100644 index 0000000..c13f233 --- /dev/null +++ b/New_College.Common/Helper/AliYunOssHelper.cs @@ -0,0 +1,44 @@ +using Aliyun.OSS; +using Aliyun.OSS.Common; +using System; +using System.Collections.Generic; +using System.Text; + + +namespace New_College.Common +{ + public class AliYunOssHelper + { + // private readonly static AliYunOssConfig ossConfig = GlobalData.AliYunOss; + + + public static string UploadFile(string key, string filepath) + { + try + { + var conf = new ClientConfiguration(); + //conf.ConnectionLimit = 512; + conf.MaxErrorRetry = 3; + conf.ConnectionTimeout = 10000*30; + conf.EnalbeMD5Check = true; + var client = new OssClient(AliYunOssConfig.endpoint, AliYunOssConfig.accessKeyId, AliYunOssConfig.accessKeySecret, conf); + try + { + // 上传文件。 + var cc = client.PutObject(AliYunOssConfig.bucket, key, filepath); + var newurl = string.Format("{0}{1}", AliYunOssConfig.wendpoint, key); + return newurl; + } + catch (ClientException ex) + { + Console.WriteLine("Put object failed, {0}", ex.Message); + } + } + catch (Exception ex) + { + throw ex; + } + return ""; + } + } +} diff --git a/New_College.Common/Helper/AliyunSmsSender.cs b/New_College.Common/Helper/AliyunSmsSender.cs new file mode 100644 index 0000000..5fd3ea7 --- /dev/null +++ b/New_College.Common/Helper/AliyunSmsSender.cs @@ -0,0 +1,230 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Net; +using System.Net.Http; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; +using System.Web; + +namespace New_College.Common +{ + public class AliyunSmsSender + { + private string RegionId = "cn-hangzhou"; + private string Version = "2017-05-25"; + private string Action = "SendSms"; + private string Format = "JSON"; + private string Domain = "dysmsapi.aliyuncs.com"; + + private int MaxRetryNumber = 3; + private bool AutoRetry = true; + private const string SEPARATOR = "&"; + private int TimeoutInMilliSeconds = 100000; + + private string AccessKeyId; + private string AccessKeySecret; + + public AliyunSmsSender(string accessKeyId, string accessKeySecret) + { + this.AccessKeyId = accessKeyId; + this.AccessKeySecret = accessKeySecret; + } + + /// + /// 发送短信 + /// + public async Task<(bool success, string response)> Send(SmsObject sms) + { + var paramers = new Dictionary(); + paramers.Add("PhoneNumbers", sms.Mobile); + paramers.Add("SignName", sms.Signature); + paramers.Add("TemplateCode", sms.TempletKey); + paramers.Add("TemplateParam", JsonConvert.SerializeObject(sms.Data)); + paramers.Add("OutId", sms.OutId); + paramers.Add("AccessKeyId", AccessKeyId); + + try + { + string url = GetSignUrl(paramers, AccessKeySecret); + + int retryTimes = 1; + var reply = await HttpGetAsync(url); + while (500 <= reply.StatusCode && AutoRetry && retryTimes < MaxRetryNumber) + { + url = GetSignUrl(paramers, AccessKeySecret); + reply = await HttpGetAsync(url); + retryTimes++; + } + + if (!string.IsNullOrEmpty(reply.response)) + { + var res = JsonConvert.DeserializeObject>(reply.response); + if (res != null && res.ContainsKey("Code") && "OK".Equals(res["Code"])) + { + return (true, response: reply.response); + } + } + + return (false, response: reply.response); + } + catch (Exception ex) + { + return (false, response: ex.Message); + } + } + + private string GetSignUrl(Dictionary parameters, string accessSecret) + { + var imutableMap = new Dictionary(parameters); + imutableMap.Add("Timestamp", FormatIso8601Date(DateTime.Now)); + imutableMap.Add("SignatureMethod", "HMAC-SHA1"); + imutableMap.Add("SignatureVersion", "1.0"); + imutableMap.Add("SignatureNonce", Guid.NewGuid().ToString()); + imutableMap.Add("Action", Action); + imutableMap.Add("Version", Version); + imutableMap.Add("Format", Format); + imutableMap.Add("RegionId", RegionId); + + IDictionary sortedDictionary = new SortedDictionary(imutableMap, StringComparer.Ordinal); + StringBuilder canonicalizedQueryString = new StringBuilder(); + foreach (var p in sortedDictionary) + { + canonicalizedQueryString.Append("&").Append(PercentEncode(p.Key)).Append("=").Append(PercentEncode(p.Value)); + } + + StringBuilder stringToSign = new StringBuilder(); + stringToSign.Append("GET"); + stringToSign.Append(SEPARATOR); + stringToSign.Append(PercentEncode("/")); + stringToSign.Append(SEPARATOR); + stringToSign.Append(PercentEncode(canonicalizedQueryString.ToString().Substring(1))); + + string signature = SignString(stringToSign.ToString(), accessSecret + "&"); + + imutableMap.Add("Signature", signature); + + return ComposeUrl(Domain, imutableMap); + } + + private static string FormatIso8601Date(DateTime date) + { + return date.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss'Z'", CultureInfo.CreateSpecificCulture("en-US")); + } + + /// + /// 签名 + /// + public static string SignString(string source, string accessSecret) + { + using (var algorithm = new HMACSHA1(Encoding.UTF8.GetBytes(accessSecret.ToCharArray()))) + { + return Convert.ToBase64String(algorithm.ComputeHash(Encoding.UTF8.GetBytes(source.ToCharArray()))); + } + } + + private static string ComposeUrl(string endpoint, Dictionary parameters) + { + StringBuilder urlBuilder = new StringBuilder(""); + urlBuilder.Append("http://").Append(endpoint); + if (-1 == urlBuilder.ToString().IndexOf("?")) + { + urlBuilder.Append("/?"); + } + string query = ConcatQueryString(parameters); + return urlBuilder.Append(query).ToString(); + } + + private static string ConcatQueryString(Dictionary parameters) + { + if (null == parameters) + { + return null; + } + StringBuilder sb = new StringBuilder(); + + foreach (var entry in parameters) + { + String key = entry.Key; + String val = entry.Value; + + sb.Append(HttpUtility.UrlEncode(key, Encoding.UTF8)); + if (val != null) + { + sb.Append("=").Append(HttpUtility.UrlEncode(val, Encoding.UTF8)); + } + sb.Append("&"); + } + + int strIndex = sb.Length; + if (parameters.Count > 0) + sb.Remove(strIndex - 1, 1); + + return sb.ToString(); + } + + public static string PercentEncode(string value) + { + StringBuilder stringBuilder = new StringBuilder(); + string text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~"; + byte[] bytes = Encoding.GetEncoding("UTF-8").GetBytes(value); + foreach (char c in bytes) + { + if (text.IndexOf(c) >= 0) + { + stringBuilder.Append(c); + } + else + { + stringBuilder.Append("%").Append( + string.Format(CultureInfo.InvariantCulture, "{0:X2}", (int)c)); + } + } + return stringBuilder.ToString(); + } + + private async Task<(int StatusCode, string response)> HttpGetAsync(string url) + { + HttpClientHandler handler = new HttpClientHandler(); + handler.Proxy = null; + handler.AutomaticDecompression = DecompressionMethods.GZip; + + using (var http = new HttpClient(handler)) + { + http.Timeout = new TimeSpan(TimeSpan.TicksPerMillisecond * TimeoutInMilliSeconds); + HttpResponseMessage response = await http.GetAsync(url); + return ((int)response.StatusCode, await response.Content.ReadAsStringAsync()); + } + } + + public class SmsObject + { + /// + /// 手机号 + /// + public string Mobile { set; get; } + + /// + /// 签名 + /// + public string Signature { get; set; } + + /// + /// 模板Key + /// + public string TempletKey { set; get; } + + /// + /// 短信数据 + /// + public IDictionary Data { set; get; } + + /// + /// 业务ID + /// + public string OutId { set; get; } + } + } +} diff --git a/New_College.Common/Helper/Appsettings.cs b/New_College.Common/Helper/Appsettings.cs new file mode 100644 index 0000000..6ae5ad1 --- /dev/null +++ b/New_College.Common/Helper/Appsettings.cs @@ -0,0 +1,69 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration.Json; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace New_College.Common +{ + /// + /// 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 List app(params string[] sections) + { + List list = new List(); + // 引用 Microsoft.Extensions.Configuration.Binder 包 + Configuration.Bind(string.Join(":", sections), list); + return list; + } + } +} diff --git a/New_College.Common/Helper/Base32Helper.cs b/New_College.Common/Helper/Base32Helper.cs new file mode 100644 index 0000000..68e592b --- /dev/null +++ b/New_College.Common/Helper/Base32Helper.cs @@ -0,0 +1,101 @@ +using System; +using System.Text; + +namespace DPE.Core.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/New_College.Common/Helper/ClearHtmlHelper.cs b/New_College.Common/Helper/ClearHtmlHelper.cs new file mode 100644 index 0000000..194cbad --- /dev/null +++ b/New_College.Common/Helper/ClearHtmlHelper.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Common.Helper +{ + public static class ClearHtmlHelper + { + + public static string SHTML(string html) + { + if (!string.IsNullOrWhiteSpace(html)) + { + html = html.Trim(); + html = html.Replace(@"/]*?>(.*?)<\/script>/si", ""); + //html = html.Replace(@"/]*?>(.*?)<\/style>/si", ""); + html = html.Replace("\t", ""); + html = html.Replace("\r\n", ""); + html = html.Replace("\r", ""); + html = html.Replace("\n", ""); + html = html.Replace(" ", ""); + html = html.Replace(" ", ""); + } + + //html=html.Replace("",""); + return html; + } + } +} diff --git a/New_College.Common/Helper/CommonTools.cs b/New_College.Common/Helper/CommonTools.cs new file mode 100644 index 0000000..1e242c0 --- /dev/null +++ b/New_College.Common/Helper/CommonTools.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace New_College.Common.Helper +{ + /// + /// 常用的基础方法 + /// + public static class CommonTools + { + /// + /// 获取美剧类型的Description + /// + /// + /// + public static string GetDescription(this Enum value) + { + return value.GetType() + .GetMember(value.ToString()) + .FirstOrDefault()? + .GetCustomAttribute()? + .Description; + } + } +} diff --git a/New_College.Common/Helper/ConsoleHelper.cs b/New_College.Common/Helper/ConsoleHelper.cs new file mode 100644 index 0000000..dc831ab --- /dev/null +++ b/New_College.Common/Helper/ConsoleHelper.cs @@ -0,0 +1,54 @@ +using System; + +namespace New_College.Common.Helper +{ + public static class ConsoleHelper + { + 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/New_College.Common/Helper/DataHelper.cs b/New_College.Common/Helper/DataHelper.cs new file mode 100644 index 0000000..b477d97 --- /dev/null +++ b/New_College.Common/Helper/DataHelper.cs @@ -0,0 +1,154 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Common.Helper +{ + public static class DataHelper + { + public static void AddInfo() + { + + } + } + + public static class ShowPsychological + { + public static List Psyintellectags { get; set; } = new List() { + new Psyintellectag() { name = "人际关系智能", title = "人际关系智能(interpersonal intelligence)", content = "是指能够有效的理解别人和与人交往的能力,辨识与了解他人的感觉、信念与意向的能力,其核心成份包括了注意并区辨他人的心情、性情、动机与意向,并做出适当反应的能力。成功的教师、社会工作者、演员或政治家就是最好的例证。" }, + new Psyintellectag() { name = "自然环境智能", title = "自然环境智能(naturalist intelligence)", content = "是指对周遭环境的动物、植物、人工制品、及其它事物进行有效辨识及分类的能力。详而言之,自然观察智能不只包括了对动植物的辨识能力,也包括了从引擎声辨识汽车,在科学实验室中辨识新奇样式,以及艺术风格与生活模式的察觉等能力。学有专长的自然观察者包括农民、植物学家、猎人、生态学家和庭园设计师。" }, + new Psyintellectag() { name = "音乐智能", title = ">音乐智能(musical intelligence)", content = "是指人敏锐地感知音调、旋律、节奏和音色的能力,以及察觉、辨别、改变和表达音乐的能力,它允许人们能对声音的意义加以创造、沟通与理解,主要包括了对节奏、音调或旋律、音色的敏感性。具有这种智能的人包括作曲家、指挥家、乐师、音乐评论家、制造乐器者和善于领悟音乐的听众。" }, + new Psyintellectag() { name = "运动智能", title = "运动智能(bodily-kinesthetic intelligence)", content = "是指人能够巧妙地操纵物体和调整身体的技能,即运用身体来表达想法与感觉、以及运用双手生产或改造事物的能力,其核心成份包括了巧妙地处理(包括粗略与精致的身体动作)物体的能力,巧妙地使用不同的身体动作来运作或表达的能力,以及自身感受的、触觉的和由触觉引起的能力。运动员、舞蹈家、外科医生和手艺人都是这方面的例证。" }, + new Psyintellectag() { name = "空间视觉智能", title = "空间视觉智能(spatial intellignece)", content = "是指人对视觉性或空间性的讯息之知觉能力,以及把所知觉到的加以表现出来的能力。其核心成份包括了精确知觉物体或形状的能力,对知觉到的物体或形状进行操作或在心中进行空间旋转的能力,在脑中形成心像以及转换心像的能力,对图像艺术所感受的视觉与空间之张力、平衡与组成等关系的敏感性,如航海家、飞行员、雕塑家、画家和建筑师所表现的能力。" }, + new Psyintellectag() { name = "逻辑数学智能", title = "逻辑数学智能(logical-mathematical intelligence)", content = "是指人能够计算、量化、思考命题和假设,并进行复杂数学运算的能力,即运用数字和推理的能力,它涉及了对抽象关系的使用与了解,其核心成份包括了觉察逻辑或数字之样式(pattern)的能力,以及进行广泛的推理,或巧妙地处理抽象分析的能力。科学家、数学家、会计师、工程师和电脑程序设计师都显示出很强的逻辑-数学智能。" }, + new Psyintellectag() { name = "语言智能", title = "语言智能(linguistic intelligence)", content = "是指用语言表达和欣赏语言深层内涵的能力,即口语及书写文字的运用能力,它包括了对语言文字之意义(语意能力)、规则(语法能力),以及声音、节奏、音调、诗韵(音韵学能力)、不同功能(语言的实用能力)的敏感性。作家、诗人、记者、演说家、新闻播音员都显示出高度的语言智能。" }, + new Psyintellectag() { name = "自我内省智能", title = "自我内省智能(intarpersonal intelligence)", content = "是指能对自我进行省察、区辨自我的感觉、建构正确自我知觉、产生适当行动的能力,并善于用这种知识计划和引导自己的人生。此种智能也扮演着「智能中枢的角色」(central intelligences agency),使得个体能知道自己的能力,并了解如何有效发挥这些能力。其核心成份为发展可靠的自我运作模式,以了解自已之欲求、目标、焦虑与优缺点,并藉以引导自己的行为之能力。心理学家、哲学家就是拥有高度自我认识智能的典型代表。" } + }; + public static List Psysuggesttypes { get; set; } = new List() { + new Psysuggesttype (){ name="人际关系智能",suggest="强化建议:经常参加聚会,掌握倾听技巧,增强同理心"}, + new Psysuggesttype (){ name="自然环境智能",suggest="强化建议:尝试郊游或参观博物馆,尝试种植花草或抚养宠物"}, + new Psysuggesttype (){ name="音乐智能",suggest="强化建议:学习乐器,经常听音乐,尝试唱歌"}, + new Psysuggesttype (){ name="运动智能",suggest="强化建议:经常运动,尝试表演或舞蹈"}, + new Psysuggesttype (){ name="空间视觉智能",suggest="强化建议:学习绘画,经常装配物件(如玩具、积木等)"}, + new Psysuggesttype (){ name="逻辑数学智能",suggest="强化建议:学习心算,多玩一些推理游戏"}, + new Psysuggesttype (){ name="语言智能",suggest="强化建议:阅读文学作品,学讲故事,学习外语"}, + new Psysuggesttype (){ name="自我内省智能",suggest="强化建议:尝试写日记(以心得体会为主),制定自我发展计划,偶尔做一些白日梦"}, + }; + } + + public class Psyintellectag + { + public string name { get; set; } + + public string title { get; set; } + + public string content { get; set; } + } + + public class Psysuggesttype + { + public string name { get; set; } + + public string suggest { get; set; } + } + + + + public static class ShowMultiDimension + { + public static List showsuggesttaggests { get; set; } = new List() { + new Showsuggesttaggest (){ name="学习方法",suggest="建议:强化视觉感元,整合多种感元,以利于对学习信息的有效加工。(见学习类型)利用自己的强势心略,比方说书法好,可以誊写知识要点;如果英语好,可以象学外语一样学数学",score=6,truetaggest="结果:你不重视学习方法,需要更新学习方法,明确自己的学习类型",falsetaggest="你很重视学习方法,学习方法得当"}, + new Showsuggesttaggest (){name="信息处理",suggest="建议:强化知识的视觉影像,遵循记忆的遗忘规律,以利于对学习内容的记忆复习。牢记知识记忆的十二原则:重点、联系、视觉、注意、复述、动力、精力、兴趣、纲目、反馈、重组、时间",score=8,truetaggest="结果:你的信息处理能力不够强,需要掌握更多知识处理的技巧、知识记忆的方法以及培养良好的复习习惯",falsetaggest="你的信息处理能力强,较好地运用科学的记忆和复习方法" }, + new Showsuggesttaggest (){name="时间管理",suggest="建议:调整自己生物钟,保证学习时间处于兴奋状态。利用时间线技术,提高时间效率。制定学习时间表:主课遵循2:1的法则排定时间,尽量不跑“马拉松”,适当安排休闲时间。时间表必须留有弹性",score=7,truetaggest="结果:不会合理安排学习时间,学习计划性较差",falsetaggest="合理安排学习时间,珍惜学习时间" }, + new Showsuggesttaggest (){name="学习目标",suggest="建议:积极的心态:“你期望的效果是什么?”,“当你达到你期望的效果时,你是怎么知道的?”,“怎样才能达到你期望的效果?”,“谁能帮你?”“哪些资源可以利用?”合理缩放目标:目标事件过小,赋予较大意义,“如果你完成,将有什么积极意义?”;目标任务过大,分解任务,“什么阻止你实现?你想做什么?” ",score=7,truetaggest="结果:学习目标不明确,不擅长设定学习目标,没有掌握学习目标设定和管理的方法",falsetaggest="学习目标明确,善于设定自己学习目标,学习有较好的计划" }, + new Showsuggesttaggest (){name="注意力集中",suggest="建议:注意力集中步骤:物质环境准备、良好身心状态(积极放松,把思考交给潜意识)、积极学习(动用多感官)",score=7,truetaggest="结果:的学习时注意力不够集中,不善于调整自己学习的身心状态,没有掌握注意力集中的技巧",falsetaggest="学习时注意力集中,善于调整自己学习的身心状态" }, + new Showsuggesttaggest (){name="阅读技巧",suggest="建议:SQ4R阅读法:快速浏览多遍(Survey)、设问(Question)、阅读(Reading)、笔记(Record)、复述(Recite)、复习(Review)",score=6,truetaggest="结果:阅读教科书效果不佳,没有养成阅读教科书的良好习惯",falsetaggest="基本掌握教科书的阅读方法,很善于利用教科书学习" }, + new Showsuggesttaggest (){name="阅读标注技巧",suggest="",score=6,truetaggest="结果:不善于在教科书上作标注,不大会利用标注学习",falsetaggest="基本掌握教科书的标注方法,很善于利用教科书标注来学习" }, + new Showsuggesttaggest (){name="听讲笔记技巧",suggest="建议:学习书写听讲笔记(比如采用Cornell笔记法),掌握课堂积极放松法",score=6,truetaggest="结果:不擅长做听讲笔记,课堂效率低",falsetaggest="你的听讲笔记比较好,善于利用听讲笔记学习,课堂效率高" }, + new Showsuggesttaggest (){name="应试策略",suggest="建议:明确考试目标内容,制定复习计划,书写复习小结,(a)考前做一些有代表性的例题和习题,从这一些题目中回想重点,回想时若发现忘了重点,翻开笔记看一看那一部份重点就可。(b)将笔记上的重点(或整理出的重点)重复多次地看,虽然不耐烦了还要再看,过度50%",score=6,truetaggest="结果:不擅长复习,没有良好的应试策略",falsetaggest="善于复习,应试策略科学有效" }, + }; + } + + public class Showsuggesttaggest + { + public string name { get; set; } + + public string suggest { get; set; } + + public string truetaggest { get; set; } + public string falsetaggest { get; set; } + + /// + /// 分数点 小于最小 大于最大 + /// + public int score { get; set; } + } + /// + /// sas + /// + public static class ShowSelfofAnxiety + { + public static List anxietyInfos { get; set; } = new List() { + new SelfofAnxietyInfo (){ title="焦虑情况:焦虑程度异常(重度)",suggess="测试表明,被试存在重度的焦虑。被试常常会为某些事情感到非常紧张、担忧,会无缘无故地感到害怕或惊恐、认为将要发生什么不好的事情,有时会有要发疯的感觉。在焦虑的时候可能会出现许多与自主神经系统有关的不良症状,例如脸红、出汗、心跳加快等;精力可能非常差,身体的各项功能会受到重度的负面影响。被试的具体表现请参看对各个分量表的解释。建议被试要全面地看待焦虑,适度的焦虑会提高工作效率和操作水平,是具有一定的积极意义的。如果要降低焦虑,就要学会调节自己的情绪,可以进行一下放松训练,让心情和身体慢慢松弛下来;也可以做一些感兴趣的事情以转移注意力;还可以找朋友聊聊天,倾诉内心的烦恼。被试要提高自信,积极地面对生活,对于引起焦虑的问题不要逃避,而是要想办法努力解决,只有这样才能比较彻底地减轻焦虑。如果问题比较严重,自我调节没有什么效果,则建议被试做做心理咨询,接受专业的心理辅导。",score=1}, + new SelfofAnxietyInfo (){ title="焦虑情况:中度焦虑",suggess="测试表明,被试存在中度的焦虑。被试常常会为某些事情感到紧张、担忧,会无缘无故地感到害怕、认为将要发生什么不好的事情。在焦虑的时候可能会出现较多与自主神经系统有关的不良症状,例如脸红、出汗、心跳加快等;精力比较差,身体的各项功能会受到中度的负面影响。被试的具体表现请参看对各个分量表的解释。建议被试要全面地看待焦虑,适度的焦虑会提高工作效率和操作水平,是具有一定的积极意义的。如果要降低焦虑,就要学会调节自己的情绪,可以进行一下放松训练,让心情和身体慢慢松弛下来;也可以做一些感兴趣的事情以转移注意力;还可以找朋友聊聊天,倾诉内心的烦恼。被试要提高自信,积极地面对生活,对于引起焦虑的问题不要逃避,而是要想办法努力解决,只有这样才能比较彻底地减轻焦虑。",score=2}, + new SelfofAnxietyInfo (){ title="焦虑情况:轻度焦虑",suggess="测试表明,被试存在轻度的焦虑。被试有时会为某些事情感到紧张、担忧,有时会无缘无故地感到害怕、认为将要发生什么不好的事情。在焦虑的时候可能会出现一些与自主神经系统有关的不良症状,例如脸红、出汗、心跳加快等;精力会所有下降,身体的各项功能会受到轻度的负面影响。被试的具体表现请参看对各个分量表的解释。建议被试要全面地看待焦虑,适度的焦虑会提高工作效率和操作水平,是具有一定的积极意义的。如果要降低焦虑,就要学会调节自己的情绪,可以进行一下放松训练,让心情和身体慢慢松弛下来;也可以做一些感兴趣的事情以转移注意力;还可以找朋友聊聊天,倾诉内心的感受。",score=3}, + new SelfofAnxietyInfo (){ title="焦虑情况:不存在焦虑",suggess="测试表明,被试不存在焦虑。被试没有或很少为某些事情感到紧张、担忧,对未来比较乐观,不会无缘无故地感到害怕、认为将要发生什么不好的事情。由于被试心情比较平静、放松,所以也很少出现与焦虑有关的自主神经系统的不良症状,例如脸红、出汗、心跳加快等,精力比较充沛,身体的各项功能比较正常。希望被试继续保持这种良好的状态。",score=4}, + + }; + } + + public class SelfofAnxietyInfo + { + public string title { get; set; } + + public string suggess { get; set; } + + public int score { get; set; } + } + + /// + /// mht + /// + public static class ShowMentalHealth + { + public static List mentalHealthInfos { get; set; } = new List() { + new MentalHealthInfo (){ title="学习焦虑",maxsuggest="可能对考试怀有恐惧心理,无法安心学习,十分关心考试分数。",minsuggest="可能学习焦虑低,学习不会受到困扰,能正确对待考试成绩。"}, + new MentalHealthInfo (){ title="对人焦虑",maxsuggest="可能过分注重自己的形象,害怕与人交往,退缩。",minsuggest="可能热情,大方,容易结交朋友。"}, + new MentalHealthInfo (){ title="孤独倾向",maxsuggest="可能孤独.抑郁,不善于与人交往,自我封闭。",minsuggest="可能爱好社交,喜欢寻求刺激,喜欢与他人在一起。"}, + new MentalHealthInfo (){ title="自责倾向",maxsuggest="可能自卑,常怀疑自己的能力,常将失败.过失归咎于自己。",minsuggest="可能自信,能正确看待失败。"}, + new MentalHealthInfo (){ title="过敏倾向",maxsuggest="可能过于敏感,容易为一些小事而烦恼。",minsuggest="可能敏感性较低,能较好地处理日常事物。"}, + new MentalHealthInfo (){ title="身体症状",maxsuggest="可能在极度焦虑的时候,会出现呕吐失眠、小便失禁等明显症状。",minsuggest="可能基本没有身体异常表现。"}, + new MentalHealthInfo (){ title="恐怖倾向",maxsuggest="可能对某些日常事物,如黑暗等,有较严重的恐怖感。",minsuggest="可能基本没有恐怖感。"}, + new MentalHealthInfo (){ title="冲动倾向",maxsuggest="可能十分冲动,自制力较差。",minsuggest="可能基本没有冲动。"}, + }; + } + + public class MentalHealthInfo + { + public string title { get; set; } + public string maxsuggest { get; set; } + public string minsuggest { get; set; } + } + + public class ShowSelfofDepression + { + public static List selfofDepressionInfos { get; set; } = new List() + { + new SelfofDepressionInfo (){title="抑郁程度:正常(没有抑郁、轻度抑郁)",result="抑郁症是一种常见的心理状态,主要表现为悲观、绝望、烦躁,饮食习惯改变,失眠,兴趣减少或注意力分散,有自杀念头,对履行社会职责有抵触感,极度疲劳感,反应迟钝或敏感等。被试情绪正常,没有抑郁。被试心情很好,情绪稳定,大脑和身体的各项功能也很正常,精力很充沛,生活充实,对未来充满了希望。希望被试继续保持这种好状态。",score=1}, + new SelfofDepressionInfo (){title="抑郁程度:轻度抑郁",result="抑郁症是一种常见的心理状态,主要表现为悲观、绝望、烦躁,饮食习惯改变,失眠,兴趣减少或注意力分散,有自杀念头,对履行社会职责有抵触感,极度疲劳感,反应迟钝或敏感等。对于每个人来说,存在抑郁心理是很普遍的事情,关键在于我们怎样去调节自己。被试有轻微或轻度抑郁。最近一周里,被试有时会感到情绪低落,夜里睡不好,身体不太舒服,或觉得自己没用,生活没有意义。但是大部分时间心情很好,精力比较充沛,大脑和身体的各项功能也比较正常,觉得自己有用,生活有意义。建议被试多找知心朋友、亲人倾诉不愉快的事;扩大人际交往,多交朋友,多和精力充沛、充满活力的人相处;加强身体锻炼,多沐浴阳光;多吃维生素B含量丰富的食物,像粗粮、鱼等。",score=2}, + new SelfofDepressionInfo (){title="抑郁程度:中度抑郁",result="抑郁症是一种常见的心理状态,主要表现为悲观、绝望、烦躁,饮食习惯改变,失眠,兴趣减少或注意力分散,有自杀念头,对履行社会职责有抵触感,极度疲劳感,反应迟钝或敏感等。对于每个人来说,存在抑郁心理是很普遍的事情,关键在于我们怎样去调节自己。被试有中度或重度抑郁。最近一周内,被试经常感到情绪沮丧郁闷,心情比较差,或者夜里睡不好,身体功能有些不正常,容易无故疲劳,头脑不清楚,做事不像以前那么顺利,经常怀疑自己的价值和生活的意义,对未来感到悲观失望,或想到死。建议被试客观地评价自己和他人;积极面对生活中遇到的挫折和困难,看到事情的光明面;多跟亲朋好友聊天、倾诉;出去逛街或旅游,给自己换个环境;加强身体锻炼,多沐浴阳光;多吃维生素B含量丰富的食物,像粗粮、鱼等。如果抑郁症状仍不能缓解,可找心理咨询师或者精神科医生咨询一下,让专业人士提供解决办法。",suggess="

心理建议:
    (1)千万不要给自己制订一些难以达到的目标,正确认识自己的现状,正视自己的实际情况;不要再担任一大堆职务;不要对很多事情大包大揽。

    (2)可以将一件大的繁杂的任务分成若干小部分,根据事情轻重缓急,做些力所能及的事;切莫“逞能”,以免完不成任务而心灰意冷。

    (3)尝试多与人们接触和交住,不要自己独来独往。

    (4)尽量参加一些活动,尝试着做一些轻微的体育锻炼,看看电影、电视或听听音乐等。可以参加不同形式和内容的社会活动,如讲演、参观、访问等,但不要太多。

    (5)不要急躁,对自己的状况不要着急,和心理辅导中心联系,他们肯定能帮助你的。

    (6)不妨把自己的感受写出来,然后分析、认识它,哪些是消极的,属于抑郁症的表现,然后想办法摆脱它。

",score=3}, + new SelfofDepressionInfo (){title="抑郁程度:抑郁程度异常(中度或重度)",result="抑郁症是一种常见的心理状态,主要表现为悲观、绝望、烦躁,饮食习惯改变,失眠,兴趣减少或注意力分散,有自杀念头,对履行社会职责有抵触感,极度疲劳感,反应迟钝或敏感等。对于每个人来说,存在抑郁心理是很普遍的事情,关键在于我们怎样去调节自己。被试有中度或重度抑郁。最近一周内,被试经常感到情绪沮丧郁闷,心情比较差,或者夜里睡不好,身体功能有些不正常,容易无故疲劳,头脑不清楚,做事不像以前那么顺利,经常怀疑自己的价值和生活的意义,对未来感到悲观失望,或想到死。建议被试客观地评价自己和他人;积极面对生活中遇到的挫折和困难,看到事情的光明面;多跟亲朋好友聊天、倾诉;出去逛街或旅游,给自己换个环境;加强身体锻炼,多沐浴阳光;多吃维生素B含量丰富的食物,像粗粮、鱼等。如果抑郁症状仍不能缓解,可找心理咨询师或者精神科医生咨询一下,让专业人士提供解决办法。",suggess="

心理建议:
    (1)千万不要给自己制订一些难以达到的目标,正确认识自己的现状,正视自己的实际情况;不要再担任一大堆职务;不要对很多事情大包大揽。

    (2)可以将一件大的繁杂的任务分成若干小部分,根据事情轻重缓急,做些力所能及的事;切莫“逞能”,以免完不成任务而心灰意冷。

    (3)尝试多与人们接触和交住,不要自己独来独往。

    (4)尽量参加一些活动,尝试着做一些轻微的体育锻炼,看看电影、电视或听听音乐等。可以参加不同形式和内容的社会活动,如讲演、参观、访问等,但不要太多。

    (5)不要急躁,对自己的状况不要着急,和心理辅导中心联系,他们肯定能帮助你的。

    (6)不妨把自己的感受写出来,然后分析、认识它,哪些是消极的,属于抑郁症的表现,然后想办法摆脱它。

",score=4}, + }; + } + + public class SelfofDepressionInfo + { + public string title { get; set; } + + public string result { get; set; } + + public string suggess { get; set; } + + public int score { get; set; } + } +} diff --git a/New_College.Common/Helper/DateHelper.cs b/New_College.Common/Helper/DateHelper.cs new file mode 100644 index 0000000..6e2ec10 --- /dev/null +++ b/New_College.Common/Helper/DateHelper.cs @@ -0,0 +1,22 @@ +using System; + +namespace New_College.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} 分 "; + } + } +} diff --git a/New_College.Common/Helper/FileHelper.cs b/New_College.Common/Helper/FileHelper.cs new file mode 100644 index 0000000..0709b3c --- /dev/null +++ b/New_College.Common/Helper/FileHelper.cs @@ -0,0 +1,377 @@ +using System; +using System.IO; +using System.Linq; +using System.Text; + +namespace New_College.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).ToList(); + + if (selectFiles.Count > 0) + { + return selectFiles.FirstOrDefault().FullName; + } + + return Path.Combine(folderPath, $@"{prefix}_{DateTime.Now.DateToTimeStamp()}.log"); + } + #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/New_College.Common/Helper/GenerateCardNumberHelper.cs b/New_College.Common/Helper/GenerateCardNumberHelper.cs new file mode 100644 index 0000000..7f0d558 --- /dev/null +++ b/New_College.Common/Helper/GenerateCardNumberHelper.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace New_College.Common +{ + public static class GenerateCardNumberHelper + { + public static string GenerateCardNumber(string bin, int length) + { + Random r = new Random() { }; + int[] digits = new int[length]; + var prefixDigits = bin.Select(p => p - '0').ToArray(); + for (var i = 0; i < prefixDigits.Length; i++) + { + digits[i] = prefixDigits[i]; + } + for (var i = bin.Length; i < length - 1; i++) + { + var digit = r.Next(0, 10); + digits[i] = digit; + } + digits[length - 1] = GenerateCheckDigit(digits[..(length - 1)]); + return string.Join(null, digits); + } + + public static bool IsLuhnValid(int[] digits) + { + var sum = CalculateSum(digits, 1); + return sum % 10 == 0; + } + + private static int CalculateSum(int[] digits, int bitShift = 0) + { + var sum = digits.Reverse() + .Select((digit, i) => + (i + bitShift) % 2 == 0 + ? digit * 2 > 9 ? digit * 2 - 9 : digit * 2 + : digit) + .Sum(); + return sum; + } + + public static int GenerateCheckDigit(int[] digits) + { + var sum = CalculateSum(digits); + var lastDigit = sum * 9 % 10; + return lastDigit; + } + } + +} diff --git a/New_College.Common/Helper/GenerateChineseWords.cs b/New_College.Common/Helper/GenerateChineseWords.cs new file mode 100644 index 0000000..5578a3c --- /dev/null +++ b/New_College.Common/Helper/GenerateChineseWords.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Common.Helper +{ + public static class GenerateChineseWords + { + /// + /// 随机产生常用汉字 + /// + /// 要产生汉字的个数 + /// 常用汉字 + public static string GenerateChineseWord(int count) + { + string chineseWords = ""; + System.Random rm = new System.Random(); + Encoding gb = Encoding.GetEncoding("gb2312"); + + for (int i = 0; i < count; i++) + { + // 获取区码(常用汉字的区码范围为16-55) + int regionCode = rm.Next(16, 56); + + // 获取位码(位码范围为1-94 由于55区的90,91,92,93,94为空,故将其排除) + int positionCode; + if (regionCode == 55) + { + // 55区排除90,91,92,93,94 + positionCode = rm.Next(1, 90); + } + else + { + positionCode = rm.Next(1, 95); + } + + // 转换区位码为机内码 + int regionCode_Machine = regionCode + 160;// 160即为十六进制的20H+80H=A0H + int positionCode_Machine = positionCode + 160;// 160即为十六进制的20H+80H=A0H + + // 转换为汉字 + byte[] bytes = new byte[] { (byte)regionCode_Machine, (byte)positionCode_Machine }; + chineseWords += gb.GetString(bytes); + } + return chineseWords; + } + } +} diff --git a/New_College.Common/Helper/GetNetData.cs b/New_College.Common/Helper/GetNetData.cs new file mode 100644 index 0000000..71c731b --- /dev/null +++ b/New_College.Common/Helper/GetNetData.cs @@ -0,0 +1,57 @@ +using System.IO; +using System.Net; +using System.Text; + +namespace New_College.Common.Helper +{ + public class GetNetData + { + public static string Get(string serviceAddress) + { + + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress); + 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.UTF8); + string retString = myStreamReader.ReadToEnd(); + myStreamReader.Close(); + myResponseStream.Close(); + + return retString; + } + + public static string Post(string serviceAddress) + { + + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress); + + request.Method = "POST"; + request.ContentType = "application/json"; + string strContent = @"{ ""mmmm"": ""89e"",""nnnnnn"": ""0101943"",""kkkkkkk"": ""e8sodijf9""}"; + using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream())) + { + dataStream.Write(strContent); + dataStream.Close(); + } + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + string encoding = response.ContentEncoding; + if (encoding == null || encoding.Length < 1) + { + encoding = "UTF-8"; //默认编码 + } + StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding)); + string retString = reader.ReadToEnd(); + + return retString; + + //解析josn + //JObject jo = JObject.Parse(retString); + //Response.Write(jo["message"]["mmmm"].ToString()); + + } + } + + +} diff --git a/New_College.Common/Helper/HtmlHelper.cs b/New_College.Common/Helper/HtmlHelper.cs new file mode 100644 index 0000000..5d02c33 --- /dev/null +++ b/New_College.Common/Helper/HtmlHelper.cs @@ -0,0 +1,24 @@ +namespace New_College.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/New_College.Common/Helper/JsonHelper.cs b/New_College.Common/Helper/JsonHelper.cs new file mode 100644 index 0000000..d35b566 --- /dev/null +++ b/New_College.Common/Helper/JsonHelper.cs @@ -0,0 +1,155 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Serialization; +using System; +using System.Collections.Generic; + +namespace New_College.Common.Helper +{ + public class JsonHelper + { + /// + /// Json 序列化配置 + /// + public static readonly JsonSerializerSettings JsonSerializerSettings = new JsonSerializerSettings + { + Converters = new List() + { + new IsoDateTimeConverter{ DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss" } + }, + NullValueHandling = NullValueHandling.Include, + ContractResolver = new CamelCasePropertyNamesContractResolver(), + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + PreserveReferencesHandling = PreserveReferencesHandling.None, + }; + + /// + /// 转换对象为json格式字符串 + /// + /// + /// 加载设置 + /// + public static string ToJson(object obj, bool loadSetting = true) + { + return loadSetting + // 设置参数为Formatting.Indented可输出格式化后的json + ? JsonConvert.SerializeObject(obj, Formatting.None, JsonSerializerSettings) + : JsonConvert.SerializeObject(obj, Formatting.None); + } + /// + /// 转换json格式字符串为指定类型对象 + /// + /// + /// + /// + public static T ParseJson(string json) + { + try + { + return JsonConvert.DeserializeObject(json); + } + catch (Exception ex) + { + return default(T); + } + } + + + + /// + /// 转换对象为JSON格式数据 + /// + /// + /// 对象 + /// 字符格式的JSON数据 + public static string GetJSON(object obj) + { + string result = String.Empty; + try + { + 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 ex) + { + throw ex; + } + 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 ex) + { + throw ex; + } + + 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 ex) + { + throw ex; + } + + return st.ToString(); + } + } +} diff --git a/New_College.Common/Helper/MD5Hepler.cs b/New_College.Common/Helper/MD5Hepler.cs new file mode 100644 index 0000000..cd68105 --- /dev/null +++ b/New_College.Common/Helper/MD5Hepler.cs @@ -0,0 +1,67 @@ +using System; +using System.Security.Cryptography; +using System.Text; + +namespace New_College.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/New_College.Common/Helper/ObjectExtension.cs b/New_College.Common/Helper/ObjectExtension.cs new file mode 100644 index 0000000..0d12328 --- /dev/null +++ b/New_College.Common/Helper/ObjectExtension.cs @@ -0,0 +1,862 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using System.Xml.Linq; + +namespace New_College.Common.Helper +{ + public static class ObjectExtension + { + /// + /// 转成友好字符串 + /// + /// 当前时间 + /// 友好的时间展示 + public static string ToFriendlyString(this DateTime current) + { + var now = DateTime.Now; + var ts = now - current; + if (ts.Days >= 365) + return (ts.Days / 365) + "年前"; + else if (ts.Days >= 30) + return (ts.Days / 30) + "个月前"; + else if (ts.Days > 0) + return ts.Days + "天前"; + else if (ts.Hours > 0) + return ts.Hours + "小时前"; + else if (ts.Minutes > 0) + return ts.Minutes + "分钟前"; + else + return "刚刚"; + } + + /// + /// 当年之初 + /// + /// + /// + public static DateTime Year(this DateTime current) + { + return new DateTime(current.Year, 1, 1); + } + + /// + /// 当月之初 + /// + /// + /// + public static DateTime Month(this DateTime current) + { + return new DateTime(current.Year, current.Month, 1); + } + + /// + /// 将对象转换为指定格式的字符串 + /// + /// + /// + public static string ToJson(this Object obj) + { + return JsonHelper.ToJson(obj); + } + + /// + /// 将手机号转换为打码格式*******5006格式 + /// + /// 手机号 + /// + public static string ToMaskPhone(this string str) + { + #region 打码格式152******** + //var phone = str + ""; + //if (phone.Length > 3) + //{ + // var starts = phone.Substring(0, 3); + // var ends = string.Empty; + // for (var i = 0; i < phone.Length - 3; i++) + // ends += "*"; + // return starts + ends; + //} + //return phone; + #endregion + + //打码格式*******5006 + var phone = str + ""; + var phoneLength = phone.Length; + if (phoneLength > 4) + { + var ends = phone.Substring(phoneLength - 4); + var starts = string.Empty; + for (var i = 0; i < phoneLength - 4; i++) + starts += "*"; + return starts + ends; + } + return phone; + } + + /// + /// 将银行号转换为打码格式6224********5006格式 + /// + /// 卡号 + /// + public static string ToMaskBankCardNo(this string str) + { + var bankCardNo = str + ""; + var bankCardNoLength = bankCardNo.Length; + if (bankCardNoLength > 8) + { + var starts = bankCardNo.Substring(0, 4); + var num = bankCardNo.Substring(4, bankCardNoLength - 4).Length; + var ends = bankCardNo.Substring(num, 4); + var middle = string.Empty; + for (var i = 0; i < num - 4; i++) + middle += "*"; + return starts + middle + ends; + } + return bankCardNo; + } + + /// + /// 去除html标签 + /// + /// 当前字符串 + /// 去除html的字符串 + public static string ClearHtml(this string str) + { + return Regex.Replace(str ?? "", @"<[^>]*>", String.Empty); + } + + /// + /// 截取字符串 + /// + /// 当前字符串 + /// + /// 符号 + /// + public static string Cut(this string str, int len, string symbol = "..") + { + if (str != null) + { + if (str.Length <= len) + return str; + else + return str.Substring(0, len) + symbol; + } + return string.Empty; + } + + /// + /// 将对象属性转换为key-value对 + /// + /// + /// + public static Dictionary ToMap(this Object o) + { + var map = new Dictionary(); + try + { + var t = o.GetType(); + var pi = t.GetProperties(BindingFlags.Public | BindingFlags.Instance); + + foreach (PropertyInfo p in pi) + { + MethodInfo mi = p.GetGetMethod(); + if (mi != null && mi.IsPublic) + { + map.Add(p.Name, mi.Invoke(o, new Object[] { })); + } + } + } + catch + { } + return map; + } + + /// + /// 将对象转换为指定格式的字符串 + /// + /// + /// + public static string ToFormatString(this Object obj) + { + //定义一个List集合,将各个实体类型存起来 + var models = obj.GetType(); + //得到公共属性集合 + var productFields = models.GetProperties(); + + StringBuilder str = new StringBuilder(); + + //得到属性上的标记属性信息即列名 + foreach (PropertyInfo pi in productFields) + { + if (pi.GetValue(obj, null) != null) + { + DescriptionAttribute desc = (DescriptionAttribute)Attribute.GetCustomAttribute(pi, typeof(Attribute)); + if (desc != null) + { + str.AppendFormat("|{0}:{1}", desc.Description ?? string.Empty, pi.GetValue(obj, null)); + } + } + } + //移除第一个竖杠 + if (str.Length > 0) + { str.Remove(0, 1); } + return str.ToString(); + } + + /// + /// 转换为short,默认值:short.MinValue + /// + /// + /// + public static short TryShort(this string strText) + { + return TryShort(strText, short.MinValue); + } + + /// + /// 转换为short + /// + /// + /// + /// + public static short TryShort(this string strText, short defValue) + { + return short.TryParse(strText + "", out short result) ? result : defValue; + } + + /// + /// 转换为short + /// + /// + /// + /// + public static short? TryShort(this string strText, short? defValue) + { + return short.TryParse(strText + "", out short result) ? result : defValue; + } + + /// + /// 转换为Int,默认值:int.MinValue + /// + public static int TryInt(this string strText) + { + return TryInt(strText, int.MinValue); + } + + /// + /// 转换为Int + /// + /// + /// 默认值 + /// + public static int TryInt(this string strText, int defValue) + { + return int.TryParse(strText + "", out int temp) ? temp : defValue; + } + + /// + /// 转换为Int + /// + /// + /// 默认值 + /// + public static int? TryInt(this string strText, int? defValue) + { + return int.TryParse(strText + "", out int temp) ? temp : defValue; + } + + /// + /// 转换为Double,默认值:double.MinValue + /// + public static double TryDouble(this string strText) + { + return TryDouble(strText, double.MinValue); + } + + /// + /// 转换为Double + /// + /// + /// 默认值 + /// + public static double TryDouble(this string strText, double defValue) + { + return double.TryParse(strText + "", out double temp) ? temp : defValue; + } + + /// + /// 转换为Double + /// + /// + /// 默认值 + /// + public static double? TryDouble(this string strText, double? defValue) + { + return double.TryParse(strText + "", out double temp) ? temp : defValue; + } + + /// + /// 转换为Decimal,默认值:decimal.MinValue + /// + public static decimal TryDecimal(this string strText) + { + return TryDecimal(strText, decimal.MinValue); + } + + /// + /// 转换为Decimal + /// + /// + /// 默认值 + /// + public static decimal TryDecimal(this string strText, decimal defValue) + { + return decimal.TryParse(strText + "", out decimal temp) ? temp : defValue; + } + + /// + /// 转换为Decimal + /// + /// + /// 默认值 + /// + public static decimal? TryDecimal(this string strText, decimal? defValue) + { + return decimal.TryParse(strText + "", out decimal temp) ? temp : defValue; + } + + /// + /// 转换为long,默认值:long.MinValue + /// + public static long TryLong(this string strText) + { + return TryLong(strText, long.MinValue); + } + + /// + /// 转换为long + /// + /// + /// 默认值 + /// + public static long TryLong(this string strText, long defValue) + { + return long.TryParse(strText + "", out long temp) ? temp : defValue; + } + + /// + /// 转换为long + /// + /// + /// 默认值 + /// + public static long? TryLong(this string strText, long? defValue) + { + return long.TryParse(strText + "", out long temp) ? temp : defValue; + } + + /// + /// 转换为Boolean,默认值:false + /// + public static Boolean TryBool(this string strText) + { + return TryBool(strText, false); + } + + /// + /// 转换为Boolean + /// + /// + /// 默认值 + /// + public static Boolean TryBool(this string strText, bool defValue) + { + if (strText.TryInt(0) == 1 || strText.TryString().ToUpper() == "TRUE") + return true; + return bool.TryParse(strText + "", out bool temp) ? temp : defValue; + } + + /// + /// 转换为Boolean + /// + /// + /// 默认值 + /// + public static Boolean? TryBool(this string strText, bool? defValue) + { + var i = strText.TryInt(null); + if (i.HasValue) + return i == 1; + return bool.TryParse(strText + "", out bool temp) ? temp : defValue; + } + + /// + /// 转换为DateTime,默认值:DateTimeExtension.DBNull + /// + public static DateTime TryDateTime(this string strText) + { + return TryDateTime(strText, new DateTime(1970, 1, 1)); + } + + /// + /// 转换为DateTime + /// + /// + /// 默认值 + /// + public static DateTime TryDateTime(this string strText, DateTime defValue) + { + //yyyy-MM-dd HH:mm + //yyyy-M-d HH:mm + //\d{4}\-\d{1,2}\-\d{1,2}( \d{1,2}:\d{2})? + var timeText = strText.ToString().Trim(); + Regex re = new Regex(@"^\d{4}\-\d{1,2}\-\d{1,2}[ \+]\d{1,2}:\d{2}?$"); + if (re.IsMatch(timeText)) + { + timeText = string.Format("{0}:00", timeText).Replace("+", " "); + } + + if (DateTime.TryParse(timeText, out var temp)) + return temp; + return defValue; + } + + /// + /// 转换为DateTime + /// + /// + /// 默认值 + /// + public static DateTime? TryDateTime(this string strText, DateTime? defValue) + { + return DateTime.TryParse(strText + "", out var temp) ? temp : defValue; + } + + /// + /// 将对象转换为指定格式的字符串 + /// + /// + /// + public static string ToString(this Object obj) + { + //定义一个List集合,将各个实体类型存起来 + var models = obj.GetType(); + //得到公共属性集合 + var productFields = models.GetProperties(); + + StringBuilder str = new StringBuilder(); + + //得到属性上的标记属性信息即列名 + foreach (PropertyInfo pi in productFields) + { + if (pi.GetValue(obj, null) != null) + { + DescriptionAttribute desc = (DescriptionAttribute)Attribute.GetCustomAttribute(pi, typeof(Attribute)); + if (desc != null) + { + str.AppendFormat("|{0}:{1}", desc.Description ?? string.Empty, pi.GetValue(obj, null)); + } + } + } + //移除第一个竖杠 + if (str.Length > 0) + { str.Remove(0, 1); } + return str.ToString(); + } + + /// + /// 转换为short,默认值:short.MinValue + /// + /// + /// + public static short TryShort(this Object strText) + { + return TryShort(strText, short.MinValue); + } + + /// + /// 转换为short + /// + /// + /// + /// + public static short TryShort(this Object strText, short defValue) + { + short result; + return short.TryParse(strText + "", out result) ? result : defValue; + } + + /// + /// 转换为short + /// + /// + /// + /// + public static short? TryShort(this Object strText, short? defValue) + { + short result; + return short.TryParse(strText + "", out result) ? result : defValue; + } + + /// + /// 转换为Int,默认值:int.MinValue + /// + public static int TryInt(this Object strText) + { + return TryInt(strText, int.MinValue); + } + + /// + /// 转换为Int + /// + /// + /// 默认值 + /// + public static int TryInt(this Object strText, int defValue) + { + int temp; + return int.TryParse(strText + "", out temp) ? temp : defValue; + } + + /// + /// 转换为Int + /// + /// + /// 默认值 + /// + public static int? TryInt(this Object strText, int? defValue) + { + int temp; + return int.TryParse(strText + "", out temp) ? temp : defValue; + } + + /// + /// 转换为Double,默认值:double.MinValue + /// + public static double TryDouble(this Object strText) + { + return TryDouble(strText, double.MinValue); + } + + /// + /// 转换为Double + /// + /// + /// 默认值 + /// + public static double TryDouble(this Object strText, double defValue) + { + double temp; + return double.TryParse(strText + "", out temp) ? temp : defValue; + } + + /// + /// 转换为Double + /// + /// + /// 默认值 + /// + public static double? TryDouble(this Object strText, double? defValue) + { + double temp; + return double.TryParse(strText + "", out temp) ? temp : defValue; + } + + /// + /// 转换为Decimal,默认值:decimal.MinValue + /// + public static decimal TryDecimal(this Object strText) + { + return TryDecimal(strText, decimal.MinValue); + } + + /// + /// 转换为Decimal + /// + /// + /// 默认值 + /// + public static decimal TryDecimal(this Object strText, decimal defValue) + { + decimal temp; + return decimal.TryParse(strText + "", out temp) ? temp : defValue; + } + + /// + /// 转换为Decimal + /// + /// + /// 默认值 + /// + public static decimal? TryDecimal(this Object strText, decimal? defValue) + { + decimal temp; + return decimal.TryParse(strText + "", out temp) ? temp : defValue; + } + + /// + /// 转换为long,默认值:long.MinValue + /// + public static long TryLong(this Object strText) + { + return TryLong(strText, long.MinValue); + } + + /// + /// 转换为long + /// + /// + /// 默认值 + /// + public static long TryLong(this Object strText, long defValue) + { + long temp; + return long.TryParse(strText + "", out temp) ? temp : defValue; + } + + /// + /// 转换为long + /// + /// + /// 默认值 + /// + public static long? TryLong(this Object strText, long? defValue) + { + long temp; + return long.TryParse(strText + "", out temp) ? temp : defValue; + } + + /// + /// 转换为Boolean,默认值:false + /// + public static Boolean TryBool(this Object strText) + { + return TryBool(strText, false); + } + + /// + /// 转换为Boolean + /// + /// + /// 默认值 + /// + public static Boolean TryBool(this Object strText, bool defValue) + { + if (strText.TryInt(0) == 1) + return true; + bool temp; + return bool.TryParse(strText + "", out temp) ? temp : defValue; + } + + /// + /// 转换为Boolean + /// + /// + /// 默认值 + /// + public static Boolean? TryBool(this Object strText, bool? defValue) + { + var i = strText.TryInt(null); + if (i.HasValue) + return i == 1; + bool temp; + return bool.TryParse(strText + "", out temp) ? temp : defValue; + } + + /// + /// 转换为DateTime,默认值:DateTimeExtension.DBNull + /// + public static DateTime TryDateTime(this Object strText) + { + return TryDateTime(strText, new DateTime(1970, 1, 1)); + } + + /// + /// 转换为DateTime + /// + /// + /// 默认值 + /// + public static DateTime TryDateTime(this Object strText, DateTime defValue) + { + //yyyy-MM-dd HH:mm + //yyyy-M-d HH:mm + //\d{4}\-\d{1,2}\-\d{1,2}( \d{1,2}:\d{2})? + var timeText = strText.ToString().Trim(); + Regex re = new Regex(@"^\d{4}\-\d{1,2}\-\d{1,2}[ \+]\d{1,2}:\d{2}?$"); + if (re.IsMatch(timeText)) + { + timeText = string.Format("{0}:00", timeText).Replace("+", " "); + } + DateTime temp; + if (DateTime.TryParse(timeText, out temp)) + return temp; + return defValue; + } + + /// + /// 转换为DateTime + /// + /// + /// 默认值 + /// + public static DateTime? TryDateTime(this Object strText, DateTime? defValue) + { + DateTime temp; + return DateTime.TryParse(strText + "", out temp) ? temp : defValue; + } + + /// + /// 为NULL 和 DBNull的返回String.Empty + /// + /// + /// + public static string TryString(this Object str) + { + return TryString(str, ""); + } + + /// + /// 转换为"" + /// + /// + /// + /// + public static string TryString(this Object str, string defvalue = "") + { + return str?.ToString() ?? defvalue; + } + + /// + /// 转化字符串编码 + /// + /// 字符串 + /// 源编码名称 + /// 目标编码名称 + /// + //public static string Encode(this string str, string srcEncodeName, string dstEncodeName) + //{ + // Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + // var srcEncoding = Encoding.GetEncoding(srcEncodeName); + // var dstEncoding = Encoding.GetEncoding(dstEncodeName); + // byte[] srcBytes = srcEncoding.GetBytes(str); + // byte[] bytes = Encoding.Convert(srcEncoding, dstEncoding, srcBytes); + // return dstEncoding.GetString(bytes); + //} + + /// + /// 转换十六进制 + /// + /// + /// + public static string ConvertX8(this int i) + { + return Convert.ToString(i, 16); + } + + /// + /// Pascal 命名方法的字符串 + /// + /// 字符串 + /// + public static string ToPascal(this string str) + { + if (string.IsNullOrEmpty(str)) + { + return ""; + } + else + { + return str.Substring(0, 1).ToUpper() + + str.Substring(1, str.Length - 1); + } + } + + /// + /// Camel 命名方法的字符串 + /// + /// 字符串 + /// + public static string ToCamel(this string str) + { + if (string.IsNullOrEmpty(str)) + { + return ""; + } + else + { + return str.Substring(0, 1).ToLower() + + str.Substring(1, str.Length - 1); + } + } + + /// + /// 当前索引 + /// + /// 数组 + /// 对象 + /// 返回当前索引 + public static int IndexOf(this string[] arr, string obj) + { + var index = -1; + for (int i = 0; i < arr.Length; i++) + { + if (arr[i] == obj) + { + index = -1; + } + } + return index; + } + + /// + /// 获取异常的根异常 + /// + /// + /// + public static Exception GetRootException(this Exception ex) + { + if (ex == null) + return null; + if (ex.InnerException == null) + return ex; + else + { + return GetRootException(ex.InnerException); + } + } + + /// + /// 把转换成字节 + /// + /// + /// + public static byte[] ToBytes(this Stream stream) + { + var bytes = new byte[stream.Length]; + stream.Read(bytes, 0, bytes.Length); + // 设置当前流的位置为流的开始 + stream.Seek(0, SeekOrigin.Begin); + return bytes; + } + + public static XDocument ToXDocument(this XmlDocument document) + { + return document.ToXDocument(LoadOptions.None); + } + + public static XDocument ToXDocument(this XmlDocument document, LoadOptions options) + { + using (XmlNodeReader reader = new XmlNodeReader(document)) + { + return XDocument.Load(reader, options); + } + } + } +} diff --git a/New_College.Common/Helper/OrderGenerateHelper.cs b/New_College.Common/Helper/OrderGenerateHelper.cs new file mode 100644 index 0000000..07bd9a6 --- /dev/null +++ b/New_College.Common/Helper/OrderGenerateHelper.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Common +{ + /** + * 根据当前系统时间加随机序列来生成订单号 + * @return 订单号 + */ + public static class OrderGenerateHelper + { + /// + /// 生成订单号 + /// + /// + /// + public static string GenerateOrderNo(string RT) + { + Random ran = new Random(); + return string.Format("{0}{1}{2}", RT, DateTime.Now.ToString("yyyyMMddHHmmss"), ran.Next(999)); + } + } +} diff --git a/New_College.Common/Helper/RadomHelper.cs b/New_College.Common/Helper/RadomHelper.cs new file mode 100644 index 0000000..46b2205 --- /dev/null +++ b/New_College.Common/Helper/RadomHelper.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Common +{ + public class RadomHelper + { + + + #region 数字随机数 + /// + /// 数字随机数 + /// + /// 生成长度 + /// + public static string RandNum(int n) + { + char[] arrChar = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; + StringBuilder num = new StringBuilder(); + + Random rnd = new Random(DateTime.Now.Millisecond); + + for (int i = 0; i < n; i++) + { + num.Append(arrChar[rnd.Next(0, 9)].ToString()); + + } + + return num.ToString(); + } + + /// + /// 数字随机数 + /// + /// 生成长度 + /// + public static string RandNumdayu0(int n) + { + char[] arrChar = new char[] { '6', '7', '8' }; + StringBuilder num = new StringBuilder(); + + Random rnd = new Random(DateTime.Now.Millisecond); + + for (int i = 0; i < n; i++) + { + num.Append(arrChar[rnd.Next(6, 8)].ToString()); + + } + + return num.ToString(); + } + #endregion + + #region 数字随机数 + /// + /// 数字随机数 + /// + /// 生成长度 + /// + public static string RandNumZF(int n) + { + string[] arrChar = new string[] { "1", "2", "3", "4", "5", "-1", "-2", "-3", "-4", "-5" }; + StringBuilder num = new StringBuilder(); + Random rnd = new Random(DateTime.Now.Millisecond); + for (int i = 0; i < n; i++) + { + num.Append(arrChar[rnd.Next(0, 9)].ToString()); + } + return num.ToString(); + } + #endregion + + #region 数字和字母随机数 + /// + /// 数字和字母随机数 + /// + /// 生成长度 + /// + public static string RandCode(int n) + { + char[] arrChar = new char[]{ + 'a','b','d','c','e','f','g','h','i','j','k','l','m','n','p','r','q','s','t','u','v','w','z','y','x', + '0','1','2','3','4','5','6','7','8','9', + 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','Q','P','R','T','S','V','U','W','X','Y','Z' + }; + + StringBuilder num = new StringBuilder(); + + Random rnd = new Random(DateTime.Now.Millisecond); + for (int i = 0; i < n; i++) + { + num.Append(arrChar[rnd.Next(0, arrChar.Length)].ToString()); + + } + + return num.ToString(); + } + #endregion + + #region 字母随机数 + /// + /// 字母随机数 + /// + /// 生成长度 + /// + public static string RandLetter(int n) + { + char[] arrChar = new char[]{ + 'a','b','d','c','e','f','g','h','i','j','k','l','m','n','p','r','q','s','t','u','v','w','z','y','x', + '_', + 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','Q','P','R','T','S','V','U','W','X','Y','Z' + }; + + StringBuilder num = new StringBuilder(); + + Random rnd = new Random(DateTime.Now.Millisecond); + for (int i = 0; i < n; i++) + { + num.Append(arrChar[rnd.Next(0, arrChar.Length)].ToString()); + + } + + return num.ToString(); + } + #endregion + + #region 日期随机函数 + /// + /// 日期随机函数 + /// + /// 长度 + /// + public static string DateRndName(Random ra) + { + DateTime d = DateTime.Now; + string s = null, y, m, dd, h, mm, ss; + y = d.Year.ToString(); + m = d.Month.ToString(); + if (m.Length < 2) m = "0" + m; + dd = d.Day.ToString(); + if (dd.Length < 2) dd = "0" + dd; + h = d.Hour.ToString(); + if (h.Length < 2) h = "0" + h; + mm = d.Minute.ToString(); + if (mm.Length < 2) mm = "0" + mm; + ss = d.Second.ToString(); + if (ss.Length < 2) ss = "0" + ss; + s += y + m + dd + h + mm + ss; + s += ra.Next(100, 999).ToString(); + return s; + } + #endregion + + #region 生成GUID + /// + /// 生成GUID + /// + /// + public static string GetGuid() + { + System.Guid g = System.Guid.NewGuid(); + return g.ToString(); + } + #endregion + } +} diff --git a/New_College.Common/Helper/RecursionHelper.cs b/New_College.Common/Helper/RecursionHelper.cs new file mode 100644 index 0000000..3a70d7b --- /dev/null +++ b/New_College.Common/Helper/RecursionHelper.cs @@ -0,0 +1,129 @@ +using System.Collections.Generic; +using System.Linq; + +namespace New_College.Common.Helper +{ + /// + /// 泛型递归求树形结构 + /// + public static class RecursionHelper + { + public static void LoopToAppendChildren(List all, PermissionTree curItem, int pid, bool needbtn) + { + + var subItems = all.Where(ee => ee.Pid == curItem.value).ToList(); + + var btnItems = subItems.Where(ss => ss.isbtn == true).ToList(); + if (subItems.Count > 0) + { + curItem.btns = new List(); + curItem.btns.AddRange(btnItems); + } + else + { + curItem.btns = null; + } + + if (!needbtn) + { + subItems = subItems.Where(ss => ss.isbtn == false).ToList(); + } + if (subItems.Count > 0) + { + curItem.children = new List(); + curItem.children.AddRange(subItems); + } + else + { + curItem.children = null; + } + + if (curItem.isbtn) + { + //curItem.label += "按钮"; + } + + foreach (var subItem in subItems) + { + if (subItem.value == pid && pid > 0) + { + //subItem.disabled = true;//禁用当前节点 + } + LoopToAppendChildren(all, subItem, pid, needbtn); + } + } + + + + public static void LoopNaviBarAppendChildren(List all, NavigationBar curItem) + { + + var subItems = all.Where(ee => ee.pid == curItem.id).ToList(); + + if (subItems.Count > 0) + { + curItem.children = new List(); + curItem.children.AddRange(subItems); + } + else + { + curItem.children = null; + } + + + foreach (var subItem in subItems) + { + LoopNaviBarAppendChildren(all, subItem); + } + } + + + + public static void LoopToAppendChildrenT(List all, T curItem, string parentIdName = "Pid", string idName = "value", string childrenName = "children") + { + var subItems = all.Where(ee => ee.GetType().GetProperty(parentIdName).GetValue(ee, null).ToString() == curItem.GetType().GetProperty(idName).GetValue(curItem, null).ToString()).ToList(); + + if (subItems.Count > 0) curItem.GetType().GetField(childrenName).SetValue(curItem, subItems); + foreach (var subItem in subItems) + { + LoopToAppendChildrenT(all, subItem); + } + } + } + + public class PermissionTree + { + public int value { get; set; } + public int Pid { get; set; } + public string label { get; set; } + public int order { get; set; } + public bool isbtn { get; set; } + public bool disabled { get; set; } + public List children { get; set; } + public List btns { get; set; } + } + public class NavigationBar + { + public int id { get; set; } + public int pid { get; set; } + public int order { get; set; } + public string name { get; set; } + public bool IsHide { get; set; } = false; + public bool IsButton { get; set; } = false; + public string path { get; set; } + public string Func { get; set; } + public string iconCls { get; set; } + public NavigationBarMeta meta { get; set; } + public List children { get; set; } + } + + public class NavigationBarMeta + { + public string title { get; set; } + public bool requireAuth { get; set; } = true; + public bool NoTabPage { get; set; } = false; + public bool keepAlive { get; set; } = false; + + + } +} diff --git a/New_College.Common/Helper/SerializeHelper.cs b/New_College.Common/Helper/SerializeHelper.cs new file mode 100644 index 0000000..e500705 --- /dev/null +++ b/New_College.Common/Helper/SerializeHelper.cs @@ -0,0 +1,35 @@ +using Newtonsoft.Json; +using System.Text; + +namespace New_College.Common +{ + 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/New_College.Common/Helper/StringHelper.cs b/New_College.Common/Helper/StringHelper.cs new file mode 100644 index 0000000..d125ef0 --- /dev/null +++ b/New_College.Common/Helper/StringHelper.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace New_College.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(); + } + } +} diff --git a/New_College.Common/Helper/TimeUtil.cs b/New_College.Common/Helper/TimeUtil.cs new file mode 100644 index 0000000..833a77d --- /dev/null +++ b/New_College.Common/Helper/TimeUtil.cs @@ -0,0 +1,23 @@ +using System; +using NodaTime; + +namespace YIJIYI.Core.Common.Helper +{ + public class TimeUtil + { + public static DateTime GetCstDateTime() + { + Instant now = SystemClock.Instance.GetCurrentInstant(); + var shanghaiZone = DateTimeZoneProviders.Tzdb["Asia/Shanghai"]; + return now.InZone(shanghaiZone).ToDateTimeUnspecified(); + } + + } + public static class DateTimeExtentions + { + public static DateTime ToCstTime(this DateTime time) + { + return TimeUtil.GetCstDateTime(); + } + } +} diff --git a/New_College.Common/Helper/UnicodeHelper.cs b/New_College.Common/Helper/UnicodeHelper.cs new file mode 100644 index 0000000..9dc4f98 --- /dev/null +++ b/New_College.Common/Helper/UnicodeHelper.cs @@ -0,0 +1,47 @@ +using System; +using System.Text; +using System.Text.RegularExpressions; + +namespace New_College.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/New_College.Common/Helper/UtilConvert.cs b/New_College.Common/Helper/UtilConvert.cs new file mode 100644 index 0000000..c5b3f71 --- /dev/null +++ b/New_College.Common/Helper/UtilConvert.cs @@ -0,0 +1,183 @@ +using System; +namespace New_College +{ + /// + /// + /// + public static class UtilConvert + { + /// + /// + /// + /// + /// + public static int ObjToInt(this object thisValue) + { + int reval = 0; + if (thisValue == null) return 0; + if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return reval; + } + /// + /// + /// + /// + /// + /// + public static int ObjToInt(this object thisValue, int errorValue) + { + int reval = 0; + if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return errorValue; + } + /// + /// + /// + /// + /// + public static double ObjToMoney(this object thisValue) + { + double reval = 0; + if (thisValue != null && thisValue != DBNull.Value && double.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return 0; + } + /// + /// + /// + /// + /// + /// + public static double ObjToMoney(this object thisValue, double errorValue) + { + double reval = 0; + if (thisValue != null && thisValue != DBNull.Value && double.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return errorValue; + } + /// + /// + /// + /// + /// + public static string ObjToString(this object thisValue) + { + if (thisValue != null) return thisValue.ToString().Trim(); + return ""; + } + /// + /// + /// + /// + /// + public static bool IsNotEmptyOrNull(this object thisValue) + { + return ObjToString(thisValue) != ""; + } + /// + /// + /// + /// + /// + /// + public static string ObjToString(this object thisValue, string errorValue) + { + if (thisValue != null) return thisValue.ToString().Trim(); + return errorValue; + } + /// + /// + /// + /// + /// + public static Decimal ObjToDecimal(this object thisValue) + { + Decimal reval = 0; + if (thisValue != null && thisValue != DBNull.Value && decimal.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return 0; + } + /// + /// + /// + /// + /// + /// + public static Decimal ObjToDecimal(this object thisValue, decimal errorValue) + { + Decimal reval = 0; + if (thisValue != null && thisValue != DBNull.Value && decimal.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return errorValue; + } + /// + /// + /// + /// + /// + public static DateTime ObjToDate(this object thisValue) + { + DateTime reval = DateTime.MinValue; + if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval)) + { + reval = Convert.ToDateTime(thisValue); + } + return reval; + } + /// + /// + /// + /// + /// + /// + public static DateTime ObjToDate(this object thisValue, DateTime errorValue) + { + DateTime reval = DateTime.MinValue; + if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return errorValue; + } + /// + /// + /// + /// + /// + public static bool ObjToBool(this object thisValue) + { + bool reval = false; + if (thisValue != null && thisValue != DBNull.Value && bool.TryParse(thisValue.ToString(), out reval)) + { + return reval; + } + return reval; + } + + + /// + /// 获取当前时间的时间戳 + /// + /// + /// + public static string DateToTimeStamp(this DateTime thisValue) + { + TimeSpan ts = thisValue - new DateTime(1970, 1, 1, 0, 0, 0, 0); + return Convert.ToInt64(ts.TotalSeconds).ToString(); + } + } +} diff --git a/New_College.Common/Helper/WeChatPayHelper.cs b/New_College.Common/Helper/WeChatPayHelper.cs new file mode 100644 index 0000000..44b3420 --- /dev/null +++ b/New_College.Common/Helper/WeChatPayHelper.cs @@ -0,0 +1,77 @@ +using Essensoft.AspNetCore.Payment.WeChatPay; +using Essensoft.AspNetCore.Payment.WeChatPay.Request; +using Essensoft.AspNetCore.Payment.WeChatPay.Response; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; + + +namespace New_College.Common.Helper +{ + public class WeChatPay + { + /// + /// 订单查询 + /// + /// + /// + /// + /// + public async Task OrderQuery(IWeChatPayClient _client, + IOptions _optionsAccessor, WeChatPayOrderQuery viewModel) + { + var request = new WeChatPayOrderQueryRequest + { + TransactionId = viewModel.TransactionId, + OutTradeNo = viewModel.OutTradeNo + }; + return await _client.ExecuteAsync(request, _optionsAccessor.Value); + } + + /// + /// 返回微信支付链接 + /// + /// + /// + public static async Task GetMwebUrl(IWeChatPayClient _client, IOptions _optionsAccessor, + WeChatPayPayRequest viewModel) + { + var request = new WeChatPayUnifiedOrderRequest + { + Body = viewModel.Body, + OutTradeNo = viewModel.OutTradeNo, + TotalFee = viewModel.TotalFee, + SpBillCreateIp = viewModel.SpBillCreateIp, + NotifyUrl = viewModel.NotifyUrl, + TradeType = viewModel.TradeType + }; + return await _client.ExecuteAsync(request, _optionsAccessor.Value); + } + /// + /// 退款 + /// + /// + /// + /// + /// + public static async Task Refund(IWeChatPayClient _client, IOptions _optionsAccessor, + WeChatPayRefundQuery query) + { + var request = new WeChatPayRefundRequest + { + OutRefundNo = query.OutRefundNo, + TransactionId = query.TransactionId, + OutTradeNo = query.OutTradeNo, + TotalFee = query.TotalFee, + RefundFee = query.RefundFee, + RefundDesc = query.RefundDesc, + NotifyUrl = query.NotifyUrl + }; + var response = await _client.ExecuteAsync(request, _optionsAccessor.Value); + return response; + } + } +} diff --git a/New_College.Common/Helper/WeChatPayOrderQuery.cs b/New_College.Common/Helper/WeChatPayOrderQuery.cs new file mode 100644 index 0000000..f85c5f7 --- /dev/null +++ b/New_College.Common/Helper/WeChatPayOrderQuery.cs @@ -0,0 +1,69 @@ +using System.ComponentModel.DataAnnotations; + +namespace New_College.Common.Helper +{ + public class WeChatPayOrderQuery + { + [Display(Name = "transaction_id")] + public string TransactionId { get; set; } + + [Display(Name = "out_trade_no")] + public string OutTradeNo { get; set; } + } + public class WeChatPayRefundQuery + { + [Required] + [Display(Name = "out_refund_no")] + public string OutRefundNo { get; set; } + + [Display(Name = "transaction_id")] + public string TransactionId { get; set; } + + [Display(Name = "out_trade_no")] + public string OutTradeNo { get; set; } + + [Required] + [Display(Name = "total_fee")] + public int TotalFee { get; set; } + + [Required] + [Display(Name = "refund_fee")] + public int RefundFee { get; set; } + + [Display(Name = "refund_desc")] + public string RefundDesc { get; set; } + + [Display(Name = "notify_url")] + public string NotifyUrl { get; set; } + } + + + public class ProductPayRequest + { + /// + /// 1商品2评测3陪考通考试 + /// + public int ProductType { get; set; } = 0; + } + public class WeChatPayPayRequest : ProductPayRequest + { + + public string OutTradeNo { get; set; } = ""; + + public string Body { get; set; } = ""; + + public int TotalFee { get; set; } = 0; + + public string SpBillCreateIp { get; set; } + + + public string NotifyUrl { get; set; } + + public string TradeType { get; set; } = "MWEB"; + + public int MemberId { get; set; } + public string OpenId { get; set; } + public string PaymentChannel { get; set; } = "微信支付"; + public string PaymentType { get; set; } = "WeChat"; + } +} \ No newline at end of file diff --git a/New_College.Common/Helper/WeixinHelper.cs b/New_College.Common/Helper/WeixinHelper.cs new file mode 100644 index 0000000..e33dd8a --- /dev/null +++ b/New_College.Common/Helper/WeixinHelper.cs @@ -0,0 +1,202 @@ +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Security.Cryptography; +using System.Text; +using Newtonsoft.Json; + +namespace New_College.Common +{ + public class WeixinHelper + { + /// + /// 获取AuthCodeSession + /// + /// + /// + /// + /// + public static T AuthCode2Session(string appid, string secret, string code) where T :new() + { + var authinfo = new T(); + try + { + + string requestUri = string.Format("https://api.weixin.qq.com/sns/jscode2session?appid={0}&secret={1}&js_code={2}&grant_type=authorization_code", appid, secret, code); ; + var httpClientHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true + }; + + using (HttpClient httpClient = new HttpClient(httpClientHandler)) + { + var responseStr = httpClient.GetAsync(requestUri).Result.Content.ReadAsStringAsync().Result; + var obj = JsonConvert.DeserializeObject(responseStr); + return obj; + } + } + catch (Exception ex) + { + throw ex; + } + } + + + /** + * + * 统一下单 + * @param WxPaydata inputObj 提交给统一下单API的参数 + * @param int timeOut 超时时间 + * @throws WePayException + * @return 成功时返回,其他抛异常 + */ + public static WxPayData UnifiedOrder(WxPayData inputObj, int timeOut = 60) + { + string url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; + //检测必填参数 + if (!inputObj.IsSet("out_trade_no")) + { + throw new Exception("缺少统一支付接口必填参数out_trade_no!"); + } + else if (!inputObj.IsSet("body")) + { + throw new Exception("缺少统一支付接口必填参数body!"); + } + else if (!inputObj.IsSet("total_fee")) + { + throw new Exception("缺少统一支付接口必填参数total_fee!"); + } + else if (!inputObj.IsSet("trade_type")) + { + throw new Exception("缺少统一支付接口必填参数trade_type!"); + } + + //关联参数 + if (inputObj.GetValue("trade_type").ToString() == "JSAPI" && !inputObj.IsSet("openid")) + { + throw new Exception("统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!"); + } + if (inputObj.GetValue("trade_type").ToString() == "NATIVE" && !inputObj.IsSet("product_id")) + { + throw new Exception("统一支付接口中,缺少必填参数product_id!trade_type为JSAPI时,product_id为必填参数!"); + } + + //异步通知url未设置,则使用配置文件中的url + if (!inputObj.IsSet("notify_url")) + { + inputObj.SetValue("notify_url", WeixinConfig.NotifyUrl);//异步通知url + } + + inputObj.SetValue("appid", WeixinConfig.Appid);//公众账号ID + inputObj.SetValue("mch_id", WeixinConfig.MCHID);//商户号 + inputObj.SetValue("spbill_create_ip", "8.8.8.8");//终端ip + inputObj.SetValue("nonce_str", GenerateNonceStr());//随机字符串 + + //签名 + inputObj.SetValue("sign", inputObj.MakeSign()); + string xml = inputObj.ToXml(); + + var start = DateTime.Now; + + // Log.Info("XcxPayApi", "UnfiedOrder request : " + xml); + string response = HttpPost(xml, url, "application/xml", timeOut); + //Log.Info("XcxPayApi", "UnfiedOrder response : " + response); + // WebHookHelper.WebHookmarkdownSend(response); + + var end = DateTime.Now; + int timeCost = (int)((end - start).TotalMilliseconds); + + WxPayData result = new WxPayData(); + result.FromXml(response); + // ReportCostTime(url, timeCost, result);//测速上报网络不好时使用 + return result; + } + + + /// + /// 生成随机数 + /// + /// + public static string GenerateNonceStr() + { + return Guid.NewGuid().ToString().Replace("-", ""); + } + + + /// + /// POST请求 + /// + /// + /// + /// application/xml、application/json、application/text、application/x-www-form-urlencoded + /// + /// + /// + public static string HttpPost(string postData, string url, string contentType = null, int timeOut = 30, Dictionary headers = null) + { + postData = postData ?? ""; + + var httpClientHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true + }; + using (HttpClient httpClient = new HttpClient(httpClientHandler)) + { + if (headers != null) + { + foreach (var header in headers) + httpClient.DefaultRequestHeaders.Add(header.Key, header.Value); + } + using (HttpContent client = new StringContent(postData, Encoding.UTF8)) + { + if (contentType != null) + client.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType); + + HttpResponseMessage response = httpClient.PostAsync(url, client).Result; + return response.Content.ReadAsStringAsync().Result; + } + } + } + + + + + /// + /// 后台解密手机号 + /// + /// + /// + /// + /// + public static string getPhoneNumber(string encryptedData, string IV, string Session_key) + { + try + { + + byte[] encryData = Convert.FromBase64String(encryptedData); // strToToHexByte(text); + RijndaelManaged rijndaelCipher = new RijndaelManaged(); + rijndaelCipher.Key = Convert.FromBase64String(Session_key); // Encoding.UTF8.GetBytes(AesKey); + rijndaelCipher.IV = Convert.FromBase64String(IV);// Encoding.UTF8.GetBytes(AesIV); + rijndaelCipher.Mode = CipherMode.CBC; + rijndaelCipher.Padding = PaddingMode.PKCS7; + ICryptoTransform transform = rijndaelCipher.CreateDecryptor(); + byte[] plainText = transform.TransformFinalBlock(encryData, 0, encryData.Length); + string result = Encoding.Default.GetString(plainText); + //动态解析result 成对象 + dynamic model = Newtonsoft.Json.Linq.JToken.Parse(result) as dynamic; + return model.phoneNumber; + + } + catch (Exception ex) + { + //MessageBox.Show(ex.Message); + return ""; + + } + } + + } + + + +} diff --git a/New_College.Common/Helper/WxPayData.cs b/New_College.Common/Helper/WxPayData.cs new file mode 100644 index 0000000..09fdcc9 --- /dev/null +++ b/New_College.Common/Helper/WxPayData.cs @@ -0,0 +1,269 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; +using System.Xml; + +namespace New_College.Common +{ + /// + /// 微信支付协议接口数据类,所有的API接口通信都依赖这个数据结构, + /// 在调用接口之前先填充各个字段的值,然后进行接口通信, + /// 这样设计的好处是可扩展性强,用户可随意对协议进行更改而不用重新设计数据结构, + /// 还可以随意组合出不同的协议数据包,不用为每个协议设计一个数据包结构 + /// + public class WxPayData + { + + public WxPayData() + { + } + + //采用排序的Dictionary的好处是方便对数据包进行签名,不用再签名之前再做一次排序 + private SortedDictionary m_values = new SortedDictionary(); + + /** + * 设置某个字段的值 + * @param key 字段名 + * @param value 字段值 + */ + public void SetValue(string key, object value) + { + m_values[key] = value; + } + + /** + * 根据字段名获取某个字段的值 + * @param key 字段名 + * @return key对应的字段值 + */ + public object GetValue(string key) + { + object o = null; + m_values.TryGetValue(key, out o); + return o; + } + + /** + * 判断某个字段是否已设置 + * @param key 字段名 + * @return 若字段key已被设置,则返回true,否则返回false + */ + public bool IsSet(string key) + { + object o = null; + m_values.TryGetValue(key, out o); + if (null != o) + return true; + else + return false; + } + + /** + * @将Dictionary转成xml + * @return 经转换得到的xml串 + * @throws WePayException + **/ + public string ToXml() + { + //数据为空时不能转化为xml格式 + if (0 == m_values.Count) + { + + //NLogHelper.WriteError("WxPayData数据为空!",DevAuthorNameEnum.Michael,false); + throw new Exception("WxPayData数据为空!"); + } + + string xml = ""; + foreach (KeyValuePair pair in m_values) + { + //字段值不能为null,会影响后续流程 + if (pair.Value == null) + { + //NLogHelper.WriteError("WxPayData内部含有值为null的字段!", DevAuthorNameEnum.Michael, false); + throw new Exception("WxPayData内部含有值为null的字段!"); + } + + if (pair.Value.GetType() == typeof(int)) + { + xml += "<" + pair.Key + ">" + pair.Value + ""; + } + else if (pair.Value.GetType() == typeof(string)) + { + xml += "<" + pair.Key + ">" + ""; + } + else//除了string和int类型不能含有其他数据类型 + { + //NLogHelper.WriteError("WxPayData字段数据类型错误!", DevAuthorNameEnum.Michael, false); + throw new Exception("WxPayData字段数据类型错误!"); + } + } + xml += ""; + return xml; + } + + /** + * @将xml转为WxPayData对象并返回对象内部的数据 + * @param string 待转换的xml串 + * @return 经转换得到的Dictionary + * @throws WePayException + */ + public SortedDictionary FromXml(string xml) + { + if (string.IsNullOrEmpty(xml)) + { + //NLogHelper.WriteError("将空的xml串转换为WxPayData不合法!", DevAuthorNameEnum.Michael, false); + throw new Exception("将空的xml串转换为WxPayData不合法!"); + } + + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.LoadXml(xml); + XmlNode xmlNode = xmlDoc.FirstChild;//获取到根节点 + XmlNodeList nodes = xmlNode.ChildNodes; + foreach (XmlNode xn in nodes) + { + XmlElement xe = (XmlElement)xn; + m_values[xe.Name] = xe.InnerText;//获取xml的键值对到WxPayData内部的数据中 + } + + try + { + //2015-06-29 错误是没有签名 + if (m_values["return_code"] != "SUCCESS") + { + return m_values; + } + CheckSign();//验证签名,不通过会抛异常 + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + + return m_values; + } + + /** + * @Dictionary格式转化成url参数格式 + * @ return url格式串, 该串不包含sign字段值 + */ + public string ToUrl() + { + string buff = ""; + foreach (KeyValuePair pair in m_values) + { + if (pair.Value == null) + { + //NLogHelper.WriteError("WxPayData内部含有值为null的字段!", DevAuthorNameEnum.Michael, false); + throw new Exception("WxPayData内部含有值为null的字段!"); + } + + if (pair.Key != "sign" && pair.Value.ToString() != "") + { + buff += pair.Key + "=" + pair.Value + "&"; + } + } + buff = buff.Trim('&'); + return buff; + } + + + /** + * @Dictionary格式化成Json + * @return json串数据 + */ + public string ToJson() + { + string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(m_values); + return jsonStr; + } + + /** + * @values格式化成能在Web页面上显示的结果(因为web页面上不能直接输出xml格式的字符串) + */ + public string ToPrintStr() + { + string str = ""; + foreach (KeyValuePair pair in m_values) + { + if (pair.Value == null) + { + //NLogHelper.WriteError("WxPayData内部含有值为null的字段!", DevAuthorNameEnum.Michael, false); + throw new Exception("WxPayData内部含有值为null的字段!"); + } + + str += string.Format("{0}={1}
", pair.Key, pair.Value.ToString()); + } + //NLogHelper.WriteInfo("Print in Web Page : " + str, DevAuthorNameEnum.Michael, false); + return str; + } + + /** + * @生成签名,详见签名生成算法 + * @return 签名, sign字段不参加签名 + */ + public string MakeSign() + { + //转url格式 + string str = ToUrl(); + //在string后加入API KEY + str += "&key=" + WeixinConfig.KEY; + //NLogHelper.WriteInfo("Signurl" + str,DevAuthorNameEnum.Michael,false); + //MD5加密 + var md5 = MD5.Create(); + var bs = md5.ComputeHash(Encoding.UTF8.GetBytes(str)); + var sb = new StringBuilder(); + foreach (byte b in bs) + { + sb.Append(b.ToString("x2")); + } + //所有字符转为大写 + return sb.ToString().ToUpper(); + } + + /** + * + * 检测签名是否正确 + * 正确返回true,错误抛异常 + */ + public bool CheckSign() + { + //如果没有设置签名,则跳过检测 + if (!IsSet("sign")) + { + // Log.Error(this.GetType().ToString(), "WxPayData签名存在但不合法!"); + throw new Exception("WxPayData签名存在但不合法!"); + } + //如果设置了签名但是签名为空,则抛异常 + else if (GetValue("sign") == null || GetValue("sign").ToString() == "") + { + //Log.Error(this.GetType().ToString(), "WxPayData签名存在但不合法!"); + throw new Exception("WxPayData签名存在但不合法!"); + } + + //获取接收到的签名 + string return_sign = GetValue("sign").ToString(); + + //在本地计算新的签名 + string cal_sign = MakeSign(); + + if (cal_sign == return_sign) + { + return true; + } + + //Log.Error(this.GetType().ToString(), "WxPayData签名验证错误!"); + throw new Exception("WxPayData签名验证错误!"); + } + + /** + * @获取Dictionary + */ + public SortedDictionary GetValues() + { + return m_values; + } + } +} \ No newline at end of file diff --git a/New_College.Common/Helper/XmlSerializeHelper.cs b/New_College.Common/Helper/XmlSerializeHelper.cs new file mode 100644 index 0000000..fc2835d --- /dev/null +++ b/New_College.Common/Helper/XmlSerializeHelper.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Xml; +using System.Xml.Serialization; + +namespace New_College.Common +{ + public class XmlSerializeHelper + { + /// + /// XML转换为对象 + /// + /// + /// + /// + public static T XMLToObject(string xml) where T : new() + { + XmlDocument doc = new XmlDocument(); + doc.LoadXml(xml); + XmlNode root = doc.FirstChild; + + Dictionary table = new Dictionary(); + foreach (XmlNode v in root.ChildNodes) + { + if (v.Name == "#text") + continue; + table.Add(v.Name, GetValue(v)); + } + + return DicToObject(table); //new RequestText(table); + } + + /// + /// 字典类型转化为对象 + /// + /// + /// + private static T DicToObject(Dictionary dic) where T : new() + { + var md = new T(); + DicToObject(md, dic); + return md; + } + + /// + /// Dictionary填充对象 + /// + /// + /// + private static void DicToObject(object md, System.Collections.IDictionary dic) + { + foreach (var filed in dic.Keys) + { + BindingFlags flag = BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance; + + try + { + var value = dic[filed]; + + if (value is System.Collections.IDictionary) + { + Type ct = md.GetType().GetProperty(filed + "", flag).PropertyType; + object o = Activator.CreateInstance(ct); + DicToObject(o, value as System.Collections.IDictionary); + md.GetType().GetProperty(filed + "", flag).SetValue(md, o, null); + } + else + { + Type type = md.GetType(); + if (type != null) + { + var pro = type.GetProperty(filed + "", flag); + if (pro != null) + pro.SetValue(md, value, null); + } + + } + + } + catch (Exception e) + { + + } + } + // return md; + } + + /// + /// 获得节点值 + /// + /// + /// + private static object GetValue(XmlNode node) + { + if (node.HasChildNodes) + { + // 这种结构 node.ChildNodes.Count==1 + if (node.ChildNodes.Count == 1 && node.ChildNodes[0].NodeType != XmlNodeType.Element) + { + return node.InnerText; + } + else + { + Dictionary table = new Dictionary(); + foreach (XmlNode n in node.ChildNodes) + { + table.Add(n.Name, GetValue(n)); + } + return table; + } + } + return node.InnerText; + } + + } +} diff --git a/New_College.Common/HttpContextUser/AspNetUser.cs b/New_College.Common/HttpContextUser/AspNetUser.cs new file mode 100644 index 0000000..abdf65f --- /dev/null +++ b/New_College.Common/HttpContextUser/AspNetUser.cs @@ -0,0 +1,81 @@ +using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; +using System.Linq; +using System.Security.Claims; +using Microsoft.AspNetCore.Http; + +namespace New_College.Common.HttpContextUser +{ + public class AspNetUser : IUser + { + private readonly IHttpContextAccessor _accessor; + + public AspNetUser(IHttpContextAccessor accessor) + { + _accessor = accessor; + } + + public string Name => GetName(); + + private string GetName() + { + if (IsAuthenticated()) + { + return _accessor.HttpContext.User.Identity.Name; + } + else { + if (!string.IsNullOrEmpty(GetToken())) + { + return GetUserInfoFromToken("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").FirstOrDefault().ObjToString(); + } + } + + return ""; + } + + public int ID => GetClaimValueByType("jti").FirstOrDefault().ObjToInt(); + + public bool IsAuthenticated() + { + return _accessor.HttpContext.User.Identity.IsAuthenticated; + } + + + public string GetToken() + { + return _accessor.HttpContext.Request.Headers["Authorization"].ObjToString().Replace("Bearer ", ""); + } + + public List GetUserInfoFromToken(string ClaimType) + { + + var jwtHandler = new JwtSecurityTokenHandler(); + if (!string.IsNullOrEmpty(GetToken())) + { + JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(GetToken()); + + return (from item in jwtToken.Claims + where item.Type == ClaimType + select item.Value).ToList(); + } + else + { + return new List() { }; + } + } + + public IEnumerable GetClaimsIdentity() + { + return _accessor.HttpContext.User.Claims; + } + + public List GetClaimValueByType(string ClaimType) + { + + return (from item in GetClaimsIdentity() + where item.Type == ClaimType + select item.Value).ToList(); + + } + } +} diff --git a/New_College.Common/HttpContextUser/IUser.cs b/New_College.Common/HttpContextUser/IUser.cs new file mode 100644 index 0000000..ec37c3b --- /dev/null +++ b/New_College.Common/HttpContextUser/IUser.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Security.Claims; + +namespace New_College.Common.HttpContextUser +{ + public interface IUser + { + string Name { get; } + int ID { get; } + bool IsAuthenticated(); + IEnumerable GetClaimsIdentity(); + List GetClaimValueByType(string ClaimType); + + string GetToken(); + List GetUserInfoFromToken(string ClaimType); + } +} diff --git a/New_College.Common/HttpRestSharp/HttpHelper.cs b/New_College.Common/HttpRestSharp/HttpHelper.cs new file mode 100644 index 0000000..8d768cb --- /dev/null +++ b/New_College.Common/HttpRestSharp/HttpHelper.cs @@ -0,0 +1,73 @@ +using RestSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Threading.Tasks; + +namespace New_College.Common.HttpRestSharp +{ + /// + /// 基于 RestSharp 封装HttpHelper + /// + public static class HttpHelper + { + /// + /// Get 请求 + /// + /// 泛型 + /// 根域名:http://apk.neters.club/ + /// 接口:api/xx/yy + /// 参数:id=2&name=老张 + /// + public static T GetApi(string baseUrl, string url, string pragm = "") + { + var client = new RestSharpClient(baseUrl); + + var request = client.Execute(string.IsNullOrEmpty(pragm) + ? new RestRequest(url, Method.GET) + : new RestRequest($"{url}?{pragm}", Method.GET)); + + if (request.StatusCode != HttpStatusCode.OK) + { + return (T)Convert.ChangeType(request.ErrorMessage, typeof(T)); + } + + dynamic temp = Newtonsoft.Json.JsonConvert.DeserializeObject(request.Content, typeof(T)); + + //T result = (T)Convert.ChangeType(request.Content, typeof(T)); + + return (T)temp; + } + + /// + /// Post 请求 + /// + /// 泛型 + /// 完整的url + /// post body,可以匿名或者反序列化 + /// + public static T PostApi(string url, object body = null) + { + var client = new RestClient($"{url}"); + IRestRequest queest = new RestRequest(); + queest.Method = Method.POST; + queest.AddHeader("Accept", "application/json"); + queest.RequestFormat = DataFormat.Json; + queest.AddBody(body); // 可以使用 JsonSerializer + var result = client.Execute(queest); + if (result.StatusCode != HttpStatusCode.OK) + { + return (T)Convert.ChangeType(result.ErrorMessage, typeof(T)); + } + + dynamic temp = Newtonsoft.Json.JsonConvert.DeserializeObject(result.Content, typeof(T)); + + //T result = (T)Convert.ChangeType(request.Content, typeof(T)); + + return (T)temp; + } + + + } +} diff --git a/New_College.Common/HttpRestSharp/IRestSharp.cs b/New_College.Common/HttpRestSharp/IRestSharp.cs new file mode 100644 index 0000000..2376d86 --- /dev/null +++ b/New_College.Common/HttpRestSharp/IRestSharp.cs @@ -0,0 +1,43 @@ +using RestSharp; +using System; + +namespace New_College.Common.HttpRestSharp +{ + /// + /// API请求执行者接口 + /// + public interface IRestSharp + { + /// + /// 同步执行方法 + /// + /// + /// + IRestResponse Execute(IRestRequest request); + + /// + /// 同步执行方法 + /// + /// 返回值 + /// 请求参数 + /// + T Execute(IRestRequest request) where T : new(); + + /// + /// 异步执行方法 + /// + /// 请求参数 + /// + /// + RestRequestAsyncHandle ExecuteAsync(IRestRequest request, Action callback); + + /// + /// 异步执行方法 + /// + /// + /// + /// + /// + RestRequestAsyncHandle ExecuteAsync(IRestRequest request, Action> callback) where T : new(); + } +} diff --git a/New_College.Common/HttpRestSharp/RestSharpClient.cs b/New_College.Common/HttpRestSharp/RestSharpClient.cs new file mode 100644 index 0000000..9415793 --- /dev/null +++ b/New_College.Common/HttpRestSharp/RestSharpClient.cs @@ -0,0 +1,135 @@ +using RestSharp; +using RestSharp.Authenticators; +using System; + +namespace New_College.Common.HttpRestSharp +{ + /// + /// Rest接口执行者 + /// + public class RestSharpClient : IRestSharp + { + /// + /// 请求客户端 + /// + private RestClient client; + + /// + /// 接口基地址 格式:http://apk.neters.club/ + /// + private string BaseUrl { get; set; } + + /// + /// 默认的时间参数格式 + /// + private string DefaultDateParameterFormat { get; set; } + + /// + /// 默认验证器 + /// + private IAuthenticator DefaultAuthenticator { get; set; } + + /// + /// 构造函数 + /// + /// + /// + public RestSharpClient(string baseUrl, IAuthenticator authenticator = null) + { + BaseUrl = baseUrl; + client = new RestClient(BaseUrl); + DefaultAuthenticator = authenticator; + + //默认时间显示格式 + DefaultDateParameterFormat = "yyyy-MM-dd HH:mm:ss"; + + //默认校验器 + if (DefaultAuthenticator != null) + { + client.Authenticator = DefaultAuthenticator; + } + } + + /// + /// 通用执行方法 + /// + /// 请求参数 + /// + /// 调用实例: + /// var client = new RestSharpClient("http://apk.neters.club/"); + /// var result = client.Execute(new RestRequest("v2/movie/in_theaters", Method.GET)); + /// var content = result.Content;//返回的字符串数据 + /// + /// + public IRestResponse Execute(IRestRequest request) + { + request.DateFormat = string.IsNullOrEmpty(request.DateFormat) ? DefaultDateParameterFormat : request.DateFormat; + var response = client.Execute(request); + return response; + } + + /// + /// 同步执行方法 + /// + /// 返回的泛型对象 + /// 请求参数 + /// + /// var client = new RestSharpClient("http://apk.neters.club/"); + /// var result = client.Execute>(new RestRequest("v2/movie/in_theaters", Method.GET)); + /// + /// + public T Execute(IRestRequest request) where T : new() + { + request.DateFormat = string.IsNullOrEmpty(request.DateFormat) ? DefaultDateParameterFormat : request.DateFormat; + var response = client.Execute(request); + return response.Data; + } + + /// + /// 异步执行方法 + /// + /// 请求参数 + /// 回调函数 + /// + /// 调用实例: + /// var client = new RestSharpClient("http://apk.neters.club/"); + /// client.ExecuteAsync>(new RestRequest("v2/movie/in_theaters", Method.GET), result => + /// { + /// var content = result.Content;//返回的字符串数据 + /// }); + /// + /// + [Obsolete] + public RestRequestAsyncHandle ExecuteAsync(IRestRequest request, Action callback) + { + request.DateFormat = string.IsNullOrEmpty(request.DateFormat) ? DefaultDateParameterFormat : request.DateFormat; + return client.ExecuteAsync(request, callback); + } + + /// + /// 异步执行方法 + /// + /// 返回的泛型对象 + /// 请求参数 + /// 回调函数 + /// + /// 调用实例: + /// var client = new RestSharpClient("http://apk.neters.club/"); + /// client.ExecuteAsync>(new RestRequest("v2/movie/in_theaters", Method.GET), result => + /// { + /// if (result.StatusCode != HttpStatusCode.OK) + /// { + /// return; + /// } + /// var data = result.Data;//返回数据 + /// }); + /// + /// + [Obsolete] + public RestRequestAsyncHandle ExecuteAsync(IRestRequest request, Action> callback) where T : new() + { + request.DateFormat = string.IsNullOrEmpty(request.DateFormat) ? DefaultDateParameterFormat : request.DateFormat; + return client.ExecuteAsync(request, callback); + } + } +} diff --git a/New_College.Common/Hubs/ChatHub.cs b/New_College.Common/Hubs/ChatHub.cs new file mode 100644 index 0000000..a9c284b --- /dev/null +++ b/New_College.Common/Hubs/ChatHub.cs @@ -0,0 +1,89 @@ +using System.Threading.Tasks; +using New_College.Common.LogHelper; +using Microsoft.AspNetCore.SignalR; + +namespace New_College.Hubs +{ + public class ChatHub : Hub + { + /// + /// 向指定群组发送信息 + /// + /// 组名 + /// 信息内容 + /// + public async Task SendMessageToGroupAsync(string groupName, string message) + { + await Clients.Group(groupName).ReceiveMessage(message); + } + + /// + /// 加入指定组 + /// + /// 组名 + /// + public async Task AddToGroup(string groupName) + { + await Groups.AddToGroupAsync(Context.ConnectionId, groupName); + } + + /// + /// 退出指定组 + /// + /// 组名 + /// + public async Task RemoveFromGroup(string groupName) + { + await Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName); + } + + /// + /// 向指定成员发送信息 + /// + /// 成员名 + /// 信息内容 + /// + public async Task SendPrivateMessage(string user, string message) + { + await Clients.User(user).ReceiveMessage(message); + } + + /// + /// 当连接建立时运行 + /// + /// + public override Task OnConnectedAsync() + { + //TODO.. + return base.OnConnectedAsync(); + } + + /// + /// 当链接断开时运行 + /// + /// + /// + public override Task OnDisconnectedAsync(System.Exception ex) + { + //TODO.. + return base.OnDisconnectedAsync(ex); + } + + + public async Task SendMessage(string user, string message) + { + await Clients.All.ReceiveMessage( user, message); + } + + //定于一个通讯管道,用来管理我们和客户端的连接 + //1、客户端调用 GetLatestCount,就像订阅 + public async Task GetLatestCount(string random) + { + //2、服务端主动向客户端发送数据,名字千万不能错 + await Clients.All.ReceiveUpdate(LogLock.GetLogData()); + + //3、客户端再通过 ReceiveUpdate ,来接收 + + } + } +} diff --git a/New_College.Common/Hubs/IChatClient.cs b/New_College.Common/Hubs/IChatClient.cs new file mode 100644 index 0000000..2639434 --- /dev/null +++ b/New_College.Common/Hubs/IChatClient.cs @@ -0,0 +1,24 @@ +using System.Threading.Tasks; + +namespace New_College.Hubs +{ + public interface IChatClient + { + /// + /// SignalR接收信息 + /// + /// 信息内容 + /// + Task ReceiveMessage(object message); + + /// + /// SignalR接收信息 + /// + /// 指定接收客户端 + /// 信息内容 + /// + Task ReceiveMessage(string user, string message); + + Task ReceiveUpdate(object message); + } +} diff --git a/New_College.Common/LogHelper/LogInfo.cs b/New_College.Common/LogHelper/LogInfo.cs new file mode 100644 index 0000000..f4adabb --- /dev/null +++ b/New_College.Common/LogHelper/LogInfo.cs @@ -0,0 +1,13 @@ +using System; + +namespace New_College.Common.LogHelper +{ + public class LogInfo + { + public DateTime Datetime { get; set; } + public string Content { get; set; } + public string IP { get; set; } + public string LogColor { get; set; } + public int Import { get; set; } = 0; + } +} diff --git a/New_College.Common/LogHelper/LogLock.cs b/New_College.Common/LogHelper/LogLock.cs new file mode 100644 index 0000000..e04c1fc --- /dev/null +++ b/New_College.Common/LogHelper/LogLock.cs @@ -0,0 +1,391 @@ +using New_College.Common.Helper; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; + +namespace New_College.Common.LogHelper +{ + public class LogLock + { + + static ReaderWriterLockSlim LogWriteLock = new ReaderWriterLockSlim(); + static int WritedCount = 0; + static int FailedCount = 0; + static string _contentRoot = string.Empty; + + public LogLock(string contentPath) + { + _contentRoot = contentPath; + } + + public static void OutSql2Log(string prefix, string[] dataParas, bool IsHeader = true) + { + try + { + //设置读写锁为写入模式独占资源,其他写入请求需要等待本次写入结束之后才能继续写入 + //注意:长时间持有读线程锁或写线程锁会使其他线程发生饥饿 (starve)。 为了得到最好的性能,需要考虑重新构造应用程序以将写访问的持续时间减少到最小。 + // 从性能方面考虑,请求进入写入模式应该紧跟文件操作之前,在此处进入写入模式仅是为了降低代码复杂度 + // 因进入与退出写入模式应在同一个try finally语句块内,所以在请求进入写入模式之前不能触发异常,否则释放次数大于请求次数将会触发异常 + LogWriteLock.EnterWriteLock(); + + var folderPath = Path.Combine(_contentRoot, "Log"); + if (!Directory.Exists(folderPath)) + { + Directory.CreateDirectory(folderPath); + } + //string logFilePath = Path.Combine(path, $@"{filename}.log"); + var logFilePath = FileHelper.GetAvailableFileWithPrefixOrderSize(folderPath, prefix); + + var now = DateTime.Now; + string logContent = String.Join("\r\n", dataParas); + if (IsHeader) + { + logContent = ( + "--------------------------------\r\n" + + DateTime.Now + "|\r\n" + + String.Join("\r\n", dataParas) + "\r\n" + ); + } + + //if (logContent.IsNotEmptyOrNull() && logContent.Length > 500) + //{ + // logContent = logContent.Substring(0, 500) + "\r\n"; + //} + + File.AppendAllText(logFilePath, logContent); + WritedCount++; + } + catch (Exception e) + { + Console.Write(e.Message); + FailedCount++; + } + finally + { + //退出写入模式,释放资源占用 + //注意:一次请求对应一次释放 + // 若释放次数大于请求次数将会触发异常[写入锁定未经保持即被释放] + // 若请求处理完成后未释放将会触发异常[此模式不下允许以递归方式获取写入锁定] + LogWriteLock.ExitWriteLock(); + } + } + + /// + /// 读取文件内容 + /// + /// 文件夹路径 + /// 文件名 + /// 编码 + /// 读取类型(0:精准,1:前缀模糊) + /// + public static string ReadLog(string folderPath, string fileName, Encoding encode, ReadType readType = ReadType.Accurate) + { + string s = ""; + try + { + LogWriteLock.EnterReadLock(); + + // 根据文件名读取当前文件内容 + if (readType == ReadType.Accurate) + { + var filePath = Path.Combine(folderPath, fileName); + if (!File.Exists(filePath)) + { + s = null; + } + else + { + StreamReader f2 = new StreamReader(filePath, encode); + s = f2.ReadToEnd(); + f2.Close(); + f2.Dispose(); + } + } + + // 根据前缀读取所有文件内容 + if (readType == ReadType.Prefix) + { + var allFiles = new DirectoryInfo(folderPath); + var selectFiles = allFiles.GetFiles().Where(fi => fi.Name.ToLower().Contains(fileName.ToLower())).ToList(); + + foreach (var item in selectFiles) + { + if (File.Exists(item.FullName)) + { + StreamReader f2 = new StreamReader(item.FullName, encode); + s += f2.ReadToEnd(); + f2.Close(); + f2.Dispose(); + } + } + } + } + catch (Exception) + { + FailedCount++; + } + finally + { + LogWriteLock.ExitReadLock(); + } + return s; + } + + + public static List GetLogData() + { + List aopLogs = new List(); + List excLogs = new List(); + List sqlLogs = new List(); + List reqresLogs = new List(); + + try + { + var aoplogContent = ReadLog(Path.Combine(_contentRoot, "Log"), "AOPLog_", Encoding.UTF8, ReadType.Prefix); + + if (!string.IsNullOrEmpty(aoplogContent)) + { + aopLogs = aoplogContent.Split("--------------------------------") + .Where(d => !string.IsNullOrEmpty(d) && d != "\n" && d != "\r\n") + .Select(d => new LogInfo + { + Datetime = d.Split("|")[0].ObjToDate(), + Content = d.Split("|")[1]?.Replace("\r\n", "
"), + LogColor = "AOP", + }).ToList(); + } + } + catch (Exception) { } + + try + { + var exclogContent = ReadLog(Path.Combine(_contentRoot, "Log"), $"GlobalExceptionLogs_{DateTime.Now.ToString("yyyMMdd")}.log", Encoding.UTF8); + + if (!string.IsNullOrEmpty(exclogContent)) + { + excLogs = exclogContent.Split("--------------------------------") + .Where(d => !string.IsNullOrEmpty(d) && d != "\n" && d != "\r\n") + .Select(d => new LogInfo + { + Datetime = (d.Split("|")[0]).Split(',')[0].ObjToDate(), + Content = d.Split("|")[1]?.Replace("\r\n", "
"), + LogColor = "EXC", + Import = 9, + }).ToList(); + } + } + catch (Exception) { } + + + try + { + var sqllogContent = ReadLog(Path.Combine(_contentRoot, "Log"), "SqlLog_", Encoding.UTF8, ReadType.Prefix); + + if (!string.IsNullOrEmpty(sqllogContent)) + { + sqlLogs = sqllogContent.Split("--------------------------------") + .Where(d => !string.IsNullOrEmpty(d) && d != "\n" && d != "\r\n") + .Select(d => new LogInfo + { + Datetime = d.Split("|")[0].ObjToDate(), + Content = d.Split("|")[1]?.Replace("\r\n", "
"), + LogColor = "SQL", + }).ToList(); + } + } + catch (Exception) { } + + //try + //{ + // reqresLogs = ReadLog(Path.Combine(_contentRoot, "Log", "RequestResponseLog.log"), Encoding.UTF8)? + // .Split("--------------------------------") + // .Where(d => !string.IsNullOrEmpty(d) && d != "\n" && d != "\r\n") + // .Select(d => new LogInfo + // { + // Datetime = d.Split("|")[0].ObjToDate(), + // Content = d.Split("|")[1]?.Replace("\r\n", "
"), + // LogColor = "ReqRes", + // }).ToList(); + //} + //catch (Exception) + //{ + //} + + try + { + var Logs = JsonConvert.DeserializeObject>("[" + ReadLog(Path.Combine(_contentRoot, "Log"), "RequestIpInfoLog_", Encoding.UTF8, ReadType.Prefix) + "]"); + + Logs = Logs.Where(d => d.Datetime.ObjToDate() >= DateTime.Today).ToList(); + + reqresLogs = Logs.Select(d => new LogInfo + { + Datetime = d.Datetime.ObjToDate(), + Content = $"IP:{d.Ip}
{d.Url}", + LogColor = "ReqRes", + }).ToList(); + } + catch (Exception) + { + } + + if (excLogs != null) + { + aopLogs.AddRange(excLogs); + } + if (sqlLogs != null) + { + aopLogs.AddRange(sqlLogs); + } + if (reqresLogs != null) + { + aopLogs.AddRange(reqresLogs); + } + aopLogs = aopLogs.OrderByDescending(d => d.Import).ThenByDescending(d => d.Datetime).Take(100).ToList(); + + return aopLogs; + } + + + public static RequestApiWeekView RequestApiinfoByWeek() + { + List Logs = new List(); + List apiWeeks = new List(); + string apiWeeksJson = string.Empty; + List columns = new List(); + columns.Add("日期"); + + + try + { + Logs = JsonConvert.DeserializeObject>("[" + ReadLog(Path.Combine(_contentRoot, "Log"), "RequestIpInfoLog_", Encoding.UTF8, ReadType.Prefix) + "]"); + + var ddd = Logs.Where(d => d.Week == "周日").ToList(); + + apiWeeks = (from n in Logs + group n by new { n.Week, n.Url } into g + select new ApiWeek + { + week = g.Key.Week, + url = g.Key.Url, + count = g.Count(), + }).ToList(); + + //apiWeeks = apiWeeks.OrderByDescending(d => d.count).Take(8).ToList(); + + } + catch (Exception) + { + } + + StringBuilder jsonBuilder = new StringBuilder(); + jsonBuilder.Append("["); + + var weeks = apiWeeks.GroupBy(x => new { x.week }).Select(s => s.First()).ToList(); + foreach (var week in weeks) + { + var apiweeksCurrentWeek = apiWeeks.Where(d => d.week == week.week).OrderByDescending(d => d.count).Take(8).ToList(); + jsonBuilder.Append("{"); + + jsonBuilder.Append("\""); + jsonBuilder.Append("日期"); + jsonBuilder.Append("\":\""); + jsonBuilder.Append(week.week); + jsonBuilder.Append("\","); + + foreach (var item in apiweeksCurrentWeek) + { + jsonBuilder.Append("\""); + jsonBuilder.Append(item.url); + jsonBuilder.Append("\":\""); + jsonBuilder.Append(item.count); + jsonBuilder.Append("\","); + } + jsonBuilder.Remove(jsonBuilder.Length - 1, 1); + jsonBuilder.Append("},"); + } + + jsonBuilder.Remove(jsonBuilder.Length - 1, 1); + jsonBuilder.Append("]"); + + columns.AddRange(apiWeeks.OrderByDescending(d => d.count).Take(8).Select(d => d.url).ToList()); + + return new RequestApiWeekView() + { + columns = columns, + rows = jsonBuilder.ToString(), + }; + } + + public static AccessApiDateView AccessApiByDate() + { + List Logs = new List(); + List apiDates = new List(); + try + { + Logs = JsonConvert.DeserializeObject>("[" + ReadLog(Path.Combine(_contentRoot, "Log"), "RequestIpInfoLog_", Encoding.UTF8, ReadType.Prefix) + "]"); + + apiDates = (from n in Logs + group n by new { n.Date } into g + select new ApiDate + { + date = g.Key.Date, + count = g.Count(), + }).ToList(); + + apiDates = apiDates.OrderByDescending(d => d.date).Take(7).ToList(); + + } + catch (Exception) + { + } + + return new AccessApiDateView() + { + columns = new string[] { "date", "count" }, + rows = apiDates.OrderBy(d => d.date).ToList(), + }; + } + + public static AccessApiDateView AccessApiByHour() + { + List Logs = new List(); + List apiDates = new List(); + try + { + Logs = JsonConvert.DeserializeObject>("[" + ReadLog(Path.Combine(_contentRoot, "Log"), "RequestIpInfoLog_", Encoding.UTF8, ReadType.Prefix) + "]"); + + apiDates = (from n in Logs + where n.Datetime.ObjToDate() >= DateTime.Today + group n by new { hour = n.Datetime.ObjToDate().Hour } into g + select new ApiDate + { + date = g.Key.hour.ToString("00"), + count = g.Count(), + }).ToList(); + + apiDates = apiDates.OrderBy(d => d.date).Take(24).ToList(); + + } + catch (Exception) + { + } + + return new AccessApiDateView() + { + columns = new string[] { "date", "count" }, + rows = apiDates, + }; + } + } + + public enum ReadType + { + Accurate, + Prefix + } + +} diff --git a/New_College.Common/LogHelper/RequestInfo.cs b/New_College.Common/LogHelper/RequestInfo.cs new file mode 100644 index 0000000..88cad20 --- /dev/null +++ b/New_College.Common/LogHelper/RequestInfo.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; + +namespace New_College.Common.LogHelper +{ + public class ApiWeek + { + public string week { get; set; } + public string url { get; set; } + public int count { get; set; } + } + public class ApiDate + { + public string date { get; set; } + public int count { get; set; } + } + + public class RequestApiWeekView + { + public List columns { get; set; } + public string rows { get; set; } + } + public class AccessApiDateView + { + public string[] columns { get; set; } + public List rows { get; set; } + } + public class RequestInfo + { + public string Ip { get; set; } + public string Url { get; set; } + public string Datetime { get; set; } + public string Date { get; set; } + public string Week { get; set; } + + } +} diff --git a/New_College.Common/LogHelper/Seri/SerilogServer.cs b/New_College.Common/LogHelper/Seri/SerilogServer.cs new file mode 100644 index 0000000..37e53de --- /dev/null +++ b/New_College.Common/LogHelper/Seri/SerilogServer.cs @@ -0,0 +1,56 @@ +using Serilog; +using Serilog.Events; +using System; +using System.IO; + +namespace New_College.Common.LogHelper +{ + public class SerilogServer + { + /// + /// 记录日常日志 + /// + /// + /// + /// + public static void WriteLog(string filename, string[] dataParas, bool IsHeader = true) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .MinimumLevel.Override("Microsoft", LogEventLevel.Error) + //.WriteTo.File(Path.Combine($"log/Serilog/{filename}/", ".log"), rollingInterval: RollingInterval.Day, outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level}] {Message}{NewLine}{Exception}") + .WriteTo.File(Path.Combine($"log/Serilog/", $"{filename}.log"), rollingInterval: RollingInterval.Infinite, outputTemplate: "{Message}{NewLine}{Exception}") + .CreateLogger(); + + var now = DateTime.Now; + string logContent = String.Join("\r\n", dataParas); + if (IsHeader) + { + logContent = ( + "--------------------------------\r\n" + + DateTime.Now + "|\r\n" + + String.Join("\r\n", dataParas) + "\r\n" + ); + } + + Log.Information(logContent); + Log.CloseAndFlush(); + } + /// + /// 记录异常日志 + /// + /// + /// + /// + public static void WriteErrorLog(string filename, string message, Exception ex) + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .MinimumLevel.Override("Microsoft", LogEventLevel.Error) + .WriteTo.File(Path.Combine($"log/Error/{filename}/", ".txt"), rollingInterval: RollingInterval.Day) + .CreateLogger(); + Log.Error(ex, message); + Log.CloseAndFlush(); + } + } +} \ No newline at end of file diff --git a/New_College.Common/MemoryCache/ICachingProvider.cs b/New_College.Common/MemoryCache/ICachingProvider.cs new file mode 100644 index 0000000..0aef069 --- /dev/null +++ b/New_College.Common/MemoryCache/ICachingProvider.cs @@ -0,0 +1,12 @@ +namespace New_College.Common.MemoryCache +{ + /// + /// 简单的缓存接口,只有查询和添加,以后会进行扩展 + /// + public interface ICaching + { + object Get(string cacheKey); + + void Set(string cacheKey, object cacheValue); + } +} diff --git a/New_College.Common/MemoryCache/MemoryCaching.cs b/New_College.Common/MemoryCache/MemoryCaching.cs new file mode 100644 index 0000000..1571fff --- /dev/null +++ b/New_College.Common/MemoryCache/MemoryCaching.cs @@ -0,0 +1,30 @@ +using Microsoft.Extensions.Caching.Memory; +using System; + +namespace New_College.Common.MemoryCache +{ + /// + /// 实例化缓存接口ICaching + /// + public class MemoryCaching : ICaching + { + //引用Microsoft.Extensions.Caching.Memory;这个和.net 还是不一样,没有了Httpruntime了 + private readonly IMemoryCache _cache; + //还是通过构造函数的方法,获取 + public MemoryCaching(IMemoryCache cache) + { + _cache = cache; + } + + public object Get(string cacheKey) + { + return _cache.Get(cacheKey); + } + + public void Set(string cacheKey, object cacheValue) + { + _cache.Set(cacheKey, cacheValue, TimeSpan.FromSeconds(7200)); + } + } + +} diff --git a/New_College.Common/New_College.Common.csproj b/New_College.Common/New_College.Common.csproj new file mode 100644 index 0000000..11f3140 --- /dev/null +++ b/New_College.Common/New_College.Common.csproj @@ -0,0 +1,34 @@ + + + + netcoreapp3.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/New_College.Common/Redis/IRedisCacheManager.cs b/New_College.Common/Redis/IRedisCacheManager.cs new file mode 100644 index 0000000..11d955e --- /dev/null +++ b/New_College.Common/Redis/IRedisCacheManager.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Common +{ + /// + /// Redis缓存接口 + /// + public interface IRedisCacheManager + { + + //获取 Reids 缓存值 + string GetValue(string key); + + //获取值,并序列化 + TEntity Get(string key); + + //保存 + void Set(string key, object value, TimeSpan cacheTime); + + //判断是否存在 + bool Get(string key); + + //移除某一个缓存值 + void Remove(string key); + + //全部清除 + void Clear(); + } +} diff --git a/New_College.Common/Redis/RedisCacheManager.cs b/New_College.Common/Redis/RedisCacheManager.cs new file mode 100644 index 0000000..8c734f1 --- /dev/null +++ b/New_College.Common/Redis/RedisCacheManager.cs @@ -0,0 +1,158 @@ +using StackExchange.Redis; +using System; + +namespace New_College.Common +{ + public class RedisCacheManager : IRedisCacheManager + { + + private readonly string redisConnenctionString; + private readonly string Password; + + public volatile ConnectionMultiplexer redisConnection; + + private readonly object redisConnectionLock = new object(); + + public RedisCacheManager() + { + string redisConfiguration = Appsettings.app(new string[] { "AppSettings", "RedisCachingAOP", "ConnectionString" });//获取连接字符串 + + if (string.IsNullOrWhiteSpace(redisConfiguration)) + { + throw new ArgumentException("redis config is empty", nameof(redisConfiguration)); + } + this.redisConnenctionString = redisConfiguration; + this.Password = Appsettings.app(new string[] { "AppSettings", "RedisCachingAOP", "Password" }); ; + this.redisConnection = GetRedisConnection(); + } + + /// + /// 核心代码,获取连接实例 + /// 通过双if 夹lock的方式,实现单例模式 + /// + /// + private ConnectionMultiplexer GetRedisConnection() + { + //如果已经连接实例,直接返回 + if (this.redisConnection != null && this.redisConnection.IsConnected) + { + return this.redisConnection; + } + //加锁,防止异步编程中,出现单例无效的问题 + lock (redisConnectionLock) + { + if (this.redisConnection != null) + { + //释放redis连接 + this.redisConnection.Dispose(); + } + try + { + var config = new ConfigurationOptions + { + AbortOnConnectFail = false, + AllowAdmin = true, + ConnectTimeout = 15000,//改成15s + SyncTimeout = 5000, + Password = Password ,//Redis数据库密码 + EndPoints = { redisConnenctionString }// connectionString 为IP:Port 如”192.168.2.110:6379” + }; + this.redisConnection = ConnectionMultiplexer.Connect(config); + } + catch (Exception) + { + throw new Exception("Redis服务未启用,请开启该服务,并且请注意端口号,本项目使用的的6319,而且我的是没有设置密码。"); + } + } + return this.redisConnection; + } + /// + /// 清除 + /// + public void Clear() + { + foreach (var endPoint in this.GetRedisConnection().GetEndPoints()) + { + var server = this.GetRedisConnection().GetServer(endPoint); + foreach (var key in server.Keys()) + { + redisConnection.GetDatabase().KeyDelete(key); + } + } + } + /// + /// 判断是否存在 + /// + /// + /// + public bool Get(string key) + { + return redisConnection.GetDatabase().KeyExists(key); + } + + /// + /// 查询 + /// + /// + /// + public string GetValue(string key) + { + return redisConnection.GetDatabase().StringGet(key); + } + + /// + /// 获取 + /// + /// + /// + /// + public TEntity Get(string key) + { + var value = redisConnection.GetDatabase().StringGet(key); + if (value.HasValue) + { + //需要用的反序列化,将Redis存储的Byte[],进行反序列化 + return SerializeHelper.Deserialize(value); + } + else + { + return default(TEntity); + } + } + + /// + /// 移除 + /// + /// + public void Remove(string key) + { + redisConnection.GetDatabase().KeyDelete(key); + } + /// + /// 设置 + /// + /// + /// + /// + public void Set(string key, object value, TimeSpan cacheTime) + { + if (value != null) + { + //序列化,将object值生成RedisValue + redisConnection.GetDatabase().StringSet(key, SerializeHelper.Serialize(value), cacheTime); + } + } + + /// + /// 增加/修改 + /// + /// + /// + /// + public bool SetValue(string key, byte[] value) + { + return redisConnection.GetDatabase().StringSet(key, value, TimeSpan.FromSeconds(120)); + } + + } +} diff --git a/New_College.ConsoleApp/New_College.ConsoleApp.csproj b/New_College.ConsoleApp/New_College.ConsoleApp.csproj new file mode 100644 index 0000000..c73e0d1 --- /dev/null +++ b/New_College.ConsoleApp/New_College.ConsoleApp.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/New_College.ConsoleApp/Program.cs b/New_College.ConsoleApp/Program.cs new file mode 100644 index 0000000..3dbc7a2 --- /dev/null +++ b/New_College.ConsoleApp/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace New_College.ConsoleApp +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/New_College.Extensions/AOP/BlogCacheAOP.cs b/New_College.Extensions/AOP/BlogCacheAOP.cs new file mode 100644 index 0000000..56233c4 --- /dev/null +++ b/New_College.Extensions/AOP/BlogCacheAOP.cs @@ -0,0 +1,53 @@ +using New_College.Common; +using New_College.Common.MemoryCache; +using Castle.DynamicProxy; +using System.Linq; + +namespace New_College.AOP +{ + /// + /// 面向切面的缓存使用 + /// + public class BlogCacheAOP : CacheAOPbase + { + //通过注入的方式,把缓存操作接口通过构造函数注入 + private readonly ICaching _cache; + public BlogCacheAOP(ICaching cache) + { + _cache = cache; + } + + //Intercept方法是拦截的关键所在,也是IInterceptor接口中的唯一定义 + public override void Intercept(IInvocation invocation) + { + var method = invocation.MethodInvocationTarget ?? invocation.Method; + //对当前方法的特性验证 + //如果需要验证 + if (method.GetCustomAttributes(true).FirstOrDefault(x => x.GetType() == typeof(CachingAttribute)) is CachingAttribute qCachingAttribute) + { + //获取自定义缓存键 + var cacheKey = CustomCacheKey(invocation); + //根据key获取相应的缓存值 + var cacheValue = _cache.Get(cacheKey); + if (cacheValue != null) + { + //将当前获取到的缓存值,赋值给当前执行方法 + invocation.ReturnValue = cacheValue; + return; + } + //去执行当前的方法 + invocation.Proceed(); + //存入缓存 + if (!string.IsNullOrWhiteSpace(cacheKey)) + { + _cache.Set(cacheKey, invocation.ReturnValue); + } + } + else + { + invocation.Proceed();//直接执行被拦截方法 + } + } + } + +} diff --git a/New_College.Extensions/AOP/BlogLogAOP.cs b/New_College.Extensions/AOP/BlogLogAOP.cs new file mode 100644 index 0000000..bb50515 --- /dev/null +++ b/New_College.Extensions/AOP/BlogLogAOP.cs @@ -0,0 +1,222 @@ +using New_College.Common.LogHelper; +using New_College.Hubs; +using Castle.DynamicProxy; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.SignalR; +using Newtonsoft.Json; +using StackExchange.Profiling; +using System; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; + +namespace New_College.AOP +{ + /// + /// 拦截器BlogLogAOP 继承IInterceptor接口 + /// + public class BlogLogAOP : IInterceptor + { + private readonly IHubContext _hubContext; + private readonly IHttpContextAccessor _accessor; + + public BlogLogAOP(IHubContext hubContext, IHttpContextAccessor accessor) + { + _hubContext = hubContext; + _accessor = accessor; + } + + + /// + /// 实例化IInterceptor唯一方法 + /// + /// 包含被拦截方法的信息 + public void Intercept(IInvocation invocation) + { + string NickName = _accessor.HttpContext?.User?.Identity?.Name; + + //记录被拦截方法信息的日志信息 + var dataIntercept = "" + + $"【当前操作用户】:{ NickName} \r\n" + + $"【当前执行方法】:{ invocation.Method.Name} \r\n" + + $"【携带的参数有】: {string.Join(", ", invocation.Arguments.Select(a => (a ?? "").ToString()).ToArray())} \r\n"; + + try + { + MiniProfiler.Current.Step($"执行Service方法:{invocation.Method.Name}() -> "); + //在被拦截的方法执行完毕后 继续执行当前方法,注意是被拦截的是异步的 + invocation.Proceed(); + + + // 异步获取异常,先执行 + if (IsAsyncMethod(invocation.Method)) + { + + #region 方案一 + //Wait task execution and modify return value + if (invocation.Method.ReturnType == typeof(Task)) + { + invocation.ReturnValue = InternalAsyncHelper.AwaitTaskWithPostActionAndFinally( + (Task)invocation.ReturnValue, + async () => await SuccessAction(invocation, dataIntercept),/*成功时执行*/ + ex => + { + LogEx(ex, dataIntercept); + }); + } + //Task + else + { + invocation.ReturnValue = InternalAsyncHelper.CallAwaitTaskWithPostActionAndFinallyAndGetResult( + invocation.Method.ReturnType.GenericTypeArguments[0], + invocation.ReturnValue, + //async () => await SuccessAction(invocation, dataIntercept),/*成功时执行*/ + async (o) => await SuccessAction(invocation, dataIntercept, o),/*成功时执行*/ + ex => + { + LogEx(ex, dataIntercept); + }); + } + #endregion + + + // 如果方案一不行,试试这个方案 + #region 方案二 + + //var type = invocation.Method.ReturnType; + //var resultProperty = type.GetProperty("Result"); + //dataIntercept += ($"【执行完成结果】:{JsonConvert.SerializeObject(resultProperty.GetValue(invocation.ReturnValue))}"); + + //Parallel.For(0, 1, e => + //{ + // LogLock.OutSql2Log("AOPLog", new string[] { dataIntercept }); + //}); + + #endregion + } + else + {// 同步1 + + dataIntercept += ($"【执行完成结果】:{invocation.ReturnValue}"); + Parallel.For(0, 1, e => + { + LogLock.OutSql2Log("AOPLog", new string[] { dataIntercept }); + }); + } + } + catch (Exception ex)// 同步2 + { + LogEx(ex, dataIntercept); + + } + + _hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()).Wait(); + } + + private async Task SuccessAction(IInvocation invocation, string dataIntercept, object o = null) + { + //invocation.ReturnValue = o; + //var type = invocation.Method.ReturnType; + //if (typeof(Task).IsAssignableFrom(type)) + //{ + // //var resultProperty = type.GetProperty("Result"); + // //类型错误 都可以不要invocation参数,直接将o系列化保存到日记中 + // dataIntercept += ($"【执行完成结果】:{JsonConvert.SerializeObject(invocation.ReturnValue)}"); + //} + //else + //{ + // dataIntercept += ($"【执行完成结果】:{invocation.ReturnValue}"); + //} + + dataIntercept += ($"【执行完成结果】:{JsonConvert.SerializeObject(o)}"); + + + await Task.Run(() => + { + Parallel.For(0, 1, e => + { + LogLock.OutSql2Log("AOPLog", new string[] { dataIntercept }); + }); + }); + } + + private void LogEx(Exception ex, string dataIntercept) + { + if (ex != null) + { + //执行的 service 中,收录异常 + MiniProfiler.Current.CustomTiming("Errors:", ex.Message); + //执行的 service 中,捕获异常 + dataIntercept += ($"【执行完成结果】:方法中出现异常:{ex.Message + ex.InnerException}\r\n"); + + // 异常日志里有详细的堆栈信息 + Parallel.For(0, 1, e => + { + LogLock.OutSql2Log("AOPLog", new string[] { dataIntercept }); + }); + } + } + + + public static bool IsAsyncMethod(MethodInfo method) + { + return ( + method.ReturnType == typeof(Task) || + (method.ReturnType.IsGenericType && method.ReturnType.GetGenericTypeDefinition() == typeof(Task<>)) + ); + } + + } + + + internal static class InternalAsyncHelper + { + public static async Task AwaitTaskWithPostActionAndFinally(Task actualReturnValue, Func postAction, Action finalAction) + { + Exception exception = null; + + try + { + await actualReturnValue; + await postAction(); + } + catch (Exception ex) + { + exception = ex; + } + finally + { + finalAction(exception); + } + } + + public static async Task AwaitTaskWithPostActionAndFinallyAndGetResult(Task actualReturnValue, Func postAction, Action finalAction) + { + Exception exception = null; + try + { + var result = await actualReturnValue; + await postAction(result); + return result; + } + catch (Exception ex) + { + exception = ex; + throw; + } + finally + { + finalAction(exception); + } + } + + public static object CallAwaitTaskWithPostActionAndFinallyAndGetResult(Type taskReturnType, object actualReturnValue, Func action, Action finalAction) + { + return typeof(InternalAsyncHelper) + .GetMethod("AwaitTaskWithPostActionAndFinallyAndGetResult", BindingFlags.Public | BindingFlags.Static) + .MakeGenericMethod(taskReturnType) + .Invoke(null, new object[] { actualReturnValue, action, finalAction }); + } + } + +} diff --git a/New_College.Extensions/AOP/BlogRedisCacheAOP.cs b/New_College.Extensions/AOP/BlogRedisCacheAOP.cs new file mode 100644 index 0000000..8409d5f --- /dev/null +++ b/New_College.Extensions/AOP/BlogRedisCacheAOP.cs @@ -0,0 +1,88 @@ +using New_College.Common; +using Castle.DynamicProxy; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace New_College.AOP +{ + /// + /// 面向切面的缓存使用 + /// + public class BlogRedisCacheAOP : CacheAOPbase + { + //通过注入的方式,把缓存操作接口通过构造函数注入 + private readonly IRedisCacheManager _cache; + public BlogRedisCacheAOP(IRedisCacheManager cache) + { + _cache = cache; + } + + //Intercept方法是拦截的关键所在,也是IInterceptor接口中的唯一定义 + //代码已经合并 ,学习pr流程 + public override void Intercept(IInvocation invocation) + { + var method = invocation.MethodInvocationTarget ?? invocation.Method; + if (method.ReturnType == typeof(void) || method.ReturnType == typeof(Task)) + { + invocation.Proceed(); + return; + } + //对当前方法的特性验证 + var qCachingAttribute = method.GetCustomAttributes(true).FirstOrDefault(x => x.GetType() == typeof(CachingAttribute)) as CachingAttribute; + + if (qCachingAttribute != null) + { + //获取自定义缓存键 + var cacheKey = CustomCacheKey(invocation); + //注意是 string 类型,方法GetValue + var cacheValue = _cache.GetValue(cacheKey); + if (cacheValue != null) + { + //将当前获取到的缓存值,赋值给当前执行方法 + Type returnType; + if (typeof(Task).IsAssignableFrom(method.ReturnType)) + { + returnType = method.ReturnType.GenericTypeArguments.FirstOrDefault(); + } + else + { + returnType = method.ReturnType; + } + + dynamic _result = Newtonsoft.Json.JsonConvert.DeserializeObject(cacheValue, returnType); + invocation.ReturnValue = (typeof(Task).IsAssignableFrom(method.ReturnType)) ? Task.FromResult(_result) : _result; + return; + } + //去执行当前的方法 + invocation.Proceed(); + + //存入缓存 + if (!string.IsNullOrWhiteSpace(cacheKey)) + { + object response; + + //Type type = invocation.ReturnValue?.GetType(); + var type = invocation.Method.ReturnType; + if (typeof(Task).IsAssignableFrom(type)) + { + var resultProperty = type.GetProperty("Result"); + response = resultProperty.GetValue(invocation.ReturnValue); + } + else + { + response = invocation.ReturnValue; + } + if (response == null) response = string.Empty; + + _cache.Set(cacheKey, response, TimeSpan.FromMinutes(qCachingAttribute.AbsoluteExpiration)); + } + } + else + { + invocation.Proceed();//直接执行被拦截方法 + } + } + } + +} diff --git a/New_College.Extensions/AOP/BlogTranAOP.cs b/New_College.Extensions/AOP/BlogTranAOP.cs new file mode 100644 index 0000000..0a865a1 --- /dev/null +++ b/New_College.Extensions/AOP/BlogTranAOP.cs @@ -0,0 +1,91 @@ +using New_College.Common; +using New_College.IRepository.UnitOfWork; +using Castle.DynamicProxy; +using System; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; + +namespace New_College.AOP +{ + /// + /// 事务拦截器BlogTranAOP 继承IInterceptor接口 + /// + public class BlogTranAOP : IInterceptor + { + private readonly IUnitOfWork _unitOfWork; + public BlogTranAOP(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + } + + /// + /// 实例化IInterceptor唯一方法 + /// + /// 包含被拦截方法的信息 + public void Intercept(IInvocation invocation) + { + var method = invocation.MethodInvocationTarget ?? invocation.Method; + //对当前方法的特性验证 + //如果需要验证 + if (method.GetCustomAttributes(true).FirstOrDefault(x => x.GetType() == typeof(UseTranAttribute)) is UseTranAttribute) + { + try + { + Console.WriteLine($"Begin Transaction"); + + _unitOfWork.BeginTran(); + + invocation.Proceed(); + + + // 异步获取异常,先执行 + if (IsAsyncMethod(invocation.Method)) + { + var result = invocation.ReturnValue; + if (result is Task) + { + Task.WaitAll(result as Task); + } + } + _unitOfWork.CommitTran(); + + } + catch (Exception) + { + Console.WriteLine($"Rollback Transaction"); + _unitOfWork.RollbackTran(); + } + } + else + { + invocation.Proceed();//直接执行被拦截方法 + } + + } + + private async Task SuccessAction(IInvocation invocation) + { + await Task.Run(() => + { + //... + }); + } + + public static bool IsAsyncMethod(MethodInfo method) + { + return ( + method.ReturnType == typeof(Task) || + (method.ReturnType.IsGenericType && method.ReturnType.GetGenericTypeDefinition() == typeof(Task<>)) + ); + } + private async Task TestActionAsync(IInvocation invocation) + { + await Task.Run(null); + } + + } + + + +} diff --git a/New_College.Extensions/AOP/BlogUserAuditAOP.cs b/New_College.Extensions/AOP/BlogUserAuditAOP.cs new file mode 100644 index 0000000..97d916d --- /dev/null +++ b/New_College.Extensions/AOP/BlogUserAuditAOP.cs @@ -0,0 +1,69 @@ +using Castle.DynamicProxy; +using Microsoft.AspNetCore.Http; +using System; + +namespace New_College.AOP +{ + /// + /// 面向切面的缓存使用 + /// + public class BlogUserAuditAOP : CacheAOPbase + { + private readonly IHttpContextAccessor _accessor; + + public BlogUserAuditAOP(IHttpContextAccessor accessor) + { + _accessor = accessor; + } + + public override void Intercept(IInvocation invocation) + { + string NickName = _accessor.HttpContext?.User?.Identity?.Name; + + //对当前方法的特性验证 + if (invocation.Method.Name?.ToLower() == "add" || invocation.Method.Name?.ToLower() == "update") + { + + if (invocation.Arguments.Length == 1) + { + if (invocation.Arguments[0].GetType().IsClass) + { + dynamic argModel = invocation.Arguments[0]; + var getType = argModel.GetType(); + if (invocation.Method.Name?.ToLower() == "add") + { + if (getType.GetProperty("CreateBy") != null) + { + argModel.CreateBy = NickName; + } + if (getType.GetProperty("bCreateTime") != null) + { + argModel.bCreateTime = DateTime.Now; + } + } + if (getType.GetProperty("bUpdateTime") != null) + { + argModel.bUpdateTime = DateTime.Now; + } + if (getType.GetProperty("ModifyBy") != null) + { + argModel.ModifyBy = NickName; + } + if (getType.GetProperty("bsubmitter") != null) + { + argModel.bsubmitter = NickName; + } + + invocation.Arguments[0] = argModel; + } + } + invocation.Proceed(); + } + else + { + invocation.Proceed(); + } + } + } + +} diff --git a/New_College.Extensions/AOP/CacheAOPbase.cs b/New_College.Extensions/AOP/CacheAOPbase.cs new file mode 100644 index 0000000..a800782 --- /dev/null +++ b/New_College.Extensions/AOP/CacheAOPbase.cs @@ -0,0 +1,224 @@ +using Castle.DynamicProxy; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; + +namespace New_College.AOP +{ + public abstract class CacheAOPbase : IInterceptor + { + /// + /// AOP的拦截方法 + /// + /// + public abstract void Intercept(IInvocation invocation); + + /// + /// 自定义缓存的key + /// + /// + /// + protected string CustomCacheKey(IInvocation invocation) + { + var typeName = invocation.TargetType.Name; + var methodName = invocation.Method.Name; + var methodArguments = invocation.Arguments.Select(GetArgumentValue).Take(3).ToList();//获取参数列表,最多三个 + + string key = $"{typeName}:{methodName}:"; + foreach (var param in methodArguments) + { + key = $"{key}{param}:"; + } + + return key.TrimEnd(':'); + } + + /// + /// object 转 string + /// + /// + /// + protected static string GetArgumentValue(object arg) + { + if (arg is DateTime || arg is DateTime?) + return ((DateTime)arg).ToString("yyyyMMddHHmmss"); + + if (arg is string || arg is ValueType || arg is Nullable) + return arg.ToString(); + + if (arg != null) + { + if (arg is Expression) + { + var obj = arg as Expression; + var result = Resolve(obj); + return Common.Helper.MD5Helper.MD5Encrypt16(result); + } + else if (arg.GetType().IsClass) + { + return Common.Helper.MD5Helper.MD5Encrypt16(Newtonsoft.Json.JsonConvert.SerializeObject(arg)); + } + } + return string.Empty; + } + + private static string Resolve(Expression expression) + { + if (expression is LambdaExpression) + { + LambdaExpression lambda = expression as LambdaExpression; + expression = lambda.Body; + return Resolve(expression); + } + if (expression is BinaryExpression) + { + BinaryExpression binary = expression as BinaryExpression; + if (binary.Left is MemberExpression && binary.Right is ConstantExpression)//解析x=>x.Name=="123" x.Age==123这类 + return ResolveFunc(binary.Left, binary.Right, binary.NodeType); + if (binary.Left is MethodCallExpression && binary.Right is ConstantExpression)//解析x=>x.Name.Contains("xxx")==false这类的 + { + object value = (binary.Right as ConstantExpression).Value; + return ResolveLinqToObject(binary.Left, value, binary.NodeType); + } + if ((binary.Left is MemberExpression && binary.Right is MemberExpression) + || (binary.Left is MemberExpression && binary.Right is UnaryExpression))//解析x=>x.Date==DateTime.Now这种 + { + LambdaExpression lambda = Expression.Lambda(binary.Right); + Delegate fn = lambda.Compile(); + ConstantExpression value = Expression.Constant(fn.DynamicInvoke(null), binary.Right.Type); + return ResolveFunc(binary.Left, value, binary.NodeType); + } + } + if (expression is UnaryExpression) + { + UnaryExpression unary = expression as UnaryExpression; + if (unary.Operand is MethodCallExpression)//解析!x=>x.Name.Contains("xxx")或!array.Contains(x.Name)这类 + return ResolveLinqToObject(unary.Operand, false); + if (unary.Operand is MemberExpression && unary.NodeType == ExpressionType.Not)//解析x=>!x.isDeletion这样的 + { + ConstantExpression constant = Expression.Constant(false); + return ResolveFunc(unary.Operand, constant, ExpressionType.Equal); + } + } + if (expression is MemberExpression && expression.NodeType == ExpressionType.MemberAccess)//解析x=>x.isDeletion这样的 + { + MemberExpression member = expression as MemberExpression; + ConstantExpression constant = Expression.Constant(true); + return ResolveFunc(member, constant, ExpressionType.Equal); + } + if (expression is MethodCallExpression)//x=>x.Name.Contains("xxx")或array.Contains(x.Name)这类 + { + MethodCallExpression methodcall = expression as MethodCallExpression; + return ResolveLinqToObject(methodcall, true); + } + var body = expression as BinaryExpression; + //已经修改过代码body应该不会是null值了 + if (body == null) + return string.Empty; + var Operator = GetOperator(body.NodeType); + var Left = Resolve(body.Left); + var Right = Resolve(body.Right); + string Result = string.Format("({0} {1} {2})", Left, Operator, Right); + return Result; + } + + private static string GetOperator(ExpressionType expressiontype) + { + switch (expressiontype) + { + case ExpressionType.And: + return "and"; + case ExpressionType.AndAlso: + return "and"; + case ExpressionType.Or: + return "or"; + case ExpressionType.OrElse: + return "or"; + case ExpressionType.Equal: + return "="; + case ExpressionType.NotEqual: + return "<>"; + case ExpressionType.LessThan: + return "<"; + case ExpressionType.LessThanOrEqual: + return "<="; + case ExpressionType.GreaterThan: + return ">"; + case ExpressionType.GreaterThanOrEqual: + return ">="; + default: + throw new Exception(string.Format("不支持{0}此种运算符查找!" + expressiontype)); + } + } + + private static string ResolveFunc(Expression left, Expression right, ExpressionType expressiontype) + { + var Name = (left as MemberExpression).Member.Name; + var Value = (right as ConstantExpression).Value; + var Operator = GetOperator(expressiontype); + return Name + Operator + Value ?? "null"; + } + + private static string ResolveLinqToObject(Expression expression, object value, ExpressionType? expressiontype = null) + { + var MethodCall = expression as MethodCallExpression; + var MethodName = MethodCall.Method.Name; + switch (MethodName) + { + case "Contains": + if (MethodCall.Object != null) + return Like(MethodCall); + return In(MethodCall, value); + case "Count": + return Len(MethodCall, value, expressiontype.Value); + case "LongCount": + return Len(MethodCall, value, expressiontype.Value); + default: + throw new Exception(string.Format("不支持{0}方法的查找!", MethodName)); + } + } + + private static string In(MethodCallExpression expression, object isTrue) + { + var Argument1 = (expression.Arguments[0] as MemberExpression).Expression as ConstantExpression; + var Argument2 = expression.Arguments[1] as MemberExpression; + var Field_Array = Argument1.Value.GetType().GetFields().First(); + object[] Array = Field_Array.GetValue(Argument1.Value) as object[]; + List SetInPara = new List(); + for (int i = 0; i < Array.Length; i++) + { + string Name_para = "InParameter" + i; + string Value = Array[i].ToString(); + SetInPara.Add(Value); + } + string Name = Argument2.Member.Name; + string Operator = Convert.ToBoolean(isTrue) ? "in" : " not in"; + string CompName = string.Join(",", SetInPara); + string Result = string.Format("{0} {1} ({2})", Name, Operator, CompName); + return Result; + } + private static string Like(MethodCallExpression expression) + { + + var Temp = expression.Arguments[0]; + LambdaExpression lambda = Expression.Lambda(Temp); + Delegate fn = lambda.Compile(); + var tempValue = Expression.Constant(fn.DynamicInvoke(null), Temp.Type); + string Value = string.Format("%{0}%", tempValue); + string Name = (expression.Object as MemberExpression).Member.Name; + string Result = string.Format("{0} like {1}", Name, Value); + return Result; + } + + + private static string Len(MethodCallExpression expression, object value, ExpressionType expressiontype) + { + object Name = (expression.Arguments[0] as MemberExpression).Member.Name; + string Operator = GetOperator(expressiontype); + string Result = string.Format("len({0}){1}{2}", Name, Operator, value.ToString()); + return Result; + } + + } +} diff --git a/New_College.Extensions/Authorizations/OverWrite/JwtHelper.cs b/New_College.Extensions/Authorizations/OverWrite/JwtHelper.cs new file mode 100644 index 0000000..35f1544 --- /dev/null +++ b/New_College.Extensions/Authorizations/OverWrite/JwtHelper.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; +using System.Linq; +using System.Security.Claims; +using System.Text; +using New_College.Common; +using New_College.Common.AppConfig; +using Microsoft.IdentityModel.Tokens; + +namespace New_College.AuthHelper.OverWrite +{ + public class JwtHelper + { + + /// + /// 颁发JWT字符串 + /// + /// + /// + public static string IssueJwt(TokenModelJwt tokenModel) + { + string iss = Appsettings.app(new string[] { "Audience", "Issuer" }); + string aud = Appsettings.app(new string[] { "Audience", "Audience" }); + string secret = AppSecretConfig.Audience_Secret_String; + + //var claims = new Claim[] //old + var claims = new List + { + /* + * 特别重要: + 1、这里将用户的部分信息,比如 uid 存到了Claim 中,如果你想知道如何在其他地方将这个 uid从 Token 中取出来,请看下边的SerializeJwt() 方法,或者在整个解决方案,搜索这个方法,看哪里使用了! + 2、你也可以研究下 HttpContext.User.Claims ,具体的你可以看看 Policys/PermissionHandler.cs 类中是如何使用的。 + */ + + + + new Claim(JwtRegisteredClaimNames.Jti, tokenModel.Uid.ToString()), + new Claim(JwtRegisteredClaimNames.Iat, $"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}"), + new Claim(JwtRegisteredClaimNames.Nbf,$"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}") , + //这个就是过期时间,目前是过期1000秒,可自定义,注意JWT有自己的缓冲过期时间 + new Claim (JwtRegisteredClaimNames.Exp,$"{new DateTimeOffset(DateTime.Now.AddDays(7)).ToUnixTimeSeconds()}"), + new Claim(ClaimTypes.Expiration, DateTime.Now.AddDays(1000).ToString()), + new Claim(JwtRegisteredClaimNames.Iss,iss), + new Claim(JwtRegisteredClaimNames.Aud,aud), + + //new Claim(ClaimTypes.Role,tokenModel.Role),//为了解决一个用户多个角色(比如:Admin,System),用下边的方法 + }; + + // 可以将一个用户的多个角色全部赋予; + // 作者:DX 提供技术支持; + claims.AddRange(tokenModel.Role.Split(',').Select(s => new Claim(ClaimTypes.Role, s))); + + + + //秘钥 (SymmetricSecurityKey 对安全性的要求,密钥的长度太短会报出异常) + var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secret)); + var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); + + var jwt = new JwtSecurityToken( + issuer: iss, + claims: claims, + signingCredentials: creds); + + var jwtHandler = new JwtSecurityTokenHandler(); + var encodedJwt = jwtHandler.WriteToken(jwt); + + return encodedJwt; + } + + /// + /// 解析 + /// + /// + /// + public static TokenModelJwt SerializeJwt(string jwtStr) + { + var jwtHandler = new JwtSecurityTokenHandler(); + JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(jwtStr); + object role; + try + { + jwtToken.Payload.TryGetValue(ClaimTypes.Role, out role); + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } + var tm = new TokenModelJwt + { + Uid = (jwtToken.Id).ObjToInt(), + Role = role != null ? role.ObjToString() : "", + }; + return tm; + } + } + + /// + /// 令牌 + /// + public class TokenModelJwt + { + /// + /// Id + /// + public long Uid { get; set; } + /// + /// 角色 + /// + public string Role { get; set; } + /// + /// 职能 + /// + public string Work { get; set; } + + } +} diff --git a/New_College.Extensions/Authorizations/OverWrite/JwtTokenAuth.cs b/New_College.Extensions/Authorizations/OverWrite/JwtTokenAuth.cs new file mode 100644 index 0000000..9d5d398 --- /dev/null +++ b/New_College.Extensions/Authorizations/OverWrite/JwtTokenAuth.cs @@ -0,0 +1,92 @@ +using Microsoft.AspNetCore.Http; +using System; +using System.Threading.Tasks; +using New_College.AuthHelper.OverWrite; + +namespace New_College.AuthHelper +{ + /// + /// 中间件 + /// 原做为自定义授权中间件 + /// 先做检查 header token的使用 + /// + public class JwtTokenAuth + { + /// + /// + /// + private readonly RequestDelegate _next; + /// + /// + /// + /// + public JwtTokenAuth(RequestDelegate next) + { + _next = next; + } + + + private void PreProceed(HttpContext next) + { + //Console.WriteLine($"{DateTime.Now} middleware invoke preproceed"); + //... + } + private void PostProceed(HttpContext next) + { + //Console.WriteLine($"{DateTime.Now} middleware invoke postproceed"); + //.... + } + + /// + /// + /// + /// + /// + public Task Invoke(HttpContext httpContext) + { + PreProceed(httpContext); + + + //检测是否包含'Authorization'请求头 + if (!httpContext.Request.Headers.ContainsKey("Authorization")) + { + PostProceed(httpContext); + + return _next(httpContext); + } + //var tokenHeader = httpContext.Request.Headers["Authorization"].ToString(); + var tokenHeader = httpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", ""); + + try + { + if (tokenHeader.Length >= 128) + { + //Console.WriteLine($"{DateTime.Now} token :{tokenHeader}"); + TokenModelJwt tm = JwtHelper.SerializeJwt(tokenHeader); + + //授权 + //var claimList = new List(); + //var claim = new Claim(ClaimTypes.Role, tm.Role); + //claimList.Add(claim); + //var identity = new ClaimsIdentity(claimList); + //var principal = new ClaimsPrincipal(identity); + //httpContext.User = principal; + } + + } + catch (Exception e) + { + Console.WriteLine($"{DateTime.Now} middleware wrong:{e.Message}"); + } + + + PostProceed(httpContext); + + + return _next(httpContext); + } + + } + +} + diff --git a/New_College.Extensions/Authorizations/Policys/ApiResponse.cs b/New_College.Extensions/Authorizations/Policys/ApiResponse.cs new file mode 100644 index 0000000..960be61 --- /dev/null +++ b/New_College.Extensions/Authorizations/Policys/ApiResponse.cs @@ -0,0 +1,52 @@ +using New_College.Model; + +namespace New_College.AuthHelper.Policys +{ + public class ApiResponse + { + public int Status { get; set; } = 404; + public string Value { get; set; } = "No Found"; + public MessageModel MessageModel = new MessageModel() { }; + + public ApiResponse(StatusCode apiCode, string msg = null) + { + switch (apiCode) + { + case StatusCode.CODE401: + { + Status = 401; + Value = "很抱歉,您无权访问该接口,请确保已经登录!"; + } + break; + case StatusCode.CODE403: + { + Status = 403; + Value = "很抱歉,您的访问权限等级不够,联系管理员!"; + } + break; + case StatusCode.CODE500: + { + Status = 500; + Value = msg; + } + break; + } + + MessageModel = new MessageModel() + { + status = Status, + msg = Value, + success = false + }; + } + } + + public enum StatusCode + { + CODE401, + CODE403, + CODE404, + CODE500 + } + +} diff --git a/New_College.Extensions/Authorizations/Policys/ApiResponseHandler.cs b/New_College.Extensions/Authorizations/Policys/ApiResponseHandler.cs new file mode 100644 index 0000000..57a3dac --- /dev/null +++ b/New_College.Extensions/Authorizations/Policys/ApiResponseHandler.cs @@ -0,0 +1,38 @@ +using New_College.AuthHelper.Policys; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using System; +using System.Text.Encodings.Web; +using System.Threading.Tasks; + +namespace New_College.AuthHelper +{ + public class ApiResponseHandler : AuthenticationHandler + { + public ApiResponseHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + { + } + + protected override Task HandleAuthenticateAsync() + { + throw new NotImplementedException(); + } + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) + { + Response.ContentType = "application/json"; + Response.StatusCode = StatusCodes.Status401Unauthorized; + await Response.WriteAsync(JsonConvert.SerializeObject((new ApiResponse(StatusCode.CODE401)).MessageModel)); + } + + protected override async Task HandleForbiddenAsync(AuthenticationProperties properties) + { + Response.ContentType = "application/json"; + Response.StatusCode = StatusCodes.Status403Forbidden; + await Response.WriteAsync(JsonConvert.SerializeObject((new ApiResponse(StatusCode.CODE403)).MessageModel)); + } + + } +} diff --git a/New_College.Extensions/Authorizations/Policys/JwtToken.cs b/New_College.Extensions/Authorizations/Policys/JwtToken.cs new file mode 100644 index 0000000..65d0fc1 --- /dev/null +++ b/New_College.Extensions/Authorizations/Policys/JwtToken.cs @@ -0,0 +1,45 @@ +using New_College.Model.ViewModels; +using System; +using System.IdentityModel.Tokens.Jwt; +using System.Security.Claims; + +namespace New_College.AuthHelper +{ + /// + /// JWTToken生成类 + /// + public class JwtToken + { + /// + /// 获取基于JWT的Token + /// + /// 需要在登陆的时候配置 + /// 在startup中定义的参数 + /// + public static TokenInfoViewModel BuildJwtToken(Claim[] claims, PermissionRequirement permissionRequirement) + { + var now = DateTime.Now; + // 实例化JwtSecurityToken + var jwt = new JwtSecurityToken( + issuer: permissionRequirement.Issuer, + audience: permissionRequirement.Audience, + claims: claims, + notBefore: now, + expires: now.Add(permissionRequirement.Expiration), + signingCredentials: permissionRequirement.SigningCredentials + ); + // 生成 Token + var encodedJwt = new JwtSecurityTokenHandler().WriteToken(jwt); + + //打包返回前台 + var responseJson = new TokenInfoViewModel + { + success = true, + token = encodedJwt, + expires_in = permissionRequirement.Expiration.TotalSeconds, + token_type = "Bearer" + }; + return responseJson; + } + } +} diff --git a/New_College.Extensions/Authorizations/Policys/PermissionHandler.cs b/New_College.Extensions/Authorizations/Policys/PermissionHandler.cs new file mode 100644 index 0000000..c84fbeb --- /dev/null +++ b/New_College.Extensions/Authorizations/Policys/PermissionHandler.cs @@ -0,0 +1,193 @@ +using New_College.Common.Helper; +using New_College.IServices; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace New_College.AuthHelper +{ + /// + /// 权限授权处理器 + /// + public class PermissionHandler : AuthorizationHandler + { + /// + /// 验证方案提供对象 + /// + public IAuthenticationSchemeProvider Schemes { get; set; } + private readonly IRoleModulePermissionServices _roleModulePermissionServices; + private readonly IHttpContextAccessor _accessor; + + /// + /// 构造函数注入 + /// + /// + /// + /// + public PermissionHandler(IAuthenticationSchemeProvider schemes, IRoleModulePermissionServices roleModulePermissionServices, IHttpContextAccessor accessor) + { + _accessor = accessor; + Schemes = schemes; + _roleModulePermissionServices = roleModulePermissionServices; + } + + // 重写异步处理程序 + protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, PermissionRequirement requirement) + { + var httpContext = _accessor.HttpContext; + + // 获取系统中所有的角色和菜单的关系集合 + if (!requirement.Permissions.Any()) + { + var data = await _roleModulePermissionServices.RoleModuleMaps(); + var list = new List(); + // ids4和jwt切换 + // ids4 + if (Permissions.IsUseIds4) + { + list = (from item in data + where item.IsDeleted == false + orderby item.Id + select new PermissionItem + { + Url = item.Module?.LinkUrl, + Role = item.Role?.Id.ObjToString(), + }).ToList(); + } + // jwt + else + { + list = (from item in data + where item.IsDeleted == false + orderby item.Id + select new PermissionItem + { + Url = item.Module?.LinkUrl, + Role = item.Role?.Name.ObjToString(), + }).ToList(); + } + requirement.Permissions = list; + } + + if (httpContext != null) + { + var questUrl = httpContext.Request.Path.Value.ToLower(); + + // 整体结构类似认证中间件UseAuthentication的逻辑,具体查看开源地址 + // https://github.com/dotnet/aspnetcore/blob/master/src/Security/Authentication/Core/src/AuthenticationMiddleware.cs + httpContext.Features.Set(new AuthenticationFeature + { + OriginalPath = httpContext.Request.Path, + OriginalPathBase = httpContext.Request.PathBase + }); + + // Give any IAuthenticationRequestHandler schemes a chance to handle the request + // 主要作用是: 判断当前是否需要进行远程验证,如果是就进行远程验证 + var handlers = httpContext.RequestServices.GetRequiredService(); + foreach (var scheme in await Schemes.GetRequestHandlerSchemesAsync()) + { + if (await handlers.GetHandlerAsync(httpContext, scheme.Name) is IAuthenticationRequestHandler handler && await handler.HandleRequestAsync()) + { + context.Fail(); + return; + } + } + + + //判断请求是否拥有凭据,即有没有登录 + var defaultAuthenticate = await Schemes.GetDefaultAuthenticateSchemeAsync(); + if (defaultAuthenticate != null) + { + var result = await httpContext.AuthenticateAsync(defaultAuthenticate.Name); + //result?.Principal不为空即登录成功 + if (result?.Principal != null) + { + + httpContext.User = result.Principal; + + // 获取当前用户的角色信息 + var currentUserRoles = new List(); + // ids4和jwt切换 + // ids4 + if (Permissions.IsUseIds4) + { + currentUserRoles = (from item in httpContext.User.Claims + where item.Type == "role" + select item.Value).ToList(); + } + else + { + // jwt + currentUserRoles = (from item in httpContext.User.Claims + where item.Type == requirement.ClaimType + select item.Value).ToList(); + } + + var isMatchRole = false; + var permisssionRoles = requirement.Permissions.Where(w => currentUserRoles.Contains(w.Role)); + foreach (var item in permisssionRoles) + { + try + { + if (Regex.Match(questUrl, item.Url?.ObjToString().ToLower())?.Value == questUrl) + { + isMatchRole = true; + break; + } + } + catch (Exception) + { + // ignored + } + } + + //验证权限 + if (currentUserRoles.Count <= 0 || !isMatchRole) + { + context.Fail(); + return; + } + + var isExp = false; + // ids4和jwt切换 + // ids4 + if (Permissions.IsUseIds4) + { + isExp = (httpContext.User.Claims.SingleOrDefault(s => s.Type == "exp")?.Value) != null && DateHelper.StampToDateTime(httpContext.User.Claims.SingleOrDefault(s => s.Type == "exp")?.Value) >= DateTime.Now; + } + else + { + // jwt + isExp = (httpContext.User.Claims.SingleOrDefault(s => s.Type == ClaimTypes.Expiration)?.Value) != null && DateTime.Parse(httpContext.User.Claims.SingleOrDefault(s => s.Type == ClaimTypes.Expiration)?.Value) >= DateTime.Now; + } + if (isExp) + { + context.Succeed(requirement); + } + else + { + context.Fail(); + return; + } + return; + } + } + //判断没有登录时,是否访问登录的url,并且是Post请求,并且是form表单提交类型,否则为失败 + if (!(questUrl.Equals(requirement.LoginPath.ToLower(), StringComparison.Ordinal) && (!httpContext.Request.Method.Equals("POST") || !httpContext.Request.HasFormContentType))) + { + context.Fail(); + return; + } + } + + //context.Succeed(requirement); + } + } +} diff --git a/New_College.Extensions/Authorizations/Policys/PermissionItem.cs b/New_College.Extensions/Authorizations/Policys/PermissionItem.cs new file mode 100644 index 0000000..80d75fa --- /dev/null +++ b/New_College.Extensions/Authorizations/Policys/PermissionItem.cs @@ -0,0 +1,19 @@ + +namespace New_College.AuthHelper +{ + /// + /// 用户或角色或其他凭据实体,就像是订单详情一样 + /// 之前的名字是 Permission + /// + public class PermissionItem + { + /// + /// 用户或角色或其他凭据名称 + /// + public virtual string Role { get; set; } + /// + /// 请求Url + /// + public virtual string Url { get; set; } + } +} diff --git a/New_College.Extensions/Authorizations/Policys/PermissionRequirement.cs b/New_College.Extensions/Authorizations/Policys/PermissionRequirement.cs new file mode 100644 index 0000000..eb73c30 --- /dev/null +++ b/New_College.Extensions/Authorizations/Policys/PermissionRequirement.cs @@ -0,0 +1,72 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.IdentityModel.Tokens; +using System; +using System.Collections.Generic; + +namespace New_College.AuthHelper +{ + /// + /// 必要参数类,类似一个订单信息 + /// 继承 IAuthorizationRequirement,用于设计自定义权限处理器PermissionHandler + /// 因为AuthorizationHandler 中的泛型参数 TRequirement 必须继承 IAuthorizationRequirement + /// + public class PermissionRequirement : IAuthorizationRequirement + { + /// + /// 用户权限集合,一个订单包含了很多详情, + /// 同理,一个网站的认证发行中,也有很多权限详情(这里是Role和URL的关系) + /// + public List Permissions { get; set; } + /// + /// 无权限action + /// + public string DeniedAction { get; set; } + + /// + /// 认证授权类型 + /// + public string ClaimType { internal get; set; } + /// + /// 请求路径 + /// + public string LoginPath { get; set; } = "/Api/Login"; + /// + /// 发行人 + /// + public string Issuer { get; set; } + /// + /// 订阅人 + /// + public string Audience { get; set; } + /// + /// 过期时间 + /// + public TimeSpan Expiration { get; set; } + /// + /// 签名验证 + /// + public SigningCredentials SigningCredentials { get; set; } + + + /// + /// 构造 + /// + /// 拒约请求的url + /// 权限集合 + /// 声明类型 + /// 发行人 + /// 订阅人 + /// 签名验证实体 + /// 过期时间 + public PermissionRequirement(string deniedAction, List permissions, string claimType, string issuer, string audience, SigningCredentials signingCredentials, TimeSpan expiration) + { + ClaimType = claimType; + DeniedAction = deniedAction; + Permissions = permissions; + Issuer = issuer; + Audience = audience; + Expiration = expiration; + SigningCredentials = signingCredentials; + } + } +} diff --git a/New_College.Extensions/AutoMapper/AutoMapperConfig.cs b/New_College.Extensions/AutoMapper/AutoMapperConfig.cs new file mode 100644 index 0000000..3f2f437 --- /dev/null +++ b/New_College.Extensions/AutoMapper/AutoMapperConfig.cs @@ -0,0 +1,18 @@ +using AutoMapper; + +namespace New_College.AutoMapper +{ + /// + /// 静态全局 AutoMapper 配置文件 + /// + public class AutoMapperConfig + { + public static MapperConfiguration RegisterMappings() + { + return new MapperConfiguration(cfg => + { + cfg.AddProfile(new CustomProfile()); + }); + } + } +} diff --git a/New_College.Extensions/AutoMapper/CustomProfile.cs b/New_College.Extensions/AutoMapper/CustomProfile.cs new file mode 100644 index 0000000..3d4daac --- /dev/null +++ b/New_College.Extensions/AutoMapper/CustomProfile.cs @@ -0,0 +1,18 @@ +using AutoMapper; +using New_College.Model.Models; +using New_College.Model.ViewModels; + +namespace New_College.AutoMapper +{ + public class CustomProfile : Profile + { + /// + /// 配置构造函数,用来创建关系映射 + /// + public CustomProfile() + { + CreateMap(); + CreateMap(); + } + } +} diff --git a/New_College.Extensions/Middlewares/AllServicesMildd.cs b/New_College.Extensions/Middlewares/AllServicesMildd.cs new file mode 100644 index 0000000..60e7819 --- /dev/null +++ b/New_College.Extensions/Middlewares/AllServicesMildd.cs @@ -0,0 +1,56 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; + +namespace New_College.Extensions +{ + /// + /// 查看所有注入的服务 + /// + public static class AllServicesMildd + { + public static void UseAllServicesMildd(this IApplicationBuilder app, IServiceCollection _services) + { + if (app == null) throw new ArgumentNullException(nameof(app)); + + List tsDIAutofac = new List(); + tsDIAutofac.AddRange(Assembly.LoadFrom(Path.Combine(AppContext.BaseDirectory, "New_College.Services.dll")).GetTypes().ToList()); + tsDIAutofac.AddRange(Assembly.LoadFrom(Path.Combine(AppContext.BaseDirectory, "New_College.Repository.dll")).GetTypes().ToList()); + + app.Map("/allservices", builder => builder.Run(async context => + { + context.Response.ContentType = "text/html; charset=utf-8"; + await context.Response.WriteAsync(""); + + await context.Response.WriteAsync($"

所有服务{_services.Count}个

"); + + foreach (var svc in _services) + { + await context.Response.WriteAsync(""); + await context.Response.WriteAsync($""); + await context.Response.WriteAsync($""); + await context.Response.WriteAsync($""); + await context.Response.WriteAsync(""); + } + foreach (var item in tsDIAutofac.Where(s => !s.IsInterface)) + { + var interfaceType = item.GetInterfaces(); + foreach (var typeArray in interfaceType) + { + await context.Response.WriteAsync(""); + await context.Response.WriteAsync($""); + await context.Response.WriteAsync($""); + await context.Response.WriteAsync($""); + await context.Response.WriteAsync(""); + } + } + await context.Response.WriteAsync("
类型生命周期Instance
{svc.ServiceType.FullName}{svc.Lifetime}{svc.ImplementationType?.Name}
{typeArray?.FullName}Scoped{item?.Name}
"); + })); + } + } +} diff --git a/New_College.Extensions/Middlewares/ConsulMildd.cs b/New_College.Extensions/Middlewares/ConsulMildd.cs new file mode 100644 index 0000000..c78d8a0 --- /dev/null +++ b/New_College.Extensions/Middlewares/ConsulMildd.cs @@ -0,0 +1,52 @@ +using Consul; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using System; + +namespace New_College.Extensions +{ + /// + /// Consul 注册服务 + /// + public static class ConsulMildd + { + public static IApplicationBuilder UseConsulMildd(this IApplicationBuilder app, IConfiguration configuration, IHostApplicationLifetime lifetime) + { + if (configuration["Middleware:Consul:Enabled"].ObjToBool()) + { + var consulClient = new ConsulClient(c => + { + //consul地址 + c.Address = new Uri(configuration["ConsulSetting:ConsulAddress"]); + }); + + var registration = new AgentServiceRegistration() + { + ID = Guid.NewGuid().ToString(),//服务实例唯一标识 + Name = configuration["ConsulSetting:ServiceName"],//服务名 + Address = configuration["ConsulSetting:ServiceIP"], //服务IP + Port = int.Parse(configuration["ConsulSetting:ServicePort"]),//服务端口 + Check = new AgentServiceCheck() + { + DeregisterCriticalServiceAfter = TimeSpan.FromSeconds(5),//服务启动多久后注册 + Interval = TimeSpan.FromSeconds(10),//健康检查时间间隔 + HTTP = $"http://{configuration["ConsulSetting:ServiceIP"]}:{configuration["ConsulSetting:ServicePort"]}{configuration["ConsulSetting:ServiceHealthCheck"]}",//健康检查地址 + Timeout = TimeSpan.FromSeconds(5)//超时时间 + } + }; + + //服务注册 + consulClient.Agent.ServiceRegister(registration).Wait(); + + //应用程序终止时,取消注册 + lifetime.ApplicationStopping.Register(() => + { + consulClient.Agent.ServiceDeregister(registration.ID).Wait(); + }); + + } + return app; + } + } +} diff --git a/New_College.Extensions/Middlewares/ExceptionHandlerMidd.cs b/New_College.Extensions/Middlewares/ExceptionHandlerMidd.cs new file mode 100644 index 0000000..e0f0905 --- /dev/null +++ b/New_College.Extensions/Middlewares/ExceptionHandlerMidd.cs @@ -0,0 +1,54 @@ +using New_College.AuthHelper.Policys; +using Microsoft.AspNetCore.Http; +using Newtonsoft.Json; +using System; +using System.Net; +using System.Threading.Tasks; + +namespace New_College.Middlewares +{ + public class ExceptionHandlerMidd + { + private readonly RequestDelegate _next; + private static readonly log4net.ILog log = + log4net.LogManager.GetLogger(typeof(ExceptionHandlerMidd)); + + public ExceptionHandlerMidd(RequestDelegate next) + { + _next = next; + } + + public async Task Invoke(HttpContext context) + { + try + { + await _next(context); + } + catch (Exception ex) + { + await HandleExceptionAsync(context, ex); + } + } + + private async Task HandleExceptionAsync(HttpContext context, Exception e) + { + if (e == null) return; + + log.Error(e.GetBaseException().ToString()); + + await WriteExceptionAsync(context, e).ConfigureAwait(false); + } + + private static async Task WriteExceptionAsync(HttpContext context, Exception e) + { + if (e is UnauthorizedAccessException) + context.Response.StatusCode = (int)HttpStatusCode.Unauthorized; + else if (e is Exception) + context.Response.StatusCode = (int)HttpStatusCode.BadRequest; + + context.Response.ContentType = "application/json"; + + await context.Response.WriteAsync(JsonConvert.SerializeObject((new ApiResponse(StatusCode.CODE500, e.Message)).MessageModel)).ConfigureAwait(false); + } + } +} diff --git a/New_College.Extensions/Middlewares/IPLogMildd.cs b/New_College.Extensions/Middlewares/IPLogMildd.cs new file mode 100644 index 0000000..92c65cc --- /dev/null +++ b/New_College.Extensions/Middlewares/IPLogMildd.cs @@ -0,0 +1,127 @@ +using New_College.Common; +using New_College.Common.LogHelper; +using Microsoft.AspNetCore.Http; +using Newtonsoft.Json; +using System; +using System.Threading.Tasks; + +namespace New_College.Middlewares +{ + /// + /// 中间件 + /// 记录IP请求数据 + /// + public class IPLogMildd + { + /// + /// + /// + private readonly RequestDelegate _next; + /// + /// + /// + /// + public IPLogMildd(RequestDelegate next) + { + _next = next; + } + + public async Task InvokeAsync(HttpContext context) + { + if (Appsettings.app("Middleware", "IPLog", "Enabled").ObjToBool()) + { + // 过滤,只有接口 + if (context.Request.Path.Value.Contains("api")) + { + context.Request.EnableBuffering(); + + try + { + // 存储请求数据 + var request = context.Request; + var requestInfo = JsonConvert.SerializeObject(new RequestInfo() + { + Ip = GetClientIP(context), + Url = request.Path.ObjToString().TrimEnd('/').ToLower(), + Datetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + Date = DateTime.Now.ToString("yyyy-MM-dd"), + Week = GetWeek(), + }); + + if (!string.IsNullOrEmpty(requestInfo)) + { + // 自定义log输出 + Parallel.For(0, 1, e => + { + LogLock.OutSql2Log("RequestIpInfoLog", new string[] { requestInfo + "," }, false); + }); + + // 这种方案也行,用的是Serilog + //SerilogServer.WriteLog("RequestIpInfoLog", new string[] { requestInfo + "," }, false); + + request.Body.Position = 0; + } + + await _next(context); + } + catch (Exception) + { + } + } + else + { + await _next(context); + } + } + else + { + await _next(context); + } + } + + private string GetWeek() + { + string week = string.Empty; + switch (DateTime.Now.DayOfWeek) + { + case DayOfWeek.Monday: + week = "周一"; + break; + case DayOfWeek.Tuesday: + week = "周二"; + break; + case DayOfWeek.Wednesday: + week = "周三"; + break; + case DayOfWeek.Thursday: + week = "周四"; + break; + case DayOfWeek.Friday: + week = "周五"; + break; + case DayOfWeek.Saturday: + week = "周六"; + break; + case DayOfWeek.Sunday: + week = "周日"; + break; + default: + week = "N/A"; + break; + } + return week; + } + + public static string GetClientIP(HttpContext context) + { + var ip = context.Request.Headers["X-Forwarded-For"].ObjToString(); + if (string.IsNullOrEmpty(ip)) + { + ip = context.Connection.RemoteIpAddress.ObjToString(); + } + return ip; + } + + } +} + diff --git a/New_College.Extensions/Middlewares/IpLimitMildd.cs b/New_College.Extensions/Middlewares/IpLimitMildd.cs new file mode 100644 index 0000000..b1e60b4 --- /dev/null +++ b/New_College.Extensions/Middlewares/IpLimitMildd.cs @@ -0,0 +1,33 @@ +using AspNetCoreRateLimit; +using New_College.Common; +using log4net; +using Microsoft.AspNetCore.Builder; +using System; + +namespace New_College.Extensions +{ + /// + /// ip 限流 + /// + public static class IpLimitMildd + { + private static readonly ILog log = LogManager.GetLogger(typeof(IpLimitMildd)); + public static void UseIpLimitMildd(this IApplicationBuilder app) + { + if (app == null) throw new ArgumentNullException(nameof(app)); + + try + { + if (Appsettings.app("Middleware", "IpRateLimit", "Enabled").ObjToBool()) + { + app.UseIpRateLimiting(); + } + } + catch (Exception e) + { + log.Error($"Error occured limiting ip rate.\n{e.Message}"); + throw; + } + } + } +} diff --git a/New_College.Extensions/Middlewares/MiddlewareHelpers.cs b/New_College.Extensions/Middlewares/MiddlewareHelpers.cs new file mode 100644 index 0000000..24bfb5b --- /dev/null +++ b/New_College.Extensions/Middlewares/MiddlewareHelpers.cs @@ -0,0 +1,68 @@ +using New_College.AuthHelper; +using Microsoft.AspNetCore.Builder; + +namespace New_College.Middlewares +{ + public static class MiddlewareHelpers + { + /// + /// 自定义授权中间件 + /// + /// + /// + public static IApplicationBuilder UseJwtTokenAuth(this IApplicationBuilder app) + { + return app.UseMiddleware(); + } + + /// + /// 请求响应中间件 + /// + /// + /// + public static IApplicationBuilder UseReuestResponseLog(this IApplicationBuilder app) + { + return app.UseMiddleware(); + } + + /// + /// SignalR中间件 + /// + /// + /// + public static IApplicationBuilder UseSignalRSendMildd(this IApplicationBuilder app) + { + return app.UseMiddleware(); + } + + /// + /// 异常处理中间件 + /// + /// + /// + public static IApplicationBuilder UseExceptionHandlerMidd(this IApplicationBuilder app) + { + return app.UseMiddleware(); + } + + /// + /// IP请求中间件 + /// + /// + /// + public static IApplicationBuilder UseIPLogMildd(this IApplicationBuilder app) + { + return app.UseMiddleware(); + } + + /// + /// 用户访问中间件 + /// + /// + /// + public static IApplicationBuilder UseRecordAccessLogsMildd(this IApplicationBuilder app) + { + return app.UseMiddleware(); + } + } +} diff --git a/New_College.Extensions/Middlewares/QuartzJobMildd.cs b/New_College.Extensions/Middlewares/QuartzJobMildd.cs new file mode 100644 index 0000000..6889a0b --- /dev/null +++ b/New_College.Extensions/Middlewares/QuartzJobMildd.cs @@ -0,0 +1,51 @@ +using New_College.Common; +using New_College.IServices; +using New_College.Tasks; +using log4net; +using Microsoft.AspNetCore.Builder; +using System; + +namespace New_College.Extensions +{ + /// + /// Quartz 启动服务 + /// + public static class QuartzJobMildd + { + private static readonly ILog log = LogManager.GetLogger(typeof(QuartzJobMildd)); + public static void UseQuartzJobMildd(this IApplicationBuilder app, ITasksQzServices tasksQzServices, ISchedulerCenter schedulerCenter) + { + if (app == null) throw new ArgumentNullException(nameof(app)); + + try + { + if (Appsettings.app("Middleware", "QuartzNetJob", "Enabled").ObjToBool()) + { + + var allQzServices = tasksQzServices.Query().Result; + foreach (var item in allQzServices) + { + if (item.IsStart) + { + var ResuleModel = schedulerCenter.AddScheduleJobAsync(item).Result; + if (ResuleModel.success) + { + Console.WriteLine($"QuartzNetJob{item.Name}启动成功!"); + } + else + { + Console.WriteLine($"QuartzNetJob{item.Name}启动失败!错误信息:{ResuleModel.msg}"); + } + } + } + + } + } + catch (Exception e) + { + log.Error($"An error was reported when starting the job service.\n{e.Message}"); + throw; + } + } + } +} diff --git a/New_College.Extensions/Middlewares/RecordAccessLogsMildd.cs b/New_College.Extensions/Middlewares/RecordAccessLogsMildd.cs new file mode 100644 index 0000000..2b3e724 --- /dev/null +++ b/New_College.Extensions/Middlewares/RecordAccessLogsMildd.cs @@ -0,0 +1,144 @@ +using New_College.Common; +using New_College.Common.HttpContextUser; +using New_College.Common.LogHelper; +using Microsoft.AspNetCore.Http; +using Newtonsoft.Json; +using System; +using System.Diagnostics; +using System.IO; +using System.Text; +using System.Threading.Tasks; +using System.Web; + +namespace New_College.Middlewares +{ + /// + /// 中间件 + /// 记录用户方访问数据 + /// + public class RecordAccessLogsMildd + { + /// + /// + /// + private readonly RequestDelegate _next; + private readonly IUser _user; + + /// + /// + /// + /// + public RecordAccessLogsMildd(RequestDelegate next, IUser user) + { + _next = next; + _user = user; + } + + public async Task InvokeAsync(HttpContext context) + { + if (Appsettings.app("Middleware", "RecordAccessLogs", "Enabled").ObjToBool()) + { + // 过滤,只有接口 + if (context.Request.Path.Value.Contains("api")) + { + + //记录Job时间 + Stopwatch stopwatch = new Stopwatch(); + stopwatch.Start(); + + context.Request.EnableBuffering(); + Stream originalBody = context.Response.Body; + + try + { + + using (var ms = new MemoryStream()) + { + context.Response.Body = ms; + + + await _next(context); + + + ms.Position = 0; + await ms.CopyToAsync(originalBody); + + + stopwatch.Stop(); + var opTime = stopwatch.Elapsed.TotalMilliseconds.ToString("00") + "ms"; + // 存储请求数据 + await RequestDataLog(context, opTime); + } + } + catch (Exception) + { + // 记录异常 + //ErrorLogData(context.Response, ex); + } + finally + { + context.Response.Body = originalBody; + } + } + else + { + await _next(context); + } + } + else + { + await _next(context); + } + } + + private async Task RequestDataLog(HttpContext context, string opTime) + { + var request = context.Request; + var sr = new StreamReader(request.Body); + + var requestData = request.Method == "GET" || request.Method == "DELETE" ? HttpUtility.UrlDecode(request.QueryString.ObjToString(), Encoding.UTF8) : (await sr.ReadToEndAsync()).ObjToString(); + if (requestData.IsNotEmptyOrNull() && requestData.Length > 30) + { + requestData = requestData.Substring(0, 30); + } + + var requestInfo = JsonConvert.SerializeObject(new UserAccessModel() + { + User = _user.Name, + IP = IPLogMildd.GetClientIP(context), + API = request.Path.ObjToString().TrimEnd('/').ToLower(), + BeginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + OPTime = opTime, + RequestMethod = request.Method, + RequestData = requestData, + Agent = request.Headers["User-Agent"].ObjToString() + }); + + if (!string.IsNullOrEmpty(requestInfo)) + { + // 自定义log输出 + Parallel.For(0, 1, e => + { + LogLock.OutSql2Log("RecordAccessLogs", new string[] { requestInfo + "," }, false); + }); + + request.Body.Position = 0; + } + } + } + + public class UserAccessModel + { + public string User { get; set; } + public string IP { get; set; } + public string API { get; set; } + public string BeginTime { get; set; } + public string OPTime { get; set; } + public string RequestMethod { get; set; } + public string RequestData { get; set; } + public string Agent { get; set; } + + } + +} + diff --git a/New_College.Extensions/Middlewares/RequRespLogMildd.cs b/New_College.Extensions/Middlewares/RequRespLogMildd.cs new file mode 100644 index 0000000..43bcdaa --- /dev/null +++ b/New_College.Extensions/Middlewares/RequRespLogMildd.cs @@ -0,0 +1,120 @@ +using New_College.Common; +using New_College.Common.LogHelper; +using Microsoft.AspNetCore.Http; +using System; +using System.IO; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace New_College.Middlewares +{ + /// + /// 中间件 + /// 记录请求和响应数据 + /// + public class RequRespLogMildd + { + /// + /// + /// + private readonly RequestDelegate _next; + /// + /// + /// + /// + public RequRespLogMildd(RequestDelegate next) + { + _next = next; + } + + + + public async Task InvokeAsync(HttpContext context) + { + if (Appsettings.app("Middleware", "RequestResponseLog", "Enabled").ObjToBool()) + { + // 过滤,只有接口 + if (context.Request.Path.Value.Contains("api")) + { + context.Request.EnableBuffering(); + Stream originalBody = context.Response.Body; + + try + { + // 存储请求数据 + await RequestDataLog(context); + + using (var ms = new MemoryStream()) + { + context.Response.Body = ms; + + await _next(context); + + // 存储响应数据 + ResponseDataLog(context.Response, ms); + + ms.Position = 0; + await ms.CopyToAsync(originalBody); + } + } + catch (Exception) + { + // 记录异常 + //ErrorLogData(context.Response, ex); + } + finally + { + context.Response.Body = originalBody; + } + } + else + { + await _next(context); + } + } + else + { + await _next(context); + } + } + + private async Task RequestDataLog(HttpContext context) + { + var request = context.Request; + var sr = new StreamReader(request.Body); + + var content = $" QueryData:{request.Path + request.QueryString}\r\n BodyData:{await sr.ReadToEndAsync()}"; + + if (!string.IsNullOrEmpty(content)) + { + Parallel.For(0, 1, e => + { + LogLock.OutSql2Log("RequestResponseLog", new string[] { "Request Data:", content }); + + }); + + request.Body.Position = 0; + } + } + + private void ResponseDataLog(HttpResponse response, MemoryStream ms) + { + ms.Position = 0; + var ResponseBody = new StreamReader(ms).ReadToEnd(); + + // 去除 Html + var reg = "<[^>]+>"; + var isHtml = Regex.IsMatch(ResponseBody, reg); + + if (!string.IsNullOrEmpty(ResponseBody)) + { + Parallel.For(0, 1, e => + { + LogLock.OutSql2Log("RequestResponseLog", new string[] { "Response Data:", ResponseBody }); + + }); + } + } + } +} + diff --git a/New_College.Extensions/Middlewares/SeedDataMildd.cs b/New_College.Extensions/Middlewares/SeedDataMildd.cs new file mode 100644 index 0000000..f592bf0 --- /dev/null +++ b/New_College.Extensions/Middlewares/SeedDataMildd.cs @@ -0,0 +1,33 @@ +using New_College.Common; +using New_College.Model.Seed; +using log4net; +using Microsoft.AspNetCore.Builder; +using System; + +namespace New_College.Extensions +{ + /// + /// 生成种子数据中间件服务 + /// + public static class SeedDataMildd + { + private static readonly ILog log = LogManager.GetLogger(typeof(SeedDataMildd)); + public static void UseSeedDataMildd(this IApplicationBuilder app, MyContext myContext, string webRootPath) + { + if (app == null) throw new ArgumentNullException(nameof(app)); + + try + { + if (Appsettings.app("AppSettings", "SeedDBEnabled").ObjToBool() || Appsettings.app("AppSettings", "SeedDBDataEnabled").ObjToBool()) + { + // DBSeed.SeedAsync(myContext, webRootPath).Wait(); + } + } + catch (Exception e) + { + log.Error($"Error occured seeding the Database.\n{e.Message}"); + throw; + } + } + } +} diff --git a/New_College.Extensions/Middlewares/SignalRSendMildd.cs b/New_College.Extensions/Middlewares/SignalRSendMildd.cs new file mode 100644 index 0000000..5388a3d --- /dev/null +++ b/New_College.Extensions/Middlewares/SignalRSendMildd.cs @@ -0,0 +1,46 @@ +using Microsoft.AspNetCore.Http; +using System.Threading.Tasks; +using New_College.Common.LogHelper; +using New_College.Hubs; +using Microsoft.AspNetCore.SignalR; +using New_College.Common; + +namespace New_College.Middlewares +{ + /// + /// 中间件 + /// SignalR发送数据 + /// + public class SignalRSendMildd + { + /// + /// + /// + private readonly RequestDelegate _next; + private readonly IHubContext _hubContext; + + /// + /// + /// + /// + /// + public SignalRSendMildd(RequestDelegate next, IHubContext hubContext) + { + _next = next; + _hubContext = hubContext; + } + + + + public async Task InvokeAsync(HttpContext context) + { + if (Appsettings.app("Middleware", "SignalR", "Enabled").ObjToBool()) + { + await _hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()); + } + await _next(context); + } + + } +} + diff --git a/New_College.Extensions/Middlewares/SwaggerMildd.cs b/New_College.Extensions/Middlewares/SwaggerMildd.cs new file mode 100644 index 0000000..15ff81f --- /dev/null +++ b/New_College.Extensions/Middlewares/SwaggerMildd.cs @@ -0,0 +1,48 @@ +using New_College.Common; +using log4net; +using Microsoft.AspNetCore.Builder; +using System; +using System.IO; +using System.Linq; +using static New_College.Extensions.CustomApiVersion; + +namespace New_College.Extensions +{ + /// + /// Swagger中间件 + /// + public static class SwaggerMildd + { + private static readonly ILog log = LogManager.GetLogger(typeof(SwaggerMildd)); + public static void UseSwaggerMildd(this IApplicationBuilder app, Func streamHtml) + { + if (app == null) throw new ArgumentNullException(nameof(app)); + + app.UseSwagger(); + app.UseSwaggerUI(c => + { + //根据版本名称倒序 遍历展示 + var ApiName = Appsettings.app(new string[] { "Startup", "ApiName" }); + typeof(ApiVersions).GetEnumNames().OrderByDescending(e => e).ToList().ForEach(version => + { + c.SwaggerEndpoint($"/swagger/{version}/swagger.json", $"{ApiName} {version}"); + }); + + c.SwaggerEndpoint($"https://petstore.swagger.io/v2/swagger.json", $"{ApiName} pet"); + + // 将swagger首页,设置成我们自定义的页面,记得这个字符串的写法:{项目名.index.html} + if (streamHtml.Invoke() == null) + { + var msg = "index.html的属性,必须设置为嵌入的资源"; + log.Error(msg); + throw new Exception(msg); + } + c.IndexStream = streamHtml; + + + // 路径配置,设置为空,表示直接在根域名(localhost:8001)访问该文件,注意localhost:8001/swagger是访问不到的,去launchSettings.json把launchUrl去掉,如果你想换一个路径,直接写名字即可,比如直接写c.RoutePrefix = "doc"; + c.RoutePrefix = ""; + }); + } + } +} diff --git a/New_College.Extensions/New_College.Extensions.csproj b/New_College.Extensions/New_College.Extensions.csproj new file mode 100644 index 0000000..aac1783 --- /dev/null +++ b/New_College.Extensions/New_College.Extensions.csproj @@ -0,0 +1,29 @@ + + + + netcoreapp3.1 + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/New_College.Extensions/ServiceExtensions/AppConfigSetup.cs b/New_College.Extensions/ServiceExtensions/AppConfigSetup.cs new file mode 100644 index 0000000..0ce5549 --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/AppConfigSetup.cs @@ -0,0 +1,129 @@ +using New_College.Common; +using New_College.Common.Helper; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Text; + +namespace New_College.Extensions +{ + /// + /// 项目 启动服务 + /// + public static class AppConfigSetup + { + public static void AddAppConfigSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + if (Appsettings.app(new string[] { "Startup", "AppConfigAlert", "Enabled" }).ObjToBool()) + { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + Console.OutputEncoding = Encoding.GetEncoding("GB2312"); + + Console.WriteLine("************ New_College Config Set *****************"); + // 授权策略方案 + if (Permissions.IsUseIds4) + { + ConsoleHelper.WriteSuccessLine($"Current authorization scheme: " + (Permissions.IsUseIds4 ? "Ids4" : "JWT")); + } + else + { + Console.WriteLine($"Current authorization scheme: " + (Permissions.IsUseIds4 ? "Ids4" : "JWT")); + } + + // Redis缓存AOP + if (!Appsettings.app(new string[] { "AppSettings", "RedisCachingAOP", "Enabled" }).ObjToBool()) + { + Console.WriteLine($"Redis Caching AOP: False"); + } + else + { + ConsoleHelper.WriteSuccessLine($"Redis Caching AOP: True"); + } + + // 内存缓存AOP + if (!Appsettings.app(new string[] { "AppSettings", "MemoryCachingAOP", "Enabled" }).ObjToBool()) + { + Console.WriteLine($"Memory Caching AOP: False"); + } + else + { + ConsoleHelper.WriteSuccessLine($"Memory Caching AOP: True"); + } + + // 服务日志AOP + if (!Appsettings.app(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool()) + { + Console.WriteLine($"Service Log AOP: False"); + } + else + { + ConsoleHelper.WriteSuccessLine($"Service Log AOP: True"); + } + + // 事务AOP + if (!Appsettings.app(new string[] { "AppSettings", "TranAOP", "Enabled" }).ObjToBool()) + { + Console.WriteLine($"Transaction AOP: False"); + } + else + { + ConsoleHelper.WriteSuccessLine($"Transaction AOP: True"); + } + + // 数据库Sql执行AOP + if (!Appsettings.app(new string[] { "AppSettings", "SqlAOP", "Enabled" }).ObjToBool()) + { + Console.WriteLine($"DB Sql AOP: False"); + } + else + { + ConsoleHelper.WriteSuccessLine($"DB Sql AOP: True"); + } + + // SingnalR发送数据 + if (!Appsettings.app(new string[] { "Middleware", "SignalR", "Enabled" }).ObjToBool()) + { + Console.WriteLine($"SignalR send data: False"); + } + else + { + ConsoleHelper.WriteSuccessLine($"SignalR send data: True"); + } + + // IP限流 + if (!Appsettings.app("Middleware", "IpRateLimit", "Enabled").ObjToBool()) + { + Console.WriteLine($"IpRateLimiting: False"); + } + else + { + ConsoleHelper.WriteSuccessLine($"IpRateLimiting: True"); + } + + // 多库 + if (!Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) + { + Console.WriteLine($"Is multi-DataBase: False"); + } + else + { + ConsoleHelper.WriteSuccessLine($"Is multi-DataBase: True"); + } + + // 读写分离 + if (!Appsettings.app(new string[] { "CQRSEnabled" }).ObjToBool()) + { + Console.WriteLine($"Is CQRS: False"); + } + else + { + ConsoleHelper.WriteSuccessLine($"Is CQRS: True"); + } + + Console.WriteLine(); + } + + } + } +} diff --git a/New_College.Extensions/ServiceExtensions/Authentication_Ids4Setup.cs b/New_College.Extensions/ServiceExtensions/Authentication_Ids4Setup.cs new file mode 100644 index 0000000..a8e3a52 --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/Authentication_Ids4Setup.cs @@ -0,0 +1,40 @@ +using New_College.AuthHelper; +using New_College.Common; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using System; + +namespace New_College.Extensions +{ + /// + /// Ids4权限 认证服务 + /// + public static class Authentication_Ids4Setup + { + public static void AddAuthentication_Ids4Setup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + + // 添加Identityserver4认证 + services.AddAuthentication(o => + { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.DefaultChallengeScheme = nameof(ApiResponseHandler); + o.DefaultForbidScheme = nameof(ApiResponseHandler); + }) + .AddIdentityServerAuthentication(options => + { + options.Authority = Appsettings.app(new string[] { "Startup", "IdentityServer4", "AuthorizationUrl" }); + options.RequireHttpsMetadata = false; + options.ApiName = Appsettings.app(new string[] { "Startup", "IdentityServer4", "ApiName" }); + options.SupportedTokens = IdentityServer4.AccessTokenValidation.SupportedTokens.Jwt; + options.ApiSecret = "api_secret"; + + }) + .AddScheme(nameof(ApiResponseHandler), o => { }); + } + } +} diff --git a/New_College.Extensions/ServiceExtensions/Authentication_JWTSetup.cs b/New_College.Extensions/ServiceExtensions/Authentication_JWTSetup.cs new file mode 100644 index 0000000..b3d5659 --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/Authentication_JWTSetup.cs @@ -0,0 +1,94 @@ +using New_College.AuthHelper; +using New_College.Common; +using New_College.Common.AppConfig; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Tokens; +using System; +using System.IdentityModel.Tokens.Jwt; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Extensions +{ + /// + /// JWT权限 认证服务 + /// + public static class Authentication_JWTSetup + { + public static void AddAuthentication_JWTSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + + var symmetricKeyAsBase64 = AppSecretConfig.Audience_Secret_String; + var keyByteArray = Encoding.ASCII.GetBytes(symmetricKeyAsBase64); + var signingKey = new SymmetricSecurityKey(keyByteArray); + var Issuer = Appsettings.app(new string[] { "Audience", "Issuer" }); + var Audience = Appsettings.app(new string[] { "Audience", "Audience" }); + + var signingCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256); + + // 令牌验证参数 + var tokenValidationParameters = new TokenValidationParameters + { + ValidateIssuerSigningKey = true, + IssuerSigningKey = signingKey, + ValidateIssuer = true, + ValidIssuer = Issuer,//发行人 + ValidateAudience = true, + ValidAudience = Audience,//订阅人 + ValidateLifetime = true, + ClockSkew = TimeSpan.FromSeconds(30), + RequireExpirationTime = true, + }; + + // 开启Bearer认证 + services.AddAuthentication(o=> { + o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; + o.DefaultChallengeScheme = nameof(ApiResponseHandler); + o.DefaultForbidScheme = nameof(ApiResponseHandler); + }) + // 添加JwtBearer服务 + .AddJwtBearer(o => + { + o.TokenValidationParameters = tokenValidationParameters; + o.Events = new JwtBearerEvents + { + OnChallenge = context => + { + context.Response.Headers.Add("Token-Error", context.ErrorDescription); + return Task.CompletedTask; + }, + OnAuthenticationFailed = context => + { + var token= context.Request.Headers["Authorization"].ObjToString().Replace("Bearer ", ""); + var jwtToken = (new JwtSecurityTokenHandler()).ReadJwtToken(token); + + if (jwtToken.Issuer != Issuer) + { + context.Response.Headers.Add("Token-Error-Iss", "issuer is wrong!"); + } + + if (jwtToken.Audiences.FirstOrDefault() != Audience) + { + context.Response.Headers.Add("Token-Error-Aud", "Audience is wrong!"); + } + + + // 如果过期,则把<是否过期>添加到,返回头信息中 + if (context.Exception.GetType() == typeof(SecurityTokenExpiredException)) + { + context.Response.Headers.Add("Token-Expired", "true"); + } + return Task.CompletedTask; + } + }; + }) + .AddScheme(nameof(ApiResponseHandler), o => { }); + + } + } +} diff --git a/New_College.Extensions/ServiceExtensions/AuthorizationSetup.cs b/New_College.Extensions/ServiceExtensions/AuthorizationSetup.cs new file mode 100644 index 0000000..6ee0b63 --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/AuthorizationSetup.cs @@ -0,0 +1,96 @@ +using New_College.AuthHelper; +using New_College.Common; +using New_College.Common.AppConfig; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Tokens; +using System; +using System.Collections.Generic; +using System.Security.Claims; +using System.Text; + +namespace New_College.Extensions +{ + /// + /// 系统 授权服务 配置 + /// + public static class AuthorizationSetup + { + public static void AddAuthorizationSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + // 以下四种常见的授权方式。 + + // 1、这个很简单,其他什么都不用做, 只需要在API层的controller上边,增加特性即可 + // [Authorize(Roles = "Admin,System")] + + + // 2、这个和上边的异曲同工,好处就是不用在controller中,写多个 roles 。 + // 然后这么写 [Authorize(Policy = "Admin")] + services.AddAuthorization(options => + { + options.AddPolicy("Client", policy => policy.RequireRole("Client").Build()); + options.AddPolicy("Admin", policy => policy.RequireRole("Admin").Build()); + options.AddPolicy("SystemOrAdmin", policy => policy.RequireRole("Admin", "System")); + options.AddPolicy("A_S_O", policy => policy.RequireRole("Admin", "System", "Others")); + }); + + + + + #region 参数 + //读取配置文件 + var symmetricKeyAsBase64 = AppSecretConfig.Audience_Secret_String; + var keyByteArray = Encoding.ASCII.GetBytes(symmetricKeyAsBase64); + var signingKey = new SymmetricSecurityKey(keyByteArray); + var Issuer = Appsettings.app(new string[] { "Audience", "Issuer" }); + var Audience = Appsettings.app(new string[] { "Audience", "Audience" }); + + var signingCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256); + + // 如果要数据库动态绑定,这里先留个空,后边处理器里动态赋值 + var permission = new List(); + + // 角色与接口的权限要求参数 + var permissionRequirement = new PermissionRequirement( + "/api/denied",// 拒绝授权的跳转地址(目前无用) + permission, + ClaimTypes.Role,//基于角色的授权 + Issuer,//发行人 + Audience,//听众 + signingCredentials,//签名凭据 + expiration: TimeSpan.FromSeconds(60 * 60)//接口的过期时间 + ); + #endregion + // 3、自定义复杂的策略授权 + services.AddAuthorization(options => + { + options.AddPolicy(Permissions.Name, + policy => policy.Requirements.Add(permissionRequirement)); + }); + + + // 4、基于Scope策略授权 + services.AddAuthorization(options => + { + options.AddPolicy("Scope_BlogModule_Policy", builder => + { + //客户端Scope中包含new_college.api.BlogModule才能访问 + builder.RequireScope("new_college.api.BlogModule"); + }); + + // 其他 Scope 策略 + // ... + + }); + + // 这里冗余写了一次,因为很多人看不到 + services.AddSingleton(); + // 注入权限处理器 + services.AddScoped(); + services.AddSingleton(permissionRequirement); + } + } +} diff --git a/New_College.Extensions/ServiceExtensions/AutoMapperSetup.cs b/New_College.Extensions/ServiceExtensions/AutoMapperSetup.cs new file mode 100644 index 0000000..325f108 --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/AutoMapperSetup.cs @@ -0,0 +1,21 @@ +using AutoMapper; +using New_College.AutoMapper; +using Microsoft.Extensions.DependencyInjection; +using System; + +namespace New_College.Extensions +{ + /// + /// Automapper 启动服务 + /// + public static class AutoMapperSetup + { + public static void AddAutoMapperSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + services.AddAutoMapper(typeof(AutoMapperConfig)); + AutoMapperConfig.RegisterMappings(); + } + } +} diff --git a/New_College.Extensions/ServiceExtensions/AutofacModuleRegister.cs b/New_College.Extensions/ServiceExtensions/AutofacModuleRegister.cs new file mode 100644 index 0000000..894fc4b --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/AutofacModuleRegister.cs @@ -0,0 +1,116 @@ +using Autofac; +using Autofac.Extras.DynamicProxy; +using New_College.AOP; +using New_College.Common; +using New_College.IRepository.Base; +using New_College.Model; +using New_College.Repository.Base; +using log4net; +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; + +namespace New_College.Extensions +{ + public class AutofacModuleRegister : Autofac.Module + { + private static readonly ILog log = LogManager.GetLogger(typeof(AutofacModuleRegister)); + protected override void Load(ContainerBuilder builder) + { + var basePath = AppContext.BaseDirectory; + //builder.RegisterType().As(); + + + #region 带有接口层的服务注入 + + var servicesDllFile = Path.Combine(basePath, "New_College.Services.dll"); + var repositoryDllFile = Path.Combine(basePath, "New_College.Repository.dll"); + //var pay = Path.Combine(basePath, "Essensoft.AspNetCore.Payment.WeChatPay.dll"); + //var pay2 = Path.Combine(basePath, "Microsoft.Extensions.Options.dll"); + + if (!(File.Exists(servicesDllFile) && File.Exists(repositoryDllFile))) + { + var msg = "Repository.dll和service.dll 丢失,因为项目解耦了,所以需要先F6编译,再F5运行,请检查 bin 文件夹,并拷贝。"; + log.Error(msg); + throw new Exception(msg); + } + + + + // AOP 开关,如果想要打开指定的功能,只需要在 appsettigns.json 对应对应 true 就行。 + var cacheType = new List(); + if (Appsettings.app(new string[] { "AppSettings", "RedisCachingAOP", "Enabled" }).ObjToBool()) + { + builder.RegisterType(); + cacheType.Add(typeof(BlogRedisCacheAOP)); + } + if (Appsettings.app(new string[] { "AppSettings", "MemoryCachingAOP", "Enabled" }).ObjToBool()) + { + builder.RegisterType(); + cacheType.Add(typeof(BlogCacheAOP)); + } + if (Appsettings.app(new string[] { "AppSettings", "TranAOP", "Enabled" }).ObjToBool()) + { + builder.RegisterType(); + cacheType.Add(typeof(BlogTranAOP)); + } + if (Appsettings.app(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool()) + { + builder.RegisterType(); + cacheType.Add(typeof(BlogLogAOP)); + } + + builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IBaseRepository<>)).InstancePerDependency();//注册仓储 + + // 获取 Service.dll 程序集服务,并注册 + var assemblysServices = Assembly.LoadFrom(servicesDllFile); + builder.RegisterAssemblyTypes(assemblysServices) + .AsImplementedInterfaces() + .InstancePerDependency() + .EnableInterfaceInterceptors()//引用Autofac.Extras.DynamicProxy; + .InterceptedBy(cacheType.ToArray());//允许将拦截器服务的列表分配给注册。 + + // 获取 Repository.dll 程序集服务,并注册 + var assemblysRepository = Assembly.LoadFrom(repositoryDllFile); + builder.RegisterAssemblyTypes(assemblysRepository) + .AsImplementedInterfaces() + .InstancePerDependency(); + + //var pay22 = Assembly.LoadFrom(pay); + //builder.RegisterAssemblyTypes(pay22) + // .AsImplementedInterfaces() + // .InstancePerDependency(); + + #endregion + + #region 没有接口层的服务层注入 + + //因为没有接口层,所以不能实现解耦,只能用 Load 方法。 + //注意如果使用没有接口的服务,并想对其使用 AOP 拦截,就必须设置为虚方法 + //var assemblysServicesNoInterfaces = Assembly.Load("New_College.Services"); + //builder.RegisterAssemblyTypes(assemblysServicesNoInterfaces); + + #endregion + + #region 没有接口的单独类,启用class代理拦截 + + //只能注入该类中的虚方法,且必须是public + //这里仅仅是一个单独类无接口测试,不用过多追问 + builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(Love))) + .EnableClassInterceptors() + .InterceptedBy(cacheType.ToArray()); + #endregion + + #region 单独注册一个含有接口的类,启用interface代理拦截 + + //不用虚方法 + //builder.RegisterType().As() + // .AsImplementedInterfaces() + // .EnableInterfaceInterceptors() + // .InterceptedBy(typeof(BlogCacheAOP)); + #endregion + + } + } +} diff --git a/New_College.Extensions/ServiceExtensions/CorsSetup.cs b/New_College.Extensions/ServiceExtensions/CorsSetup.cs new file mode 100644 index 0000000..c81438f --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/CorsSetup.cs @@ -0,0 +1,47 @@ +using New_College.Common; +using Microsoft.Extensions.DependencyInjection; +using System; + +namespace New_College.Extensions +{ + /// + /// Cors 启动服务 + /// + public static class CorsSetup + { + public static void AddCorsSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + services.AddCors(c => + { + if (!Appsettings.app(new string[] { "Startup", "Cors", "EnableAllIPs" }).ObjToBool()) + { + c.AddPolicy(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" }), + + policy => + { + + policy + .WithOrigins(Appsettings.app(new string[] { "Startup", "Cors", "IPs" }).Split(',')) + .AllowAnyHeader()//Ensures that the policy allows any header. + .AllowAnyMethod(); + }); + } + else + { + //允许任意跨域请求 + c.AddPolicy(Appsettings.app(new string[] { "Startup", "Cors", "PolicyName" }), + policy => + { + policy + .AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader(); + }); + } + + }); + } + } +} diff --git a/New_College.Extensions/ServiceExtensions/DbSetup.cs b/New_College.Extensions/ServiceExtensions/DbSetup.cs new file mode 100644 index 0000000..26d6c63 --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/DbSetup.cs @@ -0,0 +1,20 @@ +using New_College.Model.Seed; +using Microsoft.Extensions.DependencyInjection; +using System; + +namespace New_College.Extensions +{ + /// + /// Db 启动服务 + /// + public static class DbSetup + { + public static void AddDbSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + services.AddScoped(); + services.AddScoped(); + } + } +} diff --git a/New_College.Extensions/ServiceExtensions/HttpContextSetup.cs b/New_College.Extensions/ServiceExtensions/HttpContextSetup.cs new file mode 100644 index 0000000..65ed387 --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/HttpContextSetup.cs @@ -0,0 +1,21 @@ +using New_College.Common.HttpContextUser; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using System; + +namespace New_College.Extensions +{ + /// + /// HttpContext 相关服务 + /// + public static class HttpContextSetup + { + public static void AddHttpContextSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + services.AddSingleton(); + services.AddScoped(); + } + } +} diff --git a/New_College.Extensions/ServiceExtensions/IpPolicyRateLimitSetup.cs b/New_College.Extensions/ServiceExtensions/IpPolicyRateLimitSetup.cs new file mode 100644 index 0000000..911f55f --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/IpPolicyRateLimitSetup.cs @@ -0,0 +1,36 @@ +using AspNetCoreRateLimit; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using System; + +namespace New_College.Extensions +{ + /// + /// IPLimit限流 启动服务 + /// + public static class IpPolicyRateLimitSetup + { + public static void AddIpPolicyRateLimitSetup(this IServiceCollection services, IConfiguration Configuration) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + // needed to store rate limit counters and ip rules + services.AddMemoryCache(); + //load general configuration from appsettings.json + services.Configure(Configuration.GetSection("IpRateLimiting")); + // inject counter and rules stores + services.AddSingleton(); + services.AddSingleton(); + + // inject counter and rules distributed cache stores + //services.AddSingleton(); + //services.AddSingleton(); + + // the clientId/clientIp resolvers use it. + services.AddSingleton(); + // configuration (resolvers, counter key builders) + services.AddSingleton(); + } + } +} \ No newline at end of file diff --git a/New_College.Extensions/ServiceExtensions/JobSetup.cs b/New_College.Extensions/ServiceExtensions/JobSetup.cs new file mode 100644 index 0000000..8658990 --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/JobSetup.cs @@ -0,0 +1,25 @@ +using New_College.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Quartz.Spi; +using System; + +namespace New_College.Extensions +{ + /// + /// 任务调度 启动服务 + /// + public static class JobSetup + { + public static void AddJobSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + //services.AddHostedService(); + //services.AddHostedService(); + + services.AddSingleton(); + services.AddTransient();//Job使用瞬时依赖注入 + services.AddSingleton(); + } + } +} diff --git a/New_College.Extensions/ServiceExtensions/MemoryCacheSetup.cs b/New_College.Extensions/ServiceExtensions/MemoryCacheSetup.cs new file mode 100644 index 0000000..abc0f3a --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/MemoryCacheSetup.cs @@ -0,0 +1,25 @@ +using New_College.Common.MemoryCache; +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.DependencyInjection; +using System; + +namespace New_College.Extensions +{ + /// + /// Memory缓存 启动服务 + /// + public static class MemoryCacheSetup + { + public static void AddMemoryCacheSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + services.AddScoped(); + services.AddSingleton(factory => + { + var cache = new MemoryCache(new MemoryCacheOptions()); + return cache; + }); + } + } +} diff --git a/New_College.Extensions/ServiceExtensions/MiniProfilerSetup.cs b/New_College.Extensions/ServiceExtensions/MiniProfilerSetup.cs new file mode 100644 index 0000000..ec13788 --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/MiniProfilerSetup.cs @@ -0,0 +1,30 @@ +using Microsoft.Extensions.DependencyInjection; +using System; + +namespace New_College.Extensions +{ + /// + /// MiniProfiler 启动服务 + /// + public static class MiniProfilerSetup + { + public static void AddMiniProfilerSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + // 3.x使用MiniProfiler,必须要注册MemoryCache服务 + services.AddMiniProfiler(options => + { + options.RouteBasePath = "/profiler"; + //(options.Storage as MemoryCacheStorage).CacheDuration = TimeSpan.FromMinutes(10); + options.PopupRenderPosition = StackExchange.Profiling.RenderPosition.Left; + options.PopupShowTimeWithChildren = true; + + // 可以增加权限 + //options.ResultsAuthorize = request => request.HttpContext.User.IsInRole("Admin"); + //options.UserIdProvider = request => request.HttpContext.User.Identity.Name; + } + ); + } + } +} diff --git a/New_College.Extensions/ServiceExtensions/SqlsugarSetup.cs b/New_College.Extensions/ServiceExtensions/SqlsugarSetup.cs new file mode 100644 index 0000000..736f1ba --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/SqlsugarSetup.cs @@ -0,0 +1,90 @@ +using New_College.Common; +using New_College.Common.DB; +using New_College.Common.LogHelper; +using Microsoft.Extensions.DependencyInjection; +using SqlSugar; +using StackExchange.Profiling; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.Extensions +{ + /// + /// SqlSugar 启动服务 + /// + public static class SqlsugarSetup + { + public static void AddSqlsugarSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + // 默认添加主数据库连接 + MainDb.CurrentDbConnId = Appsettings.app(new string[] { "MainDB" }); + + // 把多个连接对象注入服务,这里必须采用Scope,因为有事务操作 + services.AddScoped(o => + { + // 连接字符串 + var listConfig = new List(); + // 从库 + var listConfig_Slave = new List(); + BaseDBConfig.MutiConnectionString.Item2.ForEach(s => + { + listConfig_Slave.Add(new SlaveConnectionConfig() + { + HitRate = s.HitRate, + ConnectionString = s.Connection + }); + }); + + BaseDBConfig.MutiConnectionString.Item1.ForEach(m => + { + listConfig.Add(new ConnectionConfig() + { + ConfigId = m.ConnId.ObjToString().ToLower(), + ConnectionString = m.Connection, + DbType = (DbType)m.DbType, + IsAutoCloseConnection = true, + IsShardSameThread = false, + AopEvents = new AopEvents + { + OnLogExecuting = (sql, p) => + { + if (Appsettings.app(new string[] { "AppSettings", "SqlAOP", "Enabled" }).ObjToBool()) + { + Parallel.For(0, 1, e => + { + MiniProfiler.Current.CustomTiming("SQL:", GetParas(p) + "【SQL语句】:" + sql); + LogLock.OutSql2Log("SqlLog", new string[] { GetParas(p), "【SQL语句】:" + sql }); + + }); + } + } + }, + MoreSettings = new ConnMoreSettings() + { + IsAutoRemoveDataCache = true + }, + // 从库 + SlaveConnectionConfigs = listConfig_Slave, + //InitKeyType = InitKeyType.SystemTable + } + ); + }); + return new SqlSugarClient(listConfig); + }); + } + + private static string GetParas(SugarParameter[] pars) + { + string key = "【SQL参数】:"; + foreach (var param in pars) + { + key += $"{param.ParameterName}:{param.Value}\n"; + } + + return key; + } + } +} \ No newline at end of file diff --git a/New_College.Extensions/ServiceExtensions/SwaggerSetup.cs b/New_College.Extensions/ServiceExtensions/SwaggerSetup.cs new file mode 100644 index 0000000..a8a8139 --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/SwaggerSetup.cs @@ -0,0 +1,133 @@ +using New_College.Common; +using log4net; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.Filters; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using static New_College.Extensions.CustomApiVersion; + +namespace New_College.Extensions +{ + /// + /// Swagger 启动服务 + /// + public static class SwaggerSetup + { + + private static readonly ILog log = + LogManager.GetLogger(typeof(SwaggerSetup)); + + public static void AddSwaggerSetup(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + var basePath = AppContext.BaseDirectory; + //var basePath2 = Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.ApplicationBasePath; + var ApiName = Appsettings.app(new string[] { "Startup", "ApiName" }); + + services.AddSwaggerGen(c => + { + //遍历出全部的版本,做文档信息展示 + typeof(ApiVersions).GetEnumNames().ToList().ForEach(version => + { + c.SwaggerDoc(version, new OpenApiInfo + { + Version = version, + Title = $"{ApiName} 接口文档——{RuntimeInformation.FrameworkDescription}", + Description = $"{ApiName} HTTP API " + version, + //Contact = new OpenApiContact { Name = ApiName, Email = "New_College@xxx.com", Url = new Uri("#") }, + //License = new OpenApiLicense { Name = ApiName + " 官方文档", Url = new Uri("#") } + }); + c.OrderActionsBy(o => o.RelativePath); + }); + + + try + { + //这个就是刚刚配置的xml文件名 + var xmlPath = Path.Combine(basePath, "New_College.xml"); + //默认的第二个参数是false,这个是controller的注释,记得修改 + c.IncludeXmlComments(xmlPath, true); + + //这个就是Model层的xml文件名 + var xmlModelPath = Path.Combine(basePath, "New_College.Model.xml"); + c.IncludeXmlComments(xmlModelPath); + } + catch (Exception ex) + { + log.Error("New_College.xml和New_College.Model.xml 丢失,请检查并拷贝。\n" + ex.Message); + } + + // 开启加权小锁 + c.OperationFilter(); + c.OperationFilter(); + + // 在header中添加token,传递到后台 + c.OperationFilter(); + + + // ids4和jwt切换 + if (Permissions.IsUseIds4) + { + //接入identityserver4 + c.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme + { + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows + { + Implicit = new OpenApiOAuthFlow + { + AuthorizationUrl = new Uri($"{Appsettings.app(new string[] { "Startup", "IdentityServer4", "AuthorizationUrl" })}/connect/authorize"), + Scopes = new Dictionary { + { + "new_college.api","ApiResource id" + } + } + } + } + }); + } + else + { + // Jwt Bearer 认证,必须是 oauth2 + c.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme + { + Description = "JWT授权(数据将在请求头中进行传输) 直接在下框中输入Bearer {token}(注意两者之间是一个空格)\"", + Name = "Authorization",//jwt默认的参数名称 + In = ParameterLocation.Header,//jwt默认存放Authorization信息的位置(请求头中) + Type = SecuritySchemeType.ApiKey + }); + } + + + + }); + } + } + + /// + /// 自定义版本 + /// + public class CustomApiVersion + { + /// + /// Api接口版本 自定义 + /// + public enum ApiVersions + { + /// + /// V1 版本 + /// + V1 = 1, + /// + /// V2 版本 + /// + V2 = 2, + } + } + +} diff --git a/New_College.Extensions/ServiceExtensions/WebApiClientSetup.cs b/New_College.Extensions/ServiceExtensions/WebApiClientSetup.cs new file mode 100644 index 0000000..9cedfd7 --- /dev/null +++ b/New_College.Extensions/ServiceExtensions/WebApiClientSetup.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.DependencyInjection; +using System; +using WebApiClient.Extensions.DependencyInjection; +using New_College.Common.WebApiClients.HttpApis; + +namespace New_College.Extensions +{ + /// + /// WebApiClientSetup 启动服务 + /// + public static class WebApiClientSetup + { + /// + /// 注册WebApiClient接口 + /// + /// + public static void AddHttpApi(this IServiceCollection services) + { + if (services == null) throw new ArgumentNullException(nameof(services)); + + services.AddHttpApi().ConfigureHttpApiConfig(c => + { + c.HttpHost = new Uri("http://apk.neters.club/"); + c.FormatOptions.DateTimeFormat = "yyyy-MM-dd HH:mm:ss.fff"; + }); + services.AddHttpApi().ConfigureHttpApiConfig(c => + { + c.HttpHost = new Uri("http://api.xiaomafeixiang.com/"); + c.FormatOptions.DateTimeFormat = "yyyy-MM-dd HH:mm:ss.fff"; + }); + } + } +} diff --git a/New_College.FrameWork/DbHelper.ttinclude b/New_College.FrameWork/DbHelper.ttinclude new file mode 100644 index 0000000..ad450e9 --- /dev/null +++ b/New_College.FrameWork/DbHelper.ttinclude @@ -0,0 +1,322 @@ +<#+ + public class config + { + public static readonly string ConnectionString = File.Exists(@"C:\my-file\dbCountPswSolsticeALDDD.txt") ? File.ReadAllText(@"C:\my-file\dbCountPswSolsticeALDDD.txt").Trim(): "server=.;uid=sa;pwd=sa;database=WMBlogDB"; + public static readonly string DbDatabase = ""; + public static readonly string TableName = ""; + } +#> +<#+ + public class DbHelper + { + #region GetDbTables + + public static List GetDbTablesNew(string connectionString, string database,string tables = null) + { + if (!string.IsNullOrEmpty(tables)) + { + tables = string.Format(" and obj.name in ('{0}')", tables.Replace(",", "','")); + } + string sql = string.Format(@"SELECT + obj.name tablename + from {0}.sys.objects obj + inner join {0}.dbo.sysindexes idx on obj.object_id=idx.id and idx.indid<=1 + INNER JOIN {0}.sys.schemas schem ON obj.schema_id=schem.schema_id + left join {0}.sys.extended_properties g ON (obj.object_id = g.major_id AND g.minor_id = 0 AND g.name= 'MS_Description') + where type='U' {1} + order by obj.name", database,tables); + DataTable dt = GetDataTable(connectionString, sql); + return dt.Rows.Cast().Select(row =>row.Field("tablename")).ToList(); + } + + public static List GetDbTables(string connectionString, string database, string tables = null) + { + + if (!string.IsNullOrEmpty(tables)) + { + tables = string.Format(" and obj.name in ('{0}')", tables.Replace(",", "','")); + } + #region SQL + string sql = string.Format(@"SELECT + obj.name tablename, + schem.name schemname, + idx.rows, + CAST + ( + CASE + WHEN (SELECT COUNT(1) FROM sys.indexes WHERE object_id= obj.OBJECT_ID AND is_primary_key=1) >=1 THEN 1 + ELSE 0 + END + AS BIT) HasPrimaryKey + from {0}.sys.objects obj + inner join {0}.dbo.sysindexes idx on obj.object_id=idx.id and idx.indid<=1 + INNER JOIN {0}.sys.schemas schem ON obj.schema_id=schem.schema_id + where type='U' {1} + order by obj.name", database, tables); + #endregion + DataTable dt = GetDataTable(connectionString, sql); + return dt.Rows.Cast().Select(row => new DbTable + { + TableName = row.Field("tablename"), + SchemaName = row.Field("schemname"), + Rows = row.Field("rows"), + HasPrimaryKey = row.Field("HasPrimaryKey") + }).ToList(); + } + #endregion + + #region GetDbColumns + + public static List GetDbColumns(string connectionString, string database, string tableName, string schema = "dbo") + { + #region SQL + string sql = string.Format(@" + WITH indexCTE AS + ( + SELECT + ic.column_id, + ic.index_column_id, + ic.object_id + FROM {0}.sys.indexes idx + INNER JOIN {0}.sys.index_columns ic ON idx.index_id = ic.index_id AND idx.object_id = ic.object_id + WHERE idx.object_id =OBJECT_ID(@tableName) AND idx.is_primary_key=1 + ) + select + colm.column_id ColumnID, + CAST(CASE WHEN indexCTE.column_id IS NULL THEN 0 ELSE 1 END AS BIT) IsPrimaryKey, + colm.name ColumnName, + systype.name ColumnType, + colm.is_identity IsIdentity, + colm.is_nullable IsNullable, + cast(colm.max_length as int) ByteLength, + ( + case + when systype.name='nvarchar' and colm.max_length>0 then colm.max_length/2 + when systype.name='nchar' and colm.max_length>0 then colm.max_length/2 + when systype.name='ntext' and colm.max_length>0 then colm.max_length/2 + else colm.max_length + end + ) CharLength, + cast(colm.precision as int) Precision, + cast(colm.scale as int) Scale, + prop.value Remark + from {0}.sys.columns colm + inner join {0}.sys.types systype on colm.system_type_id=systype.system_type_id and colm.user_type_id=systype.user_type_id + left join {0}.sys.extended_properties prop on colm.object_id=prop.major_id and colm.column_id=prop.minor_id + LEFT JOIN indexCTE ON colm.column_id=indexCTE.column_id AND colm.object_id=indexCTE.object_id + where colm.object_id=OBJECT_ID(@tableName) + order by colm.column_id", database); + #endregion + SqlParameter param = new SqlParameter("@tableName", SqlDbType.NVarChar, 100) { Value = string.Format("{0}.{1}.{2}", database, schema, tableName) }; + DataTable dt = GetDataTable(connectionString, sql, param); + return dt.Rows.Cast().Select(row => new DbColumn() + { + ColumnID = row.Field("ColumnID"), + IsPrimaryKey = row.Field("IsPrimaryKey"), + ColumnName = row.Field("ColumnName"), + ColumnType = row.Field("ColumnType"), + IsIdentity = row.Field("IsIdentity"), + IsNullable = row.Field("IsNullable"), + ByteLength = row.Field("ByteLength"), + CharLength = row.Field("CharLength"), + Precision=row.Field("Precision"), + Scale = row.Field("Scale"), + Remark = row["Remark"].ToString() + }).ToList(); + } + + #endregion + + #region GetDataTable + + public static DataTable GetDataTable(string connectionString, string commandText, params SqlParameter[] parms) + { + using (SqlConnection connection = new SqlConnection(connectionString)) + { + SqlCommand command = connection.CreateCommand(); + command.CommandText = commandText; + command.Parameters.AddRange(parms); + SqlDataAdapter adapter = new SqlDataAdapter(command); + + DataTable dt = new DataTable(); + adapter.Fill(dt); + + return dt; + } + } + + #endregion + + #region GetPrimaryKey + public static string GetPrimaryKey(List dbColumns) + { + string primaryKey = string.Empty; + if (dbColumns!=null&&dbColumns.Count>0) + { + foreach (var item in dbColumns) + { + if (item.IsPrimaryKey==true) + { + primaryKey = item.ColumnName; + } + } + } + return primaryKey; + } + #endregion + } + + #region DbTable + public sealed class DbTable + { + public string TableName { get; set; } + public string SchemaName { get; set; } + public int Rows { get; set; } + + public bool HasPrimaryKey { get; set; } + } + #endregion + + #region DbColumn + + public sealed class DbColumn + { + + public int ColumnID { get; set; } + + + public bool IsPrimaryKey { get; set; } + + + public string ColumnName { get; set; } + + + public string ColumnType { get; set; } + + + public string CSharpType + { + get + { + return SqlServerDbTypeMap.MapCsharpType(ColumnType); + } + } + + /// + /// + /// + public Type CommonType + { + get + { + return SqlServerDbTypeMap.MapCommonType(ColumnType); + } + } + + public int ByteLength { get; set; } + + public int CharLength { get; set; } + + public int Precision{get;set;} + public int Scale { get; set; } + + public bool IsIdentity { get; set; } + + public bool IsNullable { get; set; } + + public string Remark { get; set; } + } + #endregion + + #region SqlServerDbTypeMap + + public class SqlServerDbTypeMap + { + public static string MapCsharpType(string dbtype) + { + if (string.IsNullOrEmpty(dbtype)) return dbtype; + dbtype = dbtype.ToLower(); + string csharpType = "object"; + switch (dbtype) + { + case "bigint": csharpType = "long"; break; + case "binary": csharpType = "byte[]"; break; + case "bit": csharpType = "bool"; break; + case "char": csharpType = "string"; break; + case "date": csharpType = "DateTime"; break; + case "datetime": csharpType = "DateTime"; break; + case "datetime2": csharpType = "DateTime"; break; + case "datetimeoffset": csharpType = "DateTimeOffset"; break; + case "decimal": csharpType = "decimal"; break; + case "float": csharpType = "double"; break; + case "image": csharpType = "byte[]"; break; + case "int": csharpType = "int"; break; + case "money": csharpType = "decimal"; break; + case "nchar": csharpType = "string"; break; + case "ntext": csharpType = "string"; break; + case "numeric": csharpType = "decimal"; break; + case "nvarchar": csharpType = "string"; break; + case "real": csharpType = "Single"; break; + case "smalldatetime": csharpType = "DateTime"; break; + case "smallint": csharpType = "short"; break; + case "smallmoney": csharpType = "decimal"; break; + case "sql_variant": csharpType = "object"; break; + case "sysname": csharpType = "object"; break; + case "text": csharpType = "string"; break; + case "time": csharpType = "TimeSpan"; break; + case "timestamp": csharpType = "byte[]"; break; + case "tinyint": csharpType = "byte"; break; + case "uniqueidentifier": csharpType = "Guid"; break; + case "varbinary": csharpType = "byte[]"; break; + case "varchar": csharpType = "string"; break; + case "xml": csharpType = "string"; break; + default: csharpType = "object"; break; + } + return csharpType; + } + + public static Type MapCommonType(string dbtype) + { + if (string.IsNullOrEmpty(dbtype)) return Type.Missing.GetType(); + dbtype = dbtype.ToLower(); + Type commonType = typeof(object); + switch (dbtype) + { + case "bigint": commonType = typeof(long); break; + case "binary": commonType = typeof(byte[]); break; + case "bit": commonType = typeof(bool); break; + case "char": commonType = typeof(string); break; + case "date": commonType = typeof(DateTime); break; + case "datetime": commonType = typeof(DateTime); break; + case "datetime2": commonType = typeof(DateTime); break; + case "datetimeoffset": commonType = typeof(DateTimeOffset); break; + case "decimal": commonType = typeof(decimal); break; + case "float": commonType = typeof(double); break; + case "image": commonType = typeof(byte[]); break; + case "int": commonType = typeof(int); break; + case "money": commonType = typeof(decimal); break; + case "nchar": commonType = typeof(string); break; + case "ntext": commonType = typeof(string); break; + case "numeric": commonType = typeof(decimal); break; + case "nvarchar": commonType = typeof(string); break; + case "real": commonType = typeof(Single); break; + case "smalldatetime": commonType = typeof(DateTime); break; + case "smallint": commonType = typeof(short); break; + case "smallmoney": commonType = typeof(decimal); break; + case "sql_variant": commonType = typeof(object); break; + case "sysname": commonType = typeof(object); break; + case "text": commonType = typeof(string); break; + case "time": commonType = typeof(TimeSpan); break; + case "timestamp": commonType = typeof(byte[]); break; + case "tinyint": commonType = typeof(byte); break; + case "uniqueidentifier": commonType = typeof(Guid); break; + case "varbinary": commonType = typeof(byte[]); break; + case "varchar": commonType = typeof(string); break; + case "xml": commonType = typeof(string); break; + default: commonType = typeof(object); break; + } + return commonType; + } + } + #endregion + #> \ No newline at end of file diff --git a/New_College.FrameWork/ModelAuto.ttinclude b/New_College.FrameWork/ModelAuto.ttinclude new file mode 100644 index 0000000..5933972 --- /dev/null +++ b/New_College.FrameWork/ModelAuto.ttinclude @@ -0,0 +1,115 @@ +<#@ assembly name="System.Core"#> +<#@ assembly name="EnvDTE"#> +<#@ import namespace="System.Collections.Generic"#> +<#@ import namespace="System.IO"#> +<#@ import namespace="System.Text"#> +<#@ import namespace="Microsoft.VisualStudio.TextTemplating"#> +<#+ +class Manager +{ + public struct Block { + public int Start, Length; + public String Name,OutputPath; + } + + public List blocks = new List(); + public Block currentBlock; + public Block footerBlock = new Block(); + public Block headerBlock = new Block(); + public ITextTemplatingEngineHost host; + public ManagementStrategy strategy; + public StringBuilder template; + public Manager(ITextTemplatingEngineHost host, StringBuilder template, bool commonHeader) { + this.host = host; + this.template = template; + strategy = ManagementStrategy.Create(host); + } + public void StartBlock(String name,String outputPath) { + currentBlock = new Block { Name = name, Start = template.Length ,OutputPath=outputPath}; + } + + public void StartFooter() { + footerBlock.Start = template.Length; + } + + public void EndFooter() { + footerBlock.Length = template.Length - footerBlock.Start; + } + + public void StartHeader() { + headerBlock.Start = template.Length; + } + + public void EndHeader() { + headerBlock.Length = template.Length - headerBlock.Start; + } + + public void EndBlock() { + currentBlock.Length = template.Length - currentBlock.Start; + blocks.Add(currentBlock); + } + public void Process(bool split) { + String header = template.ToString(headerBlock.Start, headerBlock.Length); + String footer = template.ToString(footerBlock.Start, footerBlock.Length); + blocks.Reverse(); + foreach(Block block in blocks) { + String fileName = Path.Combine(block.OutputPath, block.Name); + if (split) { + String content = header + template.ToString(block.Start, block.Length) + footer; + strategy.CreateFile(fileName, content); + template.Remove(block.Start, block.Length); + } else { + strategy.DeleteFile(fileName); + } + } + } +} +class ManagementStrategy +{ + internal static ManagementStrategy Create(ITextTemplatingEngineHost host) { + return (host is IServiceProvider) ? new VSManagementStrategy(host) : new ManagementStrategy(host); + } + + internal ManagementStrategy(ITextTemplatingEngineHost host) { } + + internal virtual void CreateFile(String fileName, String content) { + File.WriteAllText(fileName, content); + } + + internal virtual void DeleteFile(String fileName) { + if (File.Exists(fileName)) + File.Delete(fileName); + } +} + +class VSManagementStrategy : ManagementStrategy +{ + private EnvDTE.ProjectItem templateProjectItem; + + internal VSManagementStrategy(ITextTemplatingEngineHost host) : base(host) { + IServiceProvider hostServiceProvider = (IServiceProvider)host; + if (hostServiceProvider == null) + throw new ArgumentNullException("Could not obtain hostServiceProvider"); + + EnvDTE.DTE dte = (EnvDTE.DTE)hostServiceProvider.GetService(typeof(EnvDTE.DTE)); + if (dte == null) + throw new ArgumentNullException("Could not obtain DTE from host"); + + templateProjectItem = dte.Solution.FindProjectItem(host.TemplateFile); + } + internal override void CreateFile(String fileName, String content) { + base.CreateFile(fileName, content); + //((EventHandler)delegate { templateProjectItem.ProjectItems.AddFromFile(fileName); }).BeginInvoke(null, null, null, null); + } + internal override void DeleteFile(String fileName) { + ((EventHandler)delegate { FindAndDeleteFile(fileName); }).BeginInvoke(null, null, null, null); + } + private void FindAndDeleteFile(String fileName) { + foreach(EnvDTE.ProjectItem projectItem in templateProjectItem.ProjectItems) { + if (projectItem.get_FileNames(0) == fileName) { + projectItem.Delete(); + return; + } + } + } +}#> \ No newline at end of file diff --git a/New_College.FrameWork/New_College.FrameWork.Entity/New_College.FrameWork.tt b/New_College.FrameWork/New_College.FrameWork.Entity/New_College.FrameWork.tt new file mode 100644 index 0000000..9c8f21a --- /dev/null +++ b/New_College.FrameWork/New_College.FrameWork.Entity/New_College.FrameWork.tt @@ -0,0 +1,60 @@ +<#@ template debug="false" hostspecific="true" language="C#" #> +<#@ output extension="/" #> +<#@ assembly name="System.Core.dll" #> +<#@ assembly name="System.Data.dll" #> +<#@ assembly name="System.Data.DataSetExtensions.dll" #> +<#@ assembly name="System.Xml.dll" #> +<#@ import namespace="System" #> +<#@ import namespace="System.Xml" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Data" #> +<#@ import namespace="System.Data.SqlClient" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="System.IO" #> +<#@ include file="$(ProjectDir)DbHelper.ttinclude" #> +<#@ include file="$(ProjectDir)ModelAuto.ttinclude" #> +<# var manager = new Manager(Host, GenerationEnvironment, true); #> +<# + var OutputPath1 =Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Host.TemplateFile+"..")+"..")+".."); + OutputPath1=Path.Combine(OutputPath1,"New_College.Model","Models_New"); + if (!Directory.Exists(OutputPath1)) + { + Directory.CreateDirectory(OutputPath1); + } +#> +<# foreach (var item in DbHelper.GetDbTablesNew(config.ConnectionString, config.DbDatabase,config.TableName)) + { + var tableName=item.ToString(); + manager.StartBlock(tableName+".cs",OutputPath1);//文件名 + #> +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +namespace New_College.Model.Models +{ + /// + ///<#=tableName#> + /// + [Table("<#=tableName#>")] + public class <#=tableName#> + { + <# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, tableName)){#> + + /// + /// <#= column.Remark == "" ? column.ColumnName : column.Remark.Replace("\r\n"," ") #> + /// + <# + if(column.IsPrimaryKey) + {#>[Key] + <#}#><# if(!column.IsNullable) {#>[Required] + <# }#>public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; } + <# + } + #> + } +} +<# + manager.EndBlock(); + } + manager.Process(true); + #> \ No newline at end of file diff --git a/New_College.FrameWork/New_College.FrameWork.IRepository/New_College.FrameWork.IRepository.cs b/New_College.FrameWork/New_College.FrameWork.IRepository/New_College.FrameWork.IRepository.cs new file mode 100644 index 0000000..5283a86 --- /dev/null +++ b/New_College.FrameWork/New_College.FrameWork.IRepository/New_College.FrameWork.IRepository.cs @@ -0,0 +1,18 @@ + + + + + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 +// 生成时间 2019-12-10 12:14:04 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- + + + + + + + + diff --git a/New_College.FrameWork/New_College.FrameWork.IRepository/New_College.FrameWork.IRepository.tt b/New_College.FrameWork/New_College.FrameWork.IRepository/New_College.FrameWork.IRepository.tt new file mode 100644 index 0000000..b7dfc1c --- /dev/null +++ b/New_College.FrameWork/New_College.FrameWork.IRepository/New_College.FrameWork.IRepository.tt @@ -0,0 +1,123 @@ +<#@ template debug="false" hostspecific="true" language="C#" #> +<#@ output extension=".cs" #> +<#@ assembly name="System.Core.dll" #> +<#@ assembly name="System.Data.dll" #> +<#@ assembly name="System.Data.DataSetExtensions.dll" #> +<#@ assembly name="System.Xml.dll" #> +<#@ import namespace="System" #> +<#@ import namespace="System.Xml" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Data" #> +<#@ import namespace="System.Data.SqlClient" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="System.IO" #> +<#@ include file="$(ProjectDir)DbHelper.ttinclude" #> +<#@ include file="$(ProjectDir)ModelAuto.ttinclude" #> +<# var manager = new Manager(Host, GenerationEnvironment, true); #> + + +<# + var OutputPath1 =Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Host.TemplateFile+"..")+"..")+".."); + OutputPath1=Path.Combine(OutputPath1,"New_College.IRepository","IRepositories_New"); + if (!Directory.Exists(OutputPath1)) + { + Directory.CreateDirectory(OutputPath1); + } +#> + + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 +// 生成时间 <#=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")#> +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- +<# + var tableName=config.TableName; + #> +<# +if(tableName!=""){ + #> +using New_College.IRepository.Base; +using New_College.Model.Models; +namespace New_College.IRepository +{ + /// + /// I<#=tableName#>Repository + /// + public interface I<#=tableName#>Repository : IBaseRepository<<#=tableName#>> + { + + + } +} + +<# + } else{ + + #> + +<# + SqlConnection conn = new SqlConnection(config.ConnectionString); + conn.Open(); + System.Data.DataTable schema = conn.GetSchema("TABLES"); + #> + +<# + foreach(System.Data.DataRow row in schema.Rows) + { + manager.StartBlock("I"+row["TABLE_NAME"].ToString()+"Repository"+".cs",OutputPath1);//文件名 + #> + //----------<#=row["TABLE_NAME"].ToString()#>开始---------- + + +using New_College.IRepository.Base; +using New_College.Model.Models; +namespace New_College.IRepository +{ + /// + /// I<#=row["TABLE_NAME"].ToString()#>Repository + /// + public interface I<#=row["TABLE_NAME"].ToString()#>Repository : IBaseRepository<<#=row["TABLE_NAME"].ToString()#>>//类名 + { + + + } +} + + //----------<#=row["TABLE_NAME"].ToString()#>结束---------- + <# + manager.EndBlock(); + } + + { + manager.StartBlock("IBaseRepository.cs",OutputPath1);//文件名 + #> + + //----------开始---------- + +using New_College.IRepository.Base; +using New_College.Model.Models; +namespace New_College.IRepository +{ + /// + /// IBaseRepository + /// + public interface IBaseRepository where TEntity : class + { + + + } +} + + //----------结束---------- + <# + manager.EndBlock(); + } + manager.Process(true); + } + #> + + + + + diff --git a/New_College.FrameWork/New_College.FrameWork.IServices/New_College.FrameWork.IServices.cs b/New_College.FrameWork/New_College.FrameWork.IServices/New_College.FrameWork.IServices.cs new file mode 100644 index 0000000..fe84bf4 --- /dev/null +++ b/New_College.FrameWork/New_College.FrameWork.IServices/New_College.FrameWork.IServices.cs @@ -0,0 +1,15 @@ + + + + + + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 +// 生成时间 2019-12-10 12:14:01 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- + + + + diff --git a/New_College.FrameWork/New_College.FrameWork.IServices/New_College.FrameWork.IServices.tt b/New_College.FrameWork/New_College.FrameWork.IServices/New_College.FrameWork.IServices.tt new file mode 100644 index 0000000..17971bc --- /dev/null +++ b/New_College.FrameWork/New_College.FrameWork.IServices/New_College.FrameWork.IServices.tt @@ -0,0 +1,126 @@ +<#@ template debug="false" hostspecific="true" language="C#" #> +<#@ output extension=".cs" #> +<#@ assembly name="System.Core.dll" #> +<#@ assembly name="System.Data.dll" #> +<#@ assembly name="System.Data.DataSetExtensions.dll" #> +<#@ assembly name="System.Xml.dll" #> +<#@ import namespace="System" #> +<#@ import namespace="System.Xml" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Data" #> +<#@ import namespace="System.Data.SqlClient" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="System.IO" #> +<#@ include file="$(ProjectDir)DbHelper.ttinclude" #> +<#@ include file="$(ProjectDir)ModelAuto.ttinclude" #> +<# var manager = new Manager(Host, GenerationEnvironment, true); #> + + +<# + var OutputPath1 =Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Host.TemplateFile+"..")+"..")+".."); + OutputPath1=Path.Combine(OutputPath1,"New_College.IServices","IServices_New"); + if (!Directory.Exists(OutputPath1)) + { + Directory.CreateDirectory(OutputPath1); + } +#> + + + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 +// 生成时间 <#=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")#> +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- +<# + var tableName=config.TableName; + #> +<# +if(tableName!=""){ + #> + + +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// I<#=tableName#>Services + /// + public interface I<#=tableName#>Services :IBaseServices<<#=tableName#>> + { + + + } +} + +<# + } else{ + + #> + +<# + SqlConnection conn = new SqlConnection(config.ConnectionString); + conn.Open(); + System.Data.DataTable schema = conn.GetSchema("TABLES"); + #> + +<# + foreach(System.Data.DataRow row in schema.Rows) + { + manager.StartBlock("I"+row["TABLE_NAME"].ToString()+"Services"+".cs",OutputPath1); + #> + //----------<#=row["TABLE_NAME"].ToString()#>开始---------- + + +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// <#=row["TABLE_NAME"].ToString()#>Services + /// + public interface I<#=row["TABLE_NAME"].ToString()#>Services :IBaseServices<<#=row["TABLE_NAME"].ToString()#>> + { + + + } +} + + //----------<#=row["TABLE_NAME"].ToString()#>结束---------- + <# + manager.EndBlock(); + } + + { + manager.StartBlock("IBaseServices.cs",OutputPath1);//文件名 + #> + + //----------开始---------- + +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// IBaseRepository + /// + public interface IBaseServices where TEntity : class + { + + + } +} + + //----------结束---------- + <# + manager.EndBlock(); + } + + manager.Process(true); + } + #> + diff --git a/New_College.FrameWork/New_College.FrameWork.Repository/New_College.FrameWork.Repository.cs b/New_College.FrameWork/New_College.FrameWork.Repository/New_College.FrameWork.Repository.cs new file mode 100644 index 0000000..bfe45a2 --- /dev/null +++ b/New_College.FrameWork/New_College.FrameWork.Repository/New_College.FrameWork.Repository.cs @@ -0,0 +1,14 @@ + + + + + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 +// 生成时间 2019-12-10 12:14:21 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- + + + + diff --git a/New_College.FrameWork/New_College.FrameWork.Repository/New_College.FrameWork.Repository.tt b/New_College.FrameWork/New_College.FrameWork.Repository/New_College.FrameWork.Repository.tt new file mode 100644 index 0000000..4f41872 --- /dev/null +++ b/New_College.FrameWork/New_College.FrameWork.Repository/New_College.FrameWork.Repository.tt @@ -0,0 +1,133 @@ +<#@ template debug="false" hostspecific="true" language="C#" #> +<#@ output extension=".cs" #> +<#@ assembly name="System.Core.dll" #> +<#@ assembly name="System.Data.dll" #> +<#@ assembly name="System.Data.DataSetExtensions.dll" #> +<#@ assembly name="System.Xml.dll" #> +<#@ import namespace="System" #> +<#@ import namespace="System.Xml" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Data" #> +<#@ import namespace="System.Data.SqlClient" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="System.IO" #> +<#@ include file="$(ProjectDir)DbHelper.ttinclude" #> +<#@ include file="$(ProjectDir)ModelAuto.ttinclude" #> +<# var manager = new Manager(Host, GenerationEnvironment, true); #> + + +<# + var OutputPath1 =Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Host.TemplateFile+"..")+"..")+".."); + OutputPath1=Path.Combine(OutputPath1,"New_College.Repository","Repositories_New"); + if (!Directory.Exists(OutputPath1)) + { + Directory.CreateDirectory(OutputPath1); + } +#> + + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 +// 生成时间 <#=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")#> +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- +<# + var tableName=config.TableName; + #> +<# +if(tableName!=""){ + #> + + +using New_College.Repository.Base; +using New_College.Model.Models; +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +namespace New_College.Repository +{ + /// + /// <#=tableName#>Repository + /// + public class <#=tableName#>Repository : BaseRepository<<#=tableName#>>, I<#=tableName#>Repository + { + public <#=tableName#>Repository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + + } +} + +<# + } else{ + + #> + +<# + SqlConnection conn = new SqlConnection(config.ConnectionString); + conn.Open(); + System.Data.DataTable schema = conn.GetSchema("TABLES"); + #> + +<# + foreach(System.Data.DataRow row in schema.Rows) + { + manager.StartBlock(row["TABLE_NAME"].ToString()+"Repository"+".cs",OutputPath1); + #> + //----------<#=row["TABLE_NAME"].ToString()#>开始---------- + + +using New_College.Repository.Base; +using New_College.Model.Models; +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +namespace New_College.Repository +{ + /// + /// <#=row["TABLE_NAME"].ToString()#>Repository + /// + public class <#=row["TABLE_NAME"].ToString()#>Repository : BaseRepository<<#=row["TABLE_NAME"].ToString()#>>, I<#=row["TABLE_NAME"].ToString() #>Repository + { + public <#=row["TABLE_NAME"].ToString()#>Repository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + + } +} + + //----------<#=row["TABLE_NAME"].ToString()#>结束---------- + <# + manager.EndBlock(); + } + + { + manager.StartBlock("BaseRepository.cs",OutputPath1);//文件名 + #> + + //----------开始---------- + +using New_College.Repository.Base; +using New_College.Model.Models; +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +namespace New_College.Repository +{ + /// + /// IBaseRepository + /// + public class BaseRepository : IBaseRepository where TEntity : class, new() + { + + + } +} + + //----------结束---------- + <# + manager.EndBlock(); + } + + + manager.Process(true); + } + #> + diff --git a/New_College.FrameWork/New_College.FrameWork.Services/New_College.FrameWork.Services.cs b/New_College.FrameWork/New_College.FrameWork.Services/New_College.FrameWork.Services.cs new file mode 100644 index 0000000..61b806b --- /dev/null +++ b/New_College.FrameWork/New_College.FrameWork.Services/New_College.FrameWork.Services.cs @@ -0,0 +1,15 @@ + + + + + + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 +// 生成时间 2019-12-10 12:14:44 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- + + + + diff --git a/New_College.FrameWork/New_College.FrameWork.Services/New_College.FrameWork.Services.tt b/New_College.FrameWork/New_College.FrameWork.Services/New_College.FrameWork.Services.tt new file mode 100644 index 0000000..91ca805 --- /dev/null +++ b/New_College.FrameWork/New_College.FrameWork.Services/New_College.FrameWork.Services.tt @@ -0,0 +1,158 @@ +<#@ template debug="false" hostspecific="true" language="C#" #> +<#@ output extension=".cs" #> +<#@ assembly name="System.Core.dll" #> +<#@ assembly name="System.Data.dll" #> +<#@ assembly name="System.Data.DataSetExtensions.dll" #> +<#@ assembly name="System.Xml.dll" #> +<#@ import namespace="System" #> +<#@ import namespace="System.Xml" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Data" #> +<#@ import namespace="System.Data.SqlClient" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="System.IO" #> +<#@ include file="$(ProjectDir)DbHelper.ttinclude" #> +<#@ include file="$(ProjectDir)ModelAuto.ttinclude" #> +<# var manager = new Manager(Host, GenerationEnvironment, true); #> + + +<# + var OutputPath1 =Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Host.TemplateFile+"..")+"..")+".."); + OutputPath1=Path.Combine(OutputPath1,"New_College.Services","Services_New"); + if (!Directory.Exists(OutputPath1)) + { + Directory.CreateDirectory(OutputPath1); + } +#> + + + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 +// 生成时间 <#=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")#> +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- +<# + var tableName=config.TableName; + #> +<# +if(tableName!=""){ + #> + + +using System; +using System.Threading.Tasks; +using New_College.Common; +using New_College.IRepository; +using New_College.IRepository.Base; +using New_College.IRepository.UnitOfWork; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +namespace New_College.Services +{ + /// + /// <#=tableName#>Services + /// + public class <#=tableName#>Services : BaseServices<<#=tableName#>>, I<#=tableName#>Services + { + + IBaseRepository<<#=tableName#>> dal; + public <#=tableName#>Services(IBaseRepository<<#=tableName#>> dal) + { + this.dal = dal; + base.baseDal = dal; + } + + } +} + +<# + } else{ + + #> + +<# + SqlConnection conn = new SqlConnection(config.ConnectionString); + conn.Open(); + System.Data.DataTable schema = conn.GetSchema("TABLES"); + #> + +<# + foreach(System.Data.DataRow row in schema.Rows) + { + manager.StartBlock(row["TABLE_NAME"].ToString()+"Services"+".cs",OutputPath1); + #> + //----------<#=row["TABLE_NAME"].ToString()#>开始---------- + + + +using System; +using System.Threading.Tasks; +using New_College.Common; +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +namespace New_College.Services +{ + /// + /// <#=row["TABLE_NAME"].ToString()#>Services + /// + public class <#=row["TABLE_NAME"].ToString()#>Services : BaseServices<<#=row["TABLE_NAME"].ToString()#>>, I<#=row["TABLE_NAME"].ToString() #>Services + { + + IBaseRepository<<#=row["TABLE_NAME"].ToString() #>> dal; + public <#=row["TABLE_NAME"].ToString() #>Services(IBaseRepository<<#=row["TABLE_NAME"].ToString() #>> dal) + { + this.dal = dal; + base.baseDal = dal; + } + + } +} + + //----------<#=row["TABLE_NAME"].ToString()#>结束---------- + <# + manager.EndBlock(); + } + + { + manager.StartBlock("BaseServices.cs",OutputPath1);//文件名 + #> + + //----------开始---------- + + +using System; +using System.Threading.Tasks; +using New_College.Common; +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +namespace New_College.Services +{ + /// + /// IBaseRepository + /// + public class BaseServices : IBaseServices where TEntity : class, new() + { + public IBaseRepository baseDal; + + } +} + + //----------结束---------- + <# + manager.EndBlock(); + } + + manager.Process(true); + } + #> + diff --git a/New_College.FrameWork/New_College.FrameWork.csproj b/New_College.FrameWork/New_College.FrameWork.csproj new file mode 100644 index 0000000..1f44dc1 --- /dev/null +++ b/New_College.FrameWork/New_College.FrameWork.csproj @@ -0,0 +1,57 @@ + + + + netcoreapp3.1 + + + + + TextTemplatingFileGenerator + New_College.FrameWork.cs + + + TextTemplatingFileGenerator + New_College.FrameWork.IRepository.cs + + + TextTemplatingFileGenerator + New_College.FrameWork.IServices.cs + + + TextTemplatingFileGenerator + New_College.FrameWork.Repository.cs + + + TextTemplatingFileGenerator + New_College.FrameWork.Services.cs + + + + + + + + + + True + True + New_College.FrameWork.IRepository.tt + + + True + True + New_College.FrameWork.IServices.tt + + + True + True + New_College.FrameWork.Repository.tt + + + True + True + New_College.FrameWork.Services.tt + + + + diff --git a/New_College.IServices/BASE/IBaseServices.cs b/New_College.IServices/BASE/IBaseServices.cs new file mode 100644 index 0000000..3cbd244 --- /dev/null +++ b/New_College.IServices/BASE/IBaseServices.cs @@ -0,0 +1,60 @@ +using New_College.Model; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq.Expressions; +using System.Threading.Tasks; + +namespace New_College.IServices.BASE +{ + public interface IBaseServices where TEntity : class + { + + Task QueryById(object objId); + Task QueryById(object objId, bool blnUseCache = false); + Task> QueryByIDs(object[] lstIds); + + Task Add(TEntity model); + + Task Add(List listEntity); + + Task DeleteById(object id); + + Task Delete(TEntity model); + + Task DeleteByIds(object[] ids); + + Task Update(TEntity model); + Task Update(TEntity entity, string strWhere); + + Task Update(object operateAnonymousObjects); + + Task Update(TEntity entity, List lstColumns = null, List lstIgnoreColumns = null, string strWhere = ""); + + Task> Query(); + Task> Query(string strWhere); + Task> Query(Expression> whereExpression); + Task> Query(Expression> whereExpression, string strOrderByFileds); + Task> Query(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true); + Task> Query(string strWhere, string strOrderByFileds); + Task> QuerySql(string strSql, SugarParameter[] parameters = null); + Task QueryTable(string strSql, SugarParameter[] parameters = null); + + Task> Query(Expression> whereExpression, int intTop, string strOrderByFileds); + Task> Query(string strWhere, int intTop, string strOrderByFileds); + + Task> Query( + Expression> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds); + Task> Query(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds); + + + Task> QueryPage(Expression> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null); + + Task> QueryMuch( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null) where T : class, new(); + } + +} diff --git a/New_College.IServices/IAdvertisementServices.cs b/New_College.IServices/IAdvertisementServices.cs new file mode 100644 index 0000000..368fb4b --- /dev/null +++ b/New_College.IServices/IAdvertisementServices.cs @@ -0,0 +1,16 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + public interface IAdvertisementServices :IBaseServices + { + //int Sum(int i, int j); + //int Add(Advertisement model); + //bool Delete(Advertisement model); + //bool Update(Advertisement model); + //List Query(Expression> whereExpression); + + void ReturnExp(); + } +} diff --git a/New_College.IServices/IBlogArticleServices.cs b/New_College.IServices/IBlogArticleServices.cs new file mode 100644 index 0000000..097d71a --- /dev/null +++ b/New_College.IServices/IBlogArticleServices.cs @@ -0,0 +1,16 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + public interface IBlogArticleServices :IBaseServices + { + Task> GetBlogs(); + Task GetBlogDetails(int id); + + } + +} diff --git a/New_College.IServices/ID_EnrollmentinproductionServices.cs b/New_College.IServices/ID_EnrollmentinproductionServices.cs new file mode 100644 index 0000000..680d0da --- /dev/null +++ b/New_College.IServices/ID_EnrollmentinproductionServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_EnrollmentinproductionServices + /// + public interface ID_EnrollmentinproductionServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_GraduateFlowServices.cs b/New_College.IServices/ID_GraduateFlowServices.cs new file mode 100644 index 0000000..94040f7 --- /dev/null +++ b/New_College.IServices/ID_GraduateFlowServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_GraduateFlowServices + /// + public interface ID_GraduateFlowServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_LongIdMapServices.cs b/New_College.IServices/ID_LongIdMapServices.cs new file mode 100644 index 0000000..69a66da --- /dev/null +++ b/New_College.IServices/ID_LongIdMapServices.cs @@ -0,0 +1,90 @@ +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// ID_LongIdMapServices + /// + public interface ID_LongIdMapServices : IBaseServices + { + Task Import(); + + Task> GetUniversitys(UniversityQuery query); + + Task> uniGetMajorInfo(MajorcategoryQuery query); + + Task> GetRecommendOccupation(); + + Task> uniGetOccupationInfo(); + + Task GetUniversityDetails(IdQuery query); + + Task GetMajorDetail(MajorQuery query); + + Task> GetRelevantSchool(MajorSchoolQuery query); + + Task GetCareerProspects(MajorCareerQuery query); + + Task>> uniGetMajorThree(ManageMajorQuery query); + + /// + /// 根据标签推荐专业 + /// + /// + /// + Task>> GetMajorThreeByTag(MajorThreeByTagQuery query); + + + Task GetRecommendIntroduce(IdQuery query); + + Task> GetUniversityMajor(IdQuery query); + + /// + /// 获取职业第三级 + /// + /// + /// + Task>> GetOccupationThree(IdQuery query); + + + Task GetBatchYearBySchoolId(PlanYearQuery query); + + Task> GetPlanBySchollId(PlanQuery query); + + /// + /// 获取院校排名 + /// + /// + /// + Task> GetUniversityRank(UniversityRankQuery query); + + + /// + /// 专业搜索 + /// + /// + /// + Task>> uniGetSearchMajor(NameBaseQuery query); + + + /// + /// 获取招生简章列表 + /// + /// + /// + Task>> GetRequestEnrollmentinproductionResult(UniversityIdQuery query); + + /// + /// 获取招生简介详情 + /// + /// + /// + Task> GetRequestEnrollmentinproductionDetailResult(StringIdQuery query); + + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_MajorCategoryServices.cs b/New_College.IServices/ID_MajorCategoryServices.cs new file mode 100644 index 0000000..c528ed6 --- /dev/null +++ b/New_College.IServices/ID_MajorCategoryServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_MajorCategoryServices + /// + public interface ID_MajorCategoryServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_MajorClassServices.cs b/New_College.IServices/ID_MajorClassServices.cs new file mode 100644 index 0000000..2ae9118 --- /dev/null +++ b/New_College.IServices/ID_MajorClassServices.cs @@ -0,0 +1,17 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// ID_MajorClassServices + /// + public interface ID_MajorClassServices :IBaseServices + { + Task> GetMajorClassListByType(IdQuery query); + + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_MajorInformationServices.cs b/New_College.IServices/ID_MajorInformationServices.cs new file mode 100644 index 0000000..5e3a28d --- /dev/null +++ b/New_College.IServices/ID_MajorInformationServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_MajorInformationServices + /// + public interface ID_MajorInformationServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_MajorMapOccouptionServices.cs b/New_College.IServices/ID_MajorMapOccouptionServices.cs new file mode 100644 index 0000000..d32df79 --- /dev/null +++ b/New_College.IServices/ID_MajorMapOccouptionServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_MajorMapOccouptionServices + /// + public interface ID_MajorMapOccouptionServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_MajorMapTagServices.cs b/New_College.IServices/ID_MajorMapTagServices.cs new file mode 100644 index 0000000..220e10f --- /dev/null +++ b/New_College.IServices/ID_MajorMapTagServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_MajorMapTagServices + /// + public interface ID_MajorMapTagServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_MajorMapUniversityServices.cs b/New_College.IServices/ID_MajorMapUniversityServices.cs new file mode 100644 index 0000000..68e15a6 --- /dev/null +++ b/New_College.IServices/ID_MajorMapUniversityServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_MajorMapUniversityServices + /// + public interface ID_MajorMapUniversityServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_MajorObtainServices.cs b/New_College.IServices/ID_MajorObtainServices.cs new file mode 100644 index 0000000..6e26c6f --- /dev/null +++ b/New_College.IServices/ID_MajorObtainServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_MajorObtainServices + /// + public interface ID_MajorObtainServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_MajorSalaryServices.cs b/New_College.IServices/ID_MajorSalaryServices.cs new file mode 100644 index 0000000..b0b857a --- /dev/null +++ b/New_College.IServices/ID_MajorSalaryServices.cs @@ -0,0 +1,24 @@ +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// ID_MajorSalaryServices + /// + public interface ID_MajorSalaryServices : IBaseServices + { + Task Import(); + + + /// + /// 获取高薪推荐 + /// + /// + Task>> GetMajorSalaryResult(MajorSalaryQuery query); + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_MajorServices.cs b/New_College.IServices/ID_MajorServices.cs new file mode 100644 index 0000000..c727d01 --- /dev/null +++ b/New_College.IServices/ID_MajorServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_MajorServices + /// + public interface ID_MajorServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_OccMapTagServices.cs b/New_College.IServices/ID_OccMapTagServices.cs new file mode 100644 index 0000000..f9e5312 --- /dev/null +++ b/New_College.IServices/ID_OccMapTagServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_OccMapTagServices + /// + public interface ID_OccMapTagServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_OccupationCategoryServices.cs b/New_College.IServices/ID_OccupationCategoryServices.cs new file mode 100644 index 0000000..2baa23d --- /dev/null +++ b/New_College.IServices/ID_OccupationCategoryServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_OccupationCategoryServices + /// + public interface ID_OccupationCategoryServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_OccupationServices.cs b/New_College.IServices/ID_OccupationServices.cs new file mode 100644 index 0000000..abfc7de --- /dev/null +++ b/New_College.IServices/ID_OccupationServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_OccupationServices + /// + public interface ID_OccupationServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_UniversityCollectionServices.cs b/New_College.IServices/ID_UniversityCollectionServices.cs new file mode 100644 index 0000000..e8ddf0b --- /dev/null +++ b/New_College.IServices/ID_UniversityCollectionServices.cs @@ -0,0 +1,35 @@ +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// ID_UniversityCollectionServices + /// + public interface ID_UniversityCollectionServices : IBaseServices + { + Task>> GetUniversityCollection(UniversityCollectionQuery query); + + Task> DeleteCollection(UniversityCollectionAddQuery query); + + Task> AddCollection(UniversityCollectionAddQuery query); + + /// + /// 获取院校对比结果 + /// + /// + Task>> GetUniversityContrasts(IdQuery query); + + /// + /// 报告 获取我喜欢的院校 + /// + /// + /// + Task>> GetUniversityMap(IdQuery query); + + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_UniversityRankServices.cs b/New_College.IServices/ID_UniversityRankServices.cs new file mode 100644 index 0000000..df341f0 --- /dev/null +++ b/New_College.IServices/ID_UniversityRankServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_UniversityRankServices + /// + public interface ID_UniversityRankServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_UniversityServices.cs b/New_College.IServices/ID_UniversityServices.cs new file mode 100644 index 0000000..a1bf94a --- /dev/null +++ b/New_College.IServices/ID_UniversityServices.cs @@ -0,0 +1,24 @@ +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// ID_UniversityServices + /// + public interface ID_UniversityServices : IBaseServices + { + Task SaveImg(); + + /// + /// 获取搜索学校 + /// + /// + /// + Task>> GetUniversitList(NameQuery query); + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_UniversityimgServices.cs b/New_College.IServices/ID_UniversityimgServices.cs new file mode 100644 index 0000000..bc3bf1b --- /dev/null +++ b/New_College.IServices/ID_UniversityimgServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_UniversityimgServices + /// + public interface ID_UniversityimgServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/IGuestbookServices.cs b/New_College.IServices/IGuestbookServices.cs new file mode 100644 index 0000000..04d8a43 --- /dev/null +++ b/New_College.IServices/IGuestbookServices.cs @@ -0,0 +1,13 @@ +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + public partial interface IGuestbookServices : IBaseServices + { + Task> TestTranInRepository(); + Task TestTranInRepositoryAOP(); + } +} diff --git a/New_College.IServices/IModulePermissionServices.cs b/New_College.IServices/IModulePermissionServices.cs new file mode 100644 index 0000000..28dd5a7 --- /dev/null +++ b/New_College.IServices/IModulePermissionServices.cs @@ -0,0 +1,9 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + public partial interface IModulePermissionServices : IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/IModuleServices.cs b/New_College.IServices/IModuleServices.cs new file mode 100644 index 0000000..73993f8 --- /dev/null +++ b/New_College.IServices/IModuleServices.cs @@ -0,0 +1,14 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ModuleServices + /// + public interface IModuleServices :IBaseServices + { + + + } +} diff --git a/New_College.IServices/IPasswordLibServices.cs b/New_College.IServices/IPasswordLibServices.cs new file mode 100644 index 0000000..d47c6c5 --- /dev/null +++ b/New_College.IServices/IPasswordLibServices.cs @@ -0,0 +1,9 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + public partial interface IPasswordLibServices :IBaseServices + { + } +} diff --git a/New_College.IServices/IPermissionServices.cs b/New_College.IServices/IPermissionServices.cs new file mode 100644 index 0000000..df662a8 --- /dev/null +++ b/New_College.IServices/IPermissionServices.cs @@ -0,0 +1,8 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +namespace New_College.IServices +{ + public partial interface IPermissionServices : IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/IRoleModulePermissionServices.cs b/New_College.IServices/IRoleModulePermissionServices.cs new file mode 100644 index 0000000..dbadcd4 --- /dev/null +++ b/New_College.IServices/IRoleModulePermissionServices.cs @@ -0,0 +1,19 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// RoleModulePermissionServices + /// + public interface IRoleModulePermissionServices :IBaseServices + { + + Task> GetRoleModule(); + Task> QueryMuchTable(); + Task> RoleModuleMaps(); + Task> GetRMPMaps(); + } +} diff --git a/New_College.IServices/IRoleServices.cs b/New_College.IServices/IRoleServices.cs new file mode 100644 index 0000000..69cb7ab --- /dev/null +++ b/New_College.IServices/IRoleServices.cs @@ -0,0 +1,16 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// RoleServices + /// + public interface IRoleServices :IBaseServices + { + Task SaveRole(string roleName); + Task GetRoleNameByRid(int rid); + + } +} diff --git a/New_College.IServices/ISysRegionServices.cs b/New_College.IServices/ISysRegionServices.cs new file mode 100644 index 0000000..a873cd9 --- /dev/null +++ b/New_College.IServices/ISysRegionServices.cs @@ -0,0 +1,18 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// ISysRegionServices + /// + public interface ISysRegionServices :IBaseServices + { + Task> GetListByParentId(string id); + + Task> GetRegionList(SysRegionQuery query); + } +} \ No newline at end of file diff --git a/New_College.IServices/IT_BatchTypeInfoServices.cs b/New_College.IServices/IT_BatchTypeInfoServices.cs new file mode 100644 index 0000000..06c3aaa --- /dev/null +++ b/New_College.IServices/IT_BatchTypeInfoServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// IT_BatchTypeInfoServices + /// + public interface IT_BatchTypeInfoServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/IT_BatchlineServices.cs b/New_College.IServices/IT_BatchlineServices.cs new file mode 100644 index 0000000..ddfa959 --- /dev/null +++ b/New_College.IServices/IT_BatchlineServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// IT_BatchlineServices + /// + public interface IT_BatchlineServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/IT_EnrollmentBatchServices.cs b/New_College.IServices/IT_EnrollmentBatchServices.cs new file mode 100644 index 0000000..89b3858 --- /dev/null +++ b/New_College.IServices/IT_EnrollmentBatchServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// IT_EnrollmentBatchServices + /// + public interface IT_EnrollmentBatchServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/IT_EnrollmentPlaneServices.cs b/New_College.IServices/IT_EnrollmentPlaneServices.cs new file mode 100644 index 0000000..a2ac542 --- /dev/null +++ b/New_College.IServices/IT_EnrollmentPlaneServices.cs @@ -0,0 +1,14 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// IT_EnrollmentPlaneServices + /// + public interface IT_EnrollmentPlaneServices :IBaseServices + { + Task Import(); + } +} \ No newline at end of file diff --git a/New_College.IServices/IT_EnrollmentPlanedescServices.cs b/New_College.IServices/IT_EnrollmentPlanedescServices.cs new file mode 100644 index 0000000..c11f349 --- /dev/null +++ b/New_College.IServices/IT_EnrollmentPlanedescServices.cs @@ -0,0 +1,131 @@ +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// IT_EnrollmentPlanedescServices + /// + public interface IT_EnrollmentPlanedescServices : IBaseServices + { + Task> GetRecommendUniversity(RecommendUniversityQuery query); + + Task>> GetEnrollmentLazyByPage(LazyEnrollmentPlaneQuery query); + + Task>> GetPlanByUniversity(PlanDetailQuery query); + + Task>> GetBatchByAreaAndYear(BatchQuery query); + + Task>> GetEnrollmentCWBByPage(CWBEnrollmentPlaneQuery query); + + + /// + /// 冲稳保详情 + /// + /// + /// + Task>> GetCWBUniversityDetail(CWBUniversityDetailQuery query); + + + Task>> GetEnrollmentTagByPage(TagEnrollmentPlaneQuery query); + + /// + /// 获取分析结果录取概率 获取之后保存一下 + /// + /// + /// + Task> GetUniversityProbability(UniversityProbabilityQuery query); + + /// + /// 获取概率历史记录列表 + /// + /// + Task>> GetProbabilityResult(ProbabilityQuery query); + + + /// + /// 保存志愿表 + /// + /// + /// + Task> SaveVolunteerTable(VolunteerTableQuery query); + + /// + /// 获取个人志愿列表 传Id + /// + /// + /// + Task>> GetVolunteerTableList(IdQuery query); + + /// + /// 获取志愿表详情 传Id + /// + /// + /// + Task>> GetVolunteerTableDetail(IdQuery query); + + /// + /// 删除志愿表 + /// + /// + /// + Task> DeleteVolunteerTable(IdQuery query); + + /// + /// 保存志愿表 霍兰德专用 + /// + /// + /// + Task> SaveHollandVolunteer(HollandVolunteerTableQuery query); + + /// + /// 获取一键生成的志愿表 + /// + /// + /// + Task>> GetAutoVolunteerTableDetail(VolunteerTableQuery query); + + /// + /// 获取霍兰德一键生成的志愿表 + /// + /// + /// + Task>> GetHollandVolunteerTableDetail(HollandVolunteerTableQuery query); + + + /// + /// 根据标签推荐选科 + /// + /// + /// + Task> GetSubjectSelectByTag(ByTagSubjectSelectQuery query); + + + /// + /// 获取喜欢的院校 + /// + /// + /// + Task>> GetLikeSchoolMajor(IdQuery query); + + + /// + /// 专业规划 + /// + /// + Task>> GetMajorPlanClaim(CustomerQuery query); + + + /// + /// 获取批次 + /// + /// + /// + Task>> GetBatchByYearArea(YearAreaQuery query); + + } +} \ No newline at end of file diff --git a/New_College.IServices/IT_GearInfoServices.cs b/New_College.IServices/IT_GearInfoServices.cs new file mode 100644 index 0000000..df29f42 --- /dev/null +++ b/New_College.IServices/IT_GearInfoServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// IT_GearInfoServices + /// + public interface IT_GearInfoServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/IT_LongIdMapServices.cs b/New_College.IServices/IT_LongIdMapServices.cs new file mode 100644 index 0000000..966cb63 --- /dev/null +++ b/New_College.IServices/IT_LongIdMapServices.cs @@ -0,0 +1,18 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// IT_LongIdMapServices + /// + public interface IT_LongIdMapServices :IBaseServices + { + Task ImportEnrollmentBatch(); + Task ImportEnrollmentPlane(); + Task ImportEnrollmentPlanedesc(); + Task ImportBatchline(); + Task ImportBatchTypeInfo(); + } +} \ No newline at end of file diff --git a/New_College.IServices/IT_PlanMapTagServices.cs b/New_College.IServices/IT_PlanMapTagServices.cs new file mode 100644 index 0000000..9fd0f54 --- /dev/null +++ b/New_College.IServices/IT_PlanMapTagServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// IT_PlanMapTagServices + /// + public interface IT_PlanMapTagServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/IT_RegionScoreServices.cs b/New_College.IServices/IT_RegionScoreServices.cs new file mode 100644 index 0000000..ee52a5f --- /dev/null +++ b/New_College.IServices/IT_RegionScoreServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// IT_RegionScoreServices + /// + public interface IT_RegionScoreServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ITasksQzServices.cs b/New_College.IServices/ITasksQzServices.cs new file mode 100644 index 0000000..6ae2cf8 --- /dev/null +++ b/New_College.IServices/ITasksQzServices.cs @@ -0,0 +1,16 @@ + +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ITasksQzServices + /// + public interface ITasksQzServices :IBaseServices + { + + + } +} + \ No newline at end of file diff --git a/New_College.IServices/ITest_CategoryInfoServices.cs b/New_College.IServices/ITest_CategoryInfoServices.cs new file mode 100644 index 0000000..074e094 --- /dev/null +++ b/New_College.IServices/ITest_CategoryInfoServices.cs @@ -0,0 +1,18 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// ITest_CategoryInfoServices + /// + public interface ITest_CategoryInfoServices :IBaseServices + { + Task> GetCateSelectByType(CategoryInfoQuery query); + + Task GetTestStatus(CategoryStatusQuery query); + } +} \ No newline at end of file diff --git a/New_College.IServices/ITest_CycleTimeInfoServices.cs b/New_College.IServices/ITest_CycleTimeInfoServices.cs new file mode 100644 index 0000000..414595d --- /dev/null +++ b/New_College.IServices/ITest_CycleTimeInfoServices.cs @@ -0,0 +1,15 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// ITest_CycleTimeInfoServices + /// + public interface ITest_CycleTimeInfoServices :IBaseServices + { + Task AutoCycleTime(); + + } +} \ No newline at end of file diff --git a/New_College.IServices/ITest_HollandResultInfoServices.cs b/New_College.IServices/ITest_HollandResultInfoServices.cs new file mode 100644 index 0000000..b1d744c --- /dev/null +++ b/New_College.IServices/ITest_HollandResultInfoServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ITest_HollandResultInfoServices + /// + public interface ITest_HollandResultInfoServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ITest_MBTIMapResultServices.cs b/New_College.IServices/ITest_MBTIMapResultServices.cs new file mode 100644 index 0000000..c327613 --- /dev/null +++ b/New_College.IServices/ITest_MBTIMapResultServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ITest_MBTIMapResultServices + /// + public interface ITest_MBTIMapResultServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ITest_PsychMeasurementInfoServices.cs b/New_College.IServices/ITest_PsychMeasurementInfoServices.cs new file mode 100644 index 0000000..242fd06 --- /dev/null +++ b/New_College.IServices/ITest_PsychMeasurementInfoServices.cs @@ -0,0 +1,66 @@ +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// ITest_PsychMeasurementInfoServices + /// + public interface ITest_PsychMeasurementInfoServices : IBaseServices + { + Task> GetPsychListByCateAndCustomerId(PsychMeasurementQuery query); + + Task SavePsych(SavePsychQuery query); + + Task GetPsychDetail(ResultLookQuery query); + + Task SaveHolland(SaveHollandQuery query); + + + Task GetHollandResult(ResultLookQuery query); + + Task GetMBTIResult(ResultLookQuery query); + + Task> SubjectChartRadar(ResultLookQuery query); + + /// + /// 传入用户Id 获取霍兰德测评状态 + /// + /// + /// + Task> GetHollandStatus(IdQuery query); + + /// + /// 传入用户Id 获取学科探索测评状态 + /// + /// + /// + Task> GetSubjectSelectStatus(IdQuery query); + + /// + /// 获取测评最新周期Id + /// + /// + /// + Task> GetReportCycleInfo(IdQuery query); + + /// + /// 获取三种推荐选科 + /// + /// + /// + Task>> GetSubjectSelectResult(NewSubjectQuery query); + + /// + /// 根绝霍兰德获取推荐选科 + /// + /// + /// + Task> GetHollandSubject(HollandSubjectQuery query); + + } +} \ No newline at end of file diff --git a/New_College.IServices/ITest_QuestionInfoServices.cs b/New_College.IServices/ITest_QuestionInfoServices.cs new file mode 100644 index 0000000..52b6dab --- /dev/null +++ b/New_College.IServices/ITest_QuestionInfoServices.cs @@ -0,0 +1,18 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// ITest_QuestionInfoServices + /// + public interface ITest_QuestionInfoServices : IBaseServices + { + Task> GetQuestion(appQuestionQuery query); + + Task> GetQuestionMBTI(); + } +} \ No newline at end of file diff --git a/New_College.IServices/ITest_QuestionTypeInfoServices.cs b/New_College.IServices/ITest_QuestionTypeInfoServices.cs new file mode 100644 index 0000000..2f9b612 --- /dev/null +++ b/New_College.IServices/ITest_QuestionTypeInfoServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ITest_QuestionTypeInfoServices + /// + public interface ITest_QuestionTypeInfoServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ITopicDetailServices.cs b/New_College.IServices/ITopicDetailServices.cs new file mode 100644 index 0000000..465e3d1 --- /dev/null +++ b/New_College.IServices/ITopicDetailServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + public interface ITopicDetailServices : IBaseServices + { + Task> GetTopicDetails(); + } +} diff --git a/New_College.IServices/ITopicServices.cs b/New_College.IServices/ITopicServices.cs new file mode 100644 index 0000000..e43f9df --- /dev/null +++ b/New_College.IServices/ITopicServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + public interface ITopicServices : IBaseServices + { + Task> GetTopics(); + } +} diff --git a/New_College.IServices/IU_ProbabilityHistoryServices.cs b/New_College.IServices/IU_ProbabilityHistoryServices.cs new file mode 100644 index 0000000..92368dc --- /dev/null +++ b/New_College.IServices/IU_ProbabilityHistoryServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// IU_ProbabilityHistoryServices + /// + public interface IU_ProbabilityHistoryServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/IU_VolunteerTableDetailServices.cs b/New_College.IServices/IU_VolunteerTableDetailServices.cs new file mode 100644 index 0000000..552d4b0 --- /dev/null +++ b/New_College.IServices/IU_VolunteerTableDetailServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// IU_VolunteerTableDetailServices + /// + public interface IU_VolunteerTableDetailServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/IU_VolunteerTableServices.cs b/New_College.IServices/IU_VolunteerTableServices.cs new file mode 100644 index 0000000..9497bc0 --- /dev/null +++ b/New_College.IServices/IU_VolunteerTableServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// IU_VolunteerTableServices + /// + public interface IU_VolunteerTableServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/IUserRoleServices.cs b/New_College.IServices/IUserRoleServices.cs new file mode 100644 index 0000000..a82407f --- /dev/null +++ b/New_College.IServices/IUserRoleServices.cs @@ -0,0 +1,17 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// UserRoleServices + /// + public interface IUserRoleServices :IBaseServices + { + + Task SaveUserRole(int uid, int rid); + Task GetRoleIdByUid(int uid); + } +} + diff --git a/New_College.IServices/IV_CustomerInfoServices.cs b/New_College.IServices/IV_CustomerInfoServices.cs new file mode 100644 index 0000000..4e98412 --- /dev/null +++ b/New_College.IServices/IV_CustomerInfoServices.cs @@ -0,0 +1,69 @@ +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.Request; +using New_College.Model.ViewModels; +using System; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// IV_CustomerInfoServices + /// + public interface IV_CustomerInfoServices : IBaseServices + { + Task Login(CustomerInfoQuery query); + + Task SendLogin(PhoneQuery query); + + Task UpdateCustomerInfo(UpdateCustomerQuery query); + + Task ResetPwd(ResetPwdQuery query); + + Task SendReset(PhoneQuery query); + + Task UpdateScore(UpdateScoreQuery query); + + Task UpdateCustomer(CustomerUpdateQuery query); + + /// + /// 根绝Id获取用户信息 + /// + /// + /// + Task> GetCustomerInfoById(IdQuery query); + + + Task>> GetCustomerInfoListByPage(CustomerSeachQuery query); + + + + Weixinauthinfo AuthCode2Session(string Code); + string GetWeixinPhone(GetPhoneInfo phoneInfo); + + Task> Logined(LoginQuery query); + Task> GetUserInfo(LoginQuery query); + /// + /// 通过openid获取用户id + /// + /// + /// + Task GetCustomerId(string OpenId); + /// + /// 通过用户id获取openid + /// + /// + /// + Task GetOpenId(int CustomerId); + + + /// + /// + /// + /// + /// + Task CustomerSave(DecryptUserInfoRequest register); + + } +} \ No newline at end of file diff --git a/New_College.IServices/IV_ExaminationPolicyServices.cs b/New_College.IServices/IV_ExaminationPolicyServices.cs new file mode 100644 index 0000000..489a44c --- /dev/null +++ b/New_College.IServices/IV_ExaminationPolicyServices.cs @@ -0,0 +1,27 @@ +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// IV_ExaminationPolicyServices + /// + public interface IV_ExaminationPolicyServices :IBaseServices + { + Task>> GetExaminationPolicyByPage(ExaminationPolicySearchQuery query); + + Task> GetExaminationPolicyOne(IdQuery query); + + Task> AddExaminationPolicy(ExaminationPolicyQuery query); + + Task> UpdateExaminationPolicy(ExaminationPolicyQuery query); + + Task> DeleteExaminationPolicy(IdQuery query); + + + Task> GetExaminationPolicyDetail(ExaminationPolicyAreaQuery query); + } +} \ No newline at end of file diff --git a/New_College.IServices/IV_OrderInfoServices.cs b/New_College.IServices/IV_OrderInfoServices.cs new file mode 100644 index 0000000..2d48ca4 --- /dev/null +++ b/New_College.IServices/IV_OrderInfoServices.cs @@ -0,0 +1,64 @@ +using New_College.Common; +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// IV_OrderInfoServices + /// + public interface IV_OrderInfoServices : IBaseServices + { + + Task CreateOrder(UniOrderQuery query); + + Task UpdateOrderStatus(string orderNo, EnumPayType payType, string trade_no); + + + /// + /// 唤醒微信H5支付 + /// + /// + /// + Task> WechatPubPay(WeChatPayQuery query); + + /// + /// 微信订单查询确认 传用户Id + /// + /// + /// + Task> WeChatPayStatus(IdQuery query); + + /// + /// 支付宝 订单确认 + /// + /// + /// + Task> AliPayStatus(IdQuery query); + + /// + /// 获取vip信息(分页) + /// + /// + /// + Task>> GetOrderInfoByPage(SearchOrderQuery query); + + /// + /// 支付成功后操作 + /// + /// + /// + Task> PaySuccess(V_OrderInfo query); + + /// + /// 支付宝H5支付 + /// + /// + /// + Task> AliH5Pay(WeChatPayQuery query); + + } +} \ No newline at end of file diff --git a/New_College.IServices/IV_SubjectSelectServices.cs b/New_College.IServices/IV_SubjectSelectServices.cs new file mode 100644 index 0000000..47fa162 --- /dev/null +++ b/New_College.IServices/IV_SubjectSelectServices.cs @@ -0,0 +1,28 @@ +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// IV_SubjectSelectServices + /// + public interface IV_SubjectSelectServices : IBaseServices + { + /// + /// 获取我的自选科目 + /// + /// + /// + Task> GetSubjectSelect(IdQuery query); + + /// + /// 保存我的选科 + /// + /// + /// + Task> SaveSubjectSelect(SubjectSelectQuery query); + } +} \ No newline at end of file diff --git a/New_College.IServices/IV_VipCardInfoServices.cs b/New_College.IServices/IV_VipCardInfoServices.cs new file mode 100644 index 0000000..b51187f --- /dev/null +++ b/New_College.IServices/IV_VipCardInfoServices.cs @@ -0,0 +1,72 @@ +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using New_College.Model.ViewModels.Query; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// IV_VipCardInfoServices + /// + public interface IV_VipCardInfoServices : IBaseServices + { + + Task> BindCardInfo(VipCardQuery query); + + + /// + /// 获取vip信息 + /// + /// + /// + Task> GetVipInfo(IdQuery query); + + + /// + /// 生成卡信息 + /// + /// + /// + Task>> AutoVipCardInfo(AutoVipInfoQuery query); + + /// + /// 获取vip信息(分页) + /// + /// + /// + Task>> GetVipCardInfoByPage(VipCardInfoSearchQuery query); + + /// + /// 获取单个vip信息 + /// + /// + /// + Task> GetVipCardInfoOne(IdQuery query); + /// + /// 添加vip + /// + /// + /// + Task> AddVipCardInfo(VipCardInfoQuery query); + + + /// + /// 更新vip + /// + /// + /// + Task> UpdateVipCardInfo(VipCardInfoQuery query); + + /// + /// 删除vip + /// + /// + /// + Task> DeleteVipCardInfo(IdQuery query); + + + } +} \ No newline at end of file diff --git a/New_College.IServices/IV_VipCardTypeServices.cs b/New_College.IServices/IV_VipCardTypeServices.cs new file mode 100644 index 0000000..d17be34 --- /dev/null +++ b/New_College.IServices/IV_VipCardTypeServices.cs @@ -0,0 +1,22 @@ +using New_College.IServices.BASE; +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using New_College.Model.ViewModels.Query; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// IV_VipCardTypeServices + /// + public interface IV_VipCardTypeServices :IBaseServices + { + Task> GetVipCardTypeList(); + + + Task> GetVipCardType(); + + } +} \ No newline at end of file diff --git a/New_College.IServices/IsysUserInfoServices.cs b/New_College.IServices/IsysUserInfoServices.cs new file mode 100644 index 0000000..29cec98 --- /dev/null +++ b/New_College.IServices/IsysUserInfoServices.cs @@ -0,0 +1,17 @@ + + +using New_College.IServices.BASE; +using New_College.Model.Models; +using System.Threading.Tasks; + +namespace New_College.IServices +{ + /// + /// sysUserInfoServices + /// + public interface ISysUserInfoServices :IBaseServices + { + Task SaveUserInfo(string loginName, string loginPwd); + Task GetUserRoleNameStr(string loginName, string loginPwd); + } +} diff --git a/New_College.IServices/New_College.IServices.csproj b/New_College.IServices/New_College.IServices.csproj new file mode 100644 index 0000000..fdf3dd7 --- /dev/null +++ b/New_College.IServices/New_College.IServices.csproj @@ -0,0 +1,11 @@ + + + + netcoreapp3.1 + + + + + + + diff --git a/New_College.IServices/WebApiClients/DoubanApis/DoubanViewModel.cs b/New_College.IServices/WebApiClients/DoubanApis/DoubanViewModel.cs new file mode 100644 index 0000000..28fac89 --- /dev/null +++ b/New_College.IServices/WebApiClients/DoubanApis/DoubanViewModel.cs @@ -0,0 +1,96 @@ +namespace New_College.Common.WebApiClients.HttpApis +{ + public class Data + { + /// + /// + /// + public string isbn { get; set; } + /// + /// 解忧杂货店 + /// + public string title { get; set; } + /// + /// ナミヤ雑貨店の奇蹟 + /// + public string origintitle { get; set; } + /// + /// + /// + public string subtitle { get; set; } + /// + /// + /// + public string image { get; set; } + /// + /// [日]东野圭吾 + /// + public string author { get; set; } + /// + /// 李盈春 + /// + public string translator { get; set; } + /// + /// 南海出版公司 + /// + public string publisher { get; set; } + /// + /// + /// + public string pubdate { get; set; } + /// + /// <东野圭吾><治愈><温暖><小说><日本><日本文学><東野圭吾><推理> + /// + public string tags { get; set; } + /// + /// + /// + public string kaiben { get; set; } + /// + /// + /// + public string zhizhang { get; set; } + /// + /// 精装 + /// + public string binding { get; set; } + /// + /// + /// + public string taozhuang { get; set; } + /// + /// 新经典文库·东野圭吾作品 + /// + public string series { get; set; } + /// + /// + /// + public string pages { get; set; } + /// + /// 39.50元 + /// + public string price { get; set; } + + public string author_intro { get; set; } + + public string summary { get; set; } + + public string catalog { get; set; } + } + + public class DoubanViewModel + { + /// + /// + /// + public string status { get; set; } + /// + /// + /// + public Data data { get; set; } + /// + /// 获取图书数据成功 + /// + public string msg { get; set; } + } +} diff --git a/New_College.IServices/WebApiClients/DoubanApis/IDoubanApi.cs b/New_College.IServices/WebApiClients/DoubanApis/IDoubanApi.cs new file mode 100644 index 0000000..4d14497 --- /dev/null +++ b/New_College.IServices/WebApiClients/DoubanApis/IDoubanApi.cs @@ -0,0 +1,22 @@ +using WebApiClient; +using WebApiClient.Attributes; + +namespace New_College.Common.WebApiClients.HttpApis +{ + /// + /// 豆瓣视频管理 + /// + [TraceFilter] + public interface IDoubanApi : IHttpApi + { + /// + /// 获取电影详情 + /// + /// + [HttpGet("api/bookinfo")] + ITask VideoDetailAsync(string isbn); + + } + + +} diff --git a/New_College.IServices/WebApiClients/HttpApis/IBlogApi.cs b/New_College.IServices/WebApiClients/HttpApis/IBlogApi.cs new file mode 100644 index 0000000..7d617db --- /dev/null +++ b/New_College.IServices/WebApiClients/HttpApis/IBlogApi.cs @@ -0,0 +1,84 @@ +using New_College.Model; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using System.ComponentModel.DataAnnotations; +using System.Threading.Tasks; +using WebApiClient; +using WebApiClient.Attributes; + +namespace New_College.Common.WebApiClients.HttpApis +{ + /// + /// 博客管理 + /// + [TraceFilter] + public interface IBlogApi : IHttpApi + { + /// + /// 获取博客列表【无权限】 + /// + /// + /// + /// + /// + /// Success + [HttpGet("api/Blog")] + Task>> BlogAsync(int? id, int page, string bcategory, string key); + + /// + /// 添加博客【无权限】 + /// + /// + /// Success + [HttpPost("api/Blog")] + Task> Blog2Async([JsonContent] BlogArticle body); + + /// + /// 获取博客详情 (Auth) + /// + /// + /// Success + [HttpGet("api/Blog/{id}")] + Task> Blog3Async([Required] int id); + + /// + /// apache jemeter 压力测试 + /// 更新接口 + /// + /// Success + [HttpGet("api/Blog/ApacheTestUpdate")] + Task> ApacheTestUpdateAsync(); + + /// + /// 删除博客 (Auth policies: Permission) + /// + /// + /// Success + [HttpDelete("api/Blog/Delete")] + Task> DeleteAsync(int? id); + + /// + /// 获取详情【无权限】 + /// + /// + /// Success + [HttpGet("api/Blog/DetailNuxtNoPer")] + Task> DetailNuxtNoPerAsync(int? id); + + /// + /// 更新博客信息 (Auth) + /// + /// + /// Success + [HttpPut("api/Blog/Update")] + Task> UpdateAsync([JsonContent] BlogArticle body); + + /// + /// 获取博客测试信息 v2版本 + /// + /// Success + [HttpGet("api/V2/Blog/Blogtest")] + Task> BlogtestAsync(); + + } +} diff --git a/New_College.Model/Love.cs b/New_College.Model/Love.cs new file mode 100644 index 0000000..b266d2b --- /dev/null +++ b/New_College.Model/Love.cs @@ -0,0 +1,25 @@ +namespace New_College.Model +{ + /// + /// 这是爱 + /// + public class Love + { + public virtual string SayLoveU() + { + return "I ♥ U"; + } + /// + /// id + /// + public int Id { get; set; } + /// + /// 姓名 + /// + public string Name { get; set; } + /// + /// 年龄 + /// + public int Age { get; set; } + } +} diff --git a/New_College.Model/MessageModel.cs b/New_College.Model/MessageModel.cs new file mode 100644 index 0000000..742165b --- /dev/null +++ b/New_College.Model/MessageModel.cs @@ -0,0 +1,26 @@ +namespace New_College.Model +{ + /// + /// 通用返回信息类 + /// + public class MessageModel + { + /// + /// 状态码 + /// + public int status { get; set; } = 200; + /// + /// 操作是否成功 + /// + public bool success { get; set; } = false; + /// + /// 返回信息 + /// + public string msg { get; set; } = "服务器异常"; + /// + /// 返回数据集合 + /// + public T response { get; set; } + + } +} diff --git a/New_College.Model/Models/Advertisement.cs b/New_College.Model/Models/Advertisement.cs new file mode 100644 index 0000000..db78578 --- /dev/null +++ b/New_College.Model/Models/Advertisement.cs @@ -0,0 +1,35 @@ +using SqlSugar; +using System; + +namespace New_College.Model.Models +{ + public class Advertisement : RootEntity + { + + /// + /// 广告图片 + /// + [SugarColumn(Length = 512, IsNullable = true, ColumnDataType = "nvarchar")] + public string ImgUrl { get; set; } + + /// + /// 广告标题 + /// + [SugarColumn(Length = 64, IsNullable = true, ColumnDataType = "nvarchar")] + public string Title { get; set; } + + /// + /// 广告链接 + /// + [SugarColumn(Length = 256, IsNullable = true, ColumnDataType = "nvarchar")] + public string Url { get; set; } + + /// + /// 备注 + /// + [SugarColumn(Length = int.MaxValue, IsNullable = true, ColumnDataType = "nvarchar")] + public string Remark { get; set; } + + + } +} diff --git a/New_College.Model/Models/BannerInfo.cs b/New_College.Model/Models/BannerInfo.cs new file mode 100644 index 0000000..3d78ca3 --- /dev/null +++ b/New_College.Model/Models/BannerInfo.cs @@ -0,0 +1,43 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + + /// + /// 海报管理 + /// + public class BannerInfo : RootEntity + { + /// + /// banner name + /// + [SugarColumn(IsNullable = true)] + public string bannerName { get; set; } + + /// + /// 图片地址 + /// + [SugarColumn(IsNullable = true)] + public string bannerUrl { get; set; } + + /// + /// 要去的地址 + /// + [SugarColumn(IsNullable = true)] + public string goUrl { get; set; } + + /// + /// banner 0,不展示,1展示是否展示 + /// + public int status { get; set; } + + /// + /// 海报位置:0 首页banner + /// + public int type { get; set; } + + } +} diff --git a/New_College.Model/Models/BlogArticle.cs b/New_College.Model/Models/BlogArticle.cs new file mode 100644 index 0000000..adc08be --- /dev/null +++ b/New_College.Model/Models/BlogArticle.cs @@ -0,0 +1,73 @@ +using SqlSugar; +using System; + +namespace New_College.Model.Models +{ + /// + /// 博客文章 + /// + public class BlogArticle + { + /// + /// 主键 + /// + /// 这里之所以没用RootEntity,是想保持和之前的数据库一致,主键是bID,不是Id + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] + public int bID { get; set; } + /// + /// 创建人 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 60, IsNullable = true)] + public string bsubmitter { get; set; } + + /// + /// 标题blog + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 256, IsNullable = true)] + public string btitle { get; set; } + + /// + /// 类别 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string bcategory { get; set; } + + /// + /// 内容 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string bcontent { get; set; } + + /// + /// 访问量 + /// + public int btraffic { get; set; } + + /// + /// 评论数量 + /// + public int bcommentNum { get; set; } + + /// + /// 修改时间 + /// + public DateTime bUpdateTime { get; set; } + + /// + /// 创建时间 + /// + public System.DateTime bCreateTime { get; set; } + /// + /// 备注 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string bRemark { get; set; } + + /// + /// 逻辑删除 + /// + [SugarColumn(IsNullable = true)] + public bool? IsDeleted { get; set; } + + } +} diff --git a/New_College.Model/Models/D_Enrollmentinproduction.cs b/New_College.Model/Models/D_Enrollmentinproduction.cs new file mode 100644 index 0000000..cc6cba4 --- /dev/null +++ b/New_College.Model/Models/D_Enrollmentinproduction.cs @@ -0,0 +1,38 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; +using YIJIYI.Core.Common.Helper; + +namespace New_College.Model.Models +{ + /// + /// 招生简章 + /// + public class D_Enrollmentinproduction : EntityModel + { + /// + /// 院校Id + /// + [SugarColumn(IsNullable = true)] + public int Universityid { get; set; } + + /// + /// 发布时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime Pushdate { get; set; } = TimeUtil.GetCstDateTime(); + + /// + /// 标题 + /// + [SugarColumn(IsNullable = true)] + public string Title { get; set; } + + /// + /// 文章内容 + /// + [SugarColumn(IsNullable = true)] + public string Content { get; set; } + } +} diff --git a/New_College.Model/Models/D_GraduateFlow.cs b/New_College.Model/Models/D_GraduateFlow.cs new file mode 100644 index 0000000..91b6c58 --- /dev/null +++ b/New_College.Model/Models/D_GraduateFlow.cs @@ -0,0 +1,19 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_GraduateFlow : EntityModel + { + [SugarColumn(IsNullable = true)] + public int UniversityId { get; set; } + + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string Provinces { get; set; } + + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string Attrs { get; set; } + } +} diff --git a/New_College.Model/Models/D_LongIdMap.cs b/New_College.Model/Models/D_LongIdMap.cs new file mode 100644 index 0000000..fb64402 --- /dev/null +++ b/New_College.Model/Models/D_LongIdMap.cs @@ -0,0 +1,18 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_LongIdMap : EntityModel + { + [SugarColumn(IsNullable = true)] + public string longid { get; set; } + [SugarColumn(IsNullable = true)] + public int newid { get; set; } + + [SugarColumn(IsNullable = true)] + public string table { get; set; } + } +} diff --git a/New_College.Model/Models/D_Major.cs b/New_College.Model/Models/D_Major.cs new file mode 100644 index 0000000..21584a4 --- /dev/null +++ b/New_College.Model/Models/D_Major.cs @@ -0,0 +1,44 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_Major : EntityModel + { + [SugarColumn(IsNullable = true)] + public string Name { get; set; } + + /// + /// 专业二级分类id + /// + [SugarColumn(IsNullable = true)] + public int CategoryClass_Id { get; set; } + /// + /// 专业名称 + /// + [SugarColumn(IsNullable = true)] + public string MajorName { get; set; } + + /// + /// 教育部专业编号 + /// + [SugarColumn(IsNullable = true)] + public string MajorCode { get; set; } + + /// + /// 热度 + /// + [SugarColumn(IsNullable = true)] + public int Hot { get; set; } + + /// + /// 专业分类 1文科 2理科 3不区分 + /// + [SugarColumn(IsNullable = true)] + public int Type { get; set; } + + + } +} diff --git a/New_College.Model/Models/D_MajorCategory.cs b/New_College.Model/Models/D_MajorCategory.cs new file mode 100644 index 0000000..9d3024c --- /dev/null +++ b/New_College.Model/Models/D_MajorCategory.cs @@ -0,0 +1,30 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_MajorCategory : EntityModel + { + [SugarColumn(IsNullable = true)] + public string Name { get; set; } + /// + /// + /// + [SugarColumn(IsNullable = true)] + public string TradeNumber { get; set; } + /// + /// + /// + [SugarColumn(IsNullable = true)] + public string TradeName { get; set; } + + /// + /// 本科/专科大类 1本科 2 专科 + /// + [SugarColumn(IsNullable = true)] + public int Type { get; set; } + + } +} diff --git a/New_College.Model/Models/D_MajorClass.cs b/New_College.Model/Models/D_MajorClass.cs new file mode 100644 index 0000000..a9b5766 --- /dev/null +++ b/New_College.Model/Models/D_MajorClass.cs @@ -0,0 +1,25 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_MajorClass : EntityModel + { + [SugarColumn(IsNullable = true)] + public string Name { get; set; } + + /// + /// 专业类型名称 + /// + [SugarColumn(IsNullable = true)] + public string Categoryname { get; set; } + /// + /// 专业一级分类id + /// + [SugarColumn(IsNullable = true)] + public int TradeId { get; set; } + + } +} diff --git a/New_College.Model/Models/D_MajorInformation.cs b/New_College.Model/Models/D_MajorInformation.cs new file mode 100644 index 0000000..55030dd --- /dev/null +++ b/New_College.Model/Models/D_MajorInformation.cs @@ -0,0 +1,48 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_MajorInformation : EntityModel + { + [SugarColumn(IsNullable = true)] + public string Name { get; set; } + /// + /// 院校id + /// + [SugarColumn(IsNullable = true)] + public int UniversityId { get; set; } + /// + /// 专业id + /// + [SugarColumn(IsNullable = true)] + public int MajorId { get; set; } + /// + /// 专业主修课程 + /// + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string Majorcourse { get; set; } + /// + /// 专业前景 + /// + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string Majorintent { get; set; } + /// + /// 专业介绍 + /// + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string Majordescription { get; set; } + /// + /// 相关技能 + /// + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string Skill { get; set; } + /// + /// 考研方向 + /// + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string Postgraduate { get; set; } + } +} diff --git a/New_College.Model/Models/D_MajorMapOccouption.cs b/New_College.Model/Models/D_MajorMapOccouption.cs new file mode 100644 index 0000000..c843b0d --- /dev/null +++ b/New_College.Model/Models/D_MajorMapOccouption.cs @@ -0,0 +1,23 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_MajorMapOccouption : EntityModel + { + /// + /// 专业ID + /// + [SugarColumn(IsNullable = true)] + public long MajorId { get; set; } + + /// + /// 职业ID + /// + [SugarColumn(IsNullable = true)] + public long OccouptionId { get; set; } + + } +} diff --git a/New_College.Model/Models/D_MajorMapTag.cs b/New_College.Model/Models/D_MajorMapTag.cs new file mode 100644 index 0000000..6d16282 --- /dev/null +++ b/New_College.Model/Models/D_MajorMapTag.cs @@ -0,0 +1,25 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_MajorMapTag : EntityModel + { + [SugarColumn(IsNullable = true)] + public string Name { get; set; } + + /// + /// 职业id + /// + [SugarColumn(IsNullable = true)] + public int MajorId { get; set; } + + /// + /// 标签 + /// + [SugarColumn(IsNullable = true)] + public string Tag { get; set; } + } +} diff --git a/New_College.Model/Models/D_MajorMapUniversity.cs b/New_College.Model/Models/D_MajorMapUniversity.cs new file mode 100644 index 0000000..4764adc --- /dev/null +++ b/New_College.Model/Models/D_MajorMapUniversity.cs @@ -0,0 +1,28 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_MajorMapUniversity : EntityModel + { + /// + /// 院校id + /// + [SugarColumn(IsNullable = true)] + public int Universityid { get; set; } + + /// + /// 专业id + /// + [SugarColumn(IsNullable = true)] + public int MajorId { get; set; } + + /// + /// 是否为特殊专业,0为不是,1为是 + /// + [SugarColumn(IsNullable = true)] + public int sp { get; set; } + } +} diff --git a/New_College.Model/Models/D_MajorObtain.cs b/New_College.Model/Models/D_MajorObtain.cs new file mode 100644 index 0000000..5f32b74 --- /dev/null +++ b/New_College.Model/Models/D_MajorObtain.cs @@ -0,0 +1,131 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_MajorObtain:EntityModel + { + public int MajorId { get; set; } + /// + /// 专业名称 + /// + [SugarColumn(IsNullable = true)] + public string MajorName { get; set; } + + /// + /// 就业概况-名次 + /// + [SugarColumn(IsNullable = true)] + public string ObtainRank { get; set; } + + /// + /// 就业概况-名次描述 + /// + [SugarColumn(IsNullable = true)] + public string ObtainRankDetail { get; set; } + + /// + /// 就业最多地区 + /// + [SugarColumn(IsNullable = true)] + public string ObtainMoreArea { get; set; } + + /// + /// 就业最多行业 + /// + [SugarColumn(IsNullable = true)] + public string ObtainMostIndustries { get; set; } + + /// + /// 就业行业分布 + /// + [SugarColumn(IsNullable = true)] + public string ObtainIndustryDis { get; set; } + + /// + /// 就业行业分布比例 + /// + [SugarColumn(IsNullable = true)] + public string ObtainIndustryDisProportion { get; set; } + + /// + /// 就业地区分布 + /// + [SugarColumn(IsNullable = true)] + public string ObtainRegionalDis { get; set; } + + /// + /// 就业地区分布比例 + /// + [SugarColumn(IsNullable = true)] + public string ObtainRegionalDisProportion { get; set; } + + /// + /// 工资情况 + /// + [SugarColumn(IsNullable = true)] + public string WageSituation { get; set; } + + /// + /// 工资比例 + /// + [SugarColumn(IsNullable = true)] + public string WageProportion { get; set; } + + /// + /// 经验情况 + /// + [SugarColumn(IsNullable = true)] + public string Experience { get; set; } + + /// + /// 经验比例 + /// + [SugarColumn(IsNullable = true)] + public string ExperienceRatio { get; set; } + + /// + /// 学历要求 + /// + [SugarColumn(IsNullable = true)] + public string EducationRequirements { get; set; } + + /// + /// 学历要求 + /// + [SugarColumn(IsNullable = true)] + public string EducationalBackgroundRatio { get; set; } + + /// + /// 就业方向 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 1000, IsNullable = true)] + public string EmploymentDirection { get; set; } + + /// + /// 从事岗位 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 1000, IsNullable = true)] + public string Position { get; set; } + + /// + /// 平均工资 + /// + [SugarColumn(IsNullable = true)] + public string AverageWage { get; set; } + + /// + /// 工作年限 + /// + [SugarColumn(IsNullable = true)] + public string WorkingYears { get; set; } + + /// + /// 工作年限工资 + /// + [SugarColumn(IsNullable = true)] + public string WorkingYearsWage { get; set; } + } +} diff --git a/New_College.Model/Models/D_MajorSalary.cs b/New_College.Model/Models/D_MajorSalary.cs new file mode 100644 index 0000000..06446e1 --- /dev/null +++ b/New_College.Model/Models/D_MajorSalary.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_MajorSalary : EntityModel + { + /// + /// 专业Id + /// + public int MajorId { get; set; } + + /// + /// 专业名称 + /// + public string MajorName { get; set; } + + /// + /// 薪资 + /// + public float Salary { get; set; } + } +} diff --git a/New_College.Model/Models/D_OccMapTag.cs b/New_College.Model/Models/D_OccMapTag.cs new file mode 100644 index 0000000..c48a685 --- /dev/null +++ b/New_College.Model/Models/D_OccMapTag.cs @@ -0,0 +1,25 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_OccMapTag : EntityModel + { + [SugarColumn(IsNullable = true)] + public string Name { get; set; } + + /// + /// 职业id + /// + [SugarColumn(IsNullable = true)] + public int OccId { get; set; } + + /// + /// 标签 + /// + [SugarColumn(IsNullable = true)] + public string Tag { get; set; } + } +} diff --git a/New_College.Model/Models/D_Occupation.cs b/New_College.Model/Models/D_Occupation.cs new file mode 100644 index 0000000..f5eb708 --- /dev/null +++ b/New_College.Model/Models/D_Occupation.cs @@ -0,0 +1,37 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_Occupation : EntityModel + { + [SugarColumn(IsNullable = true)] + public string Name { get; set; } + + /// + /// 职业分类id + /// + [SugarColumn(IsNullable = true)] + public int CategoryId { get; set; } + + /// + /// 职业名称 + /// + [SugarColumn(IsNullable = true)] + public string OccupationName { get; set; } + + /// + /// 职业介绍 + /// + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string OccupationIntraduce { get; set; } + + /// + /// 是否推荐,0为不推荐,1为推荐 + /// + [SugarColumn(IsNullable = true)] + public int Recommend { get; set; } + } +} diff --git a/New_College.Model/Models/D_OccupationCategory.cs b/New_College.Model/Models/D_OccupationCategory.cs new file mode 100644 index 0000000..8598e84 --- /dev/null +++ b/New_College.Model/Models/D_OccupationCategory.cs @@ -0,0 +1,27 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_OccupationCategory : EntityModel + { + [SugarColumn(IsNullable = true)] + public string Name { get; set; } + + /// + /// 分类名称 + /// + [SugarColumn(IsNullable = true)] + public string OccupationName { get; set; } + /// + /// 分类等级 + /// + [SugarColumn(IsNullable = true)] + public int Level { get; set; } + + [SugarColumn(IsNullable = true)] + public int ParentId { get; set; } + } +} diff --git a/New_College.Model/Models/D_University.cs b/New_College.Model/Models/D_University.cs new file mode 100644 index 0000000..154f6ca --- /dev/null +++ b/New_College.Model/Models/D_University.cs @@ -0,0 +1,121 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_University : EntityModel + { + [SugarColumn(IsNullable = true)] + public string Name { get; set; } + + /// + /// 省id + /// + [SugarColumn(IsNullable = true)] + public int Area_Id { get; set; } + + /// + /// 省name + /// + [SugarColumn(IsNullable = true)] + public string Area_Name { get; set; } + + /// + /// 排名 + /// + [SugarColumn(IsNullable = true)] + public int Rank { get; set; } + + /// + /// 创办时间 + /// + [SugarColumn(IsNullable = true)] + public string Build_Date { get; set; } + + /// + /// 办学性质 1、公立,2、私立 + /// + [SugarColumn(IsNullable = true)] + public int Nature { get; set; } + + /// + /// 隶属于 1、教育部,2、省政府, 3 其他部委,4 军校 + /// + [SugarColumn(IsNullable = true)] + public int Ascription { get; set; } + + /// + ///教育行政主管部门名称 + /// + [SugarColumn(IsNullable = true)] + public string AscriptionName { get; set; } + + /// + /// 学科层次 1、本科,2、专科 + /// + [SugarColumn(IsNullable = true)] + public int Subject_Level { get; set; } + + /// + /// 是否985 0、否,1、是 + /// + [SugarColumn(IsNullable = true)] + public int Nhef { get; set; } + + /// + /// 是否211 0、否,1、是 + /// + [SugarColumn(IsNullable = true)] + public int Sff { get; set; } + + /// + /// 是否双一流 0、否,1、是 + /// + [SugarColumn(IsNullable = true)] + public int Syl { get; set; } + + /// + /// 院士数 + /// + [SugarColumn(IsNullable = true)] + public int Academician_Count { get; set; } + + /// + /// 博士数 + /// + [SugarColumn(IsNullable = true)] + public int Doctorate_Count { get; set; } + + /// + /// 硕士数 + /// + [SugarColumn(IsNullable = true)] + public int Master_Count { get; set; } + + /// + /// 大学类型 0综合,1理工类,2医学类... + /// + [SugarColumn(IsNullable = true)] + public int Type { get; set; } + + /// + /// logo + /// + [SugarColumn(IsNullable = true)] + public string Logo { get; set; } + + /// + /// 院校官网 + /// + [SugarColumn(IsNullable = true)] + public string Web { get; set; } + + /// + /// 院校简介 + /// + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string Description { get; set; } + } +} diff --git a/New_College.Model/Models/D_UniversityCollection.cs b/New_College.Model/Models/D_UniversityCollection.cs new file mode 100644 index 0000000..97c98d0 --- /dev/null +++ b/New_College.Model/Models/D_UniversityCollection.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 院校收藏和对比 + /// + public class D_UniversityCollection : EntityModel + { + /// + /// 用户Id + /// + public int CustomerId { get; set; } + + /// + /// 院校Id + /// + public int UniversityId { get; set; } + + /// + /// 1收藏 2对比 + /// + public int Type { get; set; } + } +} diff --git a/New_College.Model/Models/D_UniversityRank.cs b/New_College.Model/Models/D_UniversityRank.cs new file mode 100644 index 0000000..e32a9c5 --- /dev/null +++ b/New_College.Model/Models/D_UniversityRank.cs @@ -0,0 +1,33 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_UniversityRank : EntityModel + { + /// + /// 院校名称 + /// + [SugarColumn(IsNullable = true)] + public string UniversityName { get; set; } + /// + /// 类型(0,校友会 1,武书连 2,软科 3,QS 4,U.S.News) + /// + [SugarColumn(IsNullable = true)] + public int UniversityType { get; set; } + + /// + /// 年份 + /// + [SugarColumn(IsNullable = true)] + public string Year { get; set; } + + /// + /// 排名 + /// + [SugarColumn(IsNullable = true)] + public int Rank { get; set; } + } +} diff --git a/New_College.Model/Models/D_Universityimg.cs b/New_College.Model/Models/D_Universityimg.cs new file mode 100644 index 0000000..1c41ed8 --- /dev/null +++ b/New_College.Model/Models/D_Universityimg.cs @@ -0,0 +1,21 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_Universityimg : EntityModel + { + /// + /// 院校Id + /// + [SugarColumn(IsNullable = true)] + public int UniversityId { get; set; } + /// + /// 院校图片列表地址 + /// + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string ImgList { get; set; } + } +} diff --git a/New_College.Model/Models/Guestbook.cs b/New_College.Model/Models/Guestbook.cs new file mode 100644 index 0000000..95917e2 --- /dev/null +++ b/New_College.Model/Models/Guestbook.cs @@ -0,0 +1,57 @@ +using SqlSugar; +using System; + +namespace New_College.Model.Models +{ + public class Guestbook + { + + /// + /// 留言表 + /// + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] + public int id { get; set; } + + /// 博客ID + /// + /// + public int? blogId { get; set; } + /// 创建时间 + /// + /// + public DateTime createdate { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string username { get; set; } + + /// 手机 + /// + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string phone { get; set; } + /// qq + /// + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string QQ { get; set; } + + /// 留言内容 + /// + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string body { get; set; } + /// ip地址 + /// + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string ip { get; set; } + + /// 是否显示在前台,0否1是 + /// + /// + public bool isshow { get; set; } + + [SugarColumn(IsIgnore = true)] + public BlogArticle blogarticle { get; set; } + } +} diff --git a/New_College.Model/Models/Module.cs b/New_College.Model/Models/Module.cs new file mode 100644 index 0000000..1b1c91b --- /dev/null +++ b/New_College.Model/Models/Module.cs @@ -0,0 +1,95 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Model.Models +{ + /// + /// 接口API地址信息表 + /// + public class Module + { + public Module() + { + //this.ChildModule = new List(); + //this.ModulePermission = new List(); + //this.RoleModulePermission = new List(); + } + /// + /// ID + /// + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + ///获取或设置是否禁用,逻辑上的删除,非物理删除 + /// + [SugarColumn(IsNullable = true)] + public bool? IsDeleted { get; set; } + /// + /// 父ID + /// + [SugarColumn(IsNullable = true)] + public int? ParentId { get; set; } + /// + /// 名称 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)] + public string Name { get; set; } + /// + /// 菜单链接地址 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string LinkUrl { get; set; } + /// + /// 区域名称 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string Area { get; set; } + /// + /// 控制器名称 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string Controller { get; set; } + /// + /// Action名称 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string Action { get; set; } + /// + /// 图标 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string Icon { get; set; } + /// + /// 菜单编号 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 10, IsNullable = true)] + public string Code { get; set; } + /// + /// 排序 + /// + public int OrderSort { get; set; } + /// + /// /描述 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string Description { get; set; } + /// + /// 是否是右侧菜单 + /// + public bool IsMenu { get; set; } + /// + /// 是否激活 + /// + public bool Enabled { get; set; } + + //public virtual Module ParentModule { get; set; } + //public virtual ICollection ChildModule { get; set; } + //public virtual ICollection ModulePermission { get; set; } + //public virtual ICollection RoleModulePermission { get; set; } + } +} diff --git a/New_College.Model/Models/ModulePermission.cs b/New_College.Model/Models/ModulePermission.cs new file mode 100644 index 0000000..b9024ff --- /dev/null +++ b/New_College.Model/Models/ModulePermission.cs @@ -0,0 +1,34 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Model.Models +{ + /// + /// 菜单与按钮关系表 + /// + public class ModulePermission : RootEntity + { + + /// + ///获取或设置是否禁用,逻辑上的删除,非物理删除 + /// + [SugarColumn(IsNullable = true)] + public bool? IsDeleted { get; set; } + /// + /// 菜单ID + /// + public int ModuleId { get; set; } + /// + /// 按钮ID + /// + public int PermissionId { get; set; } + + + //public virtual Module Module { get; set; } + //public virtual Permission Permission { get; set; } + } +} diff --git a/New_College.Model/Models/Modules.cs b/New_College.Model/Models/Modules.cs new file mode 100644 index 0000000..f75c213 --- /dev/null +++ b/New_College.Model/Models/Modules.cs @@ -0,0 +1,121 @@ +using SqlSugar; +using System; + +namespace New_College.Model.Models +{ + /// + /// 接口API地址信息表 + /// + public class Modules + { + public Modules() + { + //this.ChildModule = new List(); + //this.ModulePermission = new List(); + //this.RoleModulePermission = new List(); + } + /// + /// ID + /// + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + ///获取或设置是否禁用,逻辑上的删除,非物理删除 + /// + [SugarColumn(IsNullable = true)] + public bool? IsDeleted { get; set; } + /// + /// 父ID + /// + [SugarColumn(IsNullable = true)] + public int? ParentId { get; set; } + /// + /// 名称 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)] + public string Name { get; set; } + /// + /// 菜单链接地址 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string LinkUrl { get; set; } + /// + /// 区域名称 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)] + public string Area { get; set; } + /// + /// 控制器名称 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)] + public string Controller { get; set; } + /// + /// Action名称 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 2000, IsNullable = true)] + public string Action { get; set; } + /// + /// 图标 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string Icon { get; set; } + /// + /// 菜单编号 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 10, IsNullable = true)] + public string Code { get; set; } + /// + /// 排序 + /// + public int OrderSort { get; set; } + /// + /// /描述 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string Description { get; set; } + /// + /// 是否是右侧菜单 + /// + public bool IsMenu { get; set; } + /// + /// 是否激活 + /// + public bool Enabled { get; set; } + /// + /// 创建ID + /// + [SugarColumn(IsNullable = true)] + public int? CreateId { get; set; } + /// + /// 创建者 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)] + public string CreateBy { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime CreateTime { get; set; } + /// + /// 修改ID + /// + [SugarColumn(IsNullable = true)] + public int? ModifyId { get; set; } + /// + /// 修改者 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string ModifyBy { get; set; } + /// + /// 修改时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? ModifyTime { get; set; } = DateTime.Now; + + //public virtual Module ParentModule { get; set; } + //public virtual ICollection ChildModule { get; set; } + //public virtual ICollection ModulePermission { get; set; } + //public virtual ICollection RoleModulePermission { get; set; } + } +} diff --git a/New_College.Model/Models/N_AgentCourse.cs b/New_College.Model/Models/N_AgentCourse.cs new file mode 100644 index 0000000..3963bca --- /dev/null +++ b/New_College.Model/Models/N_AgentCourse.cs @@ -0,0 +1,24 @@ +using New_College.Common; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class N_AgentCourse : RootEntity + { + public string Title { get; set; } + + public CardTypeEnum cardType { get; set; } + + /// + /// 产品教程,赚钱攻略,操作指南 + /// + public int Type { get; set; } + + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string Content { get; set; } + + } +} diff --git a/New_College.Model/Models/N_MaterialLibrary.cs b/New_College.Model/Models/N_MaterialLibrary.cs new file mode 100644 index 0000000..9571c75 --- /dev/null +++ b/New_College.Model/Models/N_MaterialLibrary.cs @@ -0,0 +1,29 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 素材库 + /// + public class N_MaterialLibrary : RootEntity + { + + public string Title { get; set; } + + /// + /// 素材封面 + /// + public string Src { get; set; } + + /// + /// 素材内容 + /// + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string Content { get; set; } + + + } +} diff --git a/New_College.Model/Models/OperateLog.cs b/New_College.Model/Models/OperateLog.cs new file mode 100644 index 0000000..5878ee5 --- /dev/null +++ b/New_College.Model/Models/OperateLog.cs @@ -0,0 +1,60 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Model.Models +{ + /// + /// 日志记录 + /// + public class OperateLog : RootEntity + { + + + /// + /// 区域名 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string Area { get; set; } + /// + /// 区域控制器名 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string Controller { get; set; } + /// + /// Action名称 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string Action { get; set; } + /// + /// IP地址 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string IPAddress { get; set; } + /// + /// 描述 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string Description { get; set; } + /// + /// 登录时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? LogTime { get; set; } + /// + /// 登录名称 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = int.MaxValue, IsNullable = true)] + public string LoginName { get; set; } + /// + /// 用户ID + /// + public int UserId { get; set; } + + [SugarColumn(IsIgnore = true)] + public virtual sysUserInfo User { get; set; } + } +} diff --git a/New_College.Model/Models/PasswordLib.cs b/New_College.Model/Models/PasswordLib.cs new file mode 100644 index 0000000..df1cb74 --- /dev/null +++ b/New_College.Model/Models/PasswordLib.cs @@ -0,0 +1,60 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Model.Models +{ + /// + /// 密码库表 + /// + [SugarTable("PasswordLib", "WMBLOG_MSSQL_2")] + public class PasswordLib + { + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] + public int PLID { get; set; } + + /// + ///获取或设置是否禁用,逻辑上的删除,非物理删除 + /// + [SugarColumn(IsNullable = true)] + public bool? IsDeleted { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)] + public string plURL { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string plPWD { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)] + public string plAccountName { get; set; } + + [SugarColumn(IsNullable = true)] + public int? plStatus { get; set; } + + [SugarColumn(IsNullable = true)] + public int? plErrorCount { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)] + public string plHintPwd { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)] + public string plHintquestion { get; set; } + + [SugarColumn(IsNullable = true)] + public DateTime? plCreateTime { get; set; } + + [SugarColumn(IsNullable = true)] + public DateTime? plUpdateTime { get; set; } + + [SugarColumn(IsNullable = true)] + public DateTime? plLastErrTime { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)] + public string test { get; set; } + + + } +} diff --git a/New_College.Model/Models/Permission.cs b/New_College.Model/Models/Permission.cs new file mode 100644 index 0000000..1a9bbf2 --- /dev/null +++ b/New_College.Model/Models/Permission.cs @@ -0,0 +1,150 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Model.Models +{ + /// + /// 路由菜单表 + /// + public class Permission + { + public Permission() + { + //this.ModulePermission = new List(); + //this.RoleModulePermission = new List(); + } + + /// + /// ID + /// + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 菜单执行Action名 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)] + public string Code { get; set; } + /// + /// 菜单显示名(如用户页、编辑(按钮)、删除(按钮)) + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)] + public string Name { get; set; } + /// + /// 是否是按钮 + /// + public bool IsButton { get; set; } = false; + + /// + /// 组件类型(0,为button或菜单,1为下拉框,2...) + /// + public int ModuleType { get; set; } = 0; + /// + /// 是否是隐藏菜单 + /// + [SugarColumn(IsNullable = true)] + public bool? IsHide { get; set; } = false; + /// + /// 是否keepAlive + /// + [SugarColumn(IsNullable = true)] + public bool? IskeepAlive { get; set; } = false; + + + /// + /// 按钮事件 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string Func { get; set; } + + + + /// + /// 上一级菜单(0表示上一级无菜单) + /// + public int Pid { get; set; } + + + /// + /// 接口api + /// + public int Mid { get; set; } + + /// + /// 排序 + /// + public int OrderSort { get; set; } + /// + /// 菜单图标 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string Icon { get; set; } + /// + /// 菜单描述 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string Description { get; set; } + /// + /// 激活状态 + /// + public bool Enabled { get; set; } + /// + /// 创建ID + /// + [SugarColumn(IsNullable = true)] + public int? CreateId { get; set; } + /// + /// 创建者 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)] + public string CreateBy { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? CreateTime { get; set; } = DateTime.Now; + /// + /// 修改ID + /// + [SugarColumn(IsNullable = true)] + public int? ModifyId { get; set; } + /// + /// 修改者 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)] + public string ModifyBy { get; set; } + /// + /// 修改时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? ModifyTime { get; set; } = DateTime.Now; + + /// + ///获取或设置是否禁用,逻辑上的删除,非物理删除 + /// + [SugarColumn(IsNullable = true)] + public bool? IsDeleted { get; set; } + + + + + [SugarColumn(IsIgnore = true)] + public List PidArr { get; set; } + [SugarColumn(IsIgnore = true)] + public List PnameArr { get; set; } = new List(); + [SugarColumn(IsIgnore = true)] + public List PCodeArr { get; set; } = new List(); + [SugarColumn(IsIgnore = true)] + public string MName { get; set; } + + [SugarColumn(IsIgnore = true)] + public bool hasChildren { get; set; } = true; + + //public virtual ICollection ModulePermission { get; set; } + //public virtual ICollection RoleModulePermission { get; set; } + } +} diff --git a/New_College.Model/Models/Role.cs b/New_College.Model/Models/Role.cs new file mode 100644 index 0000000..ff29a56 --- /dev/null +++ b/New_College.Model/Models/Role.cs @@ -0,0 +1,92 @@ +using SqlSugar; +using System; + +namespace New_College.Model.Models +{ + /// + /// 角色表 + /// + public class Role + { + public Role() + { + OrderSort = 1; + CreateTime = DateTime.Now; + ModifyTime = DateTime.Now; + IsDeleted = false; + } + public Role(string name) + { + Name = name; + Description = ""; + OrderSort = 1; + Enabled = true; + CreateTime = DateTime.Now; + ModifyTime = DateTime.Now; + + } + + /// + /// ID + /// + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + + /// + ///获取或设置是否禁用,逻辑上的删除,非物理删除 + /// + [SugarColumn(IsNullable = true)] + public bool? IsDeleted { get; set; } + /// + /// 角色名 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)] + public string Name { get; set; } + /// + ///描述 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string Description { get; set; } + /// + ///排序 + /// + public int OrderSort { get; set; } + /// + /// 是否激活 + /// + public bool Enabled { get; set; } + /// + /// 创建ID + /// + [SugarColumn(IsNullable = true)] + public int? CreateId { get; set; } + /// + /// 创建者 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)] + public string CreateBy { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? CreateTime { get; set; } = DateTime.Now; + /// + /// 修改ID + /// + [SugarColumn(IsNullable = true)] + public int? ModifyId { get; set; } + /// + /// 修改者 + /// + [SugarColumn(IsNullable = true)] + public string ModifyBy { get; set; } + /// + /// 修改时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? ModifyTime { get; set; } = DateTime.Now; + + + } +} diff --git a/New_College.Model/Models/RoleModulePermission.cs b/New_College.Model/Models/RoleModulePermission.cs new file mode 100644 index 0000000..3819328 --- /dev/null +++ b/New_College.Model/Models/RoleModulePermission.cs @@ -0,0 +1,82 @@ +using SqlSugar; +using System; + +namespace New_College.Model.Models +{ + /// + /// 按钮跟权限关联表 + /// + public class RoleModulePermission + { + public RoleModulePermission() + { + //this.Role = new Role(); + //this.Module = new Module(); + //this.Permission = new Permission(); + + } + + /// + /// ID + /// + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + ///获取或设置是否禁用,逻辑上的删除,非物理删除 + /// + [SugarColumn(IsNullable = true)] + public bool? IsDeleted { get; set; } + /// + /// 角色ID + /// + public int RoleId { get; set; } + /// + /// 菜单ID + /// + public int ModuleId { get; set; } + /// + /// api ID + /// + [SugarColumn(IsNullable = true)] + public int? PermissionId { get; set; } + /// + /// 创建ID + /// + [SugarColumn(IsNullable = true)] + public int? CreateId { get; set; } + /// + /// 创建者 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)] + public string CreateBy { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? CreateTime { get; set; } = DateTime.Now; + /// + /// 修改ID + /// + [SugarColumn(IsNullable = true)] + public int? ModifyId { get; set; } + /// + /// 修改者 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)] + public string ModifyBy { get; set; } + /// + /// 修改时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? ModifyTime { get; set; } = DateTime.Now; + + // 下边三个实体参数,只是做传参作用,所以忽略下 + [SugarColumn(IsIgnore = true)] + public Role Role { get; set; } + [SugarColumn(IsIgnore = true)] + public Modules Module { get; set; } + [SugarColumn(IsIgnore = true)] + public Permission Permission { get; set; } + } +} diff --git a/New_College.Model/Models/RootEntity.cs b/New_College.Model/Models/RootEntity.cs new file mode 100644 index 0000000..2df5b49 --- /dev/null +++ b/New_College.Model/Models/RootEntity.cs @@ -0,0 +1,100 @@ +using SqlSugar; +using System; +using YIJIYI.Core.Common.Helper; + +namespace New_College.Model.Models +{ + /// + /// 带创建人BaseModel + /// + public partial class RootEntity + { + /// + /// ID + /// + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + + /// + ///排序 + /// + public int OrderSort { get; set; } + + /// + /// 创建ID + /// + [SugarColumn(IsNullable = true)] + public int? CreateId { get; set; } + /// + /// 创建者 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)] + public string CreateBy { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? CreateTime { get; set; } =TimeUtil.GetCstDateTime(); + /// + /// 修改ID + /// + [SugarColumn(IsNullable = true)] + public int? ModifyId { get; set; } + /// + /// 修改者 + /// + [SugarColumn(IsNullable = true)] + public string ModifyBy { get; set; } + /// + /// 修改时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? ModifyTime { get; set; } = TimeUtil.GetCstDateTime(); + + /// + /// 是否删除 + /// + public bool IsDelete { get; set; } + + } + + /// + /// 不带创建人BaseModel + /// + public partial class EntityModel + { + + /// + /// ID + /// + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + + /// + ///排序 + /// + public int OrderSort { get; set; } + + + /// + /// 创建时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? CreateTime { get; set; } = TimeUtil.GetCstDateTime(); + /// + /// + /// 修改时间 + /// + [SugarColumn(IsNullable = true)] + public DateTime? ModifyTime { get; set; } = TimeUtil.GetCstDateTime(); + + /// + /// 是否删除 + /// + public bool IsDelete { get; set; } + + } + +} \ No newline at end of file diff --git a/New_College.Model/Models/SysRegion.cs b/New_College.Model/Models/SysRegion.cs new file mode 100644 index 0000000..8a84d45 --- /dev/null +++ b/New_College.Model/Models/SysRegion.cs @@ -0,0 +1,52 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 省市区 + /// + public class SysRegion + { + /// + /// 主键ID + /// + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] + public int KeyId { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 40, IsNullable = true)] + public string RegionCode { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 40, IsNullable = true)] + public string RegionName { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 40, IsNullable = true)] + public string ParentCode { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 40, IsNullable = true)] + public string SimpleName { get; set; } + + public int Level { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 40, IsNullable = true)] + public string CityCode { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 40, IsNullable = true)] + public string ZipCode { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 100, IsNullable = true)] + public string MerName { get; set; } + + public double Lng { get; set; } + + public double Lat { get; set; } + + [SugarColumn(ColumnDataType = "nvarchar", Length = 40, IsNullable = true)] + public string PinYin { get; set; } + + [SugarColumn(IsNullable = true)] + public int IsOpen { get; set; } + } +} diff --git a/New_College.Model/Models/T_BatchTypeInfo.cs b/New_College.Model/Models/T_BatchTypeInfo.cs new file mode 100644 index 0000000..88be959 --- /dev/null +++ b/New_College.Model/Models/T_BatchTypeInfo.cs @@ -0,0 +1,37 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 批次表 + /// + public class T_BatchTypeInfo : EntityModel + { + /// + /// 省份ID + /// + [SugarColumn(IsNullable = true)] + public int AreaId { get; set; } + + /// + /// 省份名称 + /// + [SugarColumn(IsNullable = true)] + public string AreaName { get; set; } + + /// + /// 批次名称 + /// + [SugarColumn(IsNullable = true)] + public string BatchName { get; set; } + + /// + /// 年份 + /// + [SugarColumn(IsNullable = true)] + public int Year { get; set; } + } +} diff --git a/New_College.Model/Models/T_Batchline.cs b/New_College.Model/Models/T_Batchline.cs new file mode 100644 index 0000000..e472076 --- /dev/null +++ b/New_College.Model/Models/T_Batchline.cs @@ -0,0 +1,47 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class T_Batchline : EntityModel + { + + /// + /// 省份id + /// + [SugarColumn(IsNullable = true)] + public int AreaId { get; set; } + + /// + /// 省份名称 + /// + [SugarColumn(IsNullable = true)] + public string AreaName { get; set; } + + /// + /// 学界 + /// + [SugarColumn(IsNullable = true)] + public int Year { get; set; } + + /// + /// 分数 + /// + [SugarColumn(IsNullable = true)] + public int Average { get; set; } + + /// + /// 类型 + /// + [SugarColumn(IsNullable = true)] + public string Type_name { get; set; } + + /// + /// 批次名称 + /// + [SugarColumn(IsNullable = true)] + public string Batch_name { get; set; } + } +} diff --git a/New_College.Model/Models/T_EnrollmentBatch.cs b/New_College.Model/Models/T_EnrollmentBatch.cs new file mode 100644 index 0000000..f14807e --- /dev/null +++ b/New_College.Model/Models/T_EnrollmentBatch.cs @@ -0,0 +1,41 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + + public class T_EnrollmentBatch : EntityModel + { + /// + /// 省份id + /// + [SugarColumn(IsNullable = true)] + public int AreaId { get; set; } + /// + /// 省份名称 + /// + [SugarColumn(IsNullable = true)] + public string AreaName { get; set; } + /// + /// 年份 + /// + [SugarColumn(IsNullable = true)] + public int Year { get; set; } + + [SugarColumn(IsNullable = true)] + public string Batch_name { get; set; } + + /// + /// 本科1,专科0,其他-1 + /// + [SugarColumn(IsNullable = true)] + public int Subjectlevel { get; set; } + /// + /// 文理 不分文理 + /// + [SugarColumn(IsNullable = true)] + public string Type { get; set; } + } +} diff --git a/New_College.Model/Models/T_EnrollmentPlane.cs b/New_College.Model/Models/T_EnrollmentPlane.cs new file mode 100644 index 0000000..35f8cd4 --- /dev/null +++ b/New_College.Model/Models/T_EnrollmentPlane.cs @@ -0,0 +1,28 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class T_EnrollmentPlane : EntityModel + { + /// + /// 计划名称 + /// + [SugarColumn(IsNullable = true)] + public string EnrollmentName { get; set; } + + /// + /// 省份Id + /// + [SugarColumn(IsNullable = true)] + public int Area_Id { get; set; } + + /// + /// 年份 + /// + [SugarColumn(IsNullable = true)] + public int Years { get; set; } + } +} diff --git a/New_College.Model/Models/T_EnrollmentPlanedesc.cs b/New_College.Model/Models/T_EnrollmentPlanedesc.cs new file mode 100644 index 0000000..9e24f4f --- /dev/null +++ b/New_College.Model/Models/T_EnrollmentPlanedesc.cs @@ -0,0 +1,117 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class T_EnrollmentPlanedesc : EntityModel + { + + /// + /// 招生计划id + /// + [SugarColumn(IsNullable = true)] + public int PlanId { get; set; } + /// + /// 招生计划批次id + /// + [SugarColumn(IsNullable = true)] + public int BatchtypeId { get; set; } + /// + /// 招生院校id + /// + [SugarColumn(IsNullable = true)] + public int UniversityId { get; set; } + ///// + ///// 招生专业分组id + ///// + //public int MajorgroupId { get; set; } + + //[SugarColumn(IsNullable = true)]-------------------------------------- + //public string Majorgroup { get; set; } + /// + /// 选科限制:新高考(物理,化学,生物),老高考(无);新高考省份:江苏 湖北 福建 辽宁 广东 重庆 河北 湖南 + /// + [SugarColumn(IsNullable = true)] + public string Subjectclaim { get; set; } + /// + /// 计划招生数 + /// + [SugarColumn(IsNullable = true)] + public int Plancount { get; set; } + /// + /// 专业学费 + /// + [SugarColumn(IsNullable = true)] + public string Tuitionfee { get; set; } + /// + /// 语言限制-------------------------------------- + /// + [SugarColumn(IsNullable = true)] + public string Languageclaim { get; set; } + /// + /// 标签匹配 + /// + [SugarColumn(IsNullable = true)] + public string Tags { get; set; } + /// + /// 分数线 + /// + [SugarColumn(IsNullable = true)] + public float Scoreline { get; set; } + /// + /// 备注 + /// + [SugarColumn(ColumnDataType = "longtext", Length = int.MaxValue, IsNullable = true)] + public string Remark { get; set; } + + /// + /// 专业学年制(4年,3年) + /// + [SugarColumn(IsNullable = true)] + public string Studyyears { get; set; } + + /// + /// 专业ID -------------------------------------- + /// + [SugarColumn(IsNullable = true)] + public int MajorId { get; set; } + + /// + /// 专业名称-》招生计划名称 + /// + [SugarColumn(IsNullable = true)] + public string MajorName { get; set; } + + ///// + ///// 学校最低分-------------------------------------- + ///// + //[SugarColumn(IsNullable = true)] + //public float? schoollowscore { get; set; } + + ///// + ///// 学校省控线-------------------------------------- + ///// + //[SugarColumn(IsNullable = true)] + //public float? schoolprovinline { get; set; } + + /// + /// 专业平均分 + /// + [SugarColumn(IsNullable = true)] + public float? majoraverage { get; set; } + + ///// + ///// 最高分-------------------------------------- + ///// + //[SugarColumn(IsNullable = true)] + //public float? heightscore { get; set; } + + /// + /// 位次 + /// + [SugarColumn(IsNullable = true)] + public float? scorepostion { get; set; } + } +} diff --git a/New_College.Model/Models/T_GearInfo.cs b/New_College.Model/Models/T_GearInfo.cs new file mode 100644 index 0000000..a9d4f71 --- /dev/null +++ b/New_College.Model/Models/T_GearInfo.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class T_GearInfo : EntityModel + { + /// + /// 招生计划Id + /// + public int PlanId { get; set; } + + /// + /// 省份Id + /// + public int AreaId { get; set; } + + /// + /// 类型 不分文理(0),理工类(1),文史类(2),default(1) + /// + public int GearType { get; set; } + + /// + /// 档位名称 + /// + public string GearName { get; set; } + + /// + /// 最高分 + /// + public decimal GearMaxScore { get; set; } + + /// + /// 最低分 + /// + public decimal GearMinScore { get; set; } + } +} diff --git a/New_College.Model/Models/T_LongIdMap.cs b/New_College.Model/Models/T_LongIdMap.cs new file mode 100644 index 0000000..858d5fb --- /dev/null +++ b/New_College.Model/Models/T_LongIdMap.cs @@ -0,0 +1,18 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class T_LongIdMap : EntityModel + { + [SugarColumn(IsNullable = true)] + public string longid { get; set; } + [SugarColumn(IsNullable = true)] + public int newid { get; set; } + + [SugarColumn(IsNullable = true)] + public string tablename { get; set; } + } +} diff --git a/New_College.Model/Models/T_PlanMapTag.cs b/New_College.Model/Models/T_PlanMapTag.cs new file mode 100644 index 0000000..03caa9a --- /dev/null +++ b/New_College.Model/Models/T_PlanMapTag.cs @@ -0,0 +1,22 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class T_PlanMapTag : EntityModel + { + /// + /// 计划名称 + /// + [SugarColumn(IsNullable = true)] + public string Name { get; set; } + + /// + /// 标签 + /// + [SugarColumn(IsNullable = true)] + public string Tag { get; set; } + } +} diff --git a/New_College.Model/Models/T_RegionScore.cs b/New_College.Model/Models/T_RegionScore.cs new file mode 100644 index 0000000..aa4a7a4 --- /dev/null +++ b/New_College.Model/Models/T_RegionScore.cs @@ -0,0 +1,33 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class T_RegionScore : EntityModel + { + /// + /// 省份Id + /// + [SugarColumn(IsNullable = true)] + public int AreaId { get; set; } + + /// + /// 省份名称 + /// + public string AreaName { get; set; } + + /// + /// 年份 + /// + [SugarColumn(IsNullable = true)] + public int Year { get; set; } + + /// + /// 满分 + /// + [SugarColumn(IsNullable = true)] + public float Score { get; set; } + } +} diff --git a/New_College.Model/Models/TasksQz.cs b/New_College.Model/Models/TasksQz.cs new file mode 100644 index 0000000..6f33a78 --- /dev/null +++ b/New_College.Model/Models/TasksQz.cs @@ -0,0 +1,74 @@ +using SqlSugar; +using System; + +namespace New_College.Model.Models +{ + /// + /// 任务计划表 + /// + public class TasksQz : RootEntity + { + /// + /// 任务名称 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)] + public string Name { get; set; } + /// + /// 任务分组 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)] + public string JobGroup { get; set; } + /// + /// 任务运行时间表达式 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)] + public string Cron { get; set; } + /// + /// 任务所在DLL对应的程序集名称 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)] + public string AssemblyName { get; set; } + /// + /// 任务所在类 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 200, IsNullable = true)] + public string ClassName { get; set; } + /// + /// 任务描述 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 1000, IsNullable = true)] + public string Remark { get; set; } + /// + /// 执行次数 + /// + public int RunTimes { get; set; } + /// + /// 开始时间 + /// + public DateTime? BeginTime { get; set; } + /// + /// 结束时间 + /// + public DateTime? EndTime { get; set; } + /// + /// 触发器类型(0、simple 1、cron) + /// + public int TriggerType { get; set; } + /// + /// 执行间隔时间, 秒为单位 + /// + public int IntervalSecond { get; set; } + /// + /// 是否启动 + /// + public bool IsStart { get; set; } = false; + /// + /// 执行传参 + /// + public string JobParams { get; set; } + + + + + } +} diff --git a/New_College.Model/Models/TestModels.cs b/New_College.Model/Models/TestModels.cs new file mode 100644 index 0000000..ff4254e --- /dev/null +++ b/New_College.Model/Models/TestModels.cs @@ -0,0 +1,13 @@ +namespace New_College.Model.Models +{ + + public class TestMuchTableResult + { + public string moduleName { get; set; } + public string permName { get; set; } + public int rid { get; set; } + public int mid { get; set; } + public int? pid { get; set; } + + } +} diff --git a/New_College.Model/Models/Test_CategoryInfo.cs b/New_College.Model/Models/Test_CategoryInfo.cs new file mode 100644 index 0000000..d7306d6 --- /dev/null +++ b/New_College.Model/Models/Test_CategoryInfo.cs @@ -0,0 +1,32 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 测评分类表 + /// + public class Test_CategoryInfo : RootEntity + { + /// + /// 分类名称 + /// + public string Name { get; set; } + + /// + /// 解释 + /// + [SugarColumn(ColumnDataType = "nvarchar", IsNullable = true, Length = 1000)] + public string Desc { get; set; } + + + /// + /// 解释详情 + /// + [SugarColumn(ColumnDataType = "nvarchar", IsNullable = true, Length = 1000)] + public string Detail { get; set; } + } + +} diff --git a/New_College.Model/Models/Test_CycleTimeInfo.cs b/New_College.Model/Models/Test_CycleTimeInfo.cs new file mode 100644 index 0000000..956da29 --- /dev/null +++ b/New_College.Model/Models/Test_CycleTimeInfo.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class Test_CycleTimeInfo : EntityModel + { + /// + /// Vip卡类型 + /// + public int VipCardTypeId { get; set; } + + /// + /// 测评分类Id + /// + public int CategoryId { get; set; } + + /// + /// 周期名称 + /// + public string CycleName { get; set; } + + public int IsOpen { get; set; } = 1; + + + } +} diff --git a/New_College.Model/Models/Test_HollandResultInfo.cs b/New_College.Model/Models/Test_HollandResultInfo.cs new file mode 100644 index 0000000..a394fe2 --- /dev/null +++ b/New_College.Model/Models/Test_HollandResultInfo.cs @@ -0,0 +1,74 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 个性倾向结果表 + /// + public class Test_HollandResultInfo : RootEntity + { + /// + /// 学生Id + /// + public int StudentId { get; set; } + + /// + /// 周期Id + /// + public int CycleTimeId { get; set; } + + /// + /// 年级名称 + /// + public string GradeName { get; set; } + + /// + /// 班级名称 + /// + public string ClassName { get; set; } + + public string Interest { get; set; } + + public string Specialty { get; set; } + + /// + /// 喜欢的学科 + /// + public string LikeSubject { get; set; } + + /// + /// + /// + public string LikeCareer { get; set; } + + public string TargeUniversity { get; set; } + + public string AfterCareer { get; set; } + + /// + /// 是否出国留学 + /// + public int IsForeign { get; set; } + + /// + /// 结果 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 1000, IsNullable = true)] + public string Result { get; set; } + + /// + /// Tag标签 + /// + public string TagResult { get; set; } + + /// + /// 自选标签 + /// + public string SelectResult { get; set; } + + + } +} diff --git a/New_College.Model/Models/Test_MBTIMapResult.cs b/New_College.Model/Models/Test_MBTIMapResult.cs new file mode 100644 index 0000000..ec0a806 --- /dev/null +++ b/New_College.Model/Models/Test_MBTIMapResult.cs @@ -0,0 +1,51 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class Test_MBTIMapResult : EntityModel + { + /// + /// 标签 + /// + public string Tag { get; set; } + + /// + /// 适合的领域 + /// + public string Domain { get; set; } + + /// + /// 性格特征解读 + /// + public string Interpretation { get; set; } + + /// + /// 优势 + /// + public string Advantage { get; set; } + + /// + /// 劣势 + /// + public string Disadvantage { get; set; } + + /// + /// 偏好的活动特质 + /// + public string Feature { get; set; } + + /// + /// 可能存在的盲点 + /// + [SugarColumn(Length = 1000, IsNullable = true, ColumnDataType = "nvarchar")] + public string BlindSpot { get; set; } + + /// + /// 建议 + /// + public string Recommend { get; set; } + } +} diff --git a/New_College.Model/Models/Test_PsychMeasurementInfo.cs b/New_College.Model/Models/Test_PsychMeasurementInfo.cs new file mode 100644 index 0000000..2d236e1 --- /dev/null +++ b/New_College.Model/Models/Test_PsychMeasurementInfo.cs @@ -0,0 +1,51 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 测评结果表 生涯能力和心理测量 + /// + public class Test_PsychMeasurementInfo : RootEntity + { + /// + /// 学生Id + /// + public int StudentId { get; set; } + + /// + /// 周期Id + /// + public int CycleTimeId { get; set; } + + /// + /// 年级名称 + /// + [SugarColumn(IsNullable = true)] + public string GradeName { get; set; } + + /// + /// 班级名称 + /// + [SugarColumn(IsNullable = true)] + public string ClassName { get; set; } + + /// + /// 分类Id + /// + public int CategoryId { get; set; } + + /// + /// 结果 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 1000, IsNullable = true)] + public string Result { get; set; } + + /// + /// 是否打开 + /// + public int IsOpen { get; set; } = 1; + } +} diff --git a/New_College.Model/Models/Test_QuestionInfo.cs b/New_College.Model/Models/Test_QuestionInfo.cs new file mode 100644 index 0000000..1454aeb --- /dev/null +++ b/New_College.Model/Models/Test_QuestionInfo.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 问题表 + /// + public class Test_QuestionInfo : EntityModel + { + /// + /// 问题分类Id + /// + public int CategoryId { get; set; } + + /// + /// 问题类型Id + /// + public int QuestionTypeId { get; set; } + + /// + /// 问题 + /// + public string QuestionTitle { get; set; } + + /// + /// 问题类型 + /// + public string QuestionType { get; set; } + + /// + /// 问题Tag + /// + public string QuestionTag { get; set; } + + /// + /// 版本 + /// + public string Version { get; set; } + + /// + /// 正反记分 1是正向记分 0是反向记分 + /// + public int IsAddScore { get; set; } + } +} diff --git a/New_College.Model/Models/Test_QuestionTypeInfo.cs b/New_College.Model/Models/Test_QuestionTypeInfo.cs new file mode 100644 index 0000000..8c03001 --- /dev/null +++ b/New_College.Model/Models/Test_QuestionTypeInfo.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 问题类型表 + /// + public class Test_QuestionTypeInfo : RootEntity + { + /// + /// 问题类型 + /// + public string Name { get; set; } + + /// + /// 分类Id + /// + public int CategoryId { get; set; } + } +} diff --git a/New_College.Model/Models/Topic.cs b/New_College.Model/Models/Topic.cs new file mode 100644 index 0000000..40659a7 --- /dev/null +++ b/New_College.Model/Models/Topic.cs @@ -0,0 +1,45 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Model.Models +{ + /// + /// Tibug 类别 + /// + public class Topic:RootEntity + { + public Topic() + { + this.TopicDetail = new List(); + this.tUpdatetime = DateTime.Now; + } + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string tLogo { get; set; } + + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string tName { get; set; } + + [SugarColumn(ColumnDataType ="nvarchar",Length = 400, IsNullable = true)] + public string tDetail { get; set; } + + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string tAuthor { get; set; } + + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string tSectendDetail { get; set; } + + public bool tIsDelete { get; set; } + public int tRead { get; set; } + public int tCommend { get; set; } + public int tGood { get; set; } + public DateTime tCreatetime { get; set; } + public DateTime tUpdatetime { get; set; } + + [SugarColumn(IsIgnore = true)] + public virtual ICollection TopicDetail { get; set; } + } +} diff --git a/New_College.Model/Models/TopicDetail.cs b/New_College.Model/Models/TopicDetail.cs new file mode 100644 index 0000000..9c62238 --- /dev/null +++ b/New_College.Model/Models/TopicDetail.cs @@ -0,0 +1,53 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Model.Models +{ + /// + /// Tibug 博文 + /// + public class TopicDetail : RootEntity + { + public TopicDetail() + { + this.tdUpdatetime = DateTime.Now; + } + + public int TopicId { get; set; } + + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string tdLogo { get; set; } + + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string tdName { get; set; } + + [SugarColumn(ColumnDataType ="nvarchar",Length = int.MaxValue , IsNullable = true)] + public string tdContent { get; set; } + + [SugarColumn(ColumnDataType ="nvarchar",Length = 400, IsNullable = true)] + public string tdDetail { get; set; } + + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string tdSectendDetail { get; set; } + + public bool tdIsDelete { get; set; } = false; + public int tdRead { get; set; } + public int tdCommend { get; set; } + public int tdGood { get; set; } + public DateTime tdCreatetime { get; set; } + public DateTime tdUpdatetime { get; set; } + public int tdTop { get; set; } + + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string tdAuthor { get; set; } + + + [SugarColumn(IsIgnore = true)] + public virtual Topic Topic { get; set; } + + } +} diff --git a/New_College.Model/Models/U_ProbabilityHistory.cs b/New_College.Model/Models/U_ProbabilityHistory.cs new file mode 100644 index 0000000..e247385 --- /dev/null +++ b/New_College.Model/Models/U_ProbabilityHistory.cs @@ -0,0 +1,47 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 概率历史 + /// + public class U_ProbabilityHistory : EntityModel + { + /// + ///用户Id + /// + public int CustomerId { get; set; } + + /// + /// 院校Id + /// + public int UniversityId { get; set; } + + /// + /// 概率 + /// + [SugarColumn(IsNullable = true)] + public int Probability { get; set; } + + /// + /// 预估分数 + /// + [SugarColumn(IsNullable = true)] + public float EstimateScore { get; set; } + + /// + /// 区域Id + /// + [SugarColumn(IsNullable = true)] + public int AreaId { get; set; } + + /// + /// 年份 + /// + [SugarColumn(IsNullable = true)] + public int Year { get; set; } + } +} diff --git a/New_College.Model/Models/U_VolunteerTable.cs b/New_College.Model/Models/U_VolunteerTable.cs new file mode 100644 index 0000000..0fea94c --- /dev/null +++ b/New_College.Model/Models/U_VolunteerTable.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 志愿Table + /// + public class U_VolunteerTable : EntityModel + { + /// + /// 用户ID + /// + public int CustomerId { get; set; } + + /// + /// 志愿表名称 + /// + public string VolunteerTableName { get; set; } + } +} diff --git a/New_College.Model/Models/U_VolunteerTableDetail.cs b/New_College.Model/Models/U_VolunteerTableDetail.cs new file mode 100644 index 0000000..d8ed9ef --- /dev/null +++ b/New_College.Model/Models/U_VolunteerTableDetail.cs @@ -0,0 +1,39 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 志愿表详情 + /// + public class U_VolunteerTableDetail : EntityModel + { + /// + /// 志愿表Id + /// + public int VolunteerTableId { get; set; } + + /// + /// 院校Id + /// + public int UniversityId { get; set; } + + /// + /// 院校名称 + /// + public string UniversityName { get; set; } + + /// + /// 院校编码 + /// + [SugarColumn(IsNullable = true)] + public string UniversityCode { get; set; } + + /// + /// 招生计划Id列表逗号隔开 + /// + public string PlanMajorIds { get; set; } + } +} diff --git a/New_College.Model/Models/UserRole.cs b/New_College.Model/Models/UserRole.cs new file mode 100644 index 0000000..621959f --- /dev/null +++ b/New_College.Model/Models/UserRole.cs @@ -0,0 +1,45 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Model.Models +{ + /// + /// 用户跟角色关联表 + /// + public class UserRole : RootEntity + { + public UserRole() { } + + public UserRole(int uid, int rid) + { + UserId = uid; + RoleId = rid; + CreateTime = DateTime.Now; + IsDeleted = false; + CreateId = uid; + CreateTime = DateTime.Now; + } + + + + /// + ///获取或设置是否禁用,逻辑上的删除,非物理删除 + /// + [SugarColumn(IsNullable = true)] + public bool? IsDeleted { get; set; } + /// + /// 用户ID + /// + public int UserId { get; set; } + /// + /// 角色ID + /// + public int RoleId { get; set; } + + + } +} diff --git a/New_College.Model/Models/V_CustomerInfo.cs b/New_College.Model/Models/V_CustomerInfo.cs new file mode 100644 index 0000000..a2a8f7a --- /dev/null +++ b/New_College.Model/Models/V_CustomerInfo.cs @@ -0,0 +1,134 @@ +using New_College.Common; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class V_CustomerInfo : EntityModel + { + /// + /// 用户头像 + /// + [SugarColumn(IsNullable = true)] + public string AvatarUrl { get; set; } + + /// + /// 用户code + /// + [SugarColumn(IsNullable = true)] + public string UserCode { get; set; } + + /// + /// 小程序openid + /// + [SugarColumn(IsNullable = true)] + public string OpenId { get; set; } + + /// + /// 用户名 + /// + [SugarColumn(IsNullable = true)] + public string NickName { get; set; } + + /// + /// 性别 1男 2女 + /// + [SugarColumn(IsNullable = true)] + public int Gender { get; set; } + + /// + /// 电话 + /// + [SugarColumn(IsNullable = true)] + public string Phone { get; set; } + + /// + /// 用户密码 + /// + [SugarColumn(IsNullable = true)] + public string UserPwd { get; set; } + + /// + /// 密码混合验证字段 + /// + [SugarColumn(IsNullable = true)] + public string Salt { get; set; } + + + /// + ///学生所在学校 + /// + [SugarColumn(IsNullable = true)] + public string SchoolName { get; set; } + + /// + /// 学生所在班级 + /// + [SugarColumn(IsNullable = true)] + public string ClassName { get; set; } + /// + /// 用户类型 + /// + [SugarColumn(IsNullable = true)] + public CustomerTypeEnum CustomerType { get; set; } = CustomerTypeEnum.General; + /// + /// 省市区id + /// + [SugarColumn(IsNullable = true)] + public int AreaId { get; set; } = 0; + /// + /// 省市区名称 + /// + [SugarColumn(IsNullable = true)] + public string AreaName { get; set; } + + /// + /// 状态:0、未启用,1、启用,2、禁用 + /// + public int? Status { get; set; } = 1; + + /// + ///学生数据是否初始化(省份,选科等) + /// + public bool? Datainit { get; set; } = false; + + /// + /// 0(新高考),1(文科,理科) + /// + public int? Subject { get; set; } = 0; + + /// + /// 选科文字展示 + /// + [SugarColumn(IsNullable = true)] + public string Subjectgroup { get; set; } + + /// + /// 考生预计分数 + /// + public double? Expectedscore { get; set; } = 0; + + /// + /// 是否为VIP + /// + public bool IsVIP { get; set; } = false; + + [SugarColumn(IsNullable = true)] + public string VipCode { get; set; } + + /// + /// 是否更新分数 + /// + [SugarColumn(IsNullable = true)] + public int IsUpdateScore { get; set; } = 0; + + /// + /// 年份 + /// + [SugarColumn(IsNullable = true)] + public int Year { get; set; } + + } +} diff --git a/New_College.Model/Models/V_ExaminationPolicy.cs b/New_College.Model/Models/V_ExaminationPolicy.cs new file mode 100644 index 0000000..30a60b3 --- /dev/null +++ b/New_College.Model/Models/V_ExaminationPolicy.cs @@ -0,0 +1,35 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class V_ExaminationPolicy : EntityModel + { + /// + /// 省份id + /// + public int AreaId { get; set; } + + public string AreaName { get; set; } + + /// + /// 标题 + /// + [SugarColumn(IsNullable = true)] + public string Title { get; set; } + + /// + /// 图片 + /// + [SugarColumn(IsNullable = true)] + public string Img { get; set; } + + /// + /// 政策内容 + /// + [SugarColumn(ColumnDataType = "nvarchar", Length = 4000, IsNullable = true)] + public string Content { get; set; } + } +} diff --git a/New_College.Model/Models/V_OrderInfo.cs b/New_College.Model/Models/V_OrderInfo.cs new file mode 100644 index 0000000..05a82c6 --- /dev/null +++ b/New_College.Model/Models/V_OrderInfo.cs @@ -0,0 +1,74 @@ +using New_College.Common; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + /// + /// 此表用户绑定后添加和直接购买 + /// + public class V_OrderInfo : RootEntity + { + /// + /// 1支付宝支付 0微信支付 + /// + [SugarColumn(IsNullable = true)] + public EnumPayType PayType { get; set; } + + /// + /// 状态 + /// + public EnumOrderType Status { get; set; } + + /// + /// 价格 + /// + public decimal Price { get; set; } + + /// + /// 实付款 + /// + public decimal PayPrice { get; set; } + + /// + /// 卡Id + /// + [SugarColumn(IsNullable = true)] + public int CardId { get; set; } + + /// + /// 卡号 + /// + [SugarColumn(IsNullable = true)] + public string CardNo { get; set; } + + /// + /// 卡类型Id + /// + public int CardTypeId { get; set; } + + /// + /// 用户Id + /// + public int CustomerId { get; set; } + + /// + /// + /// + public string Name { get; set; } + + /// + /// + /// + [SugarColumn(IsNullable = true)] + public string out_trade_no { get; set; } + + /// + /// 订单号 + /// + [SugarColumn(IsNullable = true)] + public string OrderId { get; set; } + } +} diff --git a/New_College.Model/Models/V_SubjectSelect.cs b/New_College.Model/Models/V_SubjectSelect.cs new file mode 100644 index 0000000..f54b51f --- /dev/null +++ b/New_College.Model/Models/V_SubjectSelect.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class V_SubjectSelect : EntityModel + { + /// + /// 用户Id + /// + public int CustomerId { get; set; } + + /// + /// 逗号隔开 + /// + public string SubjectSelect { get; set; } + + /// + /// 状态1初选 + /// 状态2是结束 + /// 重新选择的时候修改为1 + /// + public int Status { get; set; } + } +} diff --git a/New_College.Model/Models/V_VipCardInfo.cs b/New_College.Model/Models/V_VipCardInfo.cs new file mode 100644 index 0000000..9d921a6 --- /dev/null +++ b/New_College.Model/Models/V_VipCardInfo.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class V_VipCardInfo : RootEntity + { + /// + /// 账号 key + /// + public string Code { get; set; } + + /// + /// 是否一绑定 + /// + public int IsBind { get; set; } + + /// + /// 天数 + /// + public int Day { get; set; } + + public DateTime EndTime { get; set; } + + /// + /// 金额 + /// + public decimal Money { get; set; } + + /// + /// 卡类型Id + /// + public int CardTypeId { get; set; } + + /// + /// 卡类型 + /// + public string CardTypeName { get; set; } + } +} diff --git a/New_College.Model/Models/V_VipCardType.cs b/New_College.Model/Models/V_VipCardType.cs new file mode 100644 index 0000000..e45fb17 --- /dev/null +++ b/New_College.Model/Models/V_VipCardType.cs @@ -0,0 +1,37 @@ +using New_College.Common; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class V_VipCardType : EntityModel + { + /// + /// 卡类型名称 + /// + public string Name { get; set; } + + /// + /// 金额 + /// + public decimal Money { get; set; } + + /// + /// + /// + public CustomerTypeEnum Type { get; set; } = CustomerTypeEnum.General; + + /// + /// 天数 + /// + public int Day { get; set; } + + /// + /// 介绍 + /// + [SugarColumn(IsNullable = true)] + public string Desc { get; set; } + } +} diff --git a/New_College.Model/Models/sysUserInfo.cs b/New_College.Model/Models/sysUserInfo.cs new file mode 100644 index 0000000..6d4582b --- /dev/null +++ b/New_College.Model/Models/sysUserInfo.cs @@ -0,0 +1,109 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Model.Models +{ + /// + /// 用户信息表 + /// + public class sysUserInfo + { + public sysUserInfo() { } + + public sysUserInfo(string loginName, string loginPWD) + { + uLoginName = loginName; + uLoginPWD = loginPWD; + uRealName = uLoginName; + uStatus = 0; + uCreateTime = DateTime.Now; + uUpdateTime = DateTime.Now; + uLastErrTime = DateTime.Now; + uErrorCount = 0; + name = ""; + + } + /// + /// 用户ID + /// + [SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = true)] + public int uID { get; set; } + /// + /// 登录账号 + /// + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string uLoginName { get; set; } + /// + /// 登录密码 + /// + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string uLoginPWD { get; set; } + /// + /// 真实姓名 + /// + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string uRealName { get; set; } + /// + /// 状态 + /// + public int uStatus { get; set; } + /// + /// 备注 + /// + [SugarColumn(ColumnDataType ="nvarchar",Length = int.MaxValue, IsNullable = true)] + public string uRemark { get; set; } + /// + /// 创建时间 + /// + public System.DateTime uCreateTime { get; set; } = DateTime.Now; + /// + /// 更新时间 + /// + public System.DateTime uUpdateTime { get; set; } = DateTime.Now; + + /// + ///最后登录时间 + /// + public DateTime uLastErrTime { get; set; }= DateTime.Now; + + /// + ///错误次数 + /// + public int uErrorCount { get; set; } + + + + /// + /// 登录账号 + /// + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string name { get; set; } + + // 性别 + [SugarColumn(IsNullable = true)] + public int sex { get; set; } = 0; + // 年龄 + [SugarColumn(IsNullable = true)] + public int age { get; set; } + // 生日 + [SugarColumn(IsNullable = true)] + public DateTime birth { get; set; } = DateTime.Now; + // 地址 + [SugarColumn(ColumnDataType ="nvarchar",Length = 200, IsNullable = true)] + public string addr { get; set; } + + [SugarColumn(IsNullable = true)] + public bool tdIsDelete { get; set; } + + + [SugarColumn(IsIgnore = true)] + public List RIDs { get; set; } + [SugarColumn(IsIgnore = true)] + public List RoleNames { get; set; } + + } +} diff --git a/New_College.Model/New_College.Model.csproj b/New_College.Model/New_College.Model.csproj new file mode 100644 index 0000000..bf70a47 --- /dev/null +++ b/New_College.Model/New_College.Model.csproj @@ -0,0 +1,25 @@ + + + + netcoreapp3.1 + + + + ..\New_College.Api\New_College.Model.xml + 1701;1702;1591 + + + + ..\New_College\New_College.Model.xml + 1701;1702;1591 + + + + + + + + + + + diff --git a/New_College.Model/PageModel.cs b/New_College.Model/PageModel.cs new file mode 100644 index 0000000..9d769e3 --- /dev/null +++ b/New_College.Model/PageModel.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; + +namespace New_College.Model +{ + /// + /// 通用分页信息类 + /// + public class PageModel + { + /// + /// 当前页标 + /// + public int page { get; set; } = 1; + /// + /// 总页数 + /// + public int pageCount { get; set; } = 6; + /// + /// 数据总数 + /// + public int dataCount { get; set; } = 0; + /// + /// 每页大小 + /// + public int PageSize { set; get; } + /// + /// 返回数据 + /// + public List data { get; set; } + + } + +} diff --git a/New_College.Model/Request/DecryptUserInfoRequest.cs b/New_College.Model/Request/DecryptUserInfoRequest.cs new file mode 100644 index 0000000..abf9dca --- /dev/null +++ b/New_College.Model/Request/DecryptUserInfoRequest.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Request +{ + public class DecryptUserInfoRequest : GetPhoneInfo + { + + /// + /// 用户头像 + /// + public string avatarUrl { get; set; } + + + public string nickName { get; set; } + + public int gender { get; set; } + + public string phone { get; set; } + + + public string AreaName { get; set; } + } +} diff --git a/New_College.Model/Request/LoginQuery.cs b/New_College.Model/Request/LoginQuery.cs new file mode 100644 index 0000000..c1ec3ce --- /dev/null +++ b/New_College.Model/Request/LoginQuery.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Request +{ + public class LoginQuery + { + /// + /// 首次注册时传此值 + /// + public string openId { get; set; } + + /// + /// 退出重新登录时传此值 + /// + public string code { get; set; } + } +} diff --git a/New_College.Model/Request/WeixinLogin.cs b/New_College.Model/Request/WeixinLogin.cs new file mode 100644 index 0000000..baba64e --- /dev/null +++ b/New_College.Model/Request/WeixinLogin.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model +{ + public class WeixinLogin + { + public string code { get; set; } + } +} diff --git a/New_College.Model/ResponseEnum.cs b/New_College.Model/ResponseEnum.cs new file mode 100644 index 0000000..70a02ae --- /dev/null +++ b/New_College.Model/ResponseEnum.cs @@ -0,0 +1,23 @@ +using System.ComponentModel; + +namespace New_College.Model +{ + public enum ResponseEnum + { + /// + /// 无权限 + /// + [Description("无权限")] + NoPermissions = 401, + /// + /// 找不到指定资源 + /// + [Description("找不到指定资源")] + NoFound = 404, + /// + /// 找不到指定资源 + /// + [Description("服务器错误")] + ServerError = 500 + } +} diff --git a/New_College.Model/Seed/DBSeed.cs b/New_College.Model/Seed/DBSeed.cs new file mode 100644 index 0000000..6dd2ef4 --- /dev/null +++ b/New_College.Model/Seed/DBSeed.cs @@ -0,0 +1,246 @@ +using New_College.Common; +using New_College.Common.DB; +using New_College.Common.Helper; +using New_College.Model.Models; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Model.Seed +{ + public class DBSeed + { + private static string SeedDataFolder = "BlogCore.Data.json/{0}.tsv"; + + + /// + /// 异步添加种子数据 + /// + /// + /// + /// + public static async Task SeedAsync(MyContext myContext, string WebRootPath) + { + try + { + if (string.IsNullOrEmpty(WebRootPath)) + { + throw new Exception("获取wwwroot路径时,异常!"); + } + + SeedDataFolder = Path.Combine(WebRootPath, SeedDataFolder); + + Console.WriteLine("************ New_College DataBase Set *****************"); + Console.WriteLine($"Is multi-DataBase: {Appsettings.app(new string[] { "MutiDBEnabled" })}"); + Console.WriteLine($"Is CQRS: {Appsettings.app(new string[] { "CQRSEnabled" })}"); + Console.WriteLine(); + Console.WriteLine($"Master DB ConId: {MyContext.ConnId}"); + Console.WriteLine($"Master DB Type: {MyContext.DbType}"); + Console.WriteLine($"Master DB ConnectString: {MyContext.ConnectionString}"); + Console.WriteLine(); + if (Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) + { + var slaveIndex = 0; + BaseDBConfig.MutiConnectionString.Item1.Where(x => x.ConnId != MainDb.CurrentDbConnId).ToList().ForEach(m => + { + slaveIndex++; + Console.WriteLine($"Slave{slaveIndex} DB ID: {m.ConnId}"); + Console.WriteLine($"Slave{slaveIndex} DB Type: {m.DbType}"); + Console.WriteLine($"Slave{slaveIndex} DB ConnectString: {m.Connection}"); + Console.WriteLine($"--------------------------------------"); + }); + } + else if (Appsettings.app(new string[] { "CQRSEnabled" }).ObjToBool()) + { + var slaveIndex = 0; + BaseDBConfig.MutiConnectionString.Item2.Where(x => x.ConnId != MainDb.CurrentDbConnId).ToList().ForEach(m => + { + slaveIndex++; + Console.WriteLine($"Slave{slaveIndex} DB ID: {m.ConnId}"); + Console.WriteLine($"Slave{slaveIndex} DB Type: {m.DbType}"); + Console.WriteLine($"Slave{slaveIndex} DB ConnectString: {m.Connection}"); + Console.WriteLine($"--------------------------------------"); + }); + } + else + { + } + + Console.WriteLine(); + + + // 创建数据库 + Console.WriteLine($"Create Database(The Db Id:{MyContext.ConnId})..."); + myContext.Db.DbMaintenance.CreateDatabase(); + ConsoleHelper.WriteSuccessLine($"Database created successfully!"); + + + // 创建数据库表,遍历指定命名空间下的class, + // 注意不要把其他命名空间下的也添加进来。 + Console.WriteLine("Create Tables..."); + var modelTypes = from t in Assembly.GetExecutingAssembly().GetTypes() + where t.IsClass && t.Namespace == "New_College.Model.Models" + select t; + modelTypes.ToList().ForEach(t => + { + if (!myContext.Db.DbMaintenance.IsAnyTable(t.Name)) + { + Console.WriteLine(t.Name); + myContext.Db.CodeFirst.InitTables(t); + } + }); + ConsoleHelper.WriteSuccessLine($"Tables created successfully!"); + Console.WriteLine(); + + + + if (Appsettings.app(new string[] { "AppSettings", "SeedDBDataEnabled" }).ObjToBool()) + { + Console.WriteLine($"Seeding database data (The Db Id:{MyContext.ConnId})..."); + + #region BlogArticle + if (!await myContext.Db.Queryable().AnyAsync()) + { + myContext.GetEntityDB().InsertRange(JsonHelper.ParseFormByJson>(FileHelper.ReadFile(string.Format(SeedDataFolder, "BlogArticle"), Encoding.UTF8))); + Console.WriteLine("Table:BlogArticle created success!"); + } + else + { + Console.WriteLine("Table:BlogArticle already exists..."); + } + #endregion + + + #region Modules + if (!await myContext.Db.Queryable().AnyAsync()) + { + myContext.GetEntityDB().InsertRange(JsonHelper.ParseFormByJson>(FileHelper.ReadFile(string.Format(SeedDataFolder, "Modules"), Encoding.UTF8))); + Console.WriteLine("Table:Modules created success!"); + } + else + { + Console.WriteLine("Table:Modules already exists..."); + } + #endregion + + + #region Permission + if (!await myContext.Db.Queryable().AnyAsync()) + { + myContext.GetEntityDB().InsertRange(JsonHelper.ParseFormByJson>(FileHelper.ReadFile(string.Format(SeedDataFolder, "Permission"), Encoding.UTF8))); + Console.WriteLine("Table:Permission created success!"); + } + else + { + Console.WriteLine("Table:Permission already exists..."); + } + #endregion + + + #region Role + if (!await myContext.Db.Queryable().AnyAsync()) + { + myContext.GetEntityDB().InsertRange(JsonHelper.ParseFormByJson>(FileHelper.ReadFile(string.Format(SeedDataFolder, "Role"), Encoding.UTF8))); + Console.WriteLine("Table:Role created success!"); + } + else + { + Console.WriteLine("Table:Role already exists..."); + } + #endregion + + + #region RoleModulePermission + if (!await myContext.Db.Queryable().AnyAsync()) + { + myContext.GetEntityDB().InsertRange(JsonHelper.ParseFormByJson>(FileHelper.ReadFile(string.Format(SeedDataFolder, "RoleModulePermission"), Encoding.UTF8))); + Console.WriteLine("Table:RoleModulePermission created success!"); + } + else + { + Console.WriteLine("Table:RoleModulePermission already exists..."); + } + #endregion + + + #region Topic + if (!await myContext.Db.Queryable().AnyAsync()) + { + myContext.GetEntityDB().InsertRange(JsonHelper.ParseFormByJson>(FileHelper.ReadFile(string.Format(SeedDataFolder, "Topic"), Encoding.UTF8))); + Console.WriteLine("Table:Topic created success!"); + } + else + { + Console.WriteLine("Table:Topic already exists..."); + } + #endregion + + + #region TopicDetail + if (!await myContext.Db.Queryable().AnyAsync()) + { + myContext.GetEntityDB().InsertRange(JsonHelper.ParseFormByJson>(FileHelper.ReadFile(string.Format(SeedDataFolder, "TopicDetail"), Encoding.UTF8))); + Console.WriteLine("Table:TopicDetail created success!"); + } + else + { + Console.WriteLine("Table:TopicDetail already exists..."); + } + #endregion + + + #region UserRole + if (!await myContext.Db.Queryable().AnyAsync()) + { + myContext.GetEntityDB().InsertRange(JsonHelper.ParseFormByJson>(FileHelper.ReadFile(string.Format(SeedDataFolder, "UserRole"), Encoding.UTF8))); + Console.WriteLine("Table:UserRole created success!"); + } + else + { + Console.WriteLine("Table:UserRole already exists..."); + } + #endregion + + + #region sysUserInfo + if (!await myContext.Db.Queryable().AnyAsync()) + { + myContext.GetEntityDB().InsertRange(JsonHelper.ParseFormByJson>(FileHelper.ReadFile(string.Format(SeedDataFolder, "sysUserInfo"), Encoding.UTF8))); + Console.WriteLine("Table:sysUserInfo created success!"); + } + else + { + Console.WriteLine("Table:sysUserInfo already exists..."); + } + #endregion + + + #region TasksQz + if (!await myContext.Db.Queryable().AnyAsync()) + { + myContext.GetEntityDB().InsertRange(JsonHelper.ParseFormByJson>(FileHelper.ReadFile(string.Format(SeedDataFolder, "TasksQz"), Encoding.UTF8))); + Console.WriteLine("Table:TasksQz created success!"); + } + else + { + Console.WriteLine("Table:TasksQz already exists..."); + } + #endregion + + ConsoleHelper.WriteSuccessLine($"Done seeding database!"); + } + + Console.WriteLine(); + + } + catch (Exception ex) + { + throw new Exception("1、如果使用的是Mysql,生成的数据库字段字符集可能不是utf8的,手动修改下,或者尝试方案:删掉数据库,在连接字符串后加上CharSet=UTF8mb4,重新生成数据库. \n 2、其他错误:" + ex.Message); + } + } + } +} \ No newline at end of file diff --git a/New_College.Model/Seed/FrameSeed.cs b/New_College.Model/Seed/FrameSeed.cs new file mode 100644 index 0000000..0ffa538 --- /dev/null +++ b/New_College.Model/Seed/FrameSeed.cs @@ -0,0 +1,648 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace New_College.Model.Seed +{ + public class FrameSeed + { + + /// + /// 生成Controller层 + /// + /// sqlsugar实例 + /// 数据库链接ID + /// 数据库表名数组,默认空,生成所有表 + /// + /// + public static bool CreateControllers(SqlSugarClient sqlSugarClient, string ConnId = null, bool isMuti = false, string[] tableNames = null) + { + + try + { + Create_Controller_ClassFileByDBTalbe(sqlSugarClient, ConnId, $@"C:\my-file\New_College.Api.Controllers", "New_College.Api.Controllers", tableNames, "", isMuti); + return true; + } + catch (Exception) + { + return false; + } + + } + + /// + /// 生成Model层 + /// + /// sqlsugar实例 + /// 数据库链接ID + /// 数据库表名数组,默认空,生成所有表 + /// + /// + public static bool CreateModels(SqlSugarClient sqlSugarClient, string ConnId, bool isMuti = false, string[] tableNames = null) + { + + try + { + Create_Model_ClassFileByDBTalbe(sqlSugarClient, ConnId, $@"C:\my-file\New_College.Model", "New_College.Model.Models", tableNames, "", isMuti); + return true; + } + catch (Exception) + { + return false; + } + + } + + /// + /// 生成IRepository层 + /// + /// sqlsugar实例 + /// 数据库链接ID + /// + /// 数据库表名数组,默认空,生成所有表 + /// + public static bool CreateIRepositorys(SqlSugarClient sqlSugarClient, string ConnId, bool isMuti = false, string[] tableNames = null) + { + + try + { + Create_IRepository_ClassFileByDBTalbe(sqlSugarClient, ConnId, $@"C:\my-file\New_College.IRepository", "New_College.IRepository", tableNames, "", isMuti); + return true; + } + catch (Exception) + { + return false; + } + + } + + + + /// + /// 生成 IService 层 + /// + /// sqlsugar实例 + /// 数据库链接ID + /// + /// 数据库表名数组,默认空,生成所有表 + /// + public static bool CreateIServices(SqlSugarClient sqlSugarClient, string ConnId, bool isMuti = false, string[] tableNames = null) + { + + try + { + Create_IServices_ClassFileByDBTalbe(sqlSugarClient, ConnId, $@"C:\my-file\New_College.IServices", "New_College.IServices", tableNames, "", isMuti); + return true; + } + catch (Exception) + { + return false; + } + + } + + + + /// + /// 生成 Repository 层 + /// + /// sqlsugar实例 + /// 数据库链接ID + /// + /// 数据库表名数组,默认空,生成所有表 + /// + public static bool CreateRepository(SqlSugarClient sqlSugarClient, string ConnId, bool isMuti = false, string[] tableNames = null) + { + + try + { + Create_Repository_ClassFileByDBTalbe(sqlSugarClient, ConnId, $@"C:\my-file\New_College.Repository", "New_College.Repository", tableNames, "", isMuti); + return true; + } + catch (Exception) + { + return false; + } + + } + + + + /// + /// 生成 Service 层 + /// + /// sqlsugar实例 + /// 数据库链接ID + /// + /// 数据库表名数组,默认空,生成所有表 + /// + public static bool CreateServices(SqlSugarClient sqlSugarClient, string ConnId, bool isMuti = false, string[] tableNames = null) + { + + try + { + Create_Services_ClassFileByDBTalbe(sqlSugarClient, ConnId, $@"C:\my-file\New_College.Services", "New_College.Services", tableNames, "", isMuti); + return true; + } + catch (Exception) + { + return false; + } + + } + + + #region 根据数据库表生产Controller层 + + /// + /// 功能描述:根据数据库表生产Controller层 + /// 作  者:New_College + /// + /// + /// 数据库链接ID + /// 实体类存放路径 + /// 命名空间 + /// 生产指定的表 + /// 实现接口 + /// + /// 是否序列化 + private static void Create_Controller_ClassFileByDBTalbe( + SqlSugarClient sqlSugarClient, + string ConnId, + string strPath, + string strNameSpace, + string[] lstTableNames, + string strInterface, + bool isMuti = false, + bool blnSerializable = false) + { + var IDbFirst = sqlSugarClient.DbFirst; + if (lstTableNames != null && lstTableNames.Length > 0) + { + IDbFirst = IDbFirst.Where(lstTableNames); + } + var ls = IDbFirst.IsCreateDefaultValue().IsCreateAttribute() + + .SettingClassTemplate(p => p = +@"using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Linq.Expressions; +using System.Threading.Tasks; + +namespace " + strNameSpace + @" +{ + [Route(""api/[controller]/[action]"")] + [ApiController] + [Authorize(Permissions.Name)] + public class {ClassName}Controller : ControllerBase + { + /// + /// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下 + /// + private readonly I{ClassName}Services _{ClassName}Services; + + public {ClassName}Controller(I{ClassName}Services {ClassName}Services) + { + _{ClassName}Services = {ClassName}Services; + } + + [HttpGet] + public async Task>> Get(int page = 1, string key = """",int intPageSize = 50) + { + if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) + { + key = """"; + } + + Expression> whereExpression = a => a.id > 0; + + return new MessageModel>() + { + msg = ""获取成功"", + success = true, + response = await _{ClassName}Services.QueryPage(whereExpression, page, intPageSize) + }; + + } + + [HttpGet(""{id}"")] + public async Task> Get(int id = 0) + { + return new MessageModel<{ClassName}>() + { + msg = ""获取成功"", + success = true, + response = await _{ClassName}Services.QueryById(id) + }; + } + + [HttpPost] + public async Task> Post([FromBody] {ClassName} request) + { + var data = new MessageModel(); + + var id = await _{ClassName}Services.Add(request); + data.success = id > 0; + + if (data.success) + { + data.response = id.ObjToString(); + data.msg = ""添加成功""; + } + + return data; + } + + [HttpPut] + public async Task> Put([FromBody] {ClassName} request) + { + var data = new MessageModel(); + if (request.id > 0) + { + data.success = await _{ClassName}Services.Update(request); + if (data.success) + { + data.msg = ""更新成功""; + data.response = request?.id.ObjToString(); + } + } + + return data; + } + + [HttpDelete(""{id}"")] + public async Task> Delete(int id = 0) + { + var data = new MessageModel(); + if (id > 0) + { + var detail = await _{ClassName}Services.QueryById(id); + + detail.IsDeleted = true; + + if (detail != null) + { + data.success = await _{ClassName}Services.Update(detail); + if (data.success) + { + data.msg = ""删除成功""; + data.response = detail?.id.ObjToString(); + } + } + } + + return data; + } +} +}") + + .ToClassStringList(strNameSpace); + + Dictionary newdic = new Dictionary(); + //循环处理 首字母小写 并插入新的 Dictionary + foreach (KeyValuePair item in ls) + { + string newkey = "_" + item.Key.First().ToString().ToLower() + item.Key.Substring(1); + string newvalue = item.Value.Replace("_" + item.Key, newkey); + newdic.Add(item.Key, newvalue); + } + CreateFilesByClassStringList(newdic, strPath, "{0}Controller"); + } + #endregion + + + #region 根据数据库表生产Model层 + + /// + /// 功能描述:根据数据库表生产Model层 + /// 作  者:New_College + /// + /// + /// 数据库链接ID + /// 实体类存放路径 + /// 命名空间 + /// 生产指定的表 + /// 实现接口 + /// + /// 是否序列化 + private static void Create_Model_ClassFileByDBTalbe( + SqlSugarClient sqlSugarClient, + string ConnId, + string strPath, + string strNameSpace, + string[] lstTableNames, + string strInterface, + bool isMuti = false, + bool blnSerializable = false) + { + //多库文件分离 + if (isMuti) + { + strPath = strPath + @"\Models\" + ConnId; + strNameSpace = strNameSpace + "." + ConnId; + } + + var IDbFirst = sqlSugarClient.DbFirst; + if (lstTableNames != null && lstTableNames.Length > 0) + { + IDbFirst = IDbFirst.Where(lstTableNames); + } + var ls = IDbFirst.IsCreateDefaultValue().IsCreateAttribute() + + .SettingClassTemplate(p => p = +@"{using} + +namespace " + strNameSpace + @" +{ +{ClassDescription} + [SugarTable( ""{ClassName}"", """ + ConnId + @""")]" + (blnSerializable ? "\n [Serializable]" : "") + @" + public class {ClassName}" + (string.IsNullOrEmpty(strInterface) ? "" : (" : " + strInterface)) + @" + { + public {ClassName}() + { + } + {PropertyName} + } +}") + .SettingPropertyDescriptionTemplate(p => p = string.Empty) + .SettingPropertyTemplate(p => p = +@"{SugarColumn} + public {PropertyType} {PropertyName} { get; set; }") + + //.SettingConstructorTemplate(p => p = " this._{PropertyName} ={DefaultValue};") + + .ToClassStringList(strNameSpace); + CreateFilesByClassStringList(ls, strPath, "{0}"); + } + #endregion + + + #region 根据数据库表生产IRepository层 + + /// + /// 功能描述:根据数据库表生产IRepository层 + /// 作  者:New_College + /// + /// + /// 数据库链接ID + /// 实体类存放路径 + /// 命名空间 + /// 生产指定的表 + /// 实现接口 + /// + private static void Create_IRepository_ClassFileByDBTalbe( + SqlSugarClient sqlSugarClient, + string ConnId, + string strPath, + string strNameSpace, + string[] lstTableNames, + string strInterface, + bool isMuti = false + ) + { + //多库文件分离 + if (isMuti) + { + strPath = strPath + @"\" + ConnId; + strNameSpace = strNameSpace + "." + ConnId; + } + + var IDbFirst = sqlSugarClient.DbFirst; + if (lstTableNames != null && lstTableNames.Length > 0) + { + IDbFirst = IDbFirst.Where(lstTableNames); + } + var ls = IDbFirst.IsCreateDefaultValue().IsCreateAttribute() + + .SettingClassTemplate(p => p = +@"using New_College.IRepository.Base; +using New_College.Model.Models" + (isMuti ? "." + ConnId + "" : "") + @"; + +namespace " + strNameSpace + @" +{ + /// + /// I{ClassName}Repository + /// + public interface I{ClassName}Repository : IBaseRepository<{ClassName}>" + (string.IsNullOrEmpty(strInterface) ? "" : (" , " + strInterface)) + @" + { + } +}") + + .ToClassStringList(strNameSpace); + CreateFilesByClassStringList(ls, strPath, "I{0}Repository"); + } + #endregion + + + #region 根据数据库表生产IServices层 + + /// + /// 功能描述:根据数据库表生产IServices层 + /// 作  者:New_College + /// + /// + /// 数据库链接ID + /// 实体类存放路径 + /// 命名空间 + /// 生产指定的表 + /// 实现接口 + /// + private static void Create_IServices_ClassFileByDBTalbe( + SqlSugarClient sqlSugarClient, + string ConnId, + string strPath, + string strNameSpace, + string[] lstTableNames, + string strInterface, + bool isMuti = false) + { + //多库文件分离 + if (isMuti) + { + strPath = strPath + @"\" + ConnId; + strNameSpace = strNameSpace + "." + ConnId; + } + + var IDbFirst = sqlSugarClient.DbFirst; + if (lstTableNames != null && lstTableNames.Length > 0) + { + IDbFirst = IDbFirst.Where(lstTableNames); + } + var ls = IDbFirst.IsCreateDefaultValue().IsCreateAttribute() + + .SettingClassTemplate(p => p = +@"using New_College.IServices.BASE; +using New_College.Model.Models" + (isMuti ? "." + ConnId + "" : "") + @"; + +namespace " + strNameSpace + @" +{ + /// + /// I{ClassName}Services + /// + public interface I{ClassName}Services :IBaseServices<{ClassName}>" + (string.IsNullOrEmpty(strInterface) ? "" : (" , " + strInterface)) + @" + { + } +}") + + .ToClassStringList(strNameSpace); + CreateFilesByClassStringList(ls, strPath, "I{0}Services"); + } + #endregion + + + + #region 根据数据库表生产 Repository 层 + + /// + /// 功能描述:根据数据库表生产 Repository 层 + /// 作  者:New_College + /// + /// + /// 数据库链接ID + /// 实体类存放路径 + /// 命名空间 + /// 生产指定的表 + /// 实现接口 + /// + private static void Create_Repository_ClassFileByDBTalbe( + SqlSugarClient sqlSugarClient, + string ConnId, + string strPath, + string strNameSpace, + string[] lstTableNames, + string strInterface, + bool isMuti = false) + { + //多库文件分离 + if (isMuti) + { + strPath = strPath + @"\" + ConnId; + strNameSpace = strNameSpace + "." + ConnId; + } + + var IDbFirst = sqlSugarClient.DbFirst; + if (lstTableNames != null && lstTableNames.Length > 0) + { + IDbFirst = IDbFirst.Where(lstTableNames); + } + var ls = IDbFirst.IsCreateDefaultValue().IsCreateAttribute() + + .SettingClassTemplate(p => p = +@"using New_College.IRepository" + (isMuti ? "." + ConnId + "" : "") + @"; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models" + (isMuti ? "." + ConnId + "" : "") + @"; +using New_College.Repository.Base; + +namespace " + strNameSpace + @" +{ + /// + /// {ClassName}Repository + /// + public class {ClassName}Repository : BaseRepository<{ClassName}>, I{ClassName}Repository" + (string.IsNullOrEmpty(strInterface) ? "" : (" , " + strInterface)) + @" + { + public {ClassName}Repository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +}") + .ToClassStringList(strNameSpace); + + + CreateFilesByClassStringList(ls, strPath, "{0}Repository"); + } + #endregion + + + #region 根据数据库表生产 Services 层 + + /// + /// 功能描述:根据数据库表生产 Services 层 + /// 作  者:New_College + /// + /// + /// 数据库链接ID + /// 实体类存放路径 + /// 命名空间 + /// 生产指定的表 + /// 实现接口 + /// + private static void Create_Services_ClassFileByDBTalbe( + SqlSugarClient sqlSugarClient, + string ConnId, + string strPath, + string strNameSpace, + string[] lstTableNames, + string strInterface, + bool isMuti = false) + { + //多库文件分离 + if (isMuti) + { + strPath = strPath + @"\" + ConnId; + strNameSpace = strNameSpace + "." + ConnId; + } + + var IDbFirst = sqlSugarClient.DbFirst; + if (lstTableNames != null && lstTableNames.Length > 0) + { + IDbFirst = IDbFirst.Where(lstTableNames); + } + var ls = IDbFirst.IsCreateDefaultValue().IsCreateAttribute() + + .SettingClassTemplate(p => p = +@" +using New_College.IServices" + (isMuti ? "." + ConnId + "" : "") + @"; +using New_College.Model.Models" + (isMuti ? "." + ConnId + "" : "") + @"; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace " + strNameSpace + @" +{ + public class {ClassName}Services : BaseServices<{ClassName}>, I{ClassName}Services" + (string.IsNullOrEmpty(strInterface) ? "" : (" , " + strInterface)) + @" + { + private readonly IBaseRepository<{ClassName}> _dal; + public {ClassName}Services(IBaseRepository<{ClassName}> dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +}") + .ToClassStringList(strNameSpace); + + CreateFilesByClassStringList(ls, strPath, "{0}Services"); + } + #endregion + + + #region 根据模板内容批量生成文件 + /// + /// 根据模板内容批量生成文件 + /// + /// 类文件字符串list + /// 生成路径 + /// 文件名格式模板 + private static void CreateFilesByClassStringList(Dictionary ls, string strPath, string fileNameTp) + { + + foreach (var item in ls) + { + var fileName = $"{string.Format(fileNameTp, item.Key)}.cs"; + var fileFullPath = Path.Combine(strPath, fileName); + if (!Directory.Exists(strPath)) + { + Directory.CreateDirectory(strPath); + } + File.WriteAllText(fileFullPath, item.Value, Encoding.UTF8); + } + } + #endregion + } +} diff --git a/New_College.Model/Seed/MyContext.cs b/New_College.Model/Seed/MyContext.cs new file mode 100644 index 0000000..9cd57b7 --- /dev/null +++ b/New_College.Model/Seed/MyContext.cs @@ -0,0 +1,254 @@ +using New_College.Common.DB; +using SqlSugar; +using System; + +namespace New_College.Model.Seed +{ + public class MyContext + { + + private static MutiDBOperate connectObject => GetMainConnectionDb(); + private static string _connectionString = connectObject.Connection; + private static DbType _dbType = (DbType)connectObject.DbType; + public static string ConnId = connectObject.ConnId; + private SqlSugarClient _db; + + /// + /// 连接字符串 + /// New_College + /// + public static MutiDBOperate GetMainConnectionDb() + { + var mainConnetctDb = BaseDBConfig.MutiConnectionString.Item1.Find(x => x.ConnId == MainDb.CurrentDbConnId); + if (BaseDBConfig.MutiConnectionString.Item1.Count > 0) + { + if (mainConnetctDb == null) + { + mainConnetctDb = BaseDBConfig.MutiConnectionString.Item1[0]; + } + } + else + { + throw new Exception("请确保appsettigns.json中配置连接字符串,并设置Enabled为true;"); + } + + return mainConnetctDb; + } + /// + /// 连接字符串 + /// New_College + /// + public static string ConnectionString + { + get { return _connectionString; } + set { _connectionString = value; } + } + /// + /// 数据库类型 + /// New_College + /// + public static DbType DbType + { + get { return _dbType; } + set { _dbType = value; } + } + /// + /// 数据连接对象 + /// New_College + /// + public SqlSugarClient Db + { + get { return _db; } + private set { _db = value; } + } + + /// + /// 数据库上下文实例(自动关闭连接) + /// New_College + /// + public static MyContext Context + { + get + { + return new MyContext(); + } + + } + + + /// + /// 功能描述:构造函数 + /// 作  者:New_College + /// + public MyContext() + { + if (string.IsNullOrEmpty(_connectionString)) + throw new ArgumentNullException("数据库连接字符串为空"); + _db = new SqlSugarClient(new ConnectionConfig() + { + ConnectionString = _connectionString, + DbType = _dbType, + IsAutoCloseConnection = true, + InitKeyType = InitKeyType.Attribute,//mark + ConfigureExternalServices = new ConfigureExternalServices() + { + //DataInfoCacheService = new HttpRuntimeCache() + }, + MoreSettings = new ConnMoreSettings() + { + //IsWithNoLockQuery = true, + IsAutoRemoveDataCache = true + } + }); + } + + + #region 实例方法 + /// + /// 功能描述:获取数据库处理对象 + /// 作  者:New_College + /// + /// 返回值 + public SimpleClient GetEntityDB() where T : class, new() + { + return new SimpleClient(_db); + } + /// + /// 功能描述:获取数据库处理对象 + /// 作  者:New_College + /// + /// db + /// 返回值 + public SimpleClient GetEntityDB(SqlSugarClient db) where T : class, new() + { + return new SimpleClient(db); + } + + + + #endregion + + + #region 根据实体类生成数据库表 + /// + /// 功能描述:根据实体类生成数据库表 + /// 作  者:New_College + /// + /// 是否备份表 + /// 指定的实体 + public void CreateTableByEntity(bool blnBackupTable, params T[] lstEntitys) where T : class, new() + { + Type[] lstTypes = null; + if (lstEntitys != null) + { + lstTypes = new Type[lstEntitys.Length]; + for (int i = 0; i < lstEntitys.Length; i++) + { + T t = lstEntitys[i]; + lstTypes[i] = typeof(T); + } + } + CreateTableByEntity(blnBackupTable, lstTypes); + } + + /// + /// 功能描述:根据实体类生成数据库表 + /// 作  者:New_College + /// + /// 是否备份表 + /// 指定的实体 + public void CreateTableByEntity(bool blnBackupTable, params Type[] lstEntitys) + { + if (blnBackupTable) + { + _db.CodeFirst.BackupTable().InitTables(lstEntitys); //change entity backupTable + } + else + { + _db.CodeFirst.InitTables(lstEntitys); + } + } + #endregion + + + #region 静态方法 + + /// + /// 功能描述:获得一个DbContext + /// 作  者:New_College + /// + /// + public static MyContext GetDbContext() + { + return new MyContext(); + } + + /// + /// 功能描述:设置初始化参数 + /// 作  者:New_College + /// + /// 连接字符串 + /// 数据库类型 + public static void Init(string strConnectionString, DbType enmDbType = SqlSugar.DbType.SqlServer) + { + _connectionString = strConnectionString; + _dbType = enmDbType; + } + + /// + /// 功能描述:创建一个链接配置 + /// 作  者:New_College + /// + /// 是否自动关闭连接 + /// 是否夸类事务 + /// ConnectionConfig + public static ConnectionConfig GetConnectionConfig(bool blnIsAutoCloseConnection = true, bool blnIsShardSameThread = false) + { + ConnectionConfig config = new ConnectionConfig() + { + ConnectionString = _connectionString, + DbType = _dbType, + IsAutoCloseConnection = blnIsAutoCloseConnection, + ConfigureExternalServices = new ConfigureExternalServices() + { + //DataInfoCacheService = new HttpRuntimeCache() + }, + IsShardSameThread = blnIsShardSameThread + }; + return config; + } + + /// + /// 功能描述:获取一个自定义的DB + /// 作  者:New_College + /// + /// config + /// 返回值 + public static SqlSugarClient GetCustomDB(ConnectionConfig config) + { + return new SqlSugarClient(config); + } + /// + /// 功能描述:获取一个自定义的数据库处理对象 + /// 作  者:New_College + /// + /// sugarClient + /// 返回值 + public static SimpleClient GetCustomEntityDB(SqlSugarClient sugarClient) where T : class, new() + { + return new SimpleClient(sugarClient); + } + /// + /// 功能描述:获取一个自定义的数据库处理对象 + /// 作  者:New_College + /// + /// config + /// 返回值 + public static SimpleClient GetCustomEntityDB(ConnectionConfig config) where T : class, new() + { + SqlSugarClient sugarClient = GetCustomDB(config); + return GetCustomEntityDB(sugarClient); + } + #endregion + } +} diff --git a/New_College.Model/TableModel.cs b/New_College.Model/TableModel.cs new file mode 100644 index 0000000..951f5bb --- /dev/null +++ b/New_College.Model/TableModel.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; + +namespace New_College.Model +{ + /// + /// 表格数据,支持分页 + /// + public class TableModel + { + /// + /// 返回编码 + /// + public int Code { get; set; } + /// + /// 返回信息 + /// + public string Msg { get; set; } + /// + /// 记录总数 + /// + public int Count { get; set; } + /// + /// 返回数据集 + /// + public List Data { get; set; } + } +} diff --git a/New_College.Model/ViewModels/AdvertisementViewModels.cs b/New_College.Model/ViewModels/AdvertisementViewModels.cs new file mode 100644 index 0000000..39f3dd9 --- /dev/null +++ b/New_College.Model/ViewModels/AdvertisementViewModels.cs @@ -0,0 +1,39 @@ +using System; + +namespace New_College.Model.ViewModels +{ + /// + /// 广告类 + /// + public class AdvertisementViewModels + { + /// + /// 分类ID + /// + public int Id { get; set; } + /// + /// 创建时间 + /// + public DateTime Createdate { get; set; } + + /// + /// 广告图片 + /// + public string ImgUrl { get; set; } + + /// + /// 广告标题 + /// + public string Title { get; set; } + + /// + /// 广告链接 + /// + public string Url { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + } +} diff --git a/New_College.Model/ViewModels/AliyunSmsSenderConfig.cs b/New_College.Model/ViewModels/AliyunSmsSenderConfig.cs new file mode 100644 index 0000000..7627d5a --- /dev/null +++ b/New_College.Model/ViewModels/AliyunSmsSenderConfig.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class AliyunSmsSenderConfig + { + public static string accessKeyId { get; set; } + public static string accessKeySecret { get; set; } + } + + /// + /// 微信小程序配置 + /// + public class WeixinConfig + { + /// + /// 绑定支付的APPID(必须配置) + /// + public static string Appid { get; set; } + + /// + /// 公众账号secert + /// + public static string Secret { get; set; } + /// + /// 商户号(必填) + /// + public static string MCHID { get; set; } + + /// + /// 商户支付密钥 + /// + public static string KEY { get; set; } + + /// + /// 支付结果回调URL + /// + public static string NotifyUrl { get; set; } + } + + /// + /// + /// + public class WePayConfig + { + //=======【商户系统后台机器IP】===================================== + /* 此参数可手动配置也可在程序中自动获取 + */ + public const string IP = "8.8.8.8"; + + + //=======【代理服务器设置】=================================== + /* 默认IP和端口号分别为0.0.0.0和0,此时不开启代理(如有需要才设置) + */ + public const string PROXY_URL = ""; + + //=======【上报信息配置】=================================== + /* 测速上报等级,0.关闭上报; 1.仅错误时上报; 2.全量上报 + */ + public const int REPORT_LEVENL = 1; + + //=======【日志级别】=================================== + /* 日志等级,0.不输出日志;1.只输出错误信息; 2.输出错误和正常信息; 3.输出错误信息、正常信息和调试信息 + */ + public const int LOG_LEVENL = 3; + } +} diff --git a/New_College.Model/ViewModels/BaseQuery.cs b/New_College.Model/ViewModels/BaseQuery.cs new file mode 100644 index 0000000..8857106 --- /dev/null +++ b/New_College.Model/ViewModels/BaseQuery.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class BasePageRequest + { + public int PageIndex { get; set; } = 1; + + public int PageSize { get; set; } = 10; + } + + public class NameQuery + { + public string Name { get; set; } + } + + public class NameBaseQuery : BasePageRequest + { + public string Name { get; set; } + + /// + /// 本科/专科大类 1本科 2 专科 + /// + public int Type { get; set; } + } + + public class XmlQuery + { + public string xml { get; set; } + } +} diff --git a/New_College.Model/ViewModels/BaseResult.cs b/New_College.Model/ViewModels/BaseResult.cs new file mode 100644 index 0000000..18a58a1 --- /dev/null +++ b/New_College.Model/ViewModels/BaseResult.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class IdNameResult + { + public int Id { get; set; } + + public string Name { get; set; } + } + + public class IdQuery + { + public int Id { get; set; } + + public List Ids { get; set; } + } + + public class BaseResponse + { + public string msg { get; set; } + + public bool success { get; set; } = true; + } +} diff --git a/New_College.Model/ViewModels/BlogViewModels.cs b/New_College.Model/ViewModels/BlogViewModels.cs new file mode 100644 index 0000000..e4f347f --- /dev/null +++ b/New_College.Model/ViewModels/BlogViewModels.cs @@ -0,0 +1,83 @@ +using System; + +namespace New_College.Model.ViewModels +{ + /// + /// 博客信息展示类 + /// + public class BlogViewModels + { + /// + /// + /// + public int bID { get; set; } + /// 创建人 + /// + /// + public string bsubmitter { get; set; } + + /// 博客标题 + /// + /// + public string btitle { get; set; } + + /// 摘要 + /// + /// + public string digest { get; set; } + + /// + /// 上一篇 + /// + public string previous { get; set; } + + /// + /// 上一篇id + /// + public int previousID { get; set; } + + /// + /// 下一篇 + /// + public string next { get; set; } + + /// + /// 下一篇id + /// + public int nextID { get; set; } + + /// 类别 + /// + /// + public string bcategory { get; set; } + + /// 内容 + /// + /// + public string bcontent { get; set; } + + /// + /// 访问量 + /// + public int btraffic { get; set; } + + /// + /// 评论数量 + /// + public int bcommentNum { get; set; } + + /// 修改时间 + /// + /// + public DateTime bUpdateTime { get; set; } + + /// + /// 创建时间 + /// + public System.DateTime bCreateTime { get; set; } + /// 备注 + /// + /// + public string bRemark { get; set; } + } +} diff --git a/New_College.Model/ViewModels/GuestbookViewModels.cs b/New_College.Model/ViewModels/GuestbookViewModels.cs new file mode 100644 index 0000000..0ba12de --- /dev/null +++ b/New_College.Model/ViewModels/GuestbookViewModels.cs @@ -0,0 +1,51 @@ +using System; +using New_College.Model.Models; + +namespace New_College.Model.ViewModels +{ + /// + /// 留言信息展示类 + /// + public class GuestbookViewModels + { + /// 留言表 + /// + /// + public int id { get; set; } + + /// 博客ID + /// + /// + public int? blogId { get; set; } + /// 创建时间 + /// + /// + public DateTime createdate { get; set; } + public string username { get; set; } + + /// 手机 + /// + /// + public string phone { get; set; } + /// qq + /// + /// + public string QQ { get; set; } + + /// 留言内容 + /// + /// + public string body { get; set; } + /// ip地址 + /// + /// + public string ip { get; set; } + + /// 是否显示在前台,0否1是 + /// + /// + public bool isshow { get; set; } + + public BlogArticle blogarticle { get; set; } + } +} diff --git a/New_College.Model/ViewModels/LoginInfoViewModels.cs b/New_College.Model/ViewModels/LoginInfoViewModels.cs new file mode 100644 index 0000000..37aebf6 --- /dev/null +++ b/New_College.Model/ViewModels/LoginInfoViewModels.cs @@ -0,0 +1,13 @@ +namespace New_College.Model.ViewModels +{ + public class LoginInfoViewModels + { + public string uLoginName { get; set; } + + public string uLoginPwd { get; set; } + + public string VCode { get; set; } + + public bool IsMember { get; set; } + } +} diff --git a/New_College.Model/ViewModels/ModuleViewModels.cs b/New_College.Model/ViewModels/ModuleViewModels.cs new file mode 100644 index 0000000..d9137f3 --- /dev/null +++ b/New_College.Model/ViewModels/ModuleViewModels.cs @@ -0,0 +1,6 @@ +namespace New_College.Model.ViewModels +{ + public class ModuleViewModels + { + } +} diff --git a/New_College.Model/ViewModels/Query/AliPayQuery.cs b/New_College.Model/ViewModels/Query/AliPayQuery.cs new file mode 100644 index 0000000..6fb03a8 --- /dev/null +++ b/New_College.Model/ViewModels/Query/AliPayQuery.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class AliPayQuery + { + } + public class AlipayTradeWapPayQuery + { + public string OutTradeNo { get; set; } = ""; + + public string Body { get; set; } = "壹志愿VIP"; + + public decimal TotalAmount { get; set; } = 0; + + public string NotifyUrl { get; set; } = ""; + + public string ReturnUrl { get; set; } = ""; + + public string PaymentChannel { get; set; } = "支付宝支付"; + + public string PaymentType { get; set; } = "ZFB"; + + public int CustomerId { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/BatchQuery.cs b/New_College.Model/ViewModels/Query/BatchQuery.cs new file mode 100644 index 0000000..2b01bed --- /dev/null +++ b/New_College.Model/ViewModels/Query/BatchQuery.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class BatchQuery + { + public string AreaName { get; set; } + + public int Year { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/CategoryInfoQuery.cs b/New_College.Model/ViewModels/Query/CategoryInfoQuery.cs new file mode 100644 index 0000000..879481d --- /dev/null +++ b/New_College.Model/ViewModels/Query/CategoryInfoQuery.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class CategoryInfoQuery + { + /// + /// 测评类型 + /// + public int Type { get; set; } + } + + /// + /// + /// + public class CategoryStatusQuery + { + /// + /// 纬度Id + /// + public int CategoryId { get; set; } + + /// + /// 用户Id + /// + public int CustomerId { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/CustomerInfoQuery.cs b/New_College.Model/ViewModels/Query/CustomerInfoQuery.cs new file mode 100644 index 0000000..211177f --- /dev/null +++ b/New_College.Model/ViewModels/Query/CustomerInfoQuery.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class CustomerInfoQuery + { + public string OpenId { get; set; } + + public string Name { get; set; } + + public string Phone { get; set; } + + public string UserPwd { get; set; } + + public string Code { get; set; } + } + + public class PhoneQuery + { + public string Phone { get; set; } + } + + public class UpdateCustomerQuery + { + public int Id { get; set; } + + public string Phone { get; set; } + + /// + /// 不传就不修改密码 + /// + public string UserPwd { get; set; } + + /// + /// 用户头像 + /// + public string AvatarUrl { get; set; } + + /// + /// 用户名 + /// + public string NickName { get; set; } + + /// + /// 性别 1男 2女 + /// + public int Gender { get; set; } + + } + + public class ResetPwdQuery + { + public string Phone { get; set; } + + public string UserPwd { get; set; } + + public string Code { get; set; } + } + + public class UpdateScoreQuery + { + public int StudentId { get; set; } + + public int Score { get; set; } + + /// + /// 0(新高考),1,文科,2 理科 + /// + public int? Subject { get; set; } + + /// + /// 选科文字展示 + /// + public string Subjectgroup { get; set; } + } + + /// + /// 更新信息query + /// + public class CustomerUpdateQuery + { + public int StudentId { get; set; } + + /// + /// 省市区id + /// + public int AreaId { get; set; } + + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + + /// + /// 0(新高考),1,文科,2 理科 + /// + public int? Subject { get; set; } + + /// + /// 选科文字展示 + /// + public string Subjectgroup { get; set; } + + /// + /// 考生预计分数 + /// + public float Expectedscore { get; set; } + + public int Year { get; set; } + + public string SchoolName { get; set; } + + public string ClassName { get; set; } + } + + /// + /// + /// + public class CustomerQuery + { + public int StudentId { get; set; } + + /// + /// 省市区id + /// + public int AreaId { get; set; } + + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + + /// + /// 年份 + /// + public int Year { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/ExaminationPolicyQuery.cs b/New_College.Model/ViewModels/Query/ExaminationPolicyQuery.cs new file mode 100644 index 0000000..49e39f7 --- /dev/null +++ b/New_College.Model/ViewModels/Query/ExaminationPolicyQuery.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class ExaminationPolicySearchQuery : BasePageRequest + { + public int AreaId { get; set; } + } + + public class ExaminationPolicyQuery + { + public int Id { get; set; } + + /// + /// + /// + public int AreaId { get; set; } + + public string AreaName { get; set; } + + /// + /// + /// + public string Title { get; set; } + + /// + /// + /// + public string Content { get; set; } + + /// + /// 图片 + /// + public string Img { get; set; } + } + + public class ExaminationPolicyAreaQuery + { + public int AreaId { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/MajorQuery.cs b/New_College.Model/ViewModels/Query/MajorQuery.cs new file mode 100644 index 0000000..5bcab93 --- /dev/null +++ b/New_College.Model/ViewModels/Query/MajorQuery.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + /// + /// 专业基础查询 + /// + public class MajorQuery + { + public int UniversityId { get; set; } + public int MajorId { get; set; } + } + + public class MajorSchoolQuery : BasePageRequest + { + public int MajorId { get; set; } + + /// + /// 学科层次 + /// + public int SubjectLevel { get; set; } + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + /// + /// 办学性质 + /// + public int Nature { get; set; } + + /// + /// 学校类型 + /// + public int Type { get; set; } = -1; + + /// + /// 是否985 0、否,1、是 + /// + public int Nhef { get; set; } + + /// + /// 是否211 0、否,1、是 + /// + public int Sff { get; set; } + + /// + /// 是否双一流 0、否,1、是 + /// + public int Syl { get; set; } + } + + public class MajorCareerQuery + { + public int MajorId { get; set; } + } + + + + public class ManageMajorQuery + { + /// + /// 选科 物化生 中文逗号(,)隔开 + /// + public string SubjectClaim { get; set; } + + + + /// + /// 高考年份 + /// + public int Year { get; set; } + + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + /// + /// 省份Id + /// + public int AreaId { get; set; } + + /// + /// 分数 + /// + public float Score { get; set; } + + public List Names { get; set; } + public string Tags { get; set; } + + public int universityId { get; set; } + + public int categoryclassid { get; set; } + /// + /// 专业分类 1文科 2理科 3不区分 + /// + public int type { get; set; } + /// + /// 教育部专业编号 + /// + public string majorcode { get; set; } + /// + /// 专业名称 + /// + public string majorname { get; set; } + /// + /// 是否前10个 1是2不是 + /// + public int IsTop { get; set; } = 2; + } + + public class MajorThreeByTagQuery + { + /// + /// 霍兰德标签 + /// + public string Tags { get; set; } + /// + /// 选科 物化生 中文逗号(,)隔开 + /// + public string SubjectClaim { get; set; } + + + + /// + /// 高考年份 + /// + public int Year { get; set; } + + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + /// + /// 省份Id + /// + public int AreaId { get; set; } + + /// + /// 分数 + /// + public float Score { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/MajorSalaryQuery.cs b/New_College.Model/ViewModels/Query/MajorSalaryQuery.cs new file mode 100644 index 0000000..21d6775 --- /dev/null +++ b/New_College.Model/ViewModels/Query/MajorSalaryQuery.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class MajorSalaryQuery : BasePageRequest + { + /// + /// 类型 1本科 2专科 + /// + public int Type { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/MajorcategoryQuery.cs b/New_College.Model/ViewModels/Query/MajorcategoryQuery.cs new file mode 100644 index 0000000..182054b --- /dev/null +++ b/New_College.Model/ViewModels/Query/MajorcategoryQuery.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class MajorcategoryQuery + { + /// + /// 办学层次 本科/专科大类 1本科 2 专科 + /// + public int SchoolLevel { get; set; } = 1; + } +} diff --git a/New_College.Model/ViewModels/Query/OccupationQuery.cs b/New_College.Model/ViewModels/Query/OccupationQuery.cs new file mode 100644 index 0000000..79c5d21 --- /dev/null +++ b/New_College.Model/ViewModels/Query/OccupationQuery.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class OccupationQuery + { + + } +} diff --git a/New_College.Model/ViewModels/Query/OrderInfoQuery.cs b/New_College.Model/ViewModels/Query/OrderInfoQuery.cs new file mode 100644 index 0000000..4b2930b --- /dev/null +++ b/New_College.Model/ViewModels/Query/OrderInfoQuery.cs @@ -0,0 +1,133 @@ +using New_College.Common; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class OrderInfoQuery : BasePageRequest + { + /// + /// 1支付宝支付 2微信支付 + /// + [SugarColumn(IsNullable = true)] + public EnumPayType PayType { get; set; } + + /// + /// 1支付宝支付 2微信支付 + /// + public string PayTypeName { get; set; } + + /// + /// 状态 1待支付 2已支付 + /// + public EnumOrderType Status { get; set; } + + /// + /// 状态 1待支付 2已支付 + /// + public string StatusName { get; set; } + + /// + /// 价格 + /// + public decimal Price { get; set; } + + /// + /// 实付款 + /// + public decimal PayPrice { get; set; } + + /// + /// 卡Id + /// + [SugarColumn(IsNullable = true)] + public int CardId { get; set; } + + /// + /// 卡号 + /// + [SugarColumn(IsNullable = true)] + public string CardNo { get; set; } + + /// + /// 卡类型Id + /// + public int CardTypeId { get; set; } + + /// + /// 卡类型名字 + /// + public string CardTypeName { get; set; } + + /// + /// 用户Id + /// + public int CustomerId { get; set; } + + /// + /// 用户名 + /// + public string CustomerName { get; set; } + + /// + /// 名字 + /// + public string Name { get; set; } + + /// + /// out_trade_no + /// + [SugarColumn(IsNullable = true)] + public string out_trade_no { get; set; } + + /// + /// 订单号 + /// + [SugarColumn(IsNullable = true)] + public string OrderId { get; set; } + + /// + /// 电话 + /// + public string Phone { get; set; } + + } + + public class SearchOrderQuery : BasePageRequest + { + /// + /// 根据卡号查询 + /// + public string CardNo { get; set; } + + /// + /// 根据VIP类别查询 + /// + public int CardTypeId { get; set; } = 0; + + /// + /// 根据支付方式查询 + /// + public int PayType { get; set; } = -1; + + /// + /// 根据支付状态查询 + /// + public int Status { get; set; } = -2; + + /// + /// 根据手机号查询 + /// + public string Phone { get; set; } + + /// + /// 根据out_trade_no号查询 + /// + public string out_trade_no { get; set; } + + + } + +} diff --git a/New_College.Model/ViewModels/Query/OrderQuery.cs b/New_College.Model/ViewModels/Query/OrderQuery.cs new file mode 100644 index 0000000..3cb5783 --- /dev/null +++ b/New_College.Model/ViewModels/Query/OrderQuery.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class UniOrderQuery + { + /// + /// 微信浏览器(标价金额) + /// + public decimal total_fee { get; set; } + + /// + /// trade_type=JSAPI时(即JSAPI支付),此参数必传,此参数为微信用户在商户对应appid下的唯一标识。openid如何获取,可参考【获取openid】。企业号请使用【企业号OAuth2.0接口】获取企业号内成员userid,再调用【企业号userid转openid接口】进行转换 + /// + public string openid { get; set; } + + public int CardTypeId { get; set; } + + /// + /// 系统生成订单号 + /// + public string OrderId { get; set; } + + public int StudentId { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/PlanDetailQuery.cs b/New_College.Model/ViewModels/Query/PlanDetailQuery.cs new file mode 100644 index 0000000..bdc4d30 --- /dev/null +++ b/New_College.Model/ViewModels/Query/PlanDetailQuery.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class PlanDetailQuery : BasePageRequest + { + ///// + ///// + ///// + //public float Score { get; set; } + + ///// + ///// 院校Id + ///// + //public int UniversityId { get; set; } + + /// + /// 招生计划Ids + /// + public List PlanIds { get; set; } + } + + public class CWBUniversityDetailQuery : BasePageRequest + { + public string Type { get; set; } + + public List UniversityIds { get; set; } + + public int BatchId { get; set; } + + /// + /// 高考年份 + /// + public int Year { get; set; } + + /// + /// 专业Ids + /// + public List MajorIds { get; set; } + + /// + /// + /// + public float Score { get; set; } + + /// + /// 省份Id + /// + public int AreaId { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/PlanQuery.cs b/New_College.Model/ViewModels/Query/PlanQuery.cs new file mode 100644 index 0000000..d1d25b3 --- /dev/null +++ b/New_College.Model/ViewModels/Query/PlanQuery.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class PlanQuery + { + public int UnviersityId { get; set; } + + public int Year { get; set; } + + public string Type { get; set; } + + public string BatchName { get; set; } + + public string AreaName { get; set; } + } + + public class PlanYearQuery + { + public int UnviersityId { get; set; } + + public string AreaName { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/ProbabilityQuery.cs b/New_College.Model/ViewModels/Query/ProbabilityQuery.cs new file mode 100644 index 0000000..63136ed --- /dev/null +++ b/New_College.Model/ViewModels/Query/ProbabilityQuery.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class ProbabilityQuery:BasePageRequest + { + public int CustomerId { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/PsychMeasurementQuery.cs b/New_College.Model/ViewModels/Query/PsychMeasurementQuery.cs new file mode 100644 index 0000000..ac5b514 --- /dev/null +++ b/New_College.Model/ViewModels/Query/PsychMeasurementQuery.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class PsychMeasurementQuery + { + public int CategoryId { get; set; } + + public int StudentId { get; set; } + } + + + + public class SaveHollandQuery + { + public int CategoryId { get; set; } + + public int StudentId { get; set; } + + public int CycleTimeId { get; set; } + + public string Tags { get; set; } + } + + /// + /// 生涯能力提交 + /// + public class SavePsychQuery + { + public int Type { get; set; } + + public int CategoryId { get; set; } + + public int StudentId { get; set; } + + public int CycleTimeId { get; set; } + + //public string ClassName { get; set; } + + //public string GradeName { get; set; } + + ///// + ///// 生涯能力传入 + ///// + //public List CareerResult { get; set; } + + /// + /// 学科探索传入 + /// + public List Result { get; set; } + /// + /// 学生发展 + /// + public List second { get; set; } + } + /// + /// 学科探索query + /// + public class SubjectSelectJson + { + public string name { get; set; } + + public List value { get; set; } + } + + /// + /// 生涯能力json + /// + public class EvalJson + { + public int Id { get; set; } + + public int Value { get; set; } + + public int CycleId { get; set; } + } + /// + /// 学生发展 + /// + public class SecondModels + { + public int Id { get; set; } + + public int Status { get; set; } + + public string Tag { get; set; } + + } + + + + public class ResultLookQuery + { + public int StudentId { get; set; } + + public int CategoryId { get; set; } + + /// + /// 霍兰德如果不传周期Id的话就获取最新的 + /// + public int CycleTimeId { get; set; } + } + +} diff --git a/New_College.Model/ViewModels/Query/RecommendUniversityQuery.cs b/New_College.Model/ViewModels/Query/RecommendUniversityQuery.cs new file mode 100644 index 0000000..376d680 --- /dev/null +++ b/New_College.Model/ViewModels/Query/RecommendUniversityQuery.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class RecommendUniversityQuery : BasePageRequest + { + public int CustomerId { get; set; } + + public float Score { get; set; } + + /// + /// 学科层次 + /// + public int SubjectLevel { get; set; } + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + /// + /// 办学性质 + /// + public int Nature { get; set; } + + /// + /// 学校类型 + /// + public int Type { get; set; } = -1; + + /// + /// 是否985 0、否,1、是 + /// + public int Nhef { get; set; } + + /// + /// 是否211 0、否,1、是 + /// + public int Sff { get; set; } + + /// + /// 是否双一流 0、否,1、是 + /// + public int Syl { get; set; } + } + + /// + /// 录取概率传入 + /// + public class UniversityProbabilityQuery + { + /// + /// 用户Id + /// + public int CustomerId { get; set; } + + /// + /// 分数 + /// + public float Score { get; set; } + + /// + /// 院校Id + /// + public int UniversityId { get; set; } + + /// + /// 省份名称 + /// + public string AreaName { get; set; } + + /// + /// 省份Id + /// + public int AreaId { get; set; } + + /// + /// 年份 + /// + public int Year { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/SubjectSelectQuery.cs b/New_College.Model/ViewModels/Query/SubjectSelectQuery.cs new file mode 100644 index 0000000..e07dd36 --- /dev/null +++ b/New_College.Model/ViewModels/Query/SubjectSelectQuery.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class SubjectSelectQuery + { + /// + /// 用户Id + /// + public int CustomerId { get; set; } + + /// + /// 逗号隔开 + /// + public string SubjectSelect { get; set; } + + /// + /// 第三部传1 第五步选择传2 + /// + public int Status { get; set; } + } + + public class ByTagSubjectSelectQuery + { + public string Tag { get; set; } + + public int Year { get; set; } + + public int AreaId { get; set; } + } + + public class HollandSubjectQuery + { + /// + /// 年份 + /// + public int Year { get; set; } + + /// + /// 省份Id + /// + public int AreaId { get; set; } + + /// + /// 标签 + /// + public string Tag { get; set; } + } + + public class NewSubjectQuery + { + /// + /// 用户Id + /// + public int CustomerId { get; set; } + + /// + /// 第四步选的专业名称 + /// + public string MajorName { get; set; } + + /// + /// 第四步选科 + /// + public string Claim { get; set; } + + /// + /// 年份 + /// + public int Year { get; set; } + + /// + /// 省份Id + /// + public int AreaId { get; set; } + + /// + /// 标签 + /// + public string Tag { get; set; } + } + + public class YearAreaQuery + { + /// + /// 年份 + /// + public int Year { get; set; } + + /// + /// 省份Id + /// + public int AreaId { get; set; } + + /// + /// 省份名称 + /// + public string AreaName { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/SysRegionQuery.cs b/New_College.Model/ViewModels/Query/SysRegionQuery.cs new file mode 100644 index 0000000..b5c1f52 --- /dev/null +++ b/New_College.Model/ViewModels/Query/SysRegionQuery.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class SysRegionQuery + { + /// + /// 传0位获取省 传其他Code为获取下级数据 + /// + public string Code { get; set; } = "0"; + } +} diff --git a/New_College.Model/ViewModels/Query/TagEnrollmentPlaneQuery.cs b/New_College.Model/ViewModels/Query/TagEnrollmentPlaneQuery.cs new file mode 100644 index 0000000..5ffbf30 --- /dev/null +++ b/New_College.Model/ViewModels/Query/TagEnrollmentPlaneQuery.cs @@ -0,0 +1,178 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class TagEnrollmentPlaneQuery + { + /// + /// 检索省份 + /// + public string SearchAreaName { get; set; } + /// + /// 科目 物化生政史地 传的话都好隔开 中文逗号 + /// + public string SubjectClaim { get; set; } + + /// + /// 高考年份 + /// + public int Year { get; set; } + ///// + ///// 学科层次 1、本科,2、专科 + ///// + //public int SubjectLevel { get; set; } + /// + /// 学生预估分数 + /// + public float Score { get; set; } + ///// + ///// CustomerId + ///// + //public int CustomerId { get; set; } + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + /// + /// 省份Id + /// + public int AreaId { get; set; } + /// + /// 霍兰德标签 + /// + public string Tag { get; set; } + ///// + ///// 办学性质 + ///// + //public int Nature { get; set; } + + ///// + ///// 学校类型:大学类型 0综合,1理工类,2医学类... + ///// + //public int Type { get; set; } + + /// + /// 1专业到学校 2学校到专业 + /// + public int SearchType { get; set; } + + /// + /// 批次Id + /// + public int BatchId { get; set; } + } + + /// + /// 懒人模式Query + /// + public class LazyEnrollmentPlaneQuery + { + //地区 学科 成绩 办学性质 高校级别 + /// + /// 高考年份 + /// + public int Year { get; set; } + + /// + /// 学生预估分数 + /// + public float Score { get; set; } + + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + /// + /// 省份Id + /// + public int AreaId { get; set; } + + /// + /// 办学性质1、公立,2、私立 + /// + public List Nature { get; set; } + + /// + /// 省份 名称 + /// + public List AreaNames { get; set; } + + ///// + ///// 高校级别 985传1 211传2 双一流传3 其他传0或者不传 + ///// + //public List SchoolLevel { get; set; } + + /// + /// 专业Ids最多三个 + /// + public List MajorIds { get; set; } + } + + /// + /// 冲稳保Query + /// + public class CWBEnrollmentPlaneQuery : BasePageRequest + { + /// + /// 高考年份 + /// + public int Year { get; set; } + + /// + /// 批次Id + /// + public int BatchId { get; set; } + + /// + /// 学生预估分数 + /// + public float Score { get; set; } + + /// + /// 学校省份 + /// + //public string UniversityAreaName { get; set; } + public List UniversityAreaName { get; set; } + + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + + /// + /// 省份Id + /// + public int AreaId { get; set; } + + /// + /// 办学性质1、公立,2、私立 + /// + //public int Nature { get; set; } + public List Nature { get; set; } + + /// + /// 高校级别 985传1 211传2 双一流传3 其他传0或者不传 + /// + public List SchoolLevel { get; set; } + + /// + /// 专业Ids + /// + public List MajorIds { get; set; } + } + + /// + /// dto query + /// + public class DTOByTagQuery + { + public decimal OnMaxScore { get; set; } + public decimal OnMinScore { get; set; } + public decimal MaxScore { get; set; } + public decimal MinScore { get; set; } + public decimal DownMaxScore { get; set; } + public decimal DownMinScore { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/TestQuery.cs b/New_College.Model/ViewModels/Query/TestQuery.cs new file mode 100644 index 0000000..c44ca9b --- /dev/null +++ b/New_College.Model/ViewModels/Query/TestQuery.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class TestQuery + { + + } + + public class IntellectJson + { + public string name { get; set; } + + public int value { get; set; } + + } +} diff --git a/New_College.Model/ViewModels/Query/UniOrderQuery.cs b/New_College.Model/ViewModels/Query/UniOrderQuery.cs new file mode 100644 index 0000000..bc00175 --- /dev/null +++ b/New_College.Model/ViewModels/Query/UniOrderQuery.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class UnifiedOrderQuery + { + public int CardTypeId { get; set; } + + public decimal total_fee { get; set; } + + public string Phone { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/UniversityCollectionQuery.cs b/New_College.Model/ViewModels/Query/UniversityCollectionQuery.cs new file mode 100644 index 0000000..aebae3d --- /dev/null +++ b/New_College.Model/ViewModels/Query/UniversityCollectionQuery.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class UniversityCollectionQuery : BasePageRequest + { + /// + /// 用户Id + /// + public int CustomerId { get; set; } + + /// + /// 1收藏 2对比 + /// + public int Type { get; set; } + } + + /// + /// 添加Query + /// + public class UniversityCollectionAddQuery + { + /// + /// 用户Id + /// + public int CustomerId { get; set; } + + /// + /// 1收藏 2对比 + /// + public int Type { get; set; } + + /// + /// 院校Id + /// + public int UniversityId { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/UniversityQuery.cs b/New_College.Model/ViewModels/Query/UniversityQuery.cs new file mode 100644 index 0000000..038e771 --- /dev/null +++ b/New_College.Model/ViewModels/Query/UniversityQuery.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class UniversityQuery : BasePageRequest + { + + + public string Name { get; set; } + /// + /// 学科层次 + /// + public int SubjectLevel { get; set; } + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + /// + /// 办学性质 + /// + public int Nature { get; set; } + /// + /// 用户id + /// + public int CustomerId { get; set; } + + /// + /// 学校类型 + /// + public int Type { get; set; } = -1; + + /// + /// 是否985 0、否,1、是 + /// + public int Nhef { get; set; } = -1; + + /// + /// 是否211 0、否,1、是 + /// + public int Sff { get; set; } = -1; + + /// + /// 是否双一流 0、否,1、是 + /// + public int Syl { get; set; } = -1; + } + + public class UniversityRankQuery + { + /// + /// 院校类型 (0,校友会 1,武书连 2,软科 3,QS 4,U.S.News) + /// + public int Type { get; set; } + } + + public class UniversityIdQuery : BasePageRequest + { + public int Id { get; set; } + } + + public class StringIdQuery + { + public string Id { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/VipCardInfoQuery.cs b/New_College.Model/ViewModels/Query/VipCardInfoQuery.cs new file mode 100644 index 0000000..bf7d048 --- /dev/null +++ b/New_College.Model/ViewModels/Query/VipCardInfoQuery.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels.Query +{ + public class VipCardInfoQuery: BasePageRequest + { + /// + /// 编号id + /// + public int Id { get; set; } + + /// + /// 账号 key + /// + public string Code { get; set; } + + + /// + /// vip 卡类别id + /// + public int CardTypeId { get; set; } + + + + + + } + public class VipCardInfoSearchQuery : BasePageRequest + { + /// + /// 编号id + /// + public int Id { get; set; } + + /// + /// 账号 key + /// + public string Code { get; set; } + + /// + /// 卡片类别 + /// + public string CardTypeId { get; set; } + + + /// + /// 是否绑定 + /// + public string IsBind { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/VipCardQuery.cs b/New_College.Model/ViewModels/Query/VipCardQuery.cs new file mode 100644 index 0000000..8e8ca98 --- /dev/null +++ b/New_College.Model/ViewModels/Query/VipCardQuery.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class VipCardQuery: BasePageRequest + { + public int CustomerId { get; set; } + + public string CardCode { get; set; } + } + + public class AutoVipInfoQuery + { + /// + /// vip卡类型id + /// + public int VipCardTypeId { get; set; } + + /// + /// 头部 + /// + public string Head { get; set; } + + /// + /// 长度 + /// + public int Length { get; set; } + + /// + /// 数量 + /// + public int Num { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/VipCardTypeQuery.cs b/New_College.Model/ViewModels/Query/VipCardTypeQuery.cs new file mode 100644 index 0000000..a65b20d --- /dev/null +++ b/New_College.Model/ViewModels/Query/VipCardTypeQuery.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels.Query +{ + public class VipCardTypeQuery:BasePageRequest + { + public int Id { get; set; } + + /// + /// 卡类型名称 + /// + public string Name { get; set; } + + /// + /// 金额 + /// + public decimal Money { get; set; } + + public string Desc { get; set; } + + /// + /// 天数 + /// + public int Day { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/VolunteerTableQuery.cs b/New_College.Model/ViewModels/Query/VolunteerTableQuery.cs new file mode 100644 index 0000000..e889e1f --- /dev/null +++ b/New_College.Model/ViewModels/Query/VolunteerTableQuery.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class VolunteerTableQuery + { + public int CustomerId { get; set; } + + public List details { get; set; } + } + + public class VolunteerDetail + { + public int UniversityId { get; set; } + + public string UniversityName { get; set; } + + public List PlanMagorIds { get; set; } + } + + public class HollandVolunteerTableQuery + { + /// + /// 用户Id + /// + public int CustomerId { get; set; } + + /// + /// 省份Id + /// + public int AreaId { get; set; } + + /// + /// 省份Name + /// + public string AreaName { get; set; } + + /// + /// 年份 + /// + public int Year { get; set; } + + /// + /// 分数 + /// + public float Score { set; get; } + + /// + /// 霍兰德推荐专业学校信息 + /// + public List infos { get; set; } + } + + /// + /// 霍兰德推荐专业学校信息 + /// + public class HollandPlanInfo + { + /// + /// 计划名称 + /// + public string MajorName { get; set; } + + /// + /// 院校信息 + /// + public List universitys { get; set; } + } + + /// + /// 院校信息 + /// + public class UniversityS + { + /// + /// 院校Id + /// + public int UniversityId { get; set; } + + /// + /// 院校名称 + /// + public string UniversityName { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/WeChatPayQuery.cs b/New_College.Model/ViewModels/Query/WeChatPayQuery.cs new file mode 100644 index 0000000..7747ed8 --- /dev/null +++ b/New_College.Model/ViewModels/Query/WeChatPayQuery.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public static class PayInfoQuery + { + /// + /// 创建者Ip + /// + public static string CreateIp { get; set; } + + /// + /// 后端域名 + /// + public static string ApiUrl { get; set; } + } + + public class WeChatPayQuery + { + /// + /// 用户Id + /// + public int CustomerId { get; set; } + + /// + /// 卡类型Id + /// + public int CardTypeId { get; set; } + + /// + /// 金额 + /// + public decimal Money { get; set; } + } + + public class ViewModelQuery + { + /// + /// 回调地址 + /// + public string NotifyUrl { get; set; } + + public string TradeType { get; set; } = "JSAPI"; + + /// + /// 订单号 + /// + public string OutTradeNo { get; set; } + + /// + /// 金额 + /// + public decimal TotalFee { get; set; } + + /// + /// 后端IP + /// + public string SpBillCreateIp { get; set; } + + /// + /// 项目编号 + /// + public string Body { get; set; } = "壹志愿VIP"; + } + + + + public class UniQuery + { + public int CustomerId { get; set; } + + public string out_trade_no { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Query/appQuestionQuery.cs b/New_College.Model/ViewModels/Query/appQuestionQuery.cs new file mode 100644 index 0000000..a36b1af --- /dev/null +++ b/New_College.Model/ViewModels/Query/appQuestionQuery.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class appQuestionQuery + { + public int CategoryId { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/AliPayOrderResponse.cs b/New_College.Model/ViewModels/Result/AliPayOrderResponse.cs new file mode 100644 index 0000000..3dfa1d6 --- /dev/null +++ b/New_College.Model/ViewModels/Result/AliPayOrderResponse.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class AliPayOrderResponse + { + /// + /// 通知时间 + /// + public string notify_time { get; set; } + /// + /// 通知的类型 + /// + public string notify_type { get; set; } + /// + /// 通知校验ID + /// + public string notify_id { get; set; } + /// + /// 开发者的app_id + /// + public string app_id { get; set; } + /// + /// 编码格式 + /// + public string charset { get; set; } + /// + /// 接口版本 + /// + public string version { get; set; } + /// + /// 签名类型 + /// + public string sign_type { get; set; } + /// + /// 签名 + /// + public string sign { get; set; } + /// + /// 支付宝交易号 + /// + public string trade_no { get; set; } + /// + /// 商户订单号 + /// + public string out_trade_no { get; set; } + + + + /// + /// 商户业务号 + /// + public string out_biz_no { get; set; } + /// + /// 买家支付宝用户号 + /// + public string buyer_id { get; set; } + /// + /// 买家支付宝账号 + /// + public string buyer_logon_id { get; set; } + /// + /// 卖家支付宝用户号 + /// + public string seller_id { get; set; } + /// + /// 卖家支付宝账号 + /// + public string seller_email { get; set; } + /// + /// 交易状态 + /// + public string trade_status { get; set; } + /// + /// 订单金额 + /// + public decimal total_amount { get; set; } + /// + /// 实收金额 + /// + public decimal receipt_amount { get; set; } + /// + /// 付款金额 + /// + public decimal buyer_pay_amount { get; set; } + /// + /// 标题 + /// + public string subject { get; set; } + /// + /// 描述 + /// + public string body { get; set; } + /// + /// 交易创建时间 + /// + public string gmt_create { get; set; } + /// + /// 交易付款时间 + /// + public string gmt_payment { get; set; } + + /// + /// 交易结束时间 + /// + public string gmt_close { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/AliPayResult.cs b/New_College.Model/ViewModels/Result/AliPayResult.cs new file mode 100644 index 0000000..9bbae72 --- /dev/null +++ b/New_College.Model/ViewModels/Result/AliPayResult.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class AliOrderResult + { + public string Body { get; set; } + + public int CustomerId { get; set; } + + public string PayType { get; set; } + + public bool Success { get; set; } + + public string out_trade_no { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/CategoryInfoResult.cs b/New_College.Model/ViewModels/Result/CategoryInfoResult.cs new file mode 100644 index 0000000..c2ab1e9 --- /dev/null +++ b/New_College.Model/ViewModels/Result/CategoryInfoResult.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class CategoryInfoResult + { + public int Id { get; set; } + + public string Name { get; set; } + public string Desc { get; set; } + public string Detail { get; set; } + + public int JoinCount { get; set; } + } + + public class CategoryStatusResult + { + /// + /// 测试次数 + /// + public int TestNum { get; set; } = 0; + + /// + /// 周期Id + /// + public int CycleTimeId { get; set; } = 0; + + /// + /// 上次测试时间 + /// + public DateTime? TopTime { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/CreateOrderModel.cs b/New_College.Model/ViewModels/Result/CreateOrderModel.cs new file mode 100644 index 0000000..97da301 --- /dev/null +++ b/New_College.Model/ViewModels/Result/CreateOrderModel.cs @@ -0,0 +1,29 @@ +using New_College.Common; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class CreateOrderModel : BaseResponse + { + /// + /// 订单ID + /// + public string OrderId { get; set; } + + /// + /// 交易号 + /// + public string PayNo { get; set; } + /// + /// 订单状态 + /// + public EnumOrderType Status { get; set; } + + /// + /// 创建时间 + /// + public string CreateTime { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/CustomerInfoResult.cs b/New_College.Model/ViewModels/Result/CustomerInfoResult.cs new file mode 100644 index 0000000..b797c14 --- /dev/null +++ b/New_College.Model/ViewModels/Result/CustomerInfoResult.cs @@ -0,0 +1,151 @@ +using New_College.Common; +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class CustomerInfoResult + { + public string Token { get; set; } + /// + /// 返回状态1成功 2验证码错误 3失败 + /// + public int Status { get; set; } + + public int Id { get; set; } + + /// + /// 小程序openid + /// + public string OpenId { get; set; } + + /// + /// 用户头像 + /// + public string AvatarUrl { get; set; } + + /// + /// 用户名 + /// + public string NickName { get; set; } + + /// + /// 性别 1男 2女 + /// + public int Gender { get; set; } + + /// + /// 省市区id + /// + public int AreaId { get; set; } = 0; + + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + + /// + ///学生数据是否初始化(省份,选科等) + /// + public bool? Datainit { get; set; } = false; + + /// + /// 0(新高考),1(文科,理科) + /// + public int? Subject { get; set; } = 0; + + /// + /// 选科文字展示 + /// + public string Subjectgroup { get; set; } + + /// + /// 考生预计分数 + /// + public double? Expectedscore { get; set; } = 0; + + /// + /// 是否为VIP + /// + public bool IsVIP { get; set; } = false; + + public string VipCode { get; set; } + + + public string Phone { get; set; } + + public int IsUpdateScore { get; set; } + + public CustomerTypeEnum CustomerType { get; set; } + + /// + /// 学届 + /// + public int Year { get; set; } + + public string SchoolName { get; set; } + + public string ClassName { get; set; } + } + public class CustomerInfoListResult : BasePageRequest + { + /// + /// 编号id + /// + public int Id { get; set; } + + /// + /// 用户名 + /// + public string NickName { get; set; } + + /// + /// 电话 + /// + public string Phone { get; set; } + + /// + /// 住址 + /// + public string AreaName { get; set; } + + /// + /// Vip账号 + /// + public string VipCode { get; set; } + + /// + /// 0(新高考),1(文科,理科) + /// + public int? Subject { get; set; } = 0; + + /// + /// 选科文字展示 + /// + public string Subjectgroup { get; set; } + + /// + /// 考生预计分数 + /// + public double? Expectedscore { get; set; } = 0; + } + + public class CustomerSeachQuery : BasePageRequest + { + /// + /// 根据用户名查询 + /// + public string VipCode { get; set; } + + /// + /// 根据选科查询 + /// + public int Subject { get; set; } = 2; + + /// + /// 根据电话查询 + /// + public string Phone { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/CycleInfoResult.cs b/New_College.Model/ViewModels/Result/CycleInfoResult.cs new file mode 100644 index 0000000..28a157e --- /dev/null +++ b/New_College.Model/ViewModels/Result/CycleInfoResult.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class CycleInfoResult + { + public int nengliCycleId { get; set; } = 0; + public int duoweiCycleId { get; set; } = 0; + public int jiaolvCycleId { get; set; } = 0; + public int jinengCycleId { get; set; } = 0; + public int fenggeCycleId { get; set; } = 0; + } +} diff --git a/New_College.Model/ViewModels/Result/EnrollmentinproductionResult.cs b/New_College.Model/ViewModels/Result/EnrollmentinproductionResult.cs new file mode 100644 index 0000000..1aadfd6 --- /dev/null +++ b/New_College.Model/ViewModels/Result/EnrollmentinproductionResult.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class RequestEnrollmentinproductionResult + { + /// + /// 主键 + /// + public string Id { get; set; } + /// + /// 招生标题 + /// + public string Title { get; set; } + } + + public class RequestBaseResponse + { + public string Code { get; set; } = "0"; + + public string Msg { get; set; } + public bool Success { get; set; } = true; + + public List Data { get; set; } + } + + public class RequestQuery : BasePageRequest + { + public string Id { get; set; } + } + + public class RequestEnrollmentinproductionDetailResult + { + /// + /// 主键 + /// + public string Id { get; set; } + /// + /// 招生标题 + /// + public string Title { get; set; } + /// + /// 发布时间 + /// + public string Pushdate { get; set; } + /// + /// 文章内容 + /// + public string Content { get; set; } + } + + public class RequestDetailBaseResponse + { + public string Code { get; set; } = "0"; + + public string Msg { get; set; } + public bool Success { get; set; } = true; + + public RequestEnrollmentinproductionDetailResult Data { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/ExaminationPolicyResult.cs b/New_College.Model/ViewModels/Result/ExaminationPolicyResult.cs new file mode 100644 index 0000000..95d775f --- /dev/null +++ b/New_College.Model/ViewModels/Result/ExaminationPolicyResult.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class ExaminationPolicyResult + { + public int Id { get; set; } + + /// + /// 省份名称 + /// + public string AreaName { get; set; } + + /// + /// 标题 + /// + public string Title { get; set; } + + /// + /// 修改时间 + /// + public DateTime? ModifyTime { get; set; } + } + + public class ExaminationPolicyOneResult + { + public int Id { get; set; } + + /// + /// 省份id + /// + public int AreaId { get; set; } + + /// + /// 标题 + /// + public string Title { get; set; } + + /// + /// 图片 + /// + public string Img { get; set; } + + /// + /// 政策内容 + /// + public string Content { get; set; } + } + + /// + /// + /// + public class ExaminationPolicyOneDetail + { + public int Id { get; set; } + + /// + /// 标题 + /// + public string Title { get; set; } + + /// + /// 图片 + /// + public string Img { get; set; } + + /// + /// 政策内容 + /// + public string Content { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/MBTICalcModel.cs b/New_College.Model/ViewModels/Result/MBTICalcModel.cs new file mode 100644 index 0000000..ccb375a --- /dev/null +++ b/New_College.Model/ViewModels/Result/MBTICalcModel.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class MBTICalcModel + { + public int E { get; set; } + public int I { get; set; } + public int S { get; set; } + public int N { get; set; } + public int T { get; set; } + public int F { get; set; } + public int J { get; set; } + public int P { get; set; } + } + + + public class HollandModel + { + public int R { get; set; } + public int I { get; set; } + public int A { get; set; } + public int S { get; set; } + public int E { get; set; } + public int C { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/MajorPlanResult.cs b/New_College.Model/ViewModels/Result/MajorPlanResult.cs new file mode 100644 index 0000000..325bfab --- /dev/null +++ b/New_College.Model/ViewModels/Result/MajorPlanResult.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class MajorPlanResult + { + /// + /// 大类名称 + /// + public string Name { get; set; } + + /// + /// 专业科目信息 + /// + public List Majors { get; set; } + + } + + /// + /// 专业科目信息 + /// + public class MajorClaim + { + /// + /// 专业名称 + /// + public string MajorName { get; set; } + + /// + /// 科目要求 + /// + public string Claim { get; set; } + } + +} diff --git a/New_College.Model/ViewModels/Result/MajorResult.cs b/New_College.Model/ViewModels/Result/MajorResult.cs new file mode 100644 index 0000000..e4d6a70 --- /dev/null +++ b/New_College.Model/ViewModels/Result/MajorResult.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + /// + /// 专业介绍 + /// + public class MajorDetail + { + public string Name { get; set; } + public int id { get; set; } + /// + /// 专业简介 + /// + public string abstracts { get; set; } + /// + /// 主要课程 + /// + public string maincourse { get; set; } + /// + /// 考研方向 + /// + public string studydirection { get; set; } + /// + /// 就业方向 + /// + public string workdirection { get; set; } + } + + public class MajorSchool + { + /// + /// 专业ID + /// + public string majorid { get; set; } + /// + /// 学校ID + /// + public string id { get; set; } + /// + /// 学校名称 + /// + public string name { get; set; } + /// + /// 学校类型/公立/私立 + /// + public string type { get; set; } + /// + /// 985/211 + /// + public string nhefSff { get; set; } + + + //学校性质 + public string nature { get; set; } + //性质 详细 + public string naturedetail { get; set; } + //所属地区 + public string address { get; set; } + //学校图标 + public string logo { get; set; } + /// + /// 双一流 + /// + public string syl { get; set; } + } + + /// + /// 就业前景 + /// + public class CareerProspects + { + /// + /// 职业分布 + /// + public List JobDistribute { get; set; } + /// + /// 行业分布 + /// + public List TradeDistribute { get; set; } + /// + /// 地区分布 + /// + public List RegionDistribute { get; set; } + /// + /// 工资分布 + /// + public List MoneyDistribute { get; set; } + public WorkingYear WorkingYear { get; set; } + } + + public class WorkingYear + { + public string WorkingYears { get; set; } + public string WorkingYearsWage { get; set; } + } + + public class distribution + { + /// + /// 名称 + /// + public string name { get; set; } + /// + /// 分布比例 + /// + public double data { get; set; } + /// + /// 备注 + /// + public string detail { get; set; } + } + + public class uniMajorInfo + { + public int Id { get; set; } + public string Name { get; set; } + //public string Detail { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/MajorSalaryResult.cs b/New_College.Model/ViewModels/Result/MajorSalaryResult.cs new file mode 100644 index 0000000..3c49904 --- /dev/null +++ b/New_College.Model/ViewModels/Result/MajorSalaryResult.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class MajorSalaryResult + { + public int MajorId { get; set; } + + /// + /// 专业名称 + /// + public string MajorName { get; set; } + + /// + /// 薪资 + /// + public float Money { get; set; } + + /// + /// 上级名称 + /// + public string ParentName { get; set; } + + /// + /// 本科还是专科 + /// + public string Type { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/OccupationResult.cs b/New_College.Model/ViewModels/Result/OccupationResult.cs new file mode 100644 index 0000000..fe47e7f --- /dev/null +++ b/New_College.Model/ViewModels/Result/OccupationResult.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class OccupationResult + { + /// + /// 主键id + /// + public int Id { get; set; } + /// + /// 职业名称 + /// + public string Name { get; set; } + } + + public class uniOccSelect + { + public int ParentId { get; set; } + public int Level { get; set; } + public int Id { get; set; } + public string Name { get; set; } + public string OccupationName { get; set; } + } + + /// + /// 职业 + /// + public class OccupationDetailResult + { + public int Status { get; set; } + /// + /// 主键id + /// + public string Id { get; set; } + /// + /// 职业名称 + /// + public string Name { get; set; } + /// + /// 排序 + /// + public int Sort { get; set; } + /// + /// 职业介绍 + /// + public string OccupationIntraduce { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/OrderResult.cs b/New_College.Model/ViewModels/Result/OrderResult.cs new file mode 100644 index 0000000..49434e0 --- /dev/null +++ b/New_College.Model/ViewModels/Result/OrderResult.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class OrderResult + { + public string OrderId { get; set; } + + public string EndTime { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/ProbabilityResult.cs b/New_College.Model/ViewModels/Result/ProbabilityResult.cs new file mode 100644 index 0000000..c5c9ac4 --- /dev/null +++ b/New_College.Model/ViewModels/Result/ProbabilityResult.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class ProbabilityResult + { + public int Id { get; set; } + + /// + /// 院校名称 + /// + public string UniversityName { get; set; } + + /// + /// 院校Id + /// + public int UniversityId { get; set; } + + /// + /// 概率 + /// + public int Probability { get; set; } + + /// + /// 预估分数 + /// + public float EstimateScore { get; set; } + + /// + /// 年份 + /// + public int Year { get; set; } + + /// + /// 省份Id + /// + public int AreaId { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/PsychMeasurementListResult.cs b/New_College.Model/ViewModels/Result/PsychMeasurementListResult.cs new file mode 100644 index 0000000..fb4d89a --- /dev/null +++ b/New_College.Model/ViewModels/Result/PsychMeasurementListResult.cs @@ -0,0 +1,195 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class PsychMeasurementListResult + { + /// + /// Id + /// + public int Id { get; set; } + + /// + /// 周期Id + /// + public int CycleTimeId { get; set; } + + /// + /// 周期名称 + /// + public string CycleName { get; set; } + + /// + /// 测评时间 + /// + public DateTime? CreateTime { get; set; } + + public int IsOpen { get; set; } + } + + + /// + /// 生涯能力反回结果 + /// + public class CareerResult + { + /// + /// 能力评估 + /// + public string TopicEval { get; set; } + + /// + /// 变化反馈 + /// + public string TopicGrow { get; set; } + + /// + /// 分数 + /// + public List Score { get; set; } + + public List List { get; set; } + } + + /// + /// namevalue + /// + public class NameValue + { + public string Name { get; set; } + + public int Value { get; set; } + } + + + public class ShowPsychologicalResult + { + public string Name { get; set; } + public List BillDatas { get; set; } + public List Billcators { get; set; } + public List Result { get; set; } + public List List { get; set; } + } + + public class PsyTagDetail + { + public string Name { get; set; } + + public string Title { get; set; } + + public string Content { get; set; } + + public int Score { get; set; } + + public int MaxScore { get; set; } + + public string Suggess { get; set; } + } + + public class EvBillDTO + { + public string Name { get; set; } + public List BillDatas { get; set; } + public List Billcators { get; set; } + } + + public class EvBillcator + { + public string text { get; set; } + public int max { get; set; } + } + + public class SubjectEvBillDTO + { + /// + /// 推荐选科 + /// + public string Name { get; set; } + + /// + /// 学科兴趣 + /// + public EvBillDTO subjectinterest { get; set; } + + /// + /// 学科能力 + /// + public EvBillDTO subjectability { get; set; } + } + + + + + /// + /// + /// + public class TagtestingHollandResult + { + public Radar radar { get; set; } + + public string TagName { get; set; } + } + + + public class Radar + { + public List categories { get; set; } + public List series { get; set; } + } + + public class serie + { + public string name { get; set; } + public List data { get; set; } + } + + + /// + /// 测评结果 + /// + public class UserResult + { + + /// + /// 标签 + /// + public string Tag { get; set; } + + /// + /// 适合的领域 + /// + public string Domain { get; set; } + + /// + /// 性格特征解读 + /// + public string Interpretation { get; set; } + + /// + /// 优势 + /// + public string Advantage { get; set; } + + /// + /// 劣势 + /// + public string Disadvantage { get; set; } + + /// + /// 偏好的活动特质 + /// + public string Feature { get; set; } + + /// + /// 可能存在的盲点 + /// + public string BlindSpot { get; set; } + + /// + /// 建议 + /// + public string Recommend { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/SubjectSelectResult.cs b/New_College.Model/ViewModels/Result/SubjectSelectResult.cs new file mode 100644 index 0000000..ce0e3e5 --- /dev/null +++ b/New_College.Model/ViewModels/Result/SubjectSelectResult.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class SubjectSelectResult + { + /// + /// 推荐选科 + /// + public string Select { get; set; } + + /// + /// 霍兰德 + /// + public float HollResult { get; set; } + + /// + /// 学科探索 + /// + public float SubjectResult { get; set; } + + /// + /// 自选结果 + /// + public float OptionalResult { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/SysRegionResult.cs b/New_College.Model/ViewModels/Result/SysRegionResult.cs new file mode 100644 index 0000000..3a443e5 --- /dev/null +++ b/New_College.Model/ViewModels/Result/SysRegionResult.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class SysRegionResult + { + public int Id { get; set; } + + public string Code { get; set; } + + public string Name { get; set; } + } + + public class SysRegionView + { + public int KeyId { get; set; } + + public int ParentCode { get; set; } + + public int Level { get; set; } + + public string RegionCode { get; set; } + + public string RegionName { get; set; } + + //public bool selected { get; set; } = false; + + } +} diff --git a/New_College.Model/ViewModels/Result/UniversityCollectionResult.cs b/New_College.Model/ViewModels/Result/UniversityCollectionResult.cs new file mode 100644 index 0000000..b328f33 --- /dev/null +++ b/New_College.Model/ViewModels/Result/UniversityCollectionResult.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class UniversityCollectionResult + { + public int Id { get; set; } + + /// + /// 院校Id + /// + public int UniversityId { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + + /// + /// 是否985 + /// + public bool? Nhef { get; set; } + /// + /// 是否211 + /// + public bool? Sff { get; set; } + /// + /// 是否双一流 + /// + public bool? Syl { get; set; } + /// + /// 学校logo + /// + public string Logo { get; set; } + + /// + /// 是否加入对比 0就是没有 + /// + public bool IsContrast { get; set; } + + /// + /// 是否收藏 + /// + public bool IsCollection { get; set; } + } + + + public class UniversitycontrastResult + { + public int Id { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + /// + /// 排名 + /// + public int? Rank { get; set; } + /// + /// 是否985 + /// + public string Nhef { get; set; } + /// + /// 是否211 + /// + public string Sff { get; set; } + /// + /// 是否双一流 + /// + public string Syl { get; set; } + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + /// + /// 办学性质 + /// + public string Nature { get; set; } + /// + /// 隶属于 + /// + public string AscriptionName { get; set; } + /// + /// 学科层次 + /// + public string SubjectLevel { get; set; } + /// + /// 学校类型 + /// + public string UniversityType { get; set; } + /// + /// 创办时间 + /// + public string BuildDate { get; set; } + /// + /// 院士数 + /// + public string AcademicianCount { get; set; } + /// + /// 博士数 + /// + public string DoctorateCount { get; set; } + /// + /// 硕士数 + /// + public string MasterCount { get; set; } + + public string MajorNum { get; set; } + } + + + public class UniversityCollectionByMapResult + { + + public double Lng { get; set; } + + public double Lat { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/UniversityResult.cs b/New_College.Model/ViewModels/Result/UniversityResult.cs new file mode 100644 index 0000000..468233a --- /dev/null +++ b/New_College.Model/ViewModels/Result/UniversityResult.cs @@ -0,0 +1,278 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class UniversityResult + { + /// + /// 主键id + /// + public int Id { get; set; } + /// + /// 名称 + /// + public string Name { get; set; } + /// + /// 排名 + /// + public int? Rank { get; set; } + /// + /// 是否985 + /// + public bool? Nhef { get; set; } + /// + /// 是否211 + /// + public bool? Sff { get; set; } + /// + /// 是否双一流 + /// + public bool? Syl { get; set; } + /// + /// 学校logo + /// + public string Logo { get; set; } + /// + /// 学校简介 + /// + public string Description { get; set; } + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + /// + /// 办学性质 + /// + public int Nature { get; set; } + /// + /// 隶属于 + /// + public string AscriptionName { get; set; } + /// + /// 学科层次 + /// + public int? SubjectLevel { get; set; } + /// + /// 学校类型 + /// + public int? UniversityType { get; set; } + /// + /// 创办时间 + /// + public string BuildDate { get; set; } + /// + /// 院士数 + /// + public int? AcademicianCount { get; set; } + /// + /// 博士数 + /// + public int DoctorateCount { get; set; } + /// + /// 硕士数 + /// + public int MasterCount { get; set; } + + /// + /// 是否收藏 + /// + public bool? IsCollection { get; set; } = false; + + /// + /// 是否对比 + /// + public bool IsContrast { get; set; } = false; + + /// + /// 是否分数接近 + /// + public bool IsNearScore { get; set; } = false; + + /// + /// 院校图片json + /// + public string Imglist { get; set; } + + public string naturedetail { get; set; } + + /// + /// 长学校id + /// + public string LongSchoolId { get; set; } + } + + /// + /// + /// + public class UniversityDetailResponse + { + /// + /// -1代表 id为空 -2代表院校为空 + /// + public int Status { get; set; } + public UniversityResult universityResult { get; set; } + + public List relatedMajors { get; set; } + /// + /// 特色专业 + /// + public List relatespMajors { get; set; } + + /// + /// 毕业生省份流向 + /// + public graduateModel graduateModels { get; set; } + } + + + + /// + /// 相关专业 + /// + public class RelatedMajorModel + { + public int mid { get; set; } + + public string majorName { get; set; } + + } + + + + + /// + /// 毕业生省份流向 + /// + public class graduateModel + { + + public object provinces { get; set; } + + public object attrs { get; set; } + + } + + /// + /// 院校招生计划 + /// + public class NewPlanDescList + { + public string Name { get; set; } + public int PlanNum { get; set; } + public string Money { get; set; } + public string Scoreline { get; set; } + } + + public class BatchYear + { + public List Batch { get; set; } + public List Year { get; set; } + public List Type { get; set; } + } + + public class UniversityRankList + { + /// + /// 院校名称 + /// + public string Name { get; set; } + + /// + /// 排名 最新 + /// + public int Sort { get; set; } + + } + + /// + /// 录取概率分析结果 + /// + public class UniversityProbabilityResult + { + /// + /// 是否985 + /// + public bool? Nhef { get; set; } + /// + /// 是否211 + /// + public bool? Sff { get; set; } + /// + /// 是否双一流 + /// + public bool? Syl { get; set; } + /// + /// 学校logo + /// + public string Logo { get; set; } + /// + /// 名称 + /// + public string Name { get; set; } + /// + /// 省市区名称 + /// + public string AreaName { get; set; } + + /// + /// 学科层次 + /// + public int? SubjectLevel { get; set; } + /// + /// 办学性质 + /// + public int Nature { get; set; } + /// + /// 隶属于 + /// + public string AscriptionName { get; set; } + + /// + /// 排行 + /// + public int Rank { get; set; } + + /// + /// 概率 + /// + public float Probability { get; set; } + + /// + /// 预估分数 + /// + public float EstimateScore { get; set; } + + /// + /// 历年最低分 + /// + public List YearBatchScores { get; set; } + + /// + /// 建议 + /// + public string Proposal { get; set; } + } + + /// + /// 历年最低分 + /// + public class YearBatchScore + { + /// + /// 年份 + /// + public int Year { get; set; } + + /// + /// 批次名称 + /// + public string BatchName { get; set; } + + /// + /// 最低分 + /// + public float Score { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/VipCardInfoResult.cs b/New_College.Model/ViewModels/Result/VipCardInfoResult.cs new file mode 100644 index 0000000..6fa4ee8 --- /dev/null +++ b/New_College.Model/ViewModels/Result/VipCardInfoResult.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class VipCardInfoResult + { + /// + /// 编号id + /// + public int Id { get; set; } + + /// + /// 账号 key + /// + public string Code { get; set; } + /// + /// 是否一绑定 + /// + public int IsBind { get; set; } = 2; + + /// + /// 是否一绑定 + /// + public string IsBindName { get; set; } + + /// + /// vip 天数 + /// + public int Day { get; set; } + + /// + /// vip 金额 + /// + public decimal Money { get; set; } + + /// + /// vip 卡类别名字 + /// + public string CardTypeName { get; set; } + } + public class VipCardInfoResultOne: VipCardInfoResult + { + + public DateTime EndTime { get; set; } + + + /// + /// 卡类型Id + /// + public int CardTypeId { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/VipCardTypeResult.cs b/New_College.Model/ViewModels/Result/VipCardTypeResult.cs new file mode 100644 index 0000000..0a2c6ed --- /dev/null +++ b/New_College.Model/ViewModels/Result/VipCardTypeResult.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class VipCardTypeResult + { + public int Id { get; set; } + + /// + /// 卡类型名称 + /// + public string Name { get; set; } + + /// + /// 金额 + /// + public decimal Money { get; set; } + + public string Desc { get; set; } + + /// + /// 天数 + /// + public int Day { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/VipInfoResult.cs b/New_College.Model/ViewModels/Result/VipInfoResult.cs new file mode 100644 index 0000000..e7ac74f --- /dev/null +++ b/New_College.Model/ViewModels/Result/VipInfoResult.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class VipInfoResult + { + /// + /// 是否是Vip + /// + public bool IsVip { get; set; } + + /// + /// 卡类型Id + /// + public int VipCardTypeId { get; set; } + + /// + /// 卡类型名称 + /// + public string VipCardTypeName { get; set; } + + /// + /// 卡号 + /// + public string VipCode { get; set; } + + /// + /// 到期时间 + /// + public DateTime VipEndTime { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/VolunteerResult.cs b/New_College.Model/ViewModels/Result/VolunteerResult.cs new file mode 100644 index 0000000..848da7e --- /dev/null +++ b/New_College.Model/ViewModels/Result/VolunteerResult.cs @@ -0,0 +1,228 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + + /// + /// 志愿填报推荐一级懒人专用 + /// + public class UniversityEnrollmentPlanLazyResult + { + + /// + /// 排名 + /// + public string Rank { get; set; } + + public int UniversityId { get; set; } + + public string UniversityName { get; set; } + + public string Logo { get; set; } + + public int? Nhef { get; set; } + /// + /// 是否211 + /// + public int? Sff { get; set; } + /// + /// 是否双一流 + /// + public int? Syl { get; set; } + + public List Infos { get; set; } + + /// + /// 行政名称 + /// + public string AscriptionName { get; set; } + } + + /// + /// 志愿填报推荐一级 + /// + public class UniversityEnrollmentPlanResult + { + /// + /// 冲稳保 类型 + /// + public string Type { get; set; } + /// + /// 排名 + /// + public string Rank { get; set; } + + public int UniversityId { get; set; } + + public string UniversityName { get; set; } + + public string Logo { get; set; } + + public string AreaName { get; set; } + + public int? Nhef { get; set; } + /// + /// 是否211 + /// + public int? Sff { get; set; } + /// + /// 是否双一流 + /// + public int? Syl { get; set; } + + + + ///// + ///// 院校最低分 + ///// + //public double? Score { get; set; } + + ///// + ///// 位次 + ///// + //public string RankLine { get; set; } + + public int planCount { get; set; } + + /// + /// 对应的Ids + /// + public List PlanIds { get; set; } + + /// + /// 对应专业数 + /// + public int MjaorPlan { get; set; } + + ///// + /////01冲-02稳-03保 + ///// + //public int DatasType { get; set; } + + ///// + ///// 批次Id + ///// + //public string BatchtypeId { get; set; } + + public string AscriptionName { get; set; } + } + + /// + /// 点开学校 展示专业 + /// + public class PlanDescList + { + public string Name { get; set; } + public int PlanNum { get; set; } + public string Year { get; set; } + public string Money { get; set; } + public int MajorId { get; set; } + public float Scoreline { get; set; } + } + + /// + /// 冲稳保返回 + /// + public class CWBEnrollmentPlanResult + { + public string Name { get; set; } + public int Count { get; set; } + public List UniversityIds { get; set; } + //public PageModel result { get; set; } + } + + /// + /// 霍兰德获取推荐专业 + /// + public class TagEnrollmentPlanResult + { + /// + /// Id + /// + public int Id { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + + /// + /// 颜色 + /// + public string Color { get; set; } + + /// + /// 对应信息 + /// + public List Info { get; set; } + } + + /// + /// 专用 + /// + public class OtherInfo + { + /// + /// Id + /// + public int Id { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + + /// + /// 颜色 + /// + public string Color { get; set; } + } + + public class majorlists + { + public string MajorName { get; set; } + + public string TagColor { get; set; } + } + + /// + /// 学校信息 + /// + public class SchoolInfo + { + /// + /// 院校Id + /// + public int UniversityId { get; set; } + + /// + /// 院校名称 + /// + public string UniversityName { get; set; } + + public string AscriptionName { get; set; } + + public string Logo { get; set; } + + public int? Nhef { get; set; } + /// + /// 是否211 + /// + public int? Sff { get; set; } + /// + /// 是否双一流 + /// + public int? Syl { get; set; } + + } + + + public class LikeSchoolMajor + { + public string SchoolName { get; set; } + + public string MajorName { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/VolunteerTableResult.cs b/New_College.Model/ViewModels/Result/VolunteerTableResult.cs new file mode 100644 index 0000000..3e30a55 --- /dev/null +++ b/New_College.Model/ViewModels/Result/VolunteerTableResult.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + /// + /// 志愿表详情 + /// + public class VolunteerTableResult + { + public int UniversityId { get; set; } + + public string UniversityName { get; set; } + + public List Infos { get; set; } + } + + public class PlanInfo + { + public int MajorId { get; set; } + + public string PlanName { get; set; } + + public int PlanNum { get; set; } + + public string Year { get; set; } + + public string Money { get; set; } + + public float Scoreline { get; set; } + } + + /// + /// 志愿列表 + /// + public class VolunteerTableListResult + { + public int Id { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + + public string CreateTime { get; set; } + } + + + + public class SimuVolunteerTableResult + { + /// + /// 排名 + /// + public int? Rank { get; set; } + /// + /// 是否985 + /// + public bool? Nhef { get; set; } + /// + /// 是否211 + /// + public bool? Sff { get; set; } + /// + /// 是否双一流 + /// + public bool? Syl { get; set; } + /// + /// 学校logo + /// + public string Logo { get; set; } + + public int UniversityId { get; set; } + + public string UniversityName { get; set; } + + public List Infos { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/WeChatPayResult.cs b/New_College.Model/ViewModels/Result/WeChatPayResult.cs new file mode 100644 index 0000000..db1948f --- /dev/null +++ b/New_College.Model/ViewModels/Result/WeChatPayResult.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class WeChatPayResult + { + + } + + /// + /// + /// + public class WeChatPubResult + { + public string appId { get; set; } + public string nonceStr { get; set; } + public string package { get; set; } + public string paySign { get; set; } + public string signType { get; set; } + public string timeStamp { get; set; } + public string parameter { get; set; } + public string response { get; set; } + public int MemberId { get; set; } + public int orderStatus { get; set; } + + public int cateId { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/WeixinPayRespose.cs b/New_College.Model/ViewModels/Result/WeixinPayRespose.cs new file mode 100644 index 0000000..fd1ce78 --- /dev/null +++ b/New_College.Model/ViewModels/Result/WeixinPayRespose.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class WeChatPayOrderResponse + { + public string return_code { get; set; } + public string return_msg { get; set; } + public string appid { get; set; } + public string mch_id { get; set; } + public string device_info { get; set; } + public string nonce_str { get; set; } + public string sign { get; set; } + public string sign_type { get; set; } + public string result_code { get; set; } + public string err_code { get; set; } + public string err_code_des { get; set; } + public int openid { get; set; } + public string is_subscribe { get; set; } + public string trade_type { get; set; } + public string bank_type { get; set; } + public int total_fee { get; set; } + public int settlement_total_fee { get; set; } + public string fee_type { get; set; } + public int cash_fee { get; set; } + public string cash_fee_type { get; set; } + public string transaction_id { get; set; } + public string out_trade_no { get; set; } + public string attach { get; set; } + public string time_end { get; set; } + + + + } +} diff --git a/New_College.Model/ViewModels/Result/WeixinPayResult.cs b/New_College.Model/ViewModels/Result/WeixinPayResult.cs new file mode 100644 index 0000000..137b51c --- /dev/null +++ b/New_College.Model/ViewModels/Result/WeixinPayResult.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class WeixinPayResult + { + public string appid { get; set; } + public string mchi_id { get; set; } + public string device_info { get; set; } + public string nonce_str { get; set; } + public string sign { get; set; } + public string result_code { get; set; } + public string err_code { get; set; } + public string err_code_des { get; set; } + public string trade_type { get; set; } + public string prepay_id { get; set; } + public string code_url { get; set; } + public string timeStamp { get; set; } + public string orderid { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/appQuestionResult.cs b/New_College.Model/ViewModels/Result/appQuestionResult.cs new file mode 100644 index 0000000..aa41a39 --- /dev/null +++ b/New_College.Model/ViewModels/Result/appQuestionResult.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class appQuestionResult + { + public int Id { get; set; } + + /// + /// 试题编号 + /// + public int QuestionSort { get; set; } + + /// + /// 问题typeid + /// + public int QuestionTypeId { get; set; } + + /// + /// 问题 + /// + public string QuestionTitle { get; set; } + + /// + /// 标签 + /// + public string QuestionTag { get; set; } + + /// + /// 问题类型 + /// + public string QuestionType { get; set; } + + /// + /// 是否正反记分 + /// + public int IsAddScore { get; set; } + } + + public class QuestionMBTI + { + /// + /// 试题编号 + /// + public int? QuestionSort { get; set; } + /// + /// 试题 + /// + public string QuestionTitle { get; set; } + + /// + /// 选项 + /// + public List Answers { get; set; } + } + + public class MBTIProperty + { + /// + /// A或者B + /// + public string key { get; set; } + + /// + /// 选项内容 + /// + public string value { get; set; } + + /// + /// 选项标签 + /// + public string type { get; set; } + } +} diff --git a/New_College.Model/ViewModels/Result/uniMajorSecond.cs b/New_College.Model/ViewModels/Result/uniMajorSecond.cs new file mode 100644 index 0000000..5b76787 --- /dev/null +++ b/New_College.Model/ViewModels/Result/uniMajorSecond.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + + + public class uniMajorSelect + { + public int Id { get; set; } + public string Name { get; set; } + } + + public class uniMajorClassSelect + { + public int TradeId { get; set; } + public int Id { get; set; } + public string Name { get; set; } + } + + /// + /// uni 专业列表 + /// + public class uniMajorInfoResult + { + public string FirstName { get; set; } + public List SecondInfo { get; set; } + public int MajorNum { get; set; } + } + /// + /// uni二级专业列表 + /// + public class uniMajorSecond + { + public int SecondId { get; set; } + public string MajorName { get; set; } + public int MajorNum { get; set; } + } +} diff --git a/New_College.Model/ViewModels/ServerViewModel.cs b/New_College.Model/ViewModels/ServerViewModel.cs new file mode 100644 index 0000000..4d7bd91 --- /dev/null +++ b/New_College.Model/ViewModels/ServerViewModel.cs @@ -0,0 +1,39 @@ +namespace New_College.Model.ViewModels +{ + /// + /// 服务器VM + /// + public class ServerViewModel + { + /// + /// 环境变量 + /// + public string EnvironmentName { get; set; } + /// + /// 系统架构 + /// + public string OSArchitecture { get; set; } + /// + /// ContentRootPath + /// + public string ContentRootPath { get; set; } + /// + /// WebRootPath + /// + public string WebRootPath { get; set; } + /// + /// .NET Core版本 + /// + public string FrameworkDescription { get; set; } + /// + /// 内存占用 + /// + public string MemoryFootprint { get; set; } + /// + /// 启动时间 + /// + public string WorkingTime { get; set; } + + + } +} diff --git a/New_College.Model/ViewModels/SidebarMenuViewModel.cs b/New_College.Model/ViewModels/SidebarMenuViewModel.cs new file mode 100644 index 0000000..2ae20a9 --- /dev/null +++ b/New_College.Model/ViewModels/SidebarMenuViewModel.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; + +namespace New_College.Model.ViewModels +{ + /// + /// 菜单展示model + /// + public class SidebarMenuViewModel + { + public SidebarMenuViewModel() + { + this.ChildMenuList = new List(); + } + + public int Id { get; set; } + public int? ParentId { get; set; } + public string Name { get; set; } + public string Icon { get; set; } + public string Code { get; set; } + public string LinkUrl { get; set; } + public string Area { get; set; } + public string Controller { get; set; } + public string Action { get; set; } + + public List ChildMenuList { get; set; } + } +} diff --git a/New_College.Model/ViewModels/TestRestSharpGetDto.cs b/New_College.Model/ViewModels/TestRestSharpGetDto.cs new file mode 100644 index 0000000..dfc3809 --- /dev/null +++ b/New_College.Model/ViewModels/TestRestSharpGetDto.cs @@ -0,0 +1,19 @@ +using New_College.Model.Models; + +namespace New_College.Model.ViewModels +{ + /// + /// 用来测试 RestSharp Get 请求 + /// + public class TestRestSharpGetDto + { + /// + /// + /// + public string success { get; set; } + /// + /// + /// + public BlogArticle data { get; set; } + } +} diff --git a/New_College.Model/ViewModels/TestRestSharpPostDto.cs b/New_College.Model/ViewModels/TestRestSharpPostDto.cs new file mode 100644 index 0000000..0b12aab --- /dev/null +++ b/New_College.Model/ViewModels/TestRestSharpPostDto.cs @@ -0,0 +1,11 @@ +namespace New_College.Model.ViewModels +{ + /// + /// 用来测试 RestSharp Post 请求 + /// + public class TestRestSharpPostDto + { + public bool success { get; set; } + public string name { get; set; } + } +} diff --git a/New_College.Model/ViewModels/TokenInfoViewModel.cs b/New_College.Model/ViewModels/TokenInfoViewModel.cs new file mode 100644 index 0000000..003e4b7 --- /dev/null +++ b/New_College.Model/ViewModels/TokenInfoViewModel.cs @@ -0,0 +1,10 @@ +namespace New_College.Model.ViewModels +{ + public class TokenInfoViewModel + { + public bool success { get; set; } + public string token { get; set; } + public double expires_in { get; set; } + public string token_type { get; set; } + } +} diff --git a/New_College.Model/ViewModels/TopgbViewModels.cs b/New_College.Model/ViewModels/TopgbViewModels.cs new file mode 100644 index 0000000..17bf477 --- /dev/null +++ b/New_College.Model/ViewModels/TopgbViewModels.cs @@ -0,0 +1,23 @@ +namespace New_College.Model.ViewModels +{ + /// + /// 留言排名展示类 + /// + public class TopgbViewModels + { + /// 博客ID + /// + /// + public int? blogId { get; set; } + + /// + /// 评论数量 + /// + public int counts { get; set; } + + /// 博客标题 + /// + /// + public string btitle { get; set; } + } +} diff --git a/New_College.Model/WeixinAuthInfo.cs b/New_College.Model/WeixinAuthInfo.cs new file mode 100644 index 0000000..5142ea9 --- /dev/null +++ b/New_College.Model/WeixinAuthInfo.cs @@ -0,0 +1,53 @@ +using System; +using System.Text.Json.Serialization; +using Newtonsoft.Json.Converters; + +namespace New_College.Model +{ + public class Weixinauthinfo + { + public string openid { get; set; } + public string session_key { get; set; } + public string unionid { get; set; } + public string errcode { get; set; } + public string errmsg { get; set; } + + } + + public class GetPhoneInfo + { + public string encryptedData { get; set; } + + public string iv { get; set; } + + public string openid { get; set; } + + public string session_key { get; set; } + } + + public class WeixinModel + { + public string appId { get; set; } + public string nonceStr { get; set; } + public string package { get; set; } + public string signType { get; set; } + public string timeStamp { get; set; } + } + + public class WeixinPayRespose + { + public string appid { get; set; } + public string mchi_id { get; set; } + public string device_info { get; set; } + public string nonce_str { get; set; } + public string sign { get; set; } + public string result_code { get; set; } + public string err_code { get; set; } + public string err_code_des { get; set; } + public string trade_type { get; set; } + public string prepay_id { get; set; } + public string code_url { get; set; } + public string timeStamp { get; set; } + public string orderid { get; set; } + } +} diff --git a/New_College.Model/WeixinResult.cs b/New_College.Model/WeixinResult.cs new file mode 100644 index 0000000..642e2d7 --- /dev/null +++ b/New_College.Model/WeixinResult.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + public class WeixinResult + { + public string openId { get; set; } + + public string token { get; set; } + + public string session_key { get; set; } + + } +} diff --git a/New_College.Publish.Docker.sh b/New_College.Publish.Docker.sh new file mode 100644 index 0000000..a35f585 --- /dev/null +++ b/New_College.Publish.Docker.sh @@ -0,0 +1,18 @@ +# 停止容器 +docker stop apkcontainer +# 删除容器 +docker rm apkcontainer +# 删除镜像 +docker rmi laozhangisphi/apkimg +# 切换目录 +cd /home/New_College +# 发布项目 +./New_College.Publish.Linux.sh +# 进入目录 +cd /home/New_College/.PublishFiles +# 编译镜像 +docker build -t laozhangisphi/apkimg . +# 生成容器 +docker run --name=apkcontainer -v /etc/localtime:/etc/localtime -it -p 8081:8081 laozhangisphi/apkimg +# 启动容器 +docker start apkcontainer diff --git a/New_College.Publish.Linux.sh b/New_College.Publish.Linux.sh new file mode 100644 index 0000000..cdc01f8 --- /dev/null +++ b/New_College.Publish.Linux.sh @@ -0,0 +1,6 @@ +git pull; +rm -rf .PublishFiles; +dotnet build; +dotnet publish -o /home/New_College/New_College.Api/bin/Debug/netcoreapp3.1; +cp -r /home/New_College/New_College.Api/bin/Debug/netcoreapp3.1 .PublishFiles; +echo "Successfully!!!! ^ please see the file .PublishFiles"; \ No newline at end of file diff --git a/New_College.Publish.bat b/New_College.Publish.bat new file mode 100644 index 0000000..c8e292d --- /dev/null +++ b/New_College.Publish.bat @@ -0,0 +1,19 @@ +color B + +del .PublishFiles\*.* /s /q + +dotnet restore + +dotnet build + +cd New_College.Api + +dotnet publish -o ..\New_College.Api\bin\Debug\netcoreapp3.1\ + +md ..\.PublishFiles + +xcopy ..\New_College.Api\bin\Debug\netcoreapp3.1\*.* ..\.PublishFiles\ /s /e + +echo "Successfully!!!! ^ please see the file .PublishFiles" + +cmd \ No newline at end of file diff --git a/New_College.Repository/BASE/BaseRepository.cs b/New_College.Repository/BASE/BaseRepository.cs new file mode 100644 index 0000000..094fe51 --- /dev/null +++ b/New_College.Repository/BASE/BaseRepository.cs @@ -0,0 +1,458 @@ +using New_College.Common; +using New_College.Common.DB; +using New_College.IRepository.Base; +using New_College.IRepository.UnitOfWork; +using New_College.Model; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Linq.Expressions; +using System.Threading.Tasks; + +namespace New_College.Repository.Base +{ + public class BaseRepository : IBaseRepository where TEntity : class, new() + { + private readonly IUnitOfWork _unitOfWork; + private SqlSugarClient _dbBase; + + private ISqlSugarClient _db + { + get + { + /* 如果要开启多库支持, + * 1、在appsettings.json 中开启MutiDBEnabled节点为true,必填 + * 2、设置一个主连接的数据库ID,节点MainDB,对应的连接字符串的Enabled也必须true,必填 + */ + if (Appsettings.app(new string[] { "MutiDBEnabled" }).ObjToBool()) + { + if (typeof(TEntity).GetTypeInfo().GetCustomAttributes(typeof(SugarTable), true).FirstOrDefault((x => x.GetType() == typeof(SugarTable))) is SugarTable sugarTable && !string.IsNullOrEmpty(sugarTable.TableDescription)) + { + _dbBase.ChangeDatabase(sugarTable.TableDescription.ToLower()); + } + else + { + _dbBase.ChangeDatabase(MainDb.CurrentDbConnId.ToLower()); + } + } + + return _dbBase; + } + } + + internal ISqlSugarClient Db + { + get { return _db; } + } + + public BaseRepository(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + _dbBase = unitOfWork.GetDbClient(); + } + + + + public async Task QueryById(object objId) + { + //return await Task.Run(() => _db.Queryable().InSingle(objId)); + return await _db.Queryable().In(objId).SingleAsync(); + } + /// + /// 功能描述:根据ID查询一条数据 + /// 作  者:New_College + /// + /// id(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 + /// 是否使用缓存 + /// 数据实体 + public async Task QueryById(object objId, bool blnUseCache = false) + { + //return await Task.Run(() => _db.Queryable().WithCacheIF(blnUseCache).InSingle(objId)); + return await _db.Queryable().WithCacheIF(blnUseCache).In(objId).SingleAsync(); + } + + /// + /// 功能描述:根据ID查询数据 + /// 作  者:New_College + /// + /// id列表(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 + /// 数据实体列表 + public async Task> QueryByIDs(object[] lstIds) + { + //return await Task.Run(() => _db.Queryable().In(lstIds).ToList()); + return await _db.Queryable().In(lstIds).ToListAsync(); + } + + /// + /// 写入实体数据 + /// + /// 博文实体类 + /// + public async Task Add(TEntity entity) + { + //var i = await Task.Run(() => _db.Insertable(entity).ExecuteReturnBigIdentity()); + ////返回的i是long类型,这里你可以根据你的业务需要进行处理 + //return (int)i; + + var insert = _db.Insertable(entity); + return await insert.ExecuteReturnIdentityAsync(); + } + + + /// + /// 写入实体数据 + /// + /// 实体类 + /// 指定只插入列 + /// 返回自增量列 + public async Task Add(TEntity entity, Expression> insertColumns = null) + { + var insert = _db.Insertable(entity); + if (insertColumns == null) + { + return await insert.ExecuteReturnIdentityAsync(); + } + else + { + return await insert.InsertColumns(insertColumns).ExecuteReturnIdentityAsync(); + } + } + + /// + /// 批量插入实体(速度快) + /// + /// 实体集合 + /// 影响行数 + public async Task Add(List listEntity) + { + return await _db.Insertable(listEntity.ToArray()).ExecuteCommandAsync(); + } + + /// + /// 更新实体数据 + /// + /// 博文实体类 + /// + public async Task Update(TEntity entity) + { + ////这种方式会以主键为条件 + //var i = await Task.Run(() => _db.Updateable(entity).ExecuteCommand()); + //return i > 0; + //这种方式会以主键为条件 + return await _db.Updateable(entity).ExecuteCommandHasChangeAsync(); + } + + public async Task Update(TEntity entity, string strWhere) + { + //return await Task.Run(() => _db.Updateable(entity).Where(strWhere).ExecuteCommand() > 0); + return await _db.Updateable(entity).Where(strWhere).ExecuteCommandHasChangeAsync(); + } + + public async Task Update(string strSql, SugarParameter[] parameters = null) + { + //return await Task.Run(() => _db.Ado.ExecuteCommand(strSql, parameters) > 0); + return await _db.Ado.ExecuteCommandAsync(strSql, parameters) > 0; + } + + public async Task Update(object operateAnonymousObjects) + { + return await _db.Updateable(operateAnonymousObjects).ExecuteCommandAsync() > 0; + } + + public async Task Update( + TEntity entity, + List lstColumns = null, + List lstIgnoreColumns = null, + string strWhere = "" + ) + { + //IUpdateable up = await Task.Run(() => _db.Updateable(entity)); + //if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) + //{ + // up = await Task.Run(() => up.IgnoreColumns(it => lstIgnoreColumns.Contains(it))); + //} + //if (lstColumns != null && lstColumns.Count > 0) + //{ + // up = await Task.Run(() => up.UpdateColumns(it => lstColumns.Contains(it))); + //} + //if (!string.IsNullOrEmpty(strWhere)) + //{ + // up = await Task.Run(() => up.Where(strWhere)); + //} + //return await Task.Run(() => up.ExecuteCommand()) > 0; + + IUpdateable up = _db.Updateable(entity); + if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) + { + up = up.IgnoreColumns(lstIgnoreColumns.ToArray()); + } + if (lstColumns != null && lstColumns.Count > 0) + { + up = up.UpdateColumns(lstColumns.ToArray()); + } + if (!string.IsNullOrEmpty(strWhere)) + { + up = up.Where(strWhere); + } + return await up.ExecuteCommandHasChangeAsync(); + } + + /// + /// 根据实体删除一条数据 + /// + /// 博文实体类 + /// + public async Task Delete(TEntity entity) + { + //var i = await Task.Run(() => _db.Deleteable(entity).ExecuteCommand()); + //return i > 0; + return await _db.Deleteable(entity).ExecuteCommandHasChangeAsync(); + } + + /// + /// 删除指定ID的数据 + /// + /// 主键ID + /// + public async Task DeleteById(object id) + { + //var i = await Task.Run(() => _db.Deleteable(id).ExecuteCommand()); + //return i > 0; + return await _db.Deleteable(id).ExecuteCommandHasChangeAsync(); + } + + /// + /// 删除指定ID集合的数据(批量删除) + /// + /// 主键ID集合 + /// + public async Task DeleteByIds(object[] ids) + { + //var i = await Task.Run(() => _db.Deleteable().In(ids).ExecuteCommand()); + //return i > 0; + return await _db.Deleteable().In(ids).ExecuteCommandHasChangeAsync(); + } + + + + /// + /// 功能描述:查询所有数据 + /// 作  者:New_College + /// + /// 数据列表 + public async Task> Query() + { + return await _db.Queryable().ToListAsync(); + } + + /// + /// 功能描述:查询数据列表 + /// 作  者:New_College + /// + /// 条件 + /// 数据列表 + public async Task> Query(string strWhere) + { + //return await Task.Run(() => _db.Queryable().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList()); + return await _db.Queryable().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToListAsync(); + } + + /// + /// 功能描述:查询数据列表 + /// 作  者:New_College + /// + /// whereExpression + /// 数据列表 + public async Task> Query(Expression> whereExpression) + { + return await _db.Queryable().WhereIF(whereExpression != null, whereExpression).ToListAsync(); + } + + /// + /// 功能描述:查询一个列表 + /// 作  者:New_College + /// + /// 条件表达式 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query(Expression> whereExpression, string strOrderByFileds) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToList()); + return await _db.Queryable().WhereIF(whereExpression != null, whereExpression).OrderByIF(strOrderByFileds != null, strOrderByFileds).ToListAsync(); + } + /// + /// 功能描述:查询一个列表 + /// + /// + /// + /// + /// + public async Task> Query(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList()); + return await _db.Queryable().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToListAsync(); + } + + /// + /// 功能描述:查询一个列表 + /// 作  者:New_College + /// + /// 条件 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query(string strWhere, string strOrderByFileds) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList()); + return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToListAsync(); + } + + + /// + /// 功能描述:查询前N条数据 + /// 作  者:New_College + /// + /// 条件表达式 + /// 前N条 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query( + Expression> whereExpression, + int intTop, + string strOrderByFileds) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToList()); + return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToListAsync(); + } + + /// + /// 功能描述:查询前N条数据 + /// 作  者:New_College + /// + /// 条件 + /// 前N条 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query( + string strWhere, + int intTop, + string strOrderByFileds) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToList()); + return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToListAsync(); + } + + /// + /// 根据sql语句查询 + /// + /// 完整的sql语句 + /// 参数 + /// 泛型集合 + public async Task> QuerySql(string strSql, SugarParameter[] parameters = null) + { + return await _db.Ado.SqlQueryAsync(strSql, parameters); + } + + /// + /// 根据sql语句查询 + /// + /// 完整的sql语句 + /// 参数 + /// DataTable + public async Task QueryTable(string strSql, SugarParameter[] parameters = null) + { + return await _db.Ado.GetDataTableAsync(strSql, parameters); + } + + /// + /// 功能描述:分页查询 + /// 作  者:New_College + /// + /// 条件表达式 + /// 页码(下标0) + /// 页大小 + /// 数据总量 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query( + Expression> whereExpression, + int intPageIndex, + int intPageSize, + string strOrderByFileds) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageList(intPageIndex, intPageSize)); + return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageListAsync(intPageIndex, intPageSize); + } + + /// + /// 功能描述:分页查询 + /// 作  者:New_College + /// + /// 条件 + /// 页码(下标0) + /// 页大小 + /// 数据总量 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query( + string strWhere, + int intPageIndex, + int intPageSize, + + string strOrderByFileds) + { + //return await Task.Run(() => _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageList(intPageIndex, intPageSize)); + return await _db.Queryable().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageListAsync(intPageIndex, intPageSize); + } + + + + /// + /// 分页查询[使用版本,其他分页未测试] + /// + /// 条件表达式 + /// 页码(下标0) + /// 页大小 + /// 排序字段,如name asc,age desc + /// + public async Task> QueryPage(Expression> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) + { + + RefAsync totalCount = 0; + var list = await _db.Queryable() + .WhereIF(whereExpression != null, whereExpression) + .OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds) + .ToPageListAsync(intPageIndex, intPageSize, totalCount); + + int pageCount = (Math.Ceiling(totalCount.ObjToDecimal() / intPageSize.ObjToDecimal())).ObjToInt(); + return new PageModel() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list }; + } + + + /// + ///查询-多表查询 + /// + /// 实体1 + /// 实体2 + /// 实体3 + /// 返回对象 + /// 关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo} + /// 返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo} + /// 查询表达式 (w1, w2) =>w1.UserNo == "") + /// + public async Task> QueryMuch( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null) where T : class, new() + { + if (whereLambda == null) + { + return await _db.Queryable(joinExpression).Select(selectExpression).ToListAsync(); + } + return await _db.Queryable(joinExpression).Where(whereLambda).Select(selectExpression).ToListAsync(); + } + + } + +} diff --git a/New_College.Repository/BASE/D_EnrollmentinproductionRepository.cs b/New_College.Repository/BASE/D_EnrollmentinproductionRepository.cs new file mode 100644 index 0000000..1989a42 --- /dev/null +++ b/New_College.Repository/BASE/D_EnrollmentinproductionRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_EnrollmentinproductionRepository + /// + public class D_EnrollmentinproductionRepository : BaseRepository, ID_EnrollmentinproductionRepository + { + public D_EnrollmentinproductionRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_GraduateFlowRepository.cs b/New_College.Repository/BASE/D_GraduateFlowRepository.cs new file mode 100644 index 0000000..2cbd7a6 --- /dev/null +++ b/New_College.Repository/BASE/D_GraduateFlowRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_GraduateFlowRepository + /// + public class D_GraduateFlowRepository : BaseRepository, ID_GraduateFlowRepository + { + public D_GraduateFlowRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_LongIdMapRepository.cs b/New_College.Repository/BASE/D_LongIdMapRepository.cs new file mode 100644 index 0000000..791048a --- /dev/null +++ b/New_College.Repository/BASE/D_LongIdMapRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_LongIdMapRepository + /// + public class D_LongIdMapRepository : BaseRepository, ID_LongIdMapRepository + { + public D_LongIdMapRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_MajorCategoryRepository.cs b/New_College.Repository/BASE/D_MajorCategoryRepository.cs new file mode 100644 index 0000000..d27dbb0 --- /dev/null +++ b/New_College.Repository/BASE/D_MajorCategoryRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_MajorCategoryRepository + /// + public class D_MajorCategoryRepository : BaseRepository, ID_MajorCategoryRepository + { + public D_MajorCategoryRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_MajorClassRepository.cs b/New_College.Repository/BASE/D_MajorClassRepository.cs new file mode 100644 index 0000000..5640509 --- /dev/null +++ b/New_College.Repository/BASE/D_MajorClassRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_MajorClassRepository + /// + public class D_MajorClassRepository : BaseRepository, ID_MajorClassRepository + { + public D_MajorClassRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_MajorInformationRepository.cs b/New_College.Repository/BASE/D_MajorInformationRepository.cs new file mode 100644 index 0000000..bc2bcc0 --- /dev/null +++ b/New_College.Repository/BASE/D_MajorInformationRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_MajorInformationRepository + /// + public class D_MajorInformationRepository : BaseRepository, ID_MajorInformationRepository + { + public D_MajorInformationRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_MajorMapOccouptionRepository.cs b/New_College.Repository/BASE/D_MajorMapOccouptionRepository.cs new file mode 100644 index 0000000..e35c264 --- /dev/null +++ b/New_College.Repository/BASE/D_MajorMapOccouptionRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_MajorMapOccouptionRepository + /// + public class D_MajorMapOccouptionRepository : BaseRepository, ID_MajorMapOccouptionRepository + { + public D_MajorMapOccouptionRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_MajorMapTagRepository.cs b/New_College.Repository/BASE/D_MajorMapTagRepository.cs new file mode 100644 index 0000000..7d2168a --- /dev/null +++ b/New_College.Repository/BASE/D_MajorMapTagRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_MajorMapTagRepository + /// + public class D_MajorMapTagRepository : BaseRepository, ID_MajorMapTagRepository + { + public D_MajorMapTagRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_MajorMapUniversityRepository.cs b/New_College.Repository/BASE/D_MajorMapUniversityRepository.cs new file mode 100644 index 0000000..0d9dbc7 --- /dev/null +++ b/New_College.Repository/BASE/D_MajorMapUniversityRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_MajorMapUniversityRepository + /// + public class D_MajorMapUniversityRepository : BaseRepository, ID_MajorMapUniversityRepository + { + public D_MajorMapUniversityRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_MajorObtainRepository.cs b/New_College.Repository/BASE/D_MajorObtainRepository.cs new file mode 100644 index 0000000..4704e30 --- /dev/null +++ b/New_College.Repository/BASE/D_MajorObtainRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_MajorObtainRepository + /// + public class D_MajorObtainRepository : BaseRepository, ID_MajorObtainRepository + { + public D_MajorObtainRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_MajorRepository.cs b/New_College.Repository/BASE/D_MajorRepository.cs new file mode 100644 index 0000000..f2c4513 --- /dev/null +++ b/New_College.Repository/BASE/D_MajorRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_MajorRepository + /// + public class D_MajorRepository : BaseRepository, ID_MajorRepository + { + public D_MajorRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_MajorSalaryRepository.cs b/New_College.Repository/BASE/D_MajorSalaryRepository.cs new file mode 100644 index 0000000..3e1b82e --- /dev/null +++ b/New_College.Repository/BASE/D_MajorSalaryRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_MajorSalaryRepository + /// + public class D_MajorSalaryRepository : BaseRepository, ID_MajorSalaryRepository + { + public D_MajorSalaryRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_OccMapTagRepository.cs b/New_College.Repository/BASE/D_OccMapTagRepository.cs new file mode 100644 index 0000000..0746603 --- /dev/null +++ b/New_College.Repository/BASE/D_OccMapTagRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_OccMapTagRepository + /// + public class D_OccMapTagRepository : BaseRepository, ID_OccMapTagRepository + { + public D_OccMapTagRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_OccupationCategoryRepository.cs b/New_College.Repository/BASE/D_OccupationCategoryRepository.cs new file mode 100644 index 0000000..b8c4f5f --- /dev/null +++ b/New_College.Repository/BASE/D_OccupationCategoryRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_OccupationCategoryRepository + /// + public class D_OccupationCategoryRepository : BaseRepository, ID_OccupationCategoryRepository + { + public D_OccupationCategoryRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_OccupationRepository.cs b/New_College.Repository/BASE/D_OccupationRepository.cs new file mode 100644 index 0000000..0c56793 --- /dev/null +++ b/New_College.Repository/BASE/D_OccupationRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_OccupationRepository + /// + public class D_OccupationRepository : BaseRepository, ID_OccupationRepository + { + public D_OccupationRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_UniversityCollectionRepository.cs b/New_College.Repository/BASE/D_UniversityCollectionRepository.cs new file mode 100644 index 0000000..ec0a744 --- /dev/null +++ b/New_College.Repository/BASE/D_UniversityCollectionRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_UniversityCollectionRepository + /// + public class D_UniversityCollectionRepository : BaseRepository, ID_UniversityCollectionRepository + { + public D_UniversityCollectionRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_UniversityRankRepository.cs b/New_College.Repository/BASE/D_UniversityRankRepository.cs new file mode 100644 index 0000000..d50da16 --- /dev/null +++ b/New_College.Repository/BASE/D_UniversityRankRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_UniversityRankRepository + /// + public class D_UniversityRankRepository : BaseRepository, ID_UniversityRankRepository + { + public D_UniversityRankRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_UniversityRepository.cs b/New_College.Repository/BASE/D_UniversityRepository.cs new file mode 100644 index 0000000..f8caa60 --- /dev/null +++ b/New_College.Repository/BASE/D_UniversityRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_UniversityRepository + /// + public class D_UniversityRepository : BaseRepository, ID_UniversityRepository + { + public D_UniversityRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_UniversityimgRepository.cs b/New_College.Repository/BASE/D_UniversityimgRepository.cs new file mode 100644 index 0000000..494ca0e --- /dev/null +++ b/New_College.Repository/BASE/D_UniversityimgRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_UniversityimgRepository + /// + public class D_UniversityimgRepository : BaseRepository, ID_UniversityimgRepository + { + public D_UniversityimgRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IBaseRepository.cs b/New_College.Repository/BASE/IBaseRepository.cs new file mode 100644 index 0000000..443b738 --- /dev/null +++ b/New_College.Repository/BASE/IBaseRepository.cs @@ -0,0 +1,58 @@ +using New_College.Model; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq.Expressions; +using System.Threading.Tasks; + +namespace New_College.IRepository.Base +{ + public interface IBaseRepository where TEntity : class + { + + Task QueryById(object objId); + Task QueryById(object objId, bool blnUseCache = false); + Task> QueryByIDs(object[] lstIds); + + Task Add(TEntity model); + + Task Add(List listEntity); + + Task DeleteById(object id); + + Task Delete(TEntity model); + + Task DeleteByIds(object[] ids); + + Task Update(TEntity model); + Task Update(TEntity entity, string strWhere); + Task Update(object operateAnonymousObjects); + + Task Update(TEntity entity, List lstColumns = null, List lstIgnoreColumns = null, string strWhere = ""); + + Task> Query(); + Task> Query(string strWhere); + Task> Query(Expression> whereExpression); + Task> Query(Expression> whereExpression, string strOrderByFileds); + Task> Query(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true); + Task> Query(string strWhere, string strOrderByFileds); + + Task> Query(Expression> whereExpression, int intTop, string strOrderByFileds); + Task> Query(string strWhere, int intTop, string strOrderByFileds); + Task> QuerySql(string strSql, SugarParameter[] parameters = null); + Task QueryTable(string strSql, SugarParameter[] parameters = null); + + Task> Query( + Expression> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds); + Task> Query(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds); + + + Task> QueryPage(Expression> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null); + + Task> QueryMuch( + Expression> joinExpression, + Expression> selectExpression, + Expression> whereLambda = null) where T : class, new(); + } +} diff --git a/New_College.Repository/BASE/ID_EnrollmentinproductionRepository.cs b/New_College.Repository/BASE/ID_EnrollmentinproductionRepository.cs new file mode 100644 index 0000000..5206dbe --- /dev/null +++ b/New_College.Repository/BASE/ID_EnrollmentinproductionRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_EnrollmentinproductionRepository + /// + public interface ID_EnrollmentinproductionRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_GraduateFlowRepository.cs b/New_College.Repository/BASE/ID_GraduateFlowRepository.cs new file mode 100644 index 0000000..1f64c0d --- /dev/null +++ b/New_College.Repository/BASE/ID_GraduateFlowRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_GraduateFlowRepository + /// + public interface ID_GraduateFlowRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_LongIdMapRepository.cs b/New_College.Repository/BASE/ID_LongIdMapRepository.cs new file mode 100644 index 0000000..bf1cb99 --- /dev/null +++ b/New_College.Repository/BASE/ID_LongIdMapRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_LongIdMapRepository + /// + public interface ID_LongIdMapRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_MajorCategoryRepository.cs b/New_College.Repository/BASE/ID_MajorCategoryRepository.cs new file mode 100644 index 0000000..ae44597 --- /dev/null +++ b/New_College.Repository/BASE/ID_MajorCategoryRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_MajorCategoryRepository + /// + public interface ID_MajorCategoryRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_MajorClassRepository.cs b/New_College.Repository/BASE/ID_MajorClassRepository.cs new file mode 100644 index 0000000..5981fcb --- /dev/null +++ b/New_College.Repository/BASE/ID_MajorClassRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_MajorClassRepository + /// + public interface ID_MajorClassRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_MajorInformationRepository.cs b/New_College.Repository/BASE/ID_MajorInformationRepository.cs new file mode 100644 index 0000000..ea8b8b8 --- /dev/null +++ b/New_College.Repository/BASE/ID_MajorInformationRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_MajorInformationRepository + /// + public interface ID_MajorInformationRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_MajorMapOccouptionRepository.cs b/New_College.Repository/BASE/ID_MajorMapOccouptionRepository.cs new file mode 100644 index 0000000..b3aefe2 --- /dev/null +++ b/New_College.Repository/BASE/ID_MajorMapOccouptionRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_MajorMapOccouptionRepository + /// + public interface ID_MajorMapOccouptionRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_MajorMapTagRepository.cs b/New_College.Repository/BASE/ID_MajorMapTagRepository.cs new file mode 100644 index 0000000..0a3ffa2 --- /dev/null +++ b/New_College.Repository/BASE/ID_MajorMapTagRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_MajorMapTagRepository + /// + public interface ID_MajorMapTagRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_MajorMapUniversityRepository.cs b/New_College.Repository/BASE/ID_MajorMapUniversityRepository.cs new file mode 100644 index 0000000..99bd180 --- /dev/null +++ b/New_College.Repository/BASE/ID_MajorMapUniversityRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_MajorMapUniversityRepository + /// + public interface ID_MajorMapUniversityRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_MajorObtainRepository.cs b/New_College.Repository/BASE/ID_MajorObtainRepository.cs new file mode 100644 index 0000000..5a1a31a --- /dev/null +++ b/New_College.Repository/BASE/ID_MajorObtainRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_MajorObtainRepository + /// + public interface ID_MajorObtainRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_MajorRepository.cs b/New_College.Repository/BASE/ID_MajorRepository.cs new file mode 100644 index 0000000..5c105f7 --- /dev/null +++ b/New_College.Repository/BASE/ID_MajorRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_MajorRepository + /// + public interface ID_MajorRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_MajorSalaryRepository.cs b/New_College.Repository/BASE/ID_MajorSalaryRepository.cs new file mode 100644 index 0000000..4da2a0b --- /dev/null +++ b/New_College.Repository/BASE/ID_MajorSalaryRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_MajorSalaryRepository + /// + public interface ID_MajorSalaryRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_OccMapTagRepository.cs b/New_College.Repository/BASE/ID_OccMapTagRepository.cs new file mode 100644 index 0000000..2dfbaac --- /dev/null +++ b/New_College.Repository/BASE/ID_OccMapTagRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_OccMapTagRepository + /// + public interface ID_OccMapTagRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_OccupationCategoryRepository.cs b/New_College.Repository/BASE/ID_OccupationCategoryRepository.cs new file mode 100644 index 0000000..13404c8 --- /dev/null +++ b/New_College.Repository/BASE/ID_OccupationCategoryRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_OccupationCategoryRepository + /// + public interface ID_OccupationCategoryRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_OccupationRepository.cs b/New_College.Repository/BASE/ID_OccupationRepository.cs new file mode 100644 index 0000000..d3bc0e5 --- /dev/null +++ b/New_College.Repository/BASE/ID_OccupationRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_OccupationRepository + /// + public interface ID_OccupationRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_UniversityCollectionRepository.cs b/New_College.Repository/BASE/ID_UniversityCollectionRepository.cs new file mode 100644 index 0000000..9a8e0a6 --- /dev/null +++ b/New_College.Repository/BASE/ID_UniversityCollectionRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_UniversityCollectionRepository + /// + public interface ID_UniversityCollectionRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_UniversityRankRepository.cs b/New_College.Repository/BASE/ID_UniversityRankRepository.cs new file mode 100644 index 0000000..82de41c --- /dev/null +++ b/New_College.Repository/BASE/ID_UniversityRankRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_UniversityRankRepository + /// + public interface ID_UniversityRankRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_UniversityRepository.cs b/New_College.Repository/BASE/ID_UniversityRepository.cs new file mode 100644 index 0000000..c937759 --- /dev/null +++ b/New_College.Repository/BASE/ID_UniversityRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_UniversityRepository + /// + public interface ID_UniversityRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_UniversityimgRepository.cs b/New_College.Repository/BASE/ID_UniversityimgRepository.cs new file mode 100644 index 0000000..c948a51 --- /dev/null +++ b/New_College.Repository/BASE/ID_UniversityimgRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_UniversityimgRepository + /// + public interface ID_UniversityimgRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ISysRegionRepository.cs b/New_College.Repository/BASE/ISysRegionRepository.cs new file mode 100644 index 0000000..d3e0059 --- /dev/null +++ b/New_College.Repository/BASE/ISysRegionRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ISysRegionRepository + /// + public interface ISysRegionRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IT_BatchTypeInfoRepository.cs b/New_College.Repository/BASE/IT_BatchTypeInfoRepository.cs new file mode 100644 index 0000000..df512bc --- /dev/null +++ b/New_College.Repository/BASE/IT_BatchTypeInfoRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IT_BatchTypeInfoRepository + /// + public interface IT_BatchTypeInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IT_BatchlineRepository.cs b/New_College.Repository/BASE/IT_BatchlineRepository.cs new file mode 100644 index 0000000..2258b07 --- /dev/null +++ b/New_College.Repository/BASE/IT_BatchlineRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IT_BatchlineRepository + /// + public interface IT_BatchlineRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IT_EnrollmentBatchRepository.cs b/New_College.Repository/BASE/IT_EnrollmentBatchRepository.cs new file mode 100644 index 0000000..defc301 --- /dev/null +++ b/New_College.Repository/BASE/IT_EnrollmentBatchRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IT_EnrollmentBatchRepository + /// + public interface IT_EnrollmentBatchRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IT_EnrollmentPlaneRepository.cs b/New_College.Repository/BASE/IT_EnrollmentPlaneRepository.cs new file mode 100644 index 0000000..cfc90df --- /dev/null +++ b/New_College.Repository/BASE/IT_EnrollmentPlaneRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IT_EnrollmentPlaneRepository + /// + public interface IT_EnrollmentPlaneRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IT_EnrollmentPlanedescRepository.cs b/New_College.Repository/BASE/IT_EnrollmentPlanedescRepository.cs new file mode 100644 index 0000000..5f9a296 --- /dev/null +++ b/New_College.Repository/BASE/IT_EnrollmentPlanedescRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IT_EnrollmentPlanedescRepository + /// + public interface IT_EnrollmentPlanedescRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IT_GearInfoRepository.cs b/New_College.Repository/BASE/IT_GearInfoRepository.cs new file mode 100644 index 0000000..1fb9fab --- /dev/null +++ b/New_College.Repository/BASE/IT_GearInfoRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IT_GearInfoRepository + /// + public interface IT_GearInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IT_LongIdMapRepository.cs b/New_College.Repository/BASE/IT_LongIdMapRepository.cs new file mode 100644 index 0000000..869f897 --- /dev/null +++ b/New_College.Repository/BASE/IT_LongIdMapRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IT_LongIdMapRepository + /// + public interface IT_LongIdMapRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IT_PlanMapTagRepository.cs b/New_College.Repository/BASE/IT_PlanMapTagRepository.cs new file mode 100644 index 0000000..5a93b98 --- /dev/null +++ b/New_College.Repository/BASE/IT_PlanMapTagRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IT_PlanMapTagRepository + /// + public interface IT_PlanMapTagRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IT_RegionScoreRepository.cs b/New_College.Repository/BASE/IT_RegionScoreRepository.cs new file mode 100644 index 0000000..c203403 --- /dev/null +++ b/New_College.Repository/BASE/IT_RegionScoreRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IT_RegionScoreRepository + /// + public interface IT_RegionScoreRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ITest_CategoryInfoRepository.cs b/New_College.Repository/BASE/ITest_CategoryInfoRepository.cs new file mode 100644 index 0000000..2fd7d11 --- /dev/null +++ b/New_College.Repository/BASE/ITest_CategoryInfoRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ITest_CategoryInfoRepository + /// + public interface ITest_CategoryInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ITest_CycleTimeInfoRepository.cs b/New_College.Repository/BASE/ITest_CycleTimeInfoRepository.cs new file mode 100644 index 0000000..4e25574 --- /dev/null +++ b/New_College.Repository/BASE/ITest_CycleTimeInfoRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ITest_CycleTimeInfoRepository + /// + public interface ITest_CycleTimeInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ITest_HollandResultInfoRepository.cs b/New_College.Repository/BASE/ITest_HollandResultInfoRepository.cs new file mode 100644 index 0000000..e91a117 --- /dev/null +++ b/New_College.Repository/BASE/ITest_HollandResultInfoRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ITest_HollandResultInfoRepository + /// + public interface ITest_HollandResultInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ITest_MBTIMapResultRepository.cs b/New_College.Repository/BASE/ITest_MBTIMapResultRepository.cs new file mode 100644 index 0000000..d4d4e02 --- /dev/null +++ b/New_College.Repository/BASE/ITest_MBTIMapResultRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ITest_MBTIMapResultRepository + /// + public interface ITest_MBTIMapResultRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ITest_PsychMeasurementInfoRepository.cs b/New_College.Repository/BASE/ITest_PsychMeasurementInfoRepository.cs new file mode 100644 index 0000000..e634b6e --- /dev/null +++ b/New_College.Repository/BASE/ITest_PsychMeasurementInfoRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ITest_PsychMeasurementInfoRepository + /// + public interface ITest_PsychMeasurementInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ITest_QuestionInfoRepository.cs b/New_College.Repository/BASE/ITest_QuestionInfoRepository.cs new file mode 100644 index 0000000..4ef89ce --- /dev/null +++ b/New_College.Repository/BASE/ITest_QuestionInfoRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ITest_QuestionInfoRepository + /// + public interface ITest_QuestionInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ITest_QuestionTypeInfoRepository.cs b/New_College.Repository/BASE/ITest_QuestionTypeInfoRepository.cs new file mode 100644 index 0000000..f91fda1 --- /dev/null +++ b/New_College.Repository/BASE/ITest_QuestionTypeInfoRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ITest_QuestionTypeInfoRepository + /// + public interface ITest_QuestionTypeInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IU_ProbabilityHistoryRepository.cs b/New_College.Repository/BASE/IU_ProbabilityHistoryRepository.cs new file mode 100644 index 0000000..716571b --- /dev/null +++ b/New_College.Repository/BASE/IU_ProbabilityHistoryRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IU_ProbabilityHistoryRepository + /// + public interface IU_ProbabilityHistoryRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IU_VolunteerTableDetailRepository.cs b/New_College.Repository/BASE/IU_VolunteerTableDetailRepository.cs new file mode 100644 index 0000000..2edc1c0 --- /dev/null +++ b/New_College.Repository/BASE/IU_VolunteerTableDetailRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IU_VolunteerTableDetailRepository + /// + public interface IU_VolunteerTableDetailRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IU_VolunteerTableRepository.cs b/New_College.Repository/BASE/IU_VolunteerTableRepository.cs new file mode 100644 index 0000000..5dda855 --- /dev/null +++ b/New_College.Repository/BASE/IU_VolunteerTableRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IU_VolunteerTableRepository + /// + public interface IU_VolunteerTableRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IV_CustomerInfoRepository.cs b/New_College.Repository/BASE/IV_CustomerInfoRepository.cs new file mode 100644 index 0000000..2eb3785 --- /dev/null +++ b/New_College.Repository/BASE/IV_CustomerInfoRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IV_CustomerInfoRepository + /// + public interface IV_CustomerInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IV_ExaminationPolicyRepository.cs b/New_College.Repository/BASE/IV_ExaminationPolicyRepository.cs new file mode 100644 index 0000000..3f1f000 --- /dev/null +++ b/New_College.Repository/BASE/IV_ExaminationPolicyRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IV_ExaminationPolicyRepository + /// + public interface IV_ExaminationPolicyRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IV_OrderInfoRepository.cs b/New_College.Repository/BASE/IV_OrderInfoRepository.cs new file mode 100644 index 0000000..735e47e --- /dev/null +++ b/New_College.Repository/BASE/IV_OrderInfoRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IV_OrderInfoRepository + /// + public interface IV_OrderInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IV_SubjectSelectRepository.cs b/New_College.Repository/BASE/IV_SubjectSelectRepository.cs new file mode 100644 index 0000000..423b0b5 --- /dev/null +++ b/New_College.Repository/BASE/IV_SubjectSelectRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IV_SubjectSelectRepository + /// + public interface IV_SubjectSelectRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IV_VipCardInfoRepository.cs b/New_College.Repository/BASE/IV_VipCardInfoRepository.cs new file mode 100644 index 0000000..0661022 --- /dev/null +++ b/New_College.Repository/BASE/IV_VipCardInfoRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IV_VipCardInfoRepository + /// + public interface IV_VipCardInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/IV_VipCardTypeRepository.cs b/New_College.Repository/BASE/IV_VipCardTypeRepository.cs new file mode 100644 index 0000000..9db583c --- /dev/null +++ b/New_College.Repository/BASE/IV_VipCardTypeRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// IV_VipCardTypeRepository + /// + public interface IV_VipCardTypeRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/SysRegionRepository.cs b/New_College.Repository/BASE/SysRegionRepository.cs new file mode 100644 index 0000000..da36da8 --- /dev/null +++ b/New_College.Repository/BASE/SysRegionRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// SysRegionRepository + /// + public class SysRegionRepository : BaseRepository, ISysRegionRepository + { + public SysRegionRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/T_BatchTypeInfoRepository.cs b/New_College.Repository/BASE/T_BatchTypeInfoRepository.cs new file mode 100644 index 0000000..57ea505 --- /dev/null +++ b/New_College.Repository/BASE/T_BatchTypeInfoRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// T_BatchTypeInfoRepository + /// + public class T_BatchTypeInfoRepository : BaseRepository, IT_BatchTypeInfoRepository + { + public T_BatchTypeInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/T_BatchlineRepository.cs b/New_College.Repository/BASE/T_BatchlineRepository.cs new file mode 100644 index 0000000..de84588 --- /dev/null +++ b/New_College.Repository/BASE/T_BatchlineRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// T_BatchlineRepository + /// + public class T_BatchlineRepository : BaseRepository, IT_BatchlineRepository + { + public T_BatchlineRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/T_EnrollmentBatchRepository.cs b/New_College.Repository/BASE/T_EnrollmentBatchRepository.cs new file mode 100644 index 0000000..305d1b2 --- /dev/null +++ b/New_College.Repository/BASE/T_EnrollmentBatchRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// T_EnrollmentBatchRepository + /// + public class T_EnrollmentBatchRepository : BaseRepository, IT_EnrollmentBatchRepository + { + public T_EnrollmentBatchRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/T_EnrollmentPlaneRepository.cs b/New_College.Repository/BASE/T_EnrollmentPlaneRepository.cs new file mode 100644 index 0000000..ef72622 --- /dev/null +++ b/New_College.Repository/BASE/T_EnrollmentPlaneRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// T_EnrollmentPlaneRepository + /// + public class T_EnrollmentPlaneRepository : BaseRepository, IT_EnrollmentPlaneRepository + { + public T_EnrollmentPlaneRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/T_EnrollmentPlanedescRepository.cs b/New_College.Repository/BASE/T_EnrollmentPlanedescRepository.cs new file mode 100644 index 0000000..c579987 --- /dev/null +++ b/New_College.Repository/BASE/T_EnrollmentPlanedescRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// T_EnrollmentPlanedescRepository + /// + public class T_EnrollmentPlanedescRepository : BaseRepository, IT_EnrollmentPlanedescRepository + { + public T_EnrollmentPlanedescRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/T_GearInfoRepository.cs b/New_College.Repository/BASE/T_GearInfoRepository.cs new file mode 100644 index 0000000..2dc6f61 --- /dev/null +++ b/New_College.Repository/BASE/T_GearInfoRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// T_GearInfoRepository + /// + public class T_GearInfoRepository : BaseRepository, IT_GearInfoRepository + { + public T_GearInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/T_LongIdMapRepository.cs b/New_College.Repository/BASE/T_LongIdMapRepository.cs new file mode 100644 index 0000000..d821b8d --- /dev/null +++ b/New_College.Repository/BASE/T_LongIdMapRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// T_LongIdMapRepository + /// + public class T_LongIdMapRepository : BaseRepository, IT_LongIdMapRepository + { + public T_LongIdMapRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/T_PlanMapTagRepository.cs b/New_College.Repository/BASE/T_PlanMapTagRepository.cs new file mode 100644 index 0000000..6e1e4fa --- /dev/null +++ b/New_College.Repository/BASE/T_PlanMapTagRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// T_PlanMapTagRepository + /// + public class T_PlanMapTagRepository : BaseRepository, IT_PlanMapTagRepository + { + public T_PlanMapTagRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/T_RegionScoreRepository.cs b/New_College.Repository/BASE/T_RegionScoreRepository.cs new file mode 100644 index 0000000..f101599 --- /dev/null +++ b/New_College.Repository/BASE/T_RegionScoreRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// T_RegionScoreRepository + /// + public class T_RegionScoreRepository : BaseRepository, IT_RegionScoreRepository + { + public T_RegionScoreRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/Test_CategoryInfoRepository.cs b/New_College.Repository/BASE/Test_CategoryInfoRepository.cs new file mode 100644 index 0000000..7c62c2b --- /dev/null +++ b/New_College.Repository/BASE/Test_CategoryInfoRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// Test_CategoryInfoRepository + /// + public class Test_CategoryInfoRepository : BaseRepository, ITest_CategoryInfoRepository + { + public Test_CategoryInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/Test_CycleTimeInfoRepository.cs b/New_College.Repository/BASE/Test_CycleTimeInfoRepository.cs new file mode 100644 index 0000000..ad5dd6c --- /dev/null +++ b/New_College.Repository/BASE/Test_CycleTimeInfoRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// Test_CycleTimeInfoRepository + /// + public class Test_CycleTimeInfoRepository : BaseRepository, ITest_CycleTimeInfoRepository + { + public Test_CycleTimeInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/Test_HollandResultInfoRepository.cs b/New_College.Repository/BASE/Test_HollandResultInfoRepository.cs new file mode 100644 index 0000000..f7f8ccd --- /dev/null +++ b/New_College.Repository/BASE/Test_HollandResultInfoRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// Test_HollandResultInfoRepository + /// + public class Test_HollandResultInfoRepository : BaseRepository, ITest_HollandResultInfoRepository + { + public Test_HollandResultInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/Test_MBTIMapResultRepository.cs b/New_College.Repository/BASE/Test_MBTIMapResultRepository.cs new file mode 100644 index 0000000..a288094 --- /dev/null +++ b/New_College.Repository/BASE/Test_MBTIMapResultRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// Test_MBTIMapResultRepository + /// + public class Test_MBTIMapResultRepository : BaseRepository, ITest_MBTIMapResultRepository + { + public Test_MBTIMapResultRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/Test_PsychMeasurementInfoRepository.cs b/New_College.Repository/BASE/Test_PsychMeasurementInfoRepository.cs new file mode 100644 index 0000000..71324b0 --- /dev/null +++ b/New_College.Repository/BASE/Test_PsychMeasurementInfoRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// Test_PsychMeasurementInfoRepository + /// + public class Test_PsychMeasurementInfoRepository : BaseRepository, ITest_PsychMeasurementInfoRepository + { + public Test_PsychMeasurementInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/Test_QuestionInfoRepository.cs b/New_College.Repository/BASE/Test_QuestionInfoRepository.cs new file mode 100644 index 0000000..c4625de --- /dev/null +++ b/New_College.Repository/BASE/Test_QuestionInfoRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// Test_QuestionInfoRepository + /// + public class Test_QuestionInfoRepository : BaseRepository, ITest_QuestionInfoRepository + { + public Test_QuestionInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/Test_QuestionTypeInfoRepository.cs b/New_College.Repository/BASE/Test_QuestionTypeInfoRepository.cs new file mode 100644 index 0000000..be08f1a --- /dev/null +++ b/New_College.Repository/BASE/Test_QuestionTypeInfoRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// Test_QuestionTypeInfoRepository + /// + public class Test_QuestionTypeInfoRepository : BaseRepository, ITest_QuestionTypeInfoRepository + { + public Test_QuestionTypeInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/U_ProbabilityHistoryRepository.cs b/New_College.Repository/BASE/U_ProbabilityHistoryRepository.cs new file mode 100644 index 0000000..160b5c2 --- /dev/null +++ b/New_College.Repository/BASE/U_ProbabilityHistoryRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// U_ProbabilityHistoryRepository + /// + public class U_ProbabilityHistoryRepository : BaseRepository, IU_ProbabilityHistoryRepository + { + public U_ProbabilityHistoryRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/U_VolunteerTableDetailRepository.cs b/New_College.Repository/BASE/U_VolunteerTableDetailRepository.cs new file mode 100644 index 0000000..9094c01 --- /dev/null +++ b/New_College.Repository/BASE/U_VolunteerTableDetailRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// U_VolunteerTableDetailRepository + /// + public class U_VolunteerTableDetailRepository : BaseRepository, IU_VolunteerTableDetailRepository + { + public U_VolunteerTableDetailRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/U_VolunteerTableRepository.cs b/New_College.Repository/BASE/U_VolunteerTableRepository.cs new file mode 100644 index 0000000..03da388 --- /dev/null +++ b/New_College.Repository/BASE/U_VolunteerTableRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// U_VolunteerTableRepository + /// + public class U_VolunteerTableRepository : BaseRepository, IU_VolunteerTableRepository + { + public U_VolunteerTableRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/V_CustomerInfoRepository.cs b/New_College.Repository/BASE/V_CustomerInfoRepository.cs new file mode 100644 index 0000000..f9e0058 --- /dev/null +++ b/New_College.Repository/BASE/V_CustomerInfoRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// V_CustomerInfoRepository + /// + public class V_CustomerInfoRepository : BaseRepository, IV_CustomerInfoRepository + { + public V_CustomerInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/V_ExaminationPolicyRepository.cs b/New_College.Repository/BASE/V_ExaminationPolicyRepository.cs new file mode 100644 index 0000000..9c1de2c --- /dev/null +++ b/New_College.Repository/BASE/V_ExaminationPolicyRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// V_ExaminationPolicyRepository + /// + public class V_ExaminationPolicyRepository : BaseRepository, IV_ExaminationPolicyRepository + { + public V_ExaminationPolicyRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/V_OrderInfoRepository.cs b/New_College.Repository/BASE/V_OrderInfoRepository.cs new file mode 100644 index 0000000..72731cb --- /dev/null +++ b/New_College.Repository/BASE/V_OrderInfoRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// V_OrderInfoRepository + /// + public class V_OrderInfoRepository : BaseRepository, IV_OrderInfoRepository + { + public V_OrderInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/V_SubjectSelectRepository.cs b/New_College.Repository/BASE/V_SubjectSelectRepository.cs new file mode 100644 index 0000000..3680614 --- /dev/null +++ b/New_College.Repository/BASE/V_SubjectSelectRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// V_SubjectSelectRepository + /// + public class V_SubjectSelectRepository : BaseRepository, IV_SubjectSelectRepository + { + public V_SubjectSelectRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/V_VipCardInfoRepository.cs b/New_College.Repository/BASE/V_VipCardInfoRepository.cs new file mode 100644 index 0000000..d6fbe00 --- /dev/null +++ b/New_College.Repository/BASE/V_VipCardInfoRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// V_VipCardInfoRepository + /// + public class V_VipCardInfoRepository : BaseRepository, IV_VipCardInfoRepository + { + public V_VipCardInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/V_VipCardTypeRepository.cs b/New_College.Repository/BASE/V_VipCardTypeRepository.cs new file mode 100644 index 0000000..2858826 --- /dev/null +++ b/New_College.Repository/BASE/V_VipCardTypeRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// V_VipCardTypeRepository + /// + public class V_VipCardTypeRepository : BaseRepository, IV_VipCardTypeRepository + { + public V_VipCardTypeRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/IRoleModulePermissionRepository.cs b/New_College.Repository/IRoleModulePermissionRepository.cs new file mode 100644 index 0000000..ff50923 --- /dev/null +++ b/New_College.Repository/IRoleModulePermissionRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.IRepository +{ + /// + /// IRoleModulePermissionRepository + /// + public interface IRoleModulePermissionRepository : IBaseRepository//类名 + { + Task> QueryMuchTable(); + Task> RoleModuleMaps(); + Task> GetRMPMaps(); + } +} diff --git a/New_College.Repository/New_College.Repository.csproj b/New_College.Repository/New_College.Repository.csproj new file mode 100644 index 0000000..4db3a5e --- /dev/null +++ b/New_College.Repository/New_College.Repository.csproj @@ -0,0 +1,23 @@ + + + + netcoreapp3.1 + + + + ..\New_College.Api\bin\Debug\ + + + + ..\New_College\bin\Release\ + + + + + + + + + + + diff --git a/New_College.Repository/RoleModulePermissionRepository.cs b/New_College.Repository/RoleModulePermissionRepository.cs new file mode 100644 index 0000000..6f3098f --- /dev/null +++ b/New_College.Repository/RoleModulePermissionRepository.cs @@ -0,0 +1,97 @@ +using New_College.Repository.Base; +using New_College.Model.Models; +using New_College.IRepository; +using System.Collections.Generic; +using System.Threading.Tasks; +using SqlSugar; +using New_College.IRepository.UnitOfWork; + +namespace New_College.Repository +{ + /// + /// RoleModulePermissionRepository + /// + public class RoleModulePermissionRepository : BaseRepository, IRoleModulePermissionRepository + { + public RoleModulePermissionRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + + public async Task> QueryMuchTable() + { + return await QueryMuch( + (rmp, m, p) => new object[] { + JoinType.Left, rmp.ModuleId == m.Id, + JoinType.Left, rmp.PermissionId == p.Id + }, + + (rmp, m, p) => new TestMuchTableResult() + { + moduleName = m.Name, + permName = p.Name, + rid = rmp.RoleId, + mid = rmp.ModuleId, + pid = rmp.PermissionId + }, + + (rmp, m, p) => rmp.IsDeleted == false + ); + } + + /// + /// 角色权限Map + /// RoleModulePermission, Module, Role 三表联合 + /// 第四个类型 RoleModulePermission 是返回值 + /// + /// + public async Task> RoleModuleMaps() + { + return await QueryMuch( + (rmp, m, r) => new object[] { + JoinType.Left, rmp.ModuleId == m.Id, + JoinType.Left, rmp.RoleId == r.Id + }, + + (rmp, m, r) => new RoleModulePermission() + { + Role = r, + Module = m, + IsDeleted = rmp.IsDeleted + }, + + (rmp, m, r) => rmp.IsDeleted == false && m.IsDeleted == false && r.IsDeleted == false + ); + } + + + + /// + /// 查询出角色-菜单-接口关系表全部Map属性数据 + /// + /// + public async Task> GetRMPMaps() + { + return await Db.Queryable() + .Mapper(rmp => rmp.Module, rmp => rmp.ModuleId) + .Mapper(rmp => rmp.Permission, rmp => rmp.PermissionId) + .Mapper(rmp => rmp.Role, rmp => rmp.RoleId) + .Where(d => d.IsDeleted == false) + .ToListAsync(); + } + + + /// + /// 查询出角色-菜单-接口关系表全部Map属性数据 + /// + /// + public async Task> GetRMPMapsPage() + { + return await Db.Queryable() + .Mapper(rmp => rmp.Module, rmp => rmp.ModuleId) + .Mapper(rmp => rmp.Permission, rmp => rmp.PermissionId) + .Mapper(rmp => rmp.Role, rmp => rmp.RoleId) + .ToPageListAsync(1, 5, 10); + } + } + +} \ No newline at end of file diff --git a/New_College.Repository/UnitOfWork/IUnitOfWork.cs b/New_College.Repository/UnitOfWork/IUnitOfWork.cs new file mode 100644 index 0000000..135a4e5 --- /dev/null +++ b/New_College.Repository/UnitOfWork/IUnitOfWork.cs @@ -0,0 +1,14 @@ +using SqlSugar; + +namespace New_College.IRepository.UnitOfWork +{ + public interface IUnitOfWork + { + SqlSugarClient GetDbClient(); + + void BeginTran(); + + void CommitTran(); + void RollbackTran(); + } +} diff --git a/New_College.Repository/UnitOfWork/UnitOfWork.cs b/New_College.Repository/UnitOfWork/UnitOfWork.cs new file mode 100644 index 0000000..25fa577 --- /dev/null +++ b/New_College.Repository/UnitOfWork/UnitOfWork.cs @@ -0,0 +1,51 @@ +using New_College.IRepository.UnitOfWork; +using SqlSugar; +using System; + +namespace New_College.Repository.UnitOfWork +{ + public class UnitOfWork : IUnitOfWork + { + private readonly ISqlSugarClient _sqlSugarClient; + + public UnitOfWork(ISqlSugarClient sqlSugarClient) + { + _sqlSugarClient = sqlSugarClient; + } + + /// + /// 获取DB,保证唯一性 + /// + /// + public SqlSugarClient GetDbClient() + { + // 必须要as,后边会用到切换数据库操作 + return _sqlSugarClient as SqlSugarClient; + } + + public void BeginTran() + { + GetDbClient().BeginTran(); + } + + public void CommitTran() + { + try + { + GetDbClient().CommitTran(); // + } + catch (Exception ex) + { + GetDbClient().RollbackTran(); + throw ex; + } + } + + public void RollbackTran() + { + GetDbClient().RollbackTran(); + } + + } + +} diff --git a/New_College.Services/AdvertisementServices.cs b/New_College.Services/AdvertisementServices.cs new file mode 100644 index 0000000..9afe376 --- /dev/null +++ b/New_College.Services/AdvertisementServices.cs @@ -0,0 +1,56 @@ +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; + +namespace New_College.Services +{ + public class AdvertisementServices : BaseServices, IAdvertisementServices + { + IBaseRepository _dal; + public AdvertisementServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + public void ReturnExp() + { + + int a = 1; + int b = 0; + + int c = a / b; + } + + //public IAdvertisementRepository dal = new AdvertisementRepository(); + //public int Sum(int i, int j) + //{ + // return base.Sum(i, j); + + //} + + + //public int Add(Advertisement model) + //{ + // return base.Add(model); + //} + + //public bool Delete(Advertisement model) + //{ + // return base.Delete(model); + //} + + //public List Query(Expression> whereExpression) + //{ + // return base.Query(whereExpression); + + //} + + //public bool Update(Advertisement model) + //{ + // return base.Update(model); + //} + + } +} diff --git a/New_College.Services/BASE/BaseServices.cs b/New_College.Services/BASE/BaseServices.cs new file mode 100644 index 0000000..5689835 --- /dev/null +++ b/New_College.Services/BASE/BaseServices.cs @@ -0,0 +1,297 @@ +using New_College.IRepository.Base; +using New_College.IServices.BASE; +using New_College.Model; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq.Expressions; +using System.Threading.Tasks; + +namespace New_College.Services.BASE +{ + public class BaseServices : IBaseServices where TEntity : class, new() + { + //public IBaseRepository baseDal = new BaseRepository(); + public IBaseRepository BaseDal;//通过在子类的构造函数中注入,这里是基类,不用构造函数 + + public async Task QueryById(object objId) + { + return await BaseDal.QueryById(objId); + } + /// + /// 功能描述:根据ID查询一条数据 + /// 作  者:AZLinli.New_College + /// + /// id(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 + /// 是否使用缓存 + /// 数据实体 + public async Task QueryById(object objId, bool blnUseCache = false) + { + return await BaseDal.QueryById(objId, blnUseCache); + } + + /// + /// 功能描述:根据ID查询数据 + /// 作  者:AZLinli.New_College + /// + /// id列表(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 + /// 数据实体列表 + public async Task> QueryByIDs(object[] lstIds) + { + return await BaseDal.QueryByIDs(lstIds); + } + + /// + /// 写入实体数据 + /// + /// 博文实体类 + /// + public async Task Add(TEntity entity) + { + return await BaseDal.Add(entity); + } + + /// + /// 批量插入实体(速度快) + /// + /// 实体集合 + /// 影响行数 + public async Task Add(List listEntity) + { + return await BaseDal.Add(listEntity); + } + + /// + /// 更新实体数据 + /// + /// 博文实体类 + /// + public async Task Update(TEntity entity) + { + return await BaseDal.Update(entity); + } + public async Task Update(TEntity entity, string strWhere) + { + return await BaseDal.Update(entity, strWhere); + } + public async Task Update(object operateAnonymousObjects) + { + return await BaseDal.Update(operateAnonymousObjects); + } + + public async Task Update( + TEntity entity, + List lstColumns = null, + List lstIgnoreColumns = null, + string strWhere = "" + ) + { + return await BaseDal.Update(entity, lstColumns, lstIgnoreColumns, strWhere); + } + + + /// + /// 根据实体删除一条数据 + /// + /// 博文实体类 + /// + public async Task Delete(TEntity entity) + { + return await BaseDal.Delete(entity); + } + + /// + /// 删除指定ID的数据 + /// + /// 主键ID + /// + public async Task DeleteById(object id) + { + return await BaseDal.DeleteById(id); + } + + /// + /// 删除指定ID集合的数据(批量删除) + /// + /// 主键ID集合 + /// + public async Task DeleteByIds(object[] ids) + { + return await BaseDal.DeleteByIds(ids); + } + + + + /// + /// 功能描述:查询所有数据 + /// 作  者:AZLinli.New_College + /// + /// 数据列表 + public async Task> Query() + { + return await BaseDal.Query(); + } + + /// + /// 功能描述:查询数据列表 + /// 作  者:AZLinli.New_College + /// + /// 条件 + /// 数据列表 + public async Task> Query(string strWhere) + { + return await BaseDal.Query(strWhere); + } + + /// + /// 功能描述:查询数据列表 + /// 作  者:AZLinli.New_College + /// + /// whereExpression + /// 数据列表 + public async Task> Query(Expression> whereExpression) + { + return await BaseDal.Query(whereExpression); + } + /// + /// 功能描述:查询一个列表 + /// 作  者:AZLinli.New_College + /// + /// 条件表达式 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query(Expression> whereExpression, Expression> orderByExpression, bool isAsc = true) + { + return await BaseDal.Query(whereExpression, orderByExpression, isAsc); + } + + public async Task> Query(Expression> whereExpression, string strOrderByFileds) + { + return await BaseDal.Query(whereExpression, strOrderByFileds); + } + + /// + /// 功能描述:查询一个列表 + /// 作  者:AZLinli.New_College + /// + /// 条件 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query(string strWhere, string strOrderByFileds) + { + return await BaseDal.Query(strWhere, strOrderByFileds); + } + + /// + /// 根据sql语句查询 + /// + /// 完整的sql语句 + /// 参数 + /// 泛型集合 + public async Task> QuerySql(string strSql, SugarParameter[] parameters = null) + { + return await BaseDal.QuerySql(strSql, parameters); + + } + + /// + /// 根据sql语句查询 + /// + /// 完整的sql语句 + /// 参数 + /// DataTable + public async Task QueryTable(string strSql, SugarParameter[] parameters = null) + { + return await BaseDal.QueryTable(strSql, parameters); + + } + /// + /// 功能描述:查询前N条数据 + /// 作  者:AZLinli.New_College + /// + /// 条件表达式 + /// 前N条 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query(Expression> whereExpression, int intTop, string strOrderByFileds) + { + return await BaseDal.Query(whereExpression, intTop, strOrderByFileds); + } + + /// + /// 功能描述:查询前N条数据 + /// 作  者:AZLinli.New_College + /// + /// 条件 + /// 前N条 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query( + string strWhere, + int intTop, + string strOrderByFileds) + { + return await BaseDal.Query(strWhere, intTop, strOrderByFileds); + } + + /// + /// 功能描述:分页查询 + /// 作  者:AZLinli.New_College + /// + /// 条件表达式 + /// 页码(下标0) + /// 页大小 + /// 数据总量 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query( + Expression> whereExpression, + int intPageIndex, + int intPageSize, + string strOrderByFileds) + { + return await BaseDal.Query( + whereExpression, + intPageIndex, + intPageSize, + strOrderByFileds); + } + + /// + /// 功能描述:分页查询 + /// 作  者:AZLinli.New_College + /// + /// 条件 + /// 页码(下标0) + /// 页大小 + /// 数据总量 + /// 排序字段,如name asc,age desc + /// 数据列表 + public async Task> Query( + string strWhere, + int intPageIndex, + int intPageSize, + string strOrderByFileds) + { + return await BaseDal.Query( + strWhere, + intPageIndex, + intPageSize, + strOrderByFileds); + } + + public async Task> QueryPage(Expression> whereExpression, + int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) + { + return await BaseDal.QueryPage(whereExpression, + intPageIndex, intPageSize, strOrderByFileds); + } + + public async Task> QueryMuch(Expression> joinExpression, Expression> selectExpression, Expression> whereLambda = null) where T : class, new() + { + return await BaseDal.QueryMuch(joinExpression, selectExpression, whereLambda); + } + } + +} diff --git a/New_College.Services/BlogArticleServices.cs b/New_College.Services/BlogArticleServices.cs new file mode 100644 index 0000000..0958c8b --- /dev/null +++ b/New_College.Services/BlogArticleServices.cs @@ -0,0 +1,113 @@ +using AutoMapper; +using New_College.Common; +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using New_College.Services.BASE; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace New_College.Services +{ + public class BlogArticleServices : BaseServices, IBlogArticleServices + { + IBaseRepository _dal; + IMapper _mapper; + public BlogArticleServices(IBaseRepository dal, IMapper mapper) + { + this._dal = dal; + base.BaseDal = dal; + this._mapper = mapper; + } + /// + /// 获取视图博客详情信息 + /// + /// + /// + public async Task GetBlogDetails(int id) + { + // 此处想获取上一条下一条数据,因此将全部数据list出来,有好的想法请提出 + //var bloglist = await base.Query(a => a.IsDeleted==false, a => a.bID); + var blogArticle = (await base.Query(a => a.bID == id && a.bcategory == "技术博文")).FirstOrDefault(); + + BlogViewModels models = null; + + if (blogArticle != null) + { + models = _mapper.Map(blogArticle); + + //要取下一篇和上一篇,以当前id开始,按id排序后top(2),而不用取出所有记录 + //这样在记录很多的时候也不会有多大影响 + var nextBlogs = await base.Query(a => a.bID >= id && a.IsDeleted == false && a.bcategory == "技术博文", 2, "bID"); + if (nextBlogs.Count == 2) + { + models.next = nextBlogs[1].btitle; + models.nextID = nextBlogs[1].bID; + } + var prevBlogs = await base.Query(a => a.bID <= id && a.IsDeleted == false && a.bcategory == "技术博文", 2, "bID desc"); + if (prevBlogs.Count == 2) + { + models.previous = prevBlogs[1].btitle; + models.previousID = prevBlogs[1].bID; + } + + //BlogArticle prevblog; + //BlogArticle nextblog; + + + //int blogIndex = bloglist.FindIndex(item => item.bID == id); + //if (blogIndex >= 0) + //{ + // try + // { + // prevblog = blogIndex > 0 ? bloglist[blogIndex - 1] : null; + // nextblog = blogIndex + 1 < bloglist.Count() ? bloglist[blogIndex + 1] : null; + + + // // 注意就是这里,mapper + // models = _mapper.Map(blogArticle); + + // if (nextblog != null) + // { + // models.next = nextblog.btitle; + // models.nextID = nextblog.bID; + // } + + // if (prevblog != null) + // { + // models.previous = prevblog.btitle; + // models.previousID = prevblog.bID; + // } + // var entity2Viewmodel = _mapper.Map(models); + + // } + // catch (Exception ex) { throw new Exception(ex.Message); } + //} + + + blogArticle.btraffic += 1; + await base.Update(blogArticle, new List { "btraffic" }); + } + + return models; + + } + + + /// + /// 获取博客列表 + /// + /// + /// + [Caching(AbsoluteExpiration = 10)] + public async Task> GetBlogs() + { + var bloglist = await base.Query(a => a.bID > 0, a => a.bID); + + return bloglist; + + } + } +} diff --git a/New_College.Services/D_EnrollmentinproductionServices.cs b/New_College.Services/D_EnrollmentinproductionServices.cs new file mode 100644 index 0000000..5b048eb --- /dev/null +++ b/New_College.Services/D_EnrollmentinproductionServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_EnrollmentinproductionServices : BaseServices, ID_EnrollmentinproductionServices + { + private readonly IBaseRepository _dal; + public D_EnrollmentinproductionServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_GraduateFlowServices.cs b/New_College.Services/D_GraduateFlowServices.cs new file mode 100644 index 0000000..49d7587 --- /dev/null +++ b/New_College.Services/D_GraduateFlowServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_GraduateFlowServices : BaseServices, ID_GraduateFlowServices + { + private readonly IBaseRepository _dal; + public D_GraduateFlowServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_LongIdMapServices.cs b/New_College.Services/D_LongIdMapServices.cs new file mode 100644 index 0000000..c0ee058 --- /dev/null +++ b/New_College.Services/D_LongIdMapServices.cs @@ -0,0 +1,1568 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.IRepository; +using System.Threading.Tasks; +using New_College.Common.Excel; +using System.Data; +using System; +using System.Linq; +using System.Collections.Generic; +using New_College.Model.ViewModels; +using LinqKit; +using New_College.Model; +using New_College.Common.Helper; +using New_College.Common; +using New_College.Common.HttpRestSharp; +using System.Text; + + +namespace New_College.Services +{ + public class D_LongIdMapServices : BaseServices, ID_LongIdMapServices + { + private readonly IBaseRepository _dal; + private readonly ID_MajorCategoryRepository d_MajorCategoryRepository; + private readonly ID_MajorClassRepository d_MajorClassRepository; + private readonly ID_MajorRepository d_MajorRepository; + private readonly ID_OccupationCategoryRepository d_OccupationCategoryRepository; + private readonly ID_OccupationRepository d_OccupationRepository; + private readonly ID_OccMapTagRepository d_OccMapTagRepository; + private readonly ID_MajorMapOccouptionRepository d_MajorMapOccouptionRepository; + private readonly ID_MajorMapTagRepository d_MajorMapTagRepository; + private readonly ID_MajorObtainRepository d_MajorObtainRepository; + private readonly ID_UniversityRepository d_UniversityRepository; + private readonly ID_UniversityimgRepository d_UniversityimgRepository; + private readonly ID_UniversityRankRepository d_UniversityRankRepository; + private readonly ID_MajorMapUniversityRepository d_MajorMapUniversityRepository; + private readonly ID_MajorInformationRepository d_MajorInformationRepository; + private readonly ID_UniversityCollectionRepository d_UniversityCollectionRepository; + private readonly IT_EnrollmentPlanedescRepository t_EnrollmentPlanedescRepository; + private readonly IT_EnrollmentBatchRepository t_EnrollmentBatchRepository; + private readonly ID_GraduateFlowRepository d_GraduateFlowRepository; + private readonly IT_EnrollmentPlaneRepository t_EnrollmentPlaneRepository; + + public D_LongIdMapServices(IBaseRepository dal + , ID_MajorCategoryRepository ID_MajorCategoryRepository + , ID_MajorClassRepository ID_MajorClassRepository + , ID_MajorRepository ID_MajorRepository + , ID_OccupationCategoryRepository ID_OccupationCategoryRepository + , ID_OccupationRepository ID_OccupationRepository + , ID_OccMapTagRepository ID_OccMapTagRepository + , ID_MajorMapOccouptionRepository ID_MajorMapOccouptionRepository + , ID_MajorMapTagRepository ID_MajorMapTagRepository + , ID_MajorObtainRepository ID_MajorObtainRepository + , ID_UniversityRepository ID_UniversityRepository + , ID_UniversityimgRepository ID_UniversityimgRepository + , ID_UniversityRankRepository ID_UniversityRankRepository + , ID_MajorMapUniversityRepository ID_MajorMapUniversityRepository + , ID_MajorInformationRepository ID_MajorInformationRepository + , ID_UniversityCollectionRepository ID_UniversityCollectionRepository + , IT_EnrollmentPlanedescRepository IT_EnrollmentPlanedescRepository + , IT_EnrollmentBatchRepository IT_EnrollmentBatchRepository + , ID_GraduateFlowRepository ID_GraduateFlowRepository + , IT_EnrollmentPlaneRepository IT_EnrollmentPlaneRepository) + { + this._dal = dal; + d_MajorCategoryRepository = ID_MajorCategoryRepository; + d_MajorClassRepository = ID_MajorClassRepository; + d_MajorRepository = ID_MajorRepository; + d_OccupationCategoryRepository = ID_OccupationCategoryRepository; + d_OccupationRepository = ID_OccupationRepository; + d_OccMapTagRepository = ID_OccMapTagRepository; + d_MajorMapOccouptionRepository = ID_MajorMapOccouptionRepository; + d_MajorMapTagRepository = ID_MajorMapTagRepository; + d_MajorObtainRepository = ID_MajorObtainRepository; + d_UniversityRepository = ID_UniversityRepository; + d_UniversityimgRepository = ID_UniversityimgRepository; + d_UniversityRankRepository = ID_UniversityRankRepository; + d_MajorMapUniversityRepository = ID_MajorMapUniversityRepository; + d_MajorInformationRepository = ID_MajorInformationRepository; + d_UniversityCollectionRepository = ID_UniversityCollectionRepository; + t_EnrollmentPlanedescRepository = IT_EnrollmentPlanedescRepository; + t_EnrollmentBatchRepository = IT_EnrollmentBatchRepository; + d_GraduateFlowRepository = ID_GraduateFlowRepository; + t_EnrollmentPlaneRepository = IT_EnrollmentPlaneRepository; + base.BaseDal = dal; + } + + /// + /// 获取院校库 添加个人收藏和对比 的验证 + /// + /// + /// + public async Task> GetUniversitys(UniversityQuery query) + { + var wheres = PredicateBuilder.New(); + wheres = wheres.And(x => x.IsDelete == false); + if (!string.IsNullOrEmpty(query.AreaName) && query.AreaName != "全国") + wheres = wheres.And(x => x.Area_Name.Contains(query.AreaName)); + if (query.SubjectLevel < 2) + wheres = wheres.And(x => x.Subject_Level == query.SubjectLevel); + if (query.Type >= 0) + wheres = wheres.And(x => x.Type == query.Type); + if (query.Nhef >= 0) + wheres = wheres.And(x => x.Nhef == query.Nhef); + if (query.Sff >= 0) + wheres = wheres.And(x => x.Sff == query.Sff); + if (query.Syl >= 0) + wheres = wheres.And(x => x.Syl == query.Syl); + if (!string.IsNullOrWhiteSpace(query.Name)) + wheres = wheres.And(u => u.Name.Contains(query.Name)); + if (query.Nature > 0) + wheres = wheres.And(x => x.Nature == query.Nature); + var info = await d_UniversityRepository.QueryPage(wheres, query.PageIndex, query.PageSize, "Rank Asc"); + if (info.data.Count <= 0) + return new PageModel() { }; + + var collectionuniversity = await d_UniversityCollectionRepository.Query(x => x.CustomerId == query.CustomerId && x.IsDelete == false); + List list = new List() { }; + info.data = info.data.OrderBy(s => s.Rank).ToList(); + foreach (var c in info.data) + { + string attribute = ""; + if (c.Nhef == 1) + attribute += "985"; + if (c.Sff == 1) + attribute += "211"; + if (c.Syl == 1) + attribute += "双一流"; + list.Add(new UniversityResult + { + Id = c.Id, + Name = c.Name, + Nature = c.Nature, + AscriptionName = c.AscriptionName, + AreaName = c.Area_Name, + Logo = c.Logo, + Syl = c.Syl == 1, + Nhef = c.Nhef == 1, + Sff = c.Sff == 1, + UniversityType = c.Type, + IsNearScore = false, + SubjectLevel = c.Subject_Level, + Rank = c.Rank, + IsCollection = collectionuniversity.Count(x => x.Type == 1 && x.UniversityId == c.Id) > 0, + IsContrast = collectionuniversity.Count(x => x.Type == 2 && x.UniversityId == c.Id) > 0, + }); + } + return new PageModel() + { + data = list, + dataCount = info.dataCount, + page = info.page, + pageCount = info.pageCount, + PageSize = info.PageSize + }; + } + + /// + /// 专业库 一级二级列表 + /// + /// + /// + public async Task> uniGetMajorInfo(MajorcategoryQuery query) + { + var majorcategories = (await d_MajorCategoryRepository.Query(x => x.Type == query.SchoolLevel && x.IsDelete == false)).Select(x => new uniMajorSelect() { Id = x.Id, Name = x.Name }); ; + var majorclasses = (await d_MajorClassRepository.Query(x => x.IsDelete == false)).Select(x => new uniMajorClassSelect() { Id = x.Id, Name = x.Name, TradeId = x.TradeId }); + var majorinfo = (await d_MajorRepository.Query(x => x.IsDelete == false)).Select(s => new uniMajorSelect() { Id = s.CategoryClass_Id, Name = s.Name }).ToList(); + List list = new List() { }; + foreach (var item in majorcategories) + { + List scond = new List() { }; + var nowmajoclass = majorclasses.Where(x => x.TradeId == item.Id).ToList(); + scond = nowmajoclass.Select(s => new uniMajorSecond() + { + MajorName = s.Name, + SecondId = s.Id, + MajorNum = majorinfo.Count(x => x.Name != s.Name && x.Id == s.Id), + }).ToList(); + + if (scond.Count() == 0) + continue; + list.Add(new uniMajorInfoResult() + { + FirstName = item.Name, + SecondInfo = scond + }); + } + return list; + } + + /// + /// 获取推荐职业 + /// + /// + public async Task> GetRecommendOccupation() + { + var info = await d_OccupationRepository.Query(x => x.Recommend > 0 && x.IsDelete == false); + if (info.Count <= 0) + return new List() { }; + return info.Select(x => new OccupationResult() { Id = x.Id, Name = x.OccupationName }).ToList(); + } + + /// + /// 职业库 一级二级列表 + /// + /// + public async Task> uniGetOccupationInfo() + { + List list = new List() { }; + var occupationCategoryList = (await d_OccupationCategoryRepository.Query(x => x.IsDelete == false)).Select(x => new uniOccSelect() { Id = x.Id, Level = x.Level, Name = x.Name, ParentId = x.ParentId, OccupationName = x.OccupationName }); + var occupations = (await d_OccupationRepository.Query(x => x.IsDelete == false)).Select(s => s.CategoryId).ToList(); + var nowoccupationCategoryList = occupationCategoryList.Where(x => x.Level == 0).ToList(); + foreach (var item in nowoccupationCategoryList) + { + List scond = new List() { }; + var nowmajoclass = occupationCategoryList.Where(x => x.ParentId == item.Id).ToList(); + scond = nowmajoclass.Select(s => new uniMajorSecond() + { + MajorName = s.OccupationName, + MajorNum = occupations.Count(e => e == s.Id), + SecondId = s.Id + + }).ToList(); + list.Add(new uniMajorInfoResult() + { + FirstName = item.Name, + SecondInfo = scond + }); + } + return list; + } + + /// + /// 院校详情 + /// + /// + /// + public async Task GetUniversityDetails(IdQuery query) + { + if (query.Id <= 0) + return new UniversityDetailResponse() { Status = -1 }; + var university = await d_UniversityRepository.QueryById(query.Id); + if (university == null) + return new UniversityDetailResponse() { Status = -2 }; + var result = new UniversityDetailResponse(); + string imgs = ""; + var imglist = (await d_UniversityimgRepository.Query(x => x.UniversityId == query.Id && x.IsDelete == false)).FirstOrDefault(); + if (imglist != null) + { + imgs = imglist.ImgList; + } + result.universityResult = new UniversityResult + { + Id = university.Id, + Name = university.Name, + Nature = university.Nature, + AscriptionName = university.AscriptionName, + Rank = university.Rank, + AreaName = university.Area_Name, + Logo = university.Logo, + Syl = university.Syl == 1 ? true : false, + Nhef = university.Nhef == 1 ? true : false, + Sff = university.Sff == 1 ? true : false, + UniversityType = university.Type, + SubjectLevel = university.Subject_Level, + Imglist = imgs, + DoctorateCount = university.Doctorate_Count, + MasterCount = university.Master_Count, + AcademicianCount = university.Academician_Count, + // IsCollection = false, + //Description = ClearHtmlHelper.SHTML(university.Description), + LongSchoolId = (await _dal.Query(x => x.IsDelete == false && x.table == "D_University" && x.newid == university.Id)).Select(x => x.longid).FirstOrDefault() + }; + var mapuniversity = await d_MajorMapUniversityRepository.Query(x => x.Universityid == query.Id && x.IsDelete == false); + var majorids = mapuniversity.Select(x => x.MajorId).ToList(); + var majorlist = await d_MajorRepository.Query(x => majorids.Contains(x.Id) && x.IsDelete == false); + var majors = new List(); + var spmajors = new List(); + int m = 0; + int sp = 0; + mapuniversity.ForEach(o => + { + if (majorlist.Where(s => s.Id == o.MajorId).Any()) + { + + if (o.sp == 0 && m <= 5) + { + m++; + majors.Add(new RelatedMajorModel() + { + majorName = majorlist.Single(s => s.Id == o.MajorId).MajorName, + mid = o.MajorId + }); + } + else if (o.sp == 1 && sp <= 5) + { + spmajors.Add(new RelatedMajorModel() + { + majorName = majorlist.Single(s => s.Id == o.MajorId).MajorName, + mid = o.MajorId + }); + } + } + }); + var graduateFlowinfo = (await d_GraduateFlowRepository.Query(x => x.UniversityId == query.Id && x.IsDelete == false)).FirstOrDefault(); + if (graduateFlowinfo != null) + { + result.graduateModels = new graduateModel() + { + provinces = graduateFlowinfo.Provinces, + attrs = graduateFlowinfo.Attrs + }; + } + + result.relatedMajors = majors; + result.relatespMajors = spmajors; + result.Status = 1; + + return result; + } + + /// + /// 获取专业介绍 + /// + /// + /// + public async Task GetMajorDetail(MajorQuery query) + { + var info = (await d_MajorInformationRepository.Query(x => x.MajorId == query.MajorId && x.IsDelete == false)).FirstOrDefault(); + if (info == null) + return new MajorDetail() { };//学校专业不匹配 获取专业概况信息为空 + return new MajorDetail() + { + id = info.Id, + abstracts = info.Majordescription.ClearHtml(), + maincourse = info.Majorcourse.ClearHtml(), + studydirection = info.Postgraduate.ClearHtml(), + workdirection = info.Majorintent.ClearHtml(), + Name = info.Name + }; + } + + /// + /// 相关院校 + /// + /// + /// + public async Task> GetRelevantSchool(MajorSchoolQuery query) + { + var majorinfo = await d_MajorMapUniversityRepository.Query(x => x.MajorId == query.MajorId && x.IsDelete == false); + if (majorinfo.Count <= 0) + return new PageModel() { }; + var universityids = majorinfo.Select(x => x.Universityid).ToList(); + var wheres = PredicateBuilder.New(); + wheres = wheres.And(x => x.IsDelete == false && universityids.Contains(x.Id)); + if (!string.IsNullOrEmpty(query.AreaName) && query.AreaName != "全国") + wheres = wheres.And(x => x.Area_Name.Contains(query.AreaName)); + if (query.SubjectLevel < 2) + wheres = wheres.And(x => x.Subject_Level == query.SubjectLevel); + if (query.Type >= 0) + wheres = wheres.And(x => x.Type == query.Type); + if (query.Nhef >= 0) + wheres = wheres.And(x => x.Nhef == query.Nhef); + if (query.Sff >= 0) + wheres = wheres.And(x => x.Sff == query.Sff); + if (query.Syl >= 0) + wheres = wheres.And(x => x.Syl == query.Syl); + wheres = wheres.And(x => x.Nature == query.Nature); + + var info = await d_UniversityRepository.QueryPage(wheres, query.PageIndex, query.PageSize, "Rank Asc"); + if (info.data.Count() <= 0) + return new PageModel() { }; + List list = new List() { }; + info.data = info.data.OrderBy(s => s.Rank).ToList(); + foreach (var t in info.data) + { + //string typeStr = GetUniversityTypeName(t.Type); + //string ascription = GetAscriptionName(t.Ascription); + //string syl = t.Syl == 1 ? "双一流" : ""; + //string nhefSff = GetNhefSff(t); + //string nature = t.Nature == 1 ? "公立" : "私立"; + //string naturedetail = string.Format("{0}{1}{2}", typeStr, ascription, syl); + list.Add(new UniversityResult() + { + Id = t.Id, + Logo = t.Logo, + Name = t.Name, + AreaName = t.Area_Name, + Nature = t.Nature, + //naturedetail = naturedetail, + Sff = t.Sff == 1, + Syl = t.Syl == 1, + Nhef = t.Nhef == 1, + UniversityType = t.Type, + Rank = t.Rank, + }); + } + return new PageModel() + { + data = list, + dataCount = info.dataCount, + page = info.page, + pageCount = info.pageCount, + PageSize = info.PageSize + }; + } + + /// + /// 获取专业就业前景 + /// + /// + /// + public async Task GetCareerProspects(MajorCareerQuery query) + { + var info = (await d_MajorObtainRepository.Query(x => x.MajorId == query.MajorId)).FirstOrDefault(); + if (info == null) + return new CareerProspects() { }; + CareerProspects result = new CareerProspects() { }; + List TradeDistribute = new List() { }; + var array = JsonHelper.ParseJson>(info.ObtainIndustryDis); + var arraynum = JsonHelper.ParseJson>(info.ObtainIndustryDisProportion.Replace("%", "")); + for (int i = 0; i < array.Count; i++) + { + TradeDistribute.Add(new distribution() { name = array[i], data = arraynum[i] }); + } + //就业地区 + List RegionDistribute = new List() { }; + var arrayarea = JsonHelper.ParseJson>(info.ObtainRegionalDis); + var arrayareanum = JsonHelper.ParseJson>(info.ObtainRegionalDisProportion.Replace("%", "")); + for (int i = 0; i < arrayarea.Count; i++) + { + RegionDistribute.Add(new distribution() { name = arrayarea[i], data = arrayareanum[i] }); + } + //工资情况 + List MoneyDistribute = new List() { }; + var arraymoney = JsonHelper.ParseJson>(info.WageSituation); + var arraymoneynum = JsonHelper.ParseJson>(info.WageProportion.Replace("%", "")); + for (int i = 0; i < arraymoney.Count; i++) + { + MoneyDistribute.Add(new distribution() { name = arraymoney[i], data = arraymoneynum[i] }); + } + //工作年限工资 WorkingYear + WorkingYear WorkingYear = new WorkingYear() { }; + WorkingYear.WorkingYears = info.WorkingYears; + WorkingYear.WorkingYearsWage = info.WorkingYearsWage; + result.RegionDistribute = RegionDistribute; + result.TradeDistribute = TradeDistribute; + result.MoneyDistribute = MoneyDistribute; + result.WorkingYear = WorkingYear; + return result; + } + + /// + /// 获取第三级 + /// + /// + /// + public async Task>> uniGetMajorThree(ManageMajorQuery query) + { + List info = new List() { }; + if (!string.IsNullOrWhiteSpace(query.Tags)) + { + if (query.Tags.Length != 3) + return new MessageModel>() { success = false, msg = "传入标签长度错误..." }; + //转化标签 + var tags = new List() { }; + string n = query.Tags; + string m = ""; + tags.AddRange(zuhe(n)); + for (int j = 2; j > -1; j--) + { + m = m + n[j]; + } + tags.AddRange(zuhe(m)); + var ids = (await d_MajorMapTagRepository.Query(x => x.Tag.Contains(tags[0]) || x.Tag.Contains(tags[1]) || x.Tag.Contains(tags[2]) || x.Tag.Contains(tags[3]) || x.Tag.Contains(tags[4]) || x.Tag.Contains(tags[5]))).Select(x => x.MajorId).ToList(); + if (ids.Count <= 0) + return new MessageModel>() { success = false, msg = "标签对应专业为空" }; + info = (await d_MajorRepository.Query(x => ids.Contains(x.Id) && x.IsDelete == false)).Select(x => new uniMajorInfo() { Id = x.Id, Name = x.MajorName }).ToList(); + + if (!string.IsNullOrWhiteSpace(query.SubjectClaim)) + { + var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + if (planinfo == null) + return new MessageModel>() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + var planid = planinfo.FirstOrDefault().Id; + var wheres = PredicateBuilder.New(); + wheres.And(x => x.IsDelete == false && x.PlanId == planid && x.Scoreline <= query.Score && x.UniversityId > 0); + if (query.SubjectClaim.Contains(",")) + { + var cc = query.SubjectClaim.Split(","); + if (cc.Length == 2) + { + var cc1 = cc[0]; + var cc2 = cc[1]; + wheres.And(x => (x.Subjectclaim.Contains("/") && x.Subjectclaim.Contains(cc1)) == true || (x.Subjectclaim.Contains(cc2) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(",") && x.Subjectclaim.Contains(query.SubjectClaim)) == true); + } + else if (cc.Length == 3) + { + var cc1 = cc[0]; + var cc2 = cc[1]; + var cc3 = cc[2]; + wheres.And(x => (x.Subjectclaim.Contains("/") && x.Subjectclaim.Contains(cc1)) == true || (x.Subjectclaim.Contains(cc2) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(cc3) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(",") && x.Subjectclaim.Contains(query.SubjectClaim)) == true); + } + } + else + { + wheres.And(x => x.Subjectclaim.Contains(query.SubjectClaim) && !x.Subjectclaim.Contains(",")); + } + var descinfo = await t_EnrollmentPlanedescRepository.Query(wheres); + var newmajorlist = descinfo.Select(x => x.MajorName).Distinct().ToList(); + info = info.Where(x => newmajorlist.Contains(x.Name)).ToList(); + } + } + else if (query.universityId > 0) + { + var majormapids = (await d_MajorMapUniversityRepository.Query(x => x.IsDelete == false && x.Universityid == query.universityId && x.MajorId > 0)).Select(x => x.MajorId).ToList(); + info = (await d_MajorRepository.Query(x => majormapids.Contains(x.Id) && x.IsDelete == false)).Select(x => new uniMajorInfo() { Id = x.Id, Name = x.MajorName }).ToList(); + } + else + { + var majorclasses = (await d_MajorClassRepository.Query(x => x.IsDelete == false)).Select(x => new uniMajorClassSelect() { Id = x.Id, Name = x.Name, TradeId = x.TradeId }); + var nowmajorname = majorclasses.Where(x => x.Id == query.categoryclassid).Select(x => x.Name)?.FirstOrDefault(); + var newmajorinfo = await d_MajorRepository.Query(x => x.IsDelete == false && x.CategoryClass_Id == query.categoryclassid); + info = newmajorinfo.Where(x => x.Name != nowmajorname).Select(x => new uniMajorInfo() { Id = x.Id, Name = x.MajorName }).ToList(); + } + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = info + }; + } + + /// + /// 根据标签推荐专业 + /// + /// + /// + public async Task>> GetMajorThreeByTag(MajorThreeByTagQuery query) + { + if (string.IsNullOrWhiteSpace(query.Tags)) + return new MessageModel>() { success = false, msg = "传入标签为空,请先去测试..." }; + if (query.Tags.Length != 3) + return new MessageModel>() { success = false, msg = "传入标签长度错误..." }; + //转化标签 + var tags = new List() { }; + string n = query.Tags; + string m = ""; + tags.AddRange(zuhe(n)); + for (int j = 2; j > -1; j--) + { + m = m + n[j]; + } + tags.AddRange(zuhe(m)); + var ids = (await d_MajorMapTagRepository.Query(x => x.Tag.Contains(tags[0]) || x.Tag.Contains(tags[1]) || x.Tag.Contains(tags[2]) || x.Tag.Contains(tags[3]) || x.Tag.Contains(tags[4]) || x.Tag.Contains(tags[5]))).Select(x => x.MajorId).ToList(); + if (ids.Count <= 0) + return new MessageModel>() { success = false, msg = "标签对应专业为空" }; + var info = (await d_MajorRepository.Query(x => ids.Contains(x.Id) && x.IsDelete == false)).Select(x => new uniMajorInfo() { Id = x.Id, Name = x.MajorName }).ToList(); + + if (!string.IsNullOrWhiteSpace(query.SubjectClaim)) + { + var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + if (planinfo == null) + return new MessageModel>() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + var planid = planinfo.FirstOrDefault().Id; + var wheres = PredicateBuilder.New(); + wheres.And(x => x.IsDelete == false && x.PlanId == planid && x.Scoreline <= query.Score && x.UniversityId > 0); + if (query.SubjectClaim.Contains(",")) + { + var cc = query.SubjectClaim.Split(","); + if (cc.Length == 2) + { + var cc1 = cc[0]; + var cc2 = cc[1]; + wheres.And(x => (x.Subjectclaim.Contains("/") && x.Subjectclaim.Contains(cc1)) == true || (x.Subjectclaim.Contains(cc2) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(",") && x.Subjectclaim.Contains(query.SubjectClaim)) == true); + } + else if (cc.Length == 3) + { + var cc1 = cc[0]; + var cc2 = cc[1]; + var cc3 = cc[2]; + wheres.And(x => (x.Subjectclaim.Contains("/") && x.Subjectclaim.Contains(cc1)) == true || (x.Subjectclaim.Contains(cc2) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(cc3) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(",") && x.Subjectclaim.Contains(query.SubjectClaim)) == true); + } + } + else + { + wheres.And(x => x.Subjectclaim.Contains(query.SubjectClaim) && !x.Subjectclaim.Contains(",")); + } + var descinfo = await t_EnrollmentPlanedescRepository.Query(wheres); + var newmajorlist = descinfo.Select(x => x.MajorName).Distinct().ToList(); + info = info.Where(x => newmajorlist.Contains(x.Name)).ToList(); + } + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = info + }; + } + + /// + /// 院校相关专业专用 + /// + /// + /// + public async Task> GetUniversityMajor(IdQuery query) + { + var majormapids = (await d_MajorMapUniversityRepository.Query(x => x.IsDelete == false && x.Universityid == query.Id && x.MajorId > 0)).Select(x => x.MajorId).ToList(); + var majorclass = (await d_MajorRepository.Query(x => x.IsDelete == false && majormapids.Contains(x.Id))); + var majorclassids = majorclass.Select(x => x.CategoryClass_Id).ToList(); + List list = new List() { }; + var majorclassinfo = await d_MajorClassRepository.Query(x => majorclassids.Contains(x.Id)); + foreach (var item in majorclassinfo) + { + List second = new List() { }; + second = majorclass.Where(x => x.CategoryClass_Id == item.Id).Select(x => new uniMajorSecond() + { + SecondId = x.Id, + MajorName = x.Name, + }).ToList(); + if (second.Count > 0) + list.Add(new uniMajorInfoResult() + { + FirstName = item.Name, + SecondInfo = second, + MajorNum = second.Count() + }); + } + return list; + } + + /// + /// 获取职业第三级 + /// + /// + /// + public async Task>> GetOccupationThree(IdQuery query) + { + StringBuilder stringBuilder = new StringBuilder() { }; + stringBuilder.AppendFormat("SELECT Id,Name FROM `D_Occupation` where CategoryId={0} and IsDelete=0", query.Id); + var info = await d_OccupationRepository.QuerySql(stringBuilder.ToString()); + if (info.Count <= 0) + return new MessageModel>() { success = false, msg = "数据为空" }; + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = info.Select(x => new IdNameResult() + { + Id = x.Id, + Name = x.Name + }).ToList() + }; + } + + /// + /// 获取职业详情-职业介绍 + /// + /// + public async Task GetRecommendIntroduce(IdQuery query) + { + if (query.Id <= 0) + return new OccupationDetailResult() { Status = -1 }; + var occupation = await d_OccupationRepository.QueryById(query.Id); + return new OccupationDetailResult() + { + Status = 1, + OccupationIntraduce = occupation.OccupationIntraduce.ClearHtml(), + Id = occupation.Id.ToString() + }; + } + + + /// + /// 查学校省份的 年份批次 + /// + /// + /// + public async Task GetBatchYearBySchoolId(PlanYearQuery query) + { + BatchYear result = new BatchYear() { }; + var info = await t_EnrollmentPlanedescRepository.Query(x => x.UniversityId == query.UnviersityId); + if (info.Count <= 0) + return new BatchYear() { }; + var batchids = info.Select(x => x.BatchtypeId).Distinct().ToList(); + var batchinfo = await t_EnrollmentBatchRepository.Query(x => batchids.Contains(x.Id) && x.AreaName == query.AreaName); + var batchselect = batchinfo.Select(x => x.Batch_name).Distinct().ToList(); + var yearselect = batchinfo.Select(x => x.Year).Distinct().OrderByDescending(x => x).ToList(); + var typeselect = batchinfo.Select(x => x.Type).Distinct().ToList(); + result.Batch = batchselect; + result.Year = yearselect; + result.Type = typeselect; + return result; + } + + /// + /// 获取招生计划 院校详情 + /// + /// + /// + public async Task> GetPlanBySchollId(PlanQuery query) + { + var check = await t_EnrollmentBatchRepository.Query(x => x.Type == query.Type && x.Year == query.Year && x.Batch_name == query.BatchName && x.AreaName == query.AreaName); + if (check.Count <= 0) + return new List() { }; + var batchid = check.Select(x => x.Id)?.FirstOrDefault(); + var info = await t_EnrollmentPlanedescRepository.Query(x => x.UniversityId == query.UnviersityId && x.BatchtypeId == batchid); + List list = new List() { }; + foreach (var item in info) + { + list.Add(new NewPlanDescList() + { + Name = item.MajorName, + Money = string.IsNullOrWhiteSpace(item.Tuitionfee) || item.Tuitionfee == "0" || item.Tuitionfee == "待定" ? "--" : item.Tuitionfee, + PlanNum = item.Plancount, + Scoreline = item.Scoreline == 0 || string.IsNullOrWhiteSpace(item.Scoreline.ToString()) ? "--" : item.Scoreline.ToString() + }); + } + return list; + } + + /// + /// 获取院校排名 + /// + /// + /// + public async Task> GetUniversityRank(UniversityRankQuery query) + { + var info = await d_UniversityRankRepository.Query(x => x.IsDelete == false && x.UniversityType == query.Type); + if (info.Count <= 0) + return new List() { }; + List list = new List() { }; + return info.OrderBy(x => x.OrderSort).Select(x => new UniversityRankList() { Name = x.UniversityName, Sort = x.Rank }).ToList(); + } + + /// + /// 专业搜索 + /// + /// + /// + public async Task>> uniGetSearchMajor(NameBaseQuery query) + { + var majorcategories = (await d_MajorCategoryRepository.Query(x => x.Type == query.Type && x.IsDelete == false)).Select(x => x.Id); ; + var majorclasses = (await d_MajorClassRepository.Query(x => x.IsDelete == false && majorcategories.Contains(x.TradeId))).Select(x => x.Id).ToList(); + + var info = await d_MajorRepository.QueryPage(x => majorclasses.Contains(x.CategoryClass_Id) && x.IsDelete == false && x.Name.Contains(query.Name), query.PageIndex, query.PageSize); + if (info.data.Count <= 0) + return new MessageModel>() { success = false, msg = "获取失败,数据为空" }; + List list = new List() { }; + foreach (var item in info.data) + { + list.Add(new IdNameResult() + { + Id = item.Id, + Name = item.Name + }); + } + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = new PageModel() + { + data = list, + dataCount = info.dataCount, + page = info.page, + pageCount = info.pageCount, + PageSize = info.PageSize + } + }; + } + + + #region 数据处理 + /// + /// 组合 + /// + /// + public List zuhe(string ssel) + { + var list = new List() { }; + string m1 = ""; + for (int i = 0; i < ssel.Length; i++) + { + m1 = ssel + ssel.Substring(i, 1); + list.Add(m1.Remove(i, 1)); + } + return list; + } + + /// + /// 获取学校类型 + /// + /// + /// + private string GetUniversityTypeName(int? type) + { + if (!Enum.IsDefined(typeof(EnumUniversityType), type)) + return ""; + //数字转为枚举 + EnumUniversityType enumUniversityType = (EnumUniversityType)Enum.ToObject(typeof(EnumUniversityType), type); + return CommonTools.GetDescription(enumUniversityType); + } + /// + /// 获取学校归属 + /// + /// + /// + public string GetAscriptionName(int AscriptionType) + { + if (AscriptionType == 1) + return "教育部"; + if (AscriptionType == 2) + return "省政府"; + return "教育部"; + } + /// + /// 获取学校性质 + /// + /// + /// + private string GetNhefSff(D_University t) + { + List array = new List(); + if (t.Nhef == 1) + array.Add("985"); + if (t.Sff == 1) + array.Add("211"); + string nhefSff = string.Join('、', array); + return nhefSff; + } + #endregion + + /// + /// 获取招生简章列表 + /// + /// + /// + public async Task>> GetRequestEnrollmentinproductionResult(UniversityIdQuery query) + { + var longinfo = (await _dal.Query(x => x.IsDelete == false && x.table == "D_University" && x.newid == query.Id)).FirstOrDefault(); + if (longinfo == null) + return new MessageModel>() { success = false, msg = "未找到数据" }; + RequestQuery request = new RequestQuery() { Id = longinfo.longid, PageIndex = query.PageIndex, PageSize = query.PageSize }; + + var stringBuilder = new StringBuilder(); + stringBuilder.AppendFormat("Id={0}&PageIndex={1}&PageSize={2}", longinfo.longid, query.PageIndex, query.PageSize); + var info = HttpHelper.GetApi("https://hbs.yrtsedu.cn/", "api/University/GetEnrollmentinproductions", stringBuilder.ToString()); + if (info.Success == false) + { + return new MessageModel>() { success = false, msg = "请求失败" }; + } + return new MessageModel>() + { + success = info.Success, + msg = "获取成功", + response = info.Data + }; + } + + /// + /// 获取招生简介详情 + /// + /// + /// + public async Task> GetRequestEnrollmentinproductionDetailResult(StringIdQuery query) + { + if (string.IsNullOrWhiteSpace(query.Id)) + { + return new MessageModel() { success = false, msg = "传入为空" }; + } + var stringBuilder = new StringBuilder(); + stringBuilder.AppendFormat("Id={0}", query.Id); + var info = HttpHelper.GetApi("https://hbs.yrtsedu.cn/", "api/University/GetEnrollmentinproductionDetali", stringBuilder.ToString()); + if (info.Success == false) + { + return new MessageModel() { success = false, msg = "请求失败" }; + } + return new MessageModel() + { + success = info.Success, + msg = "获取成功", + response = info.Data + }; + } + + + #region 数据导入 + + #region Majorcategory + ///// + ///// Majorcategory + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\Majorcategory.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string Name = dr["Name"].ToString(); + // string Sort = dr["Sort"].ToString(); + // string TradeName = dr["TradeName"].ToString(); + // string TradeNumber = dr["TradeNumber"].ToString(); + // string Type = dr["Type"].ToString(); + // var info = await d_MajorCategoryRepository.Add(new D_MajorCategory() + // { + // OrderSort = Convert.ToInt32(Sort), + // Name = Name, + // TradeName = TradeName, + // TradeNumber = TradeNumber, + // Type = Convert.ToInt32(Type) + // }); + // if (info > 0) + // { + // await _dal.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // } + + // return true; + //} + #endregion + + #region Majorclass + ///// + ///// Majorclass + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\Majorclass.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string Categoryname = dr["Categoryname"].ToString(); + // string Sort = dr["Sort"].ToString(); + // string TradeId = dr["TradeId"].ToString(); + // string Name = dr["Name"].ToString(); + + // var nowmapid = (await _dal.Query(x => x.longid == TradeId)).Select(x => x.newid).FirstOrDefault(); + // var info = await d_MajorClassRepository.Add(new D_MajorClass() + // { + // OrderSort = Convert.ToInt32(Sort), + // Name = Name, + // Categoryname = Categoryname, + // TradeId = nowmapid + // }); + // if (info > 0) + // { + // await _dal.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // } + + // return true; + //} + #endregion + + #region Major + ///// + ///// Major + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\Major.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string MajorName = dr["MajorName"].ToString(); + // string MajorCode = dr["MajorCode"].ToString(); + // string Name = dr["Name"].ToString(); + // string Type = dr["Type"].ToString(); + // string CategoryClass_Id = dr["CategoryClass_Id"].ToString(); + + // var nowmapid = mapinfo.Where(x => x.longid == CategoryClass_Id).Select(x => x.newid).FirstOrDefault(); + // var info = await d_MajorRepository.Add(new D_Major() + // { + // Name = Name, + // CategoryClass_Id = nowmapid, + // MajorCode = MajorCode, + // MajorName = MajorName, + // Type = Type == "" ? 0 : Convert.ToInt32(Type), + // }); + // if (info > 0) + // { + // await _dal.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // } + + // return true; + //} + #endregion + + #region OccupationCategory + ///// + ///// OccupationCategory + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\OccupationCategory.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // //var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string Level = dr["Level"].ToString(); + // string Name = dr["Name"].ToString(); + // string OccupationName = dr["OccupationName"].ToString(); + // var ParentId = dr["ParentId"].ToString() == "0" ? 0 : (await _dal.Query(x => x.longid == dr["ParentId"].ToString())).Select(x => x.newid).FirstOrDefault(); + // string Sort = dr["Sort"].ToString(); + // var info = await d_OccupationCategoryRepository.Add(new D_OccupationCategory() + // { + // Level = Convert.ToInt32(Level), + // Name = Name, + // OccupationName = OccupationName, + // ParentId = ParentId, + // OrderSort = Convert.ToInt32(Sort) + // }); + // if (info > 0) + // { + // await _dal.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // } + + // return true; + //} + #endregion + + #region Occupation + ///// + ///// Occupation + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\Occupation.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string CategoryId = dr["CategoryId"].ToString(); + // string Name = dr["Name"].ToString(); + // string OccupationIntraduce = dr["OccupationIntraduce"].ToString(); + // string OccupationName = dr["OccupationName"].ToString(); + // var newid = mapinfo.Where(x => x.longid == CategoryId).Select(x => x.newid).FirstOrDefault(); + + // var info = await d_OccupationRepository.Add(new D_Occupation () + // { + // CategoryId=newid, + // Name=Name, + // OccupationIntraduce=OccupationIntraduce, + // OccupationName=OccupationName, + // Recommend=0, + + // }); + // if (info > 0) + // { + // await _dal.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // } + + // return true; + //} + #endregion + + #region OccMapTag + ///// + ///// OccMapTag + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\OccMapTag.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string OccId = dr["OccId"].ToString(); + // string Name = dr["Name"].ToString(); + // string Tag = dr["Tag"].ToString(); + + // var newid = mapinfo.Where(x => x.longid == OccId).Select(x => x.newid).FirstOrDefault(); + + // var info = await d_OccMapTagRepository.Add(new D_OccMapTag () + // { + // Name=Name, + // OccId=newid, + // Tag=Tag + // }); + // if (info > 0) + // { + // await _dal.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // } + + // return true; + //} + #endregion + + #region MajorMapOccouption + ///// + ///// MajorMapOccouption + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\MajorMapOccouption.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string MajorId = dr["MajorId"].ToString(); + // string OccouptionId = dr["OccouptionId"].ToString(); + + + // var newMajorId = mapinfo.Where(x => x.longid == MajorId).Select(x => x.newid).FirstOrDefault(); + // var newOccouptionId = mapinfo.Where(x => x.longid == OccouptionId).Select(x => x.newid).FirstOrDefault(); + + // var info = await d_MajorMapOccouptionRepository.Add(new D_MajorMapOccouption() + // { + // MajorId = newMajorId, + // OccouptionId = newOccouptionId + // }); + // if (info > 0) + // { + // await _dal.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // } + + // return true; + //} + #endregion + + #region MajorMapTag + ///// + ///// MajorMapTag + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\MajorMapTag.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // List list = new List() { }; + // var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string MajorId = dr["MajorId"].ToString(); + // string Name = dr["Name"].ToString(); + // string Tag = dr["Tag"].ToString(); + + // var newMajorId = mapinfo.Where(x => x.longid == MajorId).Select(x => x.newid).FirstOrDefault(); + // var info = await d_MajorMapTagRepository.Add(new D_MajorMapTag() + // { + // MajorId = newMajorId, + // Name=Name, + // Tag=Tag, + // }); + // if (info > 0) + // { + // list.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // await _dal.Add(list); + // } + + // return true; + //} + #endregion + + #region MajorObtain + ///// + ///// MajorObtain + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\MajorObtain.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // List list = new List() { }; + // var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string AverageWage = dr["AverageWage"].ToString(); + // string EducationalBackgroundRatio = dr["EducationalBackgroundRatio"].ToString(); + // string EducationRequirements = dr["EducationRequirements"].ToString(); + // string EmploymentDirection = dr["EmploymentDirection"].ToString(); + // string Experience = dr["Experience"].ToString(); + // string ExperienceRatio = dr["ExperienceRatio"].ToString(); + // string MajorId = dr["MajorId"].ToString(); + // string MajorName = dr["MajorName"].ToString(); + // string ObtainIndustryDis = dr["ObtainIndustryDis"].ToString(); + // string ObtainIndustryDisProportion = dr["ObtainIndustryDisProportion"].ToString(); + // string ObtainMoreArea = dr["ObtainMoreArea"].ToString(); + // string ObtainMostIndustries = dr["ObtainMostIndustries"].ToString(); + // string ObtainRank = dr["ObtainRank"].ToString(); + // string ObtainRankDetail = dr["ObtainRankDetail"].ToString(); + // string ObtainRegionalDis = dr["ObtainRegionalDis"].ToString(); + // string ObtainRegionalDisProportion = dr["ObtainRegionalDisProportion"].ToString(); + // string Position = dr["Position"].ToString(); + // string WageProportion = dr["WageProportion"].ToString(); + // string WageSituation = dr["WageSituation"].ToString(); + // string WorkingYears = dr["WorkingYears"].ToString(); + // string WorkingYearsWage = dr["WorkingYearsWage"].ToString(); + + // var newMajorId = mapinfo.Where(x => x.longid == MajorId).Select(x => x.newid).FirstOrDefault(); + // var info = await d_MajorObtainRepository.Add(new D_MajorObtain() + // { + // MajorId = newMajorId, + // AverageWage = AverageWage, + // ObtainMoreArea = ObtainMoreArea, + // EducationalBackgroundRatio = EducationalBackgroundRatio, + // EducationRequirements = EducationRequirements, + // EmploymentDirection = EmploymentDirection, + // Experience = Experience, + // ExperienceRatio = ExperienceRatio, + // ObtainIndustryDis = ObtainIndustryDis, + // MajorName = MajorName, + // ObtainRank = ObtainRank, + // ObtainIndustryDisProportion = ObtainIndustryDisProportion, + // ObtainMostIndustries = ObtainMostIndustries, + // ObtainRankDetail = ObtainRankDetail, + // ObtainRegionalDis = ObtainRegionalDis, + // Position = Position, + // ObtainRegionalDisProportion = ObtainRegionalDisProportion, + // WageProportion = WageProportion, + // WageSituation = WageSituation, + // WorkingYears = WorkingYears, + // WorkingYearsWage = WorkingYearsWage + // }); + // if (info > 0) + // { + // list.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // await _dal.Add(list); + // } + + // return true; + //} + #endregion + + #region University + ///// + ///// University + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\University.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // List list = new List() { }; + // //var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string Area_Name = dr["Area_Name"].ToString(); + // string Ascription = dr["Ascription"].ToString(); + // string AscriptionName = dr["AscriptionName"].ToString(); + // string Description = dr["Description"].ToString(); + // string Doctorate_Count = dr["Doctorate_Count"].ToString(); + // string Logo = dr["Logo"].ToString(); + // string Master_Count = dr["Master_Count"].ToString(); + // string Name = dr["Name"].ToString(); + // string Nature = dr["Nature"].ToString(); + // string Nhef = dr["Nhef"].ToString(); + // string Rank = dr["Rank"].ToString(); + // string Sff = dr["Sff"].ToString(); + // string Subject_Level = dr["Subject_Level"].ToString(); + // string Syl = dr["Syl"].ToString(); + // string Type = dr["Type"].ToString(); + // string Web = dr["Web"].ToString(); + + // //var newMajorId = mapinfo.Where(x => x.longid == MajorId).Select(x => x.newid).FirstOrDefault(); + // var info = await d_UniversityRepository.Add(new D_University() + // { + // Name = Name, + // Area_Name = Area_Name, + // Ascription = Ascription == "" ? 0 : Convert.ToInt32(Ascription), + // AscriptionName = AscriptionName, + // Description = Description, + // Doctorate_Count = Doctorate_Count == "" ? 0 : Convert.ToInt32(Doctorate_Count), + // Logo = Logo, + // Master_Count = Master_Count == "" ? 0 : Convert.ToInt32(Master_Count), + // Nature = Nature == "" ? 0 : Convert.ToInt32(Nature), + // Nhef = Nhef == "" ? 0 : Convert.ToInt32(Nhef), + // Rank = Rank == "" ? 0 : Convert.ToInt32(Rank), + // Sff = Sff == "" ? 0 : Convert.ToInt32(Sff), + // Web = Web, + // Type = Type == "" ? 0 : Convert.ToInt32(Type), + // Syl = Syl == "" ? 0 : Convert.ToInt32(Syl), + // Subject_Level = Subject_Level == "" ? 0 : Convert.ToInt32(Subject_Level), + + // }); + // if (info > 0) + // { + // list.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // await _dal.Add(list); + // } + // return true; + //} + #endregion + + #region Universityimg + ///// + ///// Universityimg + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\Universityimg.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // List list = new List() { }; + // var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string ImgList = dr["ImgList"].ToString(); + // string UniversityId = dr["UniversityId"].ToString(); + + // var newuniversityid = mapinfo.Where(x => x.longid == UniversityId).Select(x => x.newid).FirstOrDefault(); + // var info = await d_UniversityimgRepository.Add(new D_Universityimg() + // { + // ImgList=ImgList, + // UniversityId=newuniversityid, + // }); + // if (info > 0) + // { + // list.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // await _dal.Add(list); + // } + // return true; + //} + #endregion + + #region UniversityRank + ///// + ///// UniversityRank + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\UniversityRank.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // List list = new List() { }; + // //var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string Rank = dr["Rank"].ToString(); + // string UniversityName = dr["UniversityName"].ToString(); + // string UniversityType = dr["UniversityType"].ToString(); + // string Year = dr["Year"].ToString(); + + // //var newuniversityid = mapinfo.Where(x => x.longid == UniversityId).Select(x => x.newid).FirstOrDefault(); + // var info = await d_UniversityRankRepository.Add(new D_UniversityRank() + // { + // Rank = Convert.ToInt32(Rank), + // UniversityName = UniversityName, + // UniversityType = Convert.ToInt32(UniversityType), + // Year = Year + // }); + // if (info > 0) + // { + // list.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // await _dal.Add(list); + // } + // return true; + //} + #endregion + + #region MajorMapUniversity + ///// + ///// MajorMapUniversity + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\MajorMapUniversity.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // List list = new List() { }; + // var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string Universityid = dr["Universityid"].ToString(); + // string majorid = dr["majorid"].ToString(); + + + // var newuniversityid = mapinfo.Where(x => x.longid == Universityid).Select(x => x.newid).FirstOrDefault(); + // var newmajorid = mapinfo.Where(x => x.longid == majorid).Select(x => x.newid).FirstOrDefault(); + // var info = await d_MajorMapUniversityRepository.Add(new D_MajorMapUniversity() + // { + // MajorId = newmajorid, + // Universityid = newuniversityid, + // sp = 0 + // }); + // if (info > 0) + // { + // list.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // await _dal.Add(list); + // } + // return true; + //} + #endregion + + #region Majorinformation + ///// + ///// Majorinformation + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\Majorinformation.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // List list = new List() { }; + // var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string Name = dr["Name"].ToString(); + // string Universityid = dr["Universityid"].ToString(); + // string MajorId = dr["MajorId"].ToString(); + // string Majorcourse = dr["Majorcourse"].ToString(); + // string Majorintent = dr["Majorintent"].ToString(); + // string Majordescription = dr["Majordescription"].ToString(); + // string Skill = dr["Skill"].ToString(); + // string Postgraduate = dr["Postgraduate"].ToString(); + + // var newuniversityid = mapinfo.Where(x => x.longid == Universityid).Select(x => x.newid).FirstOrDefault(); + // var newmajorid = mapinfo.Where(x => x.longid == MajorId).Select(x => x.newid).FirstOrDefault(); + // var info = await d_MajorInformationRepository.Add(new D_MajorInformation() + // { + // Name = Name, + // UniversityId = newuniversityid <= 0 ? 0 : newuniversityid, + // MajorId = newmajorid <= 0 ? 0 :newmajorid, + // Majorcourse = Majorcourse, + // Majordescription = Majordescription, + // Majorintent = Majorintent, + // Skill = Skill, + // Postgraduate = Postgraduate + // }); + // if (info > 0) + // { + // list.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // await _dal.Add(list); + // } + // return true; + //} + #endregion + + #region GraduateFlow + ///// + ///// GraduateFlow + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\GraduateFlow.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // List list = new List() { }; + // var mapinfo = await _dal.Query(x => x.IsDelete == false); + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string id = dr["_id"].ToString(); + // string universityId = dr["universityId"].ToString(); + // string provinces = dr["provinces"].ToString(); + // string attrs = dr["attrs"].ToString(); + + // var newuniversityid = mapinfo.Where(x => x.longid == universityId).Select(x => x.newid).FirstOrDefault(); + // var info = await d_GraduateFlowRepository.Add(new D_GraduateFlow() + // { + // Attrs = attrs, + // Provinces = provinces, + // UniversityId = newuniversityid, + // OrderSort = 0 + // }); + // if (info > 0) + // { + // list.Add(new D_LongIdMap() { longid = id, newid = info }); + // } + // } + // await _dal.Add(list); + // } + // return true; + //} + #endregion + #endregion + + + #region 院校排序 + /// + /// 院校排序 + /// + /// + public async Task Import() + { + var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\院校专业职业\\院校排名.xlsx"); + if (dataSet.Tables.Count > 0) + { + var stringBuilderinfo = new StringBuilder(); + stringBuilderinfo.AppendFormat("select Id,Name,Logo,Nhef,Sff,Syl,Area_Name,AscriptionName from D_University where IsDelete=0"); + var info = await d_UniversityRepository.QuerySql(stringBuilderinfo.ToString()); + + List list = new List() { }; + foreach (DataRow dr in dataSet.Tables[0].Rows) + { + var rank = Convert.ToInt32(dr["排序"].ToString()); + var name = dr["院校名称"].ToString(); + var nowinfo = info.Where(x => x.Name == name).FirstOrDefault(); + if (nowinfo != null) + { + nowinfo.Rank = rank; + list.Add(nowinfo); + } + } + await d_UniversityRepository.Update(list); + } + + return true; + } + #endregion + } +} \ No newline at end of file diff --git a/New_College.Services/D_MajorCategoryServices.cs b/New_College.Services/D_MajorCategoryServices.cs new file mode 100644 index 0000000..7bcf1ce --- /dev/null +++ b/New_College.Services/D_MajorCategoryServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_MajorCategoryServices : BaseServices, ID_MajorCategoryServices + { + private readonly IBaseRepository _dal; + public D_MajorCategoryServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_MajorClassServices.cs b/New_College.Services/D_MajorClassServices.cs new file mode 100644 index 0000000..31247e7 --- /dev/null +++ b/New_College.Services/D_MajorClassServices.cs @@ -0,0 +1,41 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using System.Collections.Generic; +using New_College.Model.ViewModels; +using System.Threading.Tasks; +using New_College.IRepository; +using System.Linq; + +namespace New_College.Services +{ + public class D_MajorClassServices : BaseServices, ID_MajorClassServices + { + private readonly IBaseRepository _dal; + private readonly ID_MajorCategoryRepository d_MajorCategoryRepository; + public D_MajorClassServices(IBaseRepository dal + , ID_MajorCategoryRepository ID_MajorCategoryRepository) + { + this._dal = dal; + d_MajorCategoryRepository = ID_MajorCategoryRepository; + base.BaseDal = dal; + } + + /// + /// 专业分类列表(二级) 传Id 1本科 2 专科 获取一级分类 + /// + /// + /// + public async Task> GetMajorClassListByType(IdQuery query) + { + var majorcate = await d_MajorCategoryRepository.Query(x => x.Type == query.Id && x.IsDelete == false); + if (majorcate.Count <= 0) + return new List() { }; + //var cateids = majorcate.Select(x => x.Id).ToList(); + //var info = await _dal.Query(x => cateids.Contains(x.TradeId) && x.IsDelete == false); + return majorcate.Select(x => new IdNameResult() { Id = x.Id, Name = x.Name }).ToList(); + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_MajorInformationServices.cs b/New_College.Services/D_MajorInformationServices.cs new file mode 100644 index 0000000..a54d9c0 --- /dev/null +++ b/New_College.Services/D_MajorInformationServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_MajorInformationServices : BaseServices, ID_MajorInformationServices + { + private readonly IBaseRepository _dal; + public D_MajorInformationServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_MajorMapOccouptionServices.cs b/New_College.Services/D_MajorMapOccouptionServices.cs new file mode 100644 index 0000000..5053ece --- /dev/null +++ b/New_College.Services/D_MajorMapOccouptionServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_MajorMapOccouptionServices : BaseServices, ID_MajorMapOccouptionServices + { + private readonly IBaseRepository _dal; + public D_MajorMapOccouptionServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_MajorMapTagServices.cs b/New_College.Services/D_MajorMapTagServices.cs new file mode 100644 index 0000000..8a7dbc5 --- /dev/null +++ b/New_College.Services/D_MajorMapTagServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_MajorMapTagServices : BaseServices, ID_MajorMapTagServices + { + private readonly IBaseRepository _dal; + public D_MajorMapTagServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_MajorMapUniversityServices.cs b/New_College.Services/D_MajorMapUniversityServices.cs new file mode 100644 index 0000000..c8f50e7 --- /dev/null +++ b/New_College.Services/D_MajorMapUniversityServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_MajorMapUniversityServices : BaseServices, ID_MajorMapUniversityServices + { + private readonly IBaseRepository _dal; + public D_MajorMapUniversityServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_MajorObtainServices.cs b/New_College.Services/D_MajorObtainServices.cs new file mode 100644 index 0000000..0901056 --- /dev/null +++ b/New_College.Services/D_MajorObtainServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_MajorObtainServices : BaseServices, ID_MajorObtainServices + { + private readonly IBaseRepository _dal; + public D_MajorObtainServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_MajorSalaryServices.cs b/New_College.Services/D_MajorSalaryServices.cs new file mode 100644 index 0000000..dc25ee1 --- /dev/null +++ b/New_College.Services/D_MajorSalaryServices.cs @@ -0,0 +1,128 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.Common.Excel; +using System.Linq; +using System.Collections.Generic; +using System.Data; +using System.Threading.Tasks; +using New_College.IRepository; +using New_College.Model.ViewModels; +using New_College.Model; + +namespace New_College.Services +{ + public class D_MajorSalaryServices : BaseServices, ID_MajorSalaryServices + { + private readonly IBaseRepository _dal; + private readonly ID_MajorRepository d_MajorRepository; + private readonly ID_MajorClassRepository d_MajorClassRepository; + private readonly ID_MajorCategoryRepository d_MajorCategoryRepository; + + public D_MajorSalaryServices(IBaseRepository dal + , ID_MajorRepository ID_MajorRepository + , ID_MajorClassRepository ID_MajorClassRepository + , ID_MajorCategoryRepository ID_MajorCategoryRepository) + { + this._dal = dal; + d_MajorRepository = ID_MajorRepository; + d_MajorClassRepository = ID_MajorClassRepository; + d_MajorCategoryRepository = ID_MajorCategoryRepository; + base.BaseDal = dal; + } + + #region 专业薪酬 + /// + /// 专业薪酬 + /// + /// + public async Task Import() + { + var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\新版志愿好帮手\\专业薪酬.xlsx"); + if (dataSet.Tables.Count > 0) + { + List list = new List() { }; + var majorinfo = await d_MajorRepository.Query(x => x.IsDelete == false); + List nohave = new List() { }; + foreach (DataRow dr in dataSet.Tables[0].Rows) + { + string majorname = dr["专业名称"].ToString(); + string Salary = dr["薪资水平"].ToString(); + + + var majorid = majorinfo.Where(x => x.MajorName == majorname).Select(x => x.Id).FirstOrDefault(); + if (majorid <= 0) + { + nohave.Add(majorname); + continue; + } + var info = await _dal.Add(new D_MajorSalary() + { + Salary = float.Parse(Salary), + MajorName = majorname, + MajorId = majorid + }); + } + var nohavestring = string.Join(",", nohave); + await _dal.Add(list); + } + return true; + } + #endregion + + /// + /// 获取高薪推荐 type传1位本科 传2位专科 + /// + /// + /// + public async Task>> GetMajorSalaryResult(MajorSalaryQuery query) + { + var majorcate = await d_MajorCategoryRepository.Query(x => x.Type == query.Type); + if (majorcate.Count <= 0) + return new MessageModel>() { success = false, msg = "获取失败,数据为空" }; + var majorcateids = majorcate.Select(x => x.Id).ToList(); + var majorclass = await d_MajorClassRepository.Query(x => majorcateids.Contains(x.TradeId) && x.IsDelete == false); + if (majorclass.Count <= 0) + return new MessageModel>() { success = false, msg = "获取失败,数据为空" }; + var majorclassids = majorclass.Select(x => x.Id).ToList(); + var major = await d_MajorRepository.Query(x => majorclassids.Contains(x.CategoryClass_Id) && x.IsDelete == false); + if (major.Count <= 0) + return new MessageModel>() { success = false, msg = "获取失败,数据为空" }; + var majorids = major.Select(x => x.Id).ToList(); + List list = new List() { }; + var info = await _dal.QueryPage(x => x.IsDelete == false && majorids.Contains(x.MajorId), query.PageIndex, query.PageSize, "Salary desc"); + if (info.data.Count <= 0) + return new MessageModel>() { success = false, msg = "获取失败,数据为空" }; + foreach (var item in info.data) + { + var nowinfo = major.Where(x => x.Id == item.MajorId).FirstOrDefault(); + var majorclassinfo = majorclass.Where(x => x.Id == nowinfo.CategoryClass_Id).FirstOrDefault(); + if (majorclassinfo == null) + continue; + list.Add(new MajorSalaryResult() + { + MajorId=item.MajorId, + MajorName = item.MajorName, + Money = item.Salary, + ParentName = majorclassinfo.Name, + Type = query.Type == 1 ? "本科" : "专科" + }); + } + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = new PageModel() + { + data = list, + dataCount = info.dataCount, + page = info.page, + pageCount = info.pageCount, + PageSize = info.PageSize + } + }; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_MajorServices.cs b/New_College.Services/D_MajorServices.cs new file mode 100644 index 0000000..e05ee6d --- /dev/null +++ b/New_College.Services/D_MajorServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_MajorServices : BaseServices, ID_MajorServices + { + private readonly IBaseRepository _dal; + public D_MajorServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_OccMapTagServices.cs b/New_College.Services/D_OccMapTagServices.cs new file mode 100644 index 0000000..5161f53 --- /dev/null +++ b/New_College.Services/D_OccMapTagServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_OccMapTagServices : BaseServices, ID_OccMapTagServices + { + private readonly IBaseRepository _dal; + public D_OccMapTagServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_OccupationCategoryServices.cs b/New_College.Services/D_OccupationCategoryServices.cs new file mode 100644 index 0000000..c6afdcb --- /dev/null +++ b/New_College.Services/D_OccupationCategoryServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_OccupationCategoryServices : BaseServices, ID_OccupationCategoryServices + { + private readonly IBaseRepository _dal; + public D_OccupationCategoryServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_OccupationServices.cs b/New_College.Services/D_OccupationServices.cs new file mode 100644 index 0000000..4d2393a --- /dev/null +++ b/New_College.Services/D_OccupationServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_OccupationServices : BaseServices, ID_OccupationServices + { + private readonly IBaseRepository _dal; + public D_OccupationServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_UniversityCollectionServices.cs b/New_College.Services/D_UniversityCollectionServices.cs new file mode 100644 index 0000000..43873e8 --- /dev/null +++ b/New_College.Services/D_UniversityCollectionServices.cs @@ -0,0 +1,217 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.Model; +using New_College.Model.ViewModels; +using System.Threading.Tasks; +using System.Collections.Generic; +using New_College.IRepository; +using System.Linq; + +namespace New_College.Services +{ + public class D_UniversityCollectionServices : BaseServices, ID_UniversityCollectionServices + { + private readonly IBaseRepository _dal; + private readonly ID_UniversityRepository d_UniversityRepository; + private readonly ID_MajorMapUniversityRepository d_MajorMapUniversityRepository; + private readonly ISysRegionRepository sysRegionRepository; + + public D_UniversityCollectionServices(IBaseRepository dal + , ID_UniversityRepository ID_UniversityRepository + , ID_MajorMapUniversityRepository ID_MajorMapUniversityRepository + , ISysRegionRepository ISysRegionRepository) + { + this._dal = dal; + d_UniversityRepository = ID_UniversityRepository; + d_MajorMapUniversityRepository = ID_MajorMapUniversityRepository; + sysRegionRepository = ISysRegionRepository; + base.BaseDal = dal; + } + + /// + /// 获取收藏和对比 + /// + /// + /// + public async Task>> GetUniversityCollection(UniversityCollectionQuery query) + { + var info = await _dal.QueryPage(x => x.CustomerId == query.CustomerId && x.IsDelete == false && x.Type == query.Type, query.PageIndex, query.PageSize, "CreateTime desc"); + if (info.data.Count <= 0) + return new MessageModel>() { success = false, msg = "数据为空" }; + var universityids = info.data.Select(x => x.UniversityId).ToList(); + var universityinfo = await d_UniversityRepository.Query(x => x.IsDelete == false && universityids.Contains(x.Id)); + + var HaveContrast = await _dal.Query(x => x.CustomerId == query.CustomerId && x.IsDelete == false && x.Type == 2); + List list = new List() { }; + foreach (var item in info.data) + { + var nowinfo = universityinfo.Where(x => x.Id == item.UniversityId)?.FirstOrDefault(); + if (nowinfo == null) + continue; + List attribute = new List() { }; + //if (nowinfo.Nhef == 1) + // attribute.Add("985"); + //if (nowinfo.Sff == 1) + // attribute.Add("211"); + //if (nowinfo.Syl == 1) + // attribute.Add("双一流"); + list.Add(new UniversityCollectionResult() + { + Id = item.Id, + UniversityId = nowinfo.Id, + Logo = nowinfo.Logo, + Syl = nowinfo.Syl == 1, + Nhef = nowinfo.Nhef == 1, + Sff = nowinfo.Sff == 1, + //Tags = attribute, + Name = nowinfo.Name, + IsContrast = HaveContrast.Count(x => x.UniversityId == item.UniversityId) > 0, + IsCollection = true + }); + } + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = new PageModel() + { + data = list, + dataCount = info.dataCount, + page = info.page, + pageCount = info.pageCount, + PageSize = info.PageSize + } + }; + } + + /// + /// 删除 + /// + /// + /// + public async Task> DeleteCollection(UniversityCollectionAddQuery query) + { + if (query.UniversityId <= 0) + return new MessageModel() { success = false, msg = "请先选择删除项" }; + var info = await _dal.Query(x => x.CustomerId == query.CustomerId && x.UniversityId == query.UniversityId && x.Type == query.Type); + if (info.Count <= 0) + return new MessageModel() { success = false, msg = "所选不存在,或已被删除" }; + foreach (var item in info) + { + item.IsDelete = true; + } + var result = await _dal.Update(info); + if (result) + { + return new MessageModel() { success = true, msg = "删除成功" }; + } + else + { + return new MessageModel() { success = false, msg = "删除失败" }; + } + } + + /// + /// 添加收藏、对比 + /// + /// + /// + public async Task> AddCollection(UniversityCollectionAddQuery query) + { + var info = await _dal.Query(x => x.IsDelete == false && x.CustomerId == query.CustomerId && x.Type == query.Type && x.UniversityId == query.UniversityId); + if (info.Count() > 0) + return new MessageModel() { success = false, msg = "添加失败,所选院校已加入成功" }; + var result = await _dal.Add(new D_UniversityCollection() + { + CustomerId = query.CustomerId, + Type = query.Type, + UniversityId = query.UniversityId + }); + if (result > 0) + { + return new MessageModel() { success = true, msg = "添加成功" }; + } + else + { + return new MessageModel() { success = false, msg = "添加失败" }; + } + } + + /// + /// 获取院校对比结果 + /// + /// + public async Task>> GetUniversityContrasts(IdQuery query) + { + if (query.Ids == null || query.Ids.Count <= 0) + return new MessageModel>() { success = false, msg = "请选择需要对比的院校" }; + var info = await d_UniversityRepository.Query(x => x.IsDelete == false && query.Ids.Contains(x.Id)); + if (info.Count <= 0) + return new MessageModel>() { success = false, msg = "需要对比的院校数据为空" }; + var majormap = await d_MajorMapUniversityRepository.Query(x => query.Ids.Contains(x.Universityid) && x.IsDelete == false); + List list = new List() { }; + foreach (var c in info) + { + list.Add(new UniversitycontrastResult + { + Id = c.Id, + Name = c.Name, + Nature = c.Nature == 1 ? "公立" : "私立", + AscriptionName = string.IsNullOrWhiteSpace(c.AscriptionName) ? "-" : c.AscriptionName, + Rank = c.Rank, + AreaName = c.Area_Name, + Syl = c.Syl == 1 ? "是" : "否", + Nhef = c.Nhef == 1 ? "是" : "否", + Sff = c.Sff == 1 ? "是" : "否", + UniversityType = c.Type == 0 ? "综合" : c.Type == 1 ? "理工" : "医学类", + BuildDate = c.Build_Date, + SubjectLevel = c.Subject_Level == 1 ? "本科" : c.Subject_Level == 2 ? "专科" : "-", + AcademicianCount = c.Academician_Count <= 0 ? "-" : c.Academician_Count.ToString(), + DoctorateCount = c.Doctorate_Count <= 0 ? "-" : c.Doctorate_Count.ToString(), + MasterCount = c.Master_Count.ToString(), + MajorNum = majormap.Count(x => x.Universityid == c.Id).ToString() + }); + } + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = list + }; + } + + + /// + /// 报告 获取我喜欢的院校 + /// + /// + /// + public async Task>> GetUniversityMap(IdQuery query) + { + var info = await _dal.Query(x => x.IsDelete == false && x.CustomerId == query.Id && x.Type == 1); + if (info.Count <= 0) + return new MessageModel>() { success = false, msg = "暂未收藏学校" }; + var universityids = info.Select(x => x.UniversityId).ToList(); + var universityinfo = await d_UniversityRepository.Query(x => universityids.Contains(x.Id) && x.IsDelete == false,"Rank Asc"); + if (universityinfo.Count <= 0) + return new MessageModel>() { success = false, msg = "学校数据为空" }; + var arealist = universityinfo.Select(x => x.Area_Name).Distinct().ToList(); + var regioninfo = await sysRegionRepository.Query(x => arealist.Contains(x.RegionName)); + if (regioninfo.Count <= 0) + return new MessageModel>() { success = false, msg = "省份数据为空" }; + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = regioninfo.Select(x => new UniversityCollectionByMapResult() + { + Lat = x.Lat, + Lng = x.Lng + }).ToList() + }; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_UniversityRankServices.cs b/New_College.Services/D_UniversityRankServices.cs new file mode 100644 index 0000000..37d24e0 --- /dev/null +++ b/New_College.Services/D_UniversityRankServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_UniversityRankServices : BaseServices, ID_UniversityRankServices + { + private readonly IBaseRepository _dal; + public D_UniversityRankServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_UniversityServices.cs b/New_College.Services/D_UniversityServices.cs new file mode 100644 index 0000000..80a34a2 --- /dev/null +++ b/New_College.Services/D_UniversityServices.cs @@ -0,0 +1,77 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using System.Threading.Tasks; +using System.Threading; +using System.Net; +using System.IO; +using System.Collections.Generic; +using New_College.Model.ViewModels; +using New_College.Model; +using System.Linq; + +namespace New_College.Services +{ + public class D_UniversityServices : BaseServices, ID_UniversityServices + { + private readonly IBaseRepository _dal; + public D_UniversityServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + /// + /// 下载图片 + /// + /// + public async Task SaveImg() + { + var info = await _dal.QuerySql("SELECT Logo FROM `D_University`"); + foreach (var item in info) + { + var url = item.Logo; + if (!string.IsNullOrWhiteSpace(url)) + { + var name = item.Logo.Substring(item.Logo.LastIndexOf("/")); + if (!System.IO.File.Exists("D:\\Ashuju\\schoologo\\" + name + "")) + { + WebClient my = new WebClient(); + byte[] mybyte; + mybyte = my.DownloadData(url); + MemoryStream ms = new MemoryStream(mybyte); + System.Drawing.Image img; + img = System.Drawing.Image.FromStream(ms); + img.Save("D:\\Ashuju\\schoologo\\" + name + ""); //保存 + } + } + } + return true; + } + + + /// + /// 获取搜索学校 + /// + /// + /// + public async Task>> GetUniversitList(NameQuery query) + { + var info = await _dal.Query(x => x.Name.Contains(query.Name) && x.IsDelete == false); + if (info.Count <= 0) + return new MessageModel>() { success = false, msg = "获取失败,数据为空" }; + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = info.Select(x => new IdNameResult() + { + Id = x.Id, + Name = x.Name + }).ToList() + }; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_UniversityimgServices.cs b/New_College.Services/D_UniversityimgServices.cs new file mode 100644 index 0000000..f8eafe1 --- /dev/null +++ b/New_College.Services/D_UniversityimgServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_UniversityimgServices : BaseServices, ID_UniversityimgServices + { + private readonly IBaseRepository _dal; + public D_UniversityimgServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/GuestbookServices.cs b/New_College.Services/GuestbookServices.cs new file mode 100644 index 0000000..e1b4400 --- /dev/null +++ b/New_College.Services/GuestbookServices.cs @@ -0,0 +1,140 @@ +using New_College.Common; +using New_College.IRepository.Base; +using New_College.IRepository.UnitOfWork; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Models; +using New_College.Services.BASE; +using System; +using System.Threading.Tasks; + +namespace New_College.Services +{ + public class GuestbookServices : BaseServices, IGuestbookServices + { + private readonly IBaseRepository _dal; + private readonly IUnitOfWork _unitOfWork; + private readonly IBaseRepository _passwordLibRepository; + public GuestbookServices(IUnitOfWork unitOfWork, IBaseRepository dal, IBaseRepository passwordLibRepository) + { + this._dal = dal; + base.BaseDal = dal; + _unitOfWork = unitOfWork; + _passwordLibRepository = passwordLibRepository; + } + + public async Task> TestTranInRepository() + { + try + { + Console.WriteLine($""); + Console.WriteLine($"事务操作开始"); + _unitOfWork.BeginTran(); + Console.WriteLine($""); + + Console.WriteLine($"insert a data into the table PasswordLib now."); + var insertPassword = await _passwordLibRepository.Add(new PasswordLib() + { + IsDeleted = false, + plAccountName = "aaa", + plCreateTime = DateTime.Now + }); + + + var passwords = await _passwordLibRepository.Query(d => d.IsDeleted == false); + Console.WriteLine($"second time : the count of passwords is :{passwords.Count}"); + + //...... + + Console.WriteLine($""); + var guestbooks = await _dal.Query(); + Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}"); + + int ex = 0; + Console.WriteLine($"\nThere's an exception!!"); + int throwEx = 1 / ex; + + Console.WriteLine($"insert a data into the table Guestbook now."); + var insertGuestbook = await _dal.Add(new Guestbook() + { + username = "bbb", + blogId = 1, + createdate = DateTime.Now, + isshow = true + }); + + guestbooks = await _dal.Query(); + Console.WriteLine($"second time : the count of guestbooks is :{guestbooks.Count}"); + + + _unitOfWork.CommitTran(); + + return new MessageModel() + { + success = true, + msg = "操作完成" + }; + } + catch (Exception) + { + _unitOfWork.RollbackTran(); + var passwords = await _passwordLibRepository.Query(); + Console.WriteLine($"third time : the count of passwords is :{passwords.Count}"); + + var guestbooks = await _dal.Query(); + Console.WriteLine($"third time : the count of guestbooks is :{guestbooks.Count}"); + + return new MessageModel() + { + success = false, + msg = "操作异常" + }; + } + } + + [UseTran] + public async Task TestTranInRepositoryAOP() + { + var passwords = await _passwordLibRepository.Query(); + Console.WriteLine($"first time : the count of passwords is :{passwords.Count}"); + + + Console.WriteLine($"insert a data into the table PasswordLib now."); + var insertPassword = await _passwordLibRepository.Add(new PasswordLib() + { + IsDeleted = false, + plAccountName = "aaa", + plCreateTime = DateTime.Now + }); + + + passwords = await _passwordLibRepository.Query(d => d.IsDeleted == false); + Console.WriteLine($"second time : the count of passwords is :{passwords.Count}"); + + //...... + + Console.WriteLine($""); + var guestbooks = await _dal.Query(); + Console.WriteLine($"first time : the count of guestbooks is :{guestbooks.Count}"); + + int ex = 0; + Console.WriteLine($"\nThere's an exception!!"); + int throwEx = 1 / ex; + + Console.WriteLine($"insert a data into the table Guestbook now."); + var insertGuestbook = await _dal.Add(new Guestbook() + { + username = "bbb", + blogId = 1, + createdate = DateTime.Now, + isshow = true + }); + + guestbooks = await _dal.Query(); + Console.WriteLine($"second time : the count of guestbooks is :{guestbooks.Count}"); + + return true; + } + + } +} diff --git a/New_College.Services/ModulePermissionServices.cs b/New_College.Services/ModulePermissionServices.cs new file mode 100644 index 0000000..c24b35d --- /dev/null +++ b/New_College.Services/ModulePermissionServices.cs @@ -0,0 +1,23 @@ +using New_College.Services.BASE; +using New_College.Model.Models; +using New_College.IRepository; +using New_College.IServices; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + /// + /// ModulePermissionServices + /// + public class ModulePermissionServices : BaseServices, IModulePermissionServices + { + + IBaseRepository _dal; + public ModulePermissionServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + } +} diff --git a/New_College.Services/ModuleServices.cs b/New_College.Services/ModuleServices.cs new file mode 100644 index 0000000..5bc71a9 --- /dev/null +++ b/New_College.Services/ModuleServices.cs @@ -0,0 +1,22 @@ +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; + +namespace New_College.Services +{ + /// + /// ModuleServices + /// + public class ModuleServices : BaseServices, IModuleServices + { + + IBaseRepository _dal; + public ModuleServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + } +} diff --git a/New_College.Services/New_College.Services.csproj b/New_College.Services/New_College.Services.csproj new file mode 100644 index 0000000..3b893ab --- /dev/null +++ b/New_College.Services/New_College.Services.csproj @@ -0,0 +1,27 @@ + + + + netcoreapp3.1 + + + + ..\New_College.Api\bin\Debug\ + + + + ..\New_College\bin\Release\ + + + + + + + + + + + + + + + diff --git a/New_College.Services/PasswordLibServices.cs b/New_College.Services/PasswordLibServices.cs new file mode 100644 index 0000000..1f1cb84 --- /dev/null +++ b/New_College.Services/PasswordLibServices.cs @@ -0,0 +1,18 @@ +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; + +namespace New_College.Services +{ + public partial class PasswordLibServices : BaseServices, IPasswordLibServices + { + IBaseRepository _dal; + public PasswordLibServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + } +} diff --git a/New_College.Services/PermissionServices.cs b/New_College.Services/PermissionServices.cs new file mode 100644 index 0000000..5f9210b --- /dev/null +++ b/New_College.Services/PermissionServices.cs @@ -0,0 +1,22 @@ +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; + +namespace New_College.Services +{ + /// + /// PermissionServices + /// + public class PermissionServices : BaseServices, IPermissionServices + { + + IBaseRepository _dal; + public PermissionServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + } +} diff --git a/New_College.Services/RoleModulePermissionServices.cs b/New_College.Services/RoleModulePermissionServices.cs new file mode 100644 index 0000000..a8fb87d --- /dev/null +++ b/New_College.Services/RoleModulePermissionServices.cs @@ -0,0 +1,81 @@ +using New_College.Common; +using New_College.IRepository; +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace New_College.Services +{ + /// + /// RoleModulePermissionServices 应用服务 + /// + public class RoleModulePermissionServices : BaseServices, IRoleModulePermissionServices + { + readonly IRoleModulePermissionRepository _dal; + readonly IBaseRepository _moduleRepository; + readonly IBaseRepository _roleRepository; + + // 将多个仓储接口注入 + public RoleModulePermissionServices( + IRoleModulePermissionRepository dal, + IBaseRepository moduleRepository, + IBaseRepository roleRepository) + { + this._dal = dal; + this._moduleRepository = moduleRepository; + this._roleRepository = roleRepository; + base.BaseDal = dal; + } + + /// + /// 获取全部 角色接口(按钮)关系数据 + /// + /// + [Caching(AbsoluteExpiration = 10)] + public async Task> GetRoleModule() + { + var roleModulePermissions = await base.Query(a => a.IsDeleted == false); + var roles = await _roleRepository.Query(a => a.IsDeleted == false); + var modules = await _moduleRepository.Query(a => a.IsDeleted == false); + + //var roleModulePermissionsAsync = base.Query(a => a.IsDeleted == false); + //var rolesAsync = _roleRepository.Query(a => a.IsDeleted == false); + //var modulesAsync = _moduleRepository.Query(a => a.IsDeleted == false); + + //var roleModulePermissions = await roleModulePermissionsAsync; + //var roles = await rolesAsync; + //var modules = await modulesAsync; + + + if (roleModulePermissions.Count > 0) + { + foreach (var item in roleModulePermissions) + { + item.Role = roles.FirstOrDefault(d => d.Id == item.RoleId); + item.Module = modules.FirstOrDefault(d => d.Id == item.ModuleId); + } + + } + return roleModulePermissions; + } + + public async Task> QueryMuchTable() + { + return await _dal.QueryMuchTable(); + } + + public async Task> RoleModuleMaps() + { + return await _dal.RoleModuleMaps(); + } + + public async Task> GetRMPMaps() + { + return await _dal.GetRMPMaps(); + } + } +} diff --git a/New_College.Services/RoleServices.cs b/New_College.Services/RoleServices.cs new file mode 100644 index 0000000..efab91c --- /dev/null +++ b/New_College.Services/RoleServices.cs @@ -0,0 +1,53 @@ +using New_College.Common; +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using System.Linq; +using System.Threading.Tasks; + +namespace New_College.Services +{ + /// + /// RoleServices + /// + public class RoleServices : BaseServices, IRoleServices + { + + IBaseRepository _dal; + public RoleServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + /// + /// + /// + /// + /// + public async Task SaveRole(string roleName) + { + Role role = new Role(roleName); + Role model = new Role(); + var userList = await base.Query(a => a.Name == role.Name && a.Enabled); + if (userList.Count > 0) + { + model = userList.FirstOrDefault(); + } + else + { + var id = await base.Add(role); + model = await base.QueryById(id); + } + + return model; + + } + + [Caching(AbsoluteExpiration = 30)] + public async Task GetRoleNameByRid(int rid) + { + return ((await base.QueryById(rid))?.Name); + } + } +} diff --git a/New_College.Services/SysRegionServices.cs b/New_College.Services/SysRegionServices.cs new file mode 100644 index 0000000..9c9551a --- /dev/null +++ b/New_College.Services/SysRegionServices.cs @@ -0,0 +1,54 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Linq; +using New_College.Common; + +namespace New_College.Services +{ + public class SysRegionServices : BaseServices, ISysRegionServices + { + private readonly IBaseRepository _dal; + public SysRegionServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + /// + /// + /// + /// + /// + [Caching(AbsoluteExpiration = 10)] + public async Task> GetListByParentId(string id) + { + return await this.Query(w => w.ParentCode == id); + } + + /// + /// 获取省市区 + /// + /// + /// + public async Task> GetRegionList(SysRegionQuery query) + { + if (query.Code == "0") + query.Code = "100000"; + var info = await _dal.Query(x => x.ParentCode == query.Code); + if (info == null) + return new List() { }; + return info.Select(x => new SysRegionResult() + { + Code = x.RegionCode, + Name = x.RegionName, + Id = x.KeyId + }).ToList(); + } + } +} \ No newline at end of file diff --git a/New_College.Services/T_BatchTypeInfoServices.cs b/New_College.Services/T_BatchTypeInfoServices.cs new file mode 100644 index 0000000..830036c --- /dev/null +++ b/New_College.Services/T_BatchTypeInfoServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class T_BatchTypeInfoServices : BaseServices, IT_BatchTypeInfoServices + { + private readonly IBaseRepository _dal; + public T_BatchTypeInfoServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/T_BatchlineServices.cs b/New_College.Services/T_BatchlineServices.cs new file mode 100644 index 0000000..635d942 --- /dev/null +++ b/New_College.Services/T_BatchlineServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class T_BatchlineServices : BaseServices, IT_BatchlineServices + { + private readonly IBaseRepository _dal; + public T_BatchlineServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/T_EnrollmentBatchServices.cs b/New_College.Services/T_EnrollmentBatchServices.cs new file mode 100644 index 0000000..c163b98 --- /dev/null +++ b/New_College.Services/T_EnrollmentBatchServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class T_EnrollmentBatchServices : BaseServices, IT_EnrollmentBatchServices + { + private readonly IBaseRepository _dal; + public T_EnrollmentBatchServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/T_EnrollmentPlaneServices.cs b/New_College.Services/T_EnrollmentPlaneServices.cs new file mode 100644 index 0000000..138eb67 --- /dev/null +++ b/New_College.Services/T_EnrollmentPlaneServices.cs @@ -0,0 +1,157 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using System.Threading.Tasks; +using New_College.IRepository; +using New_College.Common.Excel; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Data.Entity.ModelConfiguration.Conventions; +using System; + +namespace New_College.Services +{ + public class T_EnrollmentPlaneServices : BaseServices, IT_EnrollmentPlaneServices + { + private readonly IBaseRepository _dal; + private readonly IT_EnrollmentPlanedescServices t_EnrollmentPlanedescServices; + private readonly IT_EnrollmentBatchRepository t_EnrollmentBatchRepository; + private readonly ID_UniversityRepository d_UniversityRepository; + private readonly ID_MajorRepository d_MajorRepository; + + public T_EnrollmentPlaneServices(IBaseRepository dal + , IT_EnrollmentPlanedescServices IT_EnrollmentPlanedescServices + , IT_EnrollmentBatchRepository IT_EnrollmentBatchRepository + , ID_UniversityRepository ID_UniversityRepository + , ID_MajorRepository ID_MajorRepository) + { + this._dal = dal; + t_EnrollmentPlanedescServices = IT_EnrollmentPlanedescServices; + t_EnrollmentBatchRepository = IT_EnrollmentBatchRepository; + d_UniversityRepository = ID_UniversityRepository; + d_MajorRepository = ID_MajorRepository; + base.BaseDal = dal; + } + + #region 2019上海招生分数更新 + ///// + ///// 2019上海招生分数更新 + ///// + ///// + //public async Task Import() + //{ + // var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\数据\\好帮手\\招生计划\\导入步骤\\更新3\\2019上海招生分数更新.xlsx"); + // if (dataSet.Tables.Count > 0) + // { + // var universitylist = await d_UniversityRepository.Query(x => x.IsDelete == false); + // var majorlist = await d_MajorRepository.Query(x => x.IsDelete == false); + // var batchlist = await t_EnrollmentBatchRepository.Query(x => x.IsDelete == false); + + // List list = new List() { }; + // List adduniversity = new List() { }; + // foreach (DataRow dr in dataSet.Tables[0].Rows) + // { + // string schoolname = dr["学校名称"].ToString(); + // string area = dr["省份"].ToString(); + // string major = dr["专业"].ToString(); + // string batch = dr["批次"].ToString(); + // string avgscore = dr["平均分"].ToString(); + // string scoreline = dr["最低分"].ToString(); + // string mustsubject = dr["必修课数"].ToString(); + // string subjectclaim = dr["选科描述"].ToString(); + // string plannum = dr["实际录取人数"].ToString(); + // string type = dr["文理"].ToString(); + + // var universityid = universitylist.Where(x => x.Name == schoolname).Select(x => x.Id).FirstOrDefault(); + // if (universityid <= 0) + // { + // //记录学校 并添加 + // adduniversity.Add(schoolname); + // continue; + // } + // var batchid = batchlist.Where(x => x.Batch_name == batch).Select(x => x.Id).FirstOrDefault(); + + // var remake = ""; + // if (major.Contains("(")) + // { + // int indexs = major.IndexOf("("); + // remake = major.Substring(indexs); + // major = major.Substring(0, indexs); + // } + // var majorid = majorlist.Where(x => x.Name == major).Select(x => x.Id).FirstOrDefault(); + // list.Add(new T_EnrollmentPlanedesc() + // { + // UniversityId = universityid, + // BatchtypeId = batchid, + // Plancount = Convert.ToInt32(plannum), + // PlanId = 1, + // Scoreline = float.Parse(scoreline), + // majoraverage = float.Parse(avgscore), + // MajorName = major, + // Remark = remake, + // MajorId= majorid, + // Subjectclaim= subjectclaim, + // }); + // } + // var cc = adduniversity; + // var count = await t_EnrollmentPlanedescServices.Add(list); + // } + // return true; + //} + #endregion + + /// + /// 2019上海招生分数更新 + /// + /// + public async Task Import() + { + try + { + var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\数据\\好帮手\\招生计划\\导入步骤\\江苏省2019缺失分数线补充.xlsx"); + if (dataSet.Tables.Count > 0) + { + var info = await t_EnrollmentPlanedescServices.Query(x => x.PlanId == 9 && x.IsDelete == false && x.Scoreline <= 0); + var universitylist = await d_UniversityRepository.Query(x => x.IsDelete == false); + List list = new List() { }; + List adduniversity = new List() { }; + foreach (DataRow dr in dataSet.Tables[0].Rows) + { + string Name = dr["Name"].ToString(); + string MajorName = dr["MajorName"].ToString(); + string Scoreline = dr["Scoreline"].ToString(); + if (Scoreline != "0") + { + var universityid = universitylist.Where(x => x.Name == Name).Select(x => x.Id).FirstOrDefault(); + if (universityid > 0) + { + var nowinfo = info.Where(x => x.UniversityId == universityid && x.MajorName == MajorName).FirstOrDefault(); + if (nowinfo != null) + { + + + nowinfo.Scoreline = Convert.ToSingle(Scoreline); + list.Add(nowinfo); + } + } + } + + } + + var count = await t_EnrollmentPlanedescServices.Update(list); + var cc = 0; + } + return true; + } + catch (Exception ex) + { + + throw; + } + + } + } +} \ No newline at end of file diff --git a/New_College.Services/T_EnrollmentPlanedescServices.cs b/New_College.Services/T_EnrollmentPlanedescServices.cs new file mode 100644 index 0000000..18a9b2a --- /dev/null +++ b/New_College.Services/T_EnrollmentPlanedescServices.cs @@ -0,0 +1,2178 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.Model.ViewModels; +using System.Threading.Tasks; +using New_College.Model; +using System.Collections.Generic; +using New_College.IRepository; +using System.Linq; +using LinqKit; +using System; +using System.Text; +using New_College.Repository; +using New_College.Common; + +namespace New_College.Services +{ + public class T_EnrollmentPlanedescServices : BaseServices, IT_EnrollmentPlanedescServices + { + private readonly IBaseRepository _dal; + private readonly ID_UniversityRepository d_UniversityRepository; + private readonly IT_EnrollmentBatchRepository t_EnrollmentBatchRepository; + private readonly IT_EnrollmentPlaneRepository t_EnrollmentPlaneRepository; + private readonly ID_MajorRepository d_MajorRepository; + private readonly ID_MajorClassRepository d_MajorClassRepository; + private readonly ID_MajorCategoryRepository d_MajorCategoryRepository; + private readonly ID_MajorMapUniversityRepository d_MajorMapUniversityRepository; + private readonly IT_PlanMapTagRepository t_PlanMapTagRepository; + private readonly IT_RegionScoreRepository t_RegionScoreRepository; + private readonly IU_ProbabilityHistoryRepository u_ProbabilityHistoryRepository; + private readonly IU_VolunteerTableRepository u_VolunteerTableRepository; + private readonly IU_VolunteerTableDetailRepository u_VolunteerTableDetailRepository; + private readonly ID_UniversityCollectionRepository d_UniversityCollectionRepository; + private readonly IT_GearInfoRepository t_GearInfo; + + public T_EnrollmentPlanedescServices(IBaseRepository dal + , ID_UniversityRepository ID_UniversityRepository + , IT_EnrollmentBatchRepository IT_EnrollmentBatchRepository + , IT_EnrollmentPlaneRepository IT_EnrollmentPlaneRepository + , ID_MajorRepository ID_MajorRepository + , ID_MajorClassRepository ID_MajorClassRepository + , ID_MajorCategoryRepository ID_MajorCategoryRepository + , ID_MajorMapUniversityRepository ID_MajorMapUniversityRepository + , IT_PlanMapTagRepository IT_PlanMapTagRepository + , IT_RegionScoreRepository IT_RegionScoreRepository + , IU_ProbabilityHistoryRepository IU_ProbabilityHistoryRepository + , IU_VolunteerTableRepository IU_VolunteerTableRepository + , IU_VolunteerTableDetailRepository IU_VolunteerTableDetailRepository + , ID_UniversityCollectionRepository ID_UniversityCollectionRepository + , IT_GearInfoRepository IT_GearInfoRepository) + { + this._dal = dal; + d_UniversityRepository = ID_UniversityRepository; + t_EnrollmentBatchRepository = IT_EnrollmentBatchRepository; + t_EnrollmentPlaneRepository = IT_EnrollmentPlaneRepository; + d_MajorRepository = ID_MajorRepository; + d_MajorClassRepository = ID_MajorClassRepository; + d_MajorCategoryRepository = ID_MajorCategoryRepository; + d_MajorMapUniversityRepository = ID_MajorMapUniversityRepository; + t_PlanMapTagRepository = IT_PlanMapTagRepository; + t_RegionScoreRepository = IT_RegionScoreRepository; + u_ProbabilityHistoryRepository = IU_ProbabilityHistoryRepository; + u_VolunteerTableRepository = IU_VolunteerTableRepository; + u_VolunteerTableDetailRepository = IU_VolunteerTableDetailRepository; + d_UniversityCollectionRepository = ID_UniversityCollectionRepository; + t_GearInfo = IT_GearInfoRepository; + base.BaseDal = dal; + } + + public List permut = new List(); + + /// + /// 根据分数获取个性推荐学校 + /// + /// + /// + public async Task> GetRecommendUniversity(RecommendUniversityQuery query) + { + var maxscore = query.Score + 10; + var minscore = query.Score - 10; + var descnear = await _dal.QuerySql("select Scoreline,UniversityId from T_EnrollmentPlanedesc where IsDelete=0 and Scoreline<=" + maxscore + " and Scoreline>" + minscore + ""); + var nearids = descnear.Select(x => x.UniversityId).Distinct().ToList(); + + var desc = await _dal.QuerySql("select Scoreline,UniversityId from T_EnrollmentPlanedesc where IsDelete=0 and Scoreline<=" + maxscore + " and Scoreline>180"); + //降序求出所符合院校 + var orderdesc = desc.OrderByDescending(x => x.Scoreline).Select(x => x.UniversityId).Distinct().ToList(); + + var wheres = PredicateBuilder.New(); + wheres = wheres.And(x => x.IsDelete == false && orderdesc.Contains(x.Id)); + if (!string.IsNullOrEmpty(query.AreaName) && query.AreaName != "全国") + wheres = wheres.And(x => x.Area_Name.Contains(query.AreaName)); + if (query.SubjectLevel < 2) + wheres = wheres.And(x => x.Subject_Level == query.SubjectLevel); + if (query.Type >= 0) + wheres = wheres.And(x => x.Type == query.Type); + if (query.Nhef < 2) + wheres = wheres.And(x => x.Nhef == query.Nhef); + if (query.Sff < 2) + wheres = wheres.And(x => x.Sff == query.Sff); + if (query.Syl < 2) + wheres = wheres.And(x => x.Syl == query.Syl); + if (query.Nature > 0) + wheres = wheres.And(x => x.Nature == query.Nature); + + var info = await d_UniversityRepository.QueryPage(wheres, query.PageIndex, query.PageSize, "Rank Asc"); + if (info.data.Count <= 0) + return new PageModel() { }; + var collectionuniversity = await d_UniversityCollectionRepository.Query(x => x.CustomerId == query.CustomerId && x.IsDelete == false); + List list = new List() { }; + foreach (var c in info.data) + { + string attribute = ""; + if (c.Nhef == 1) + attribute += "985"; + if (c.Sff == 1) + attribute += "211"; + if (c.Syl == 1) + attribute += "双一流"; + list.Add(new UniversityResult + { + Id = c.Id, + Name = c.Name, + Nature = c.Nature, + AscriptionName = c.AscriptionName, + AreaName = c.Area_Name, + Logo = c.Logo, + Syl = c.Syl == 1 ? true : false, + Nhef = c.Nhef == 1 ? true : false, + Sff = c.Sff == 1 ? true : false, + UniversityType = c.Type, + IsNearScore = nearids.Contains(c.Id), + IsContrast = collectionuniversity.Count(x => x.Type == 2 && x.UniversityId == c.Id) > 0 + }); + } + return new PageModel() + { + data = list, + dataCount = info.dataCount, + page = info.page, + pageCount = info.pageCount, + PageSize = info.PageSize + }; + } + + /// + /// 霍兰德推荐学校专业 + /// + /// + /// + public async Task>> GetEnrollmentTagByPage(TagEnrollmentPlaneQuery query) + { + + //学校到专业 专业到学校 + var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + if (planinfo == null) + return new MessageModel>() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + var planid = planinfo.FirstOrDefault().Id; + if (string.IsNullOrWhiteSpace(query.Tag)) + return new MessageModel>() { success = false, msg = "Tag传入为空..." }; + var newTags = GetTag(query.Tag).Distinct().ToList(); + var planmaptag = await t_PlanMapTagRepository.Query(x => x.IsDelete == false); + List majorcolorlists = new List() { }; + List majorlists = new List() { }; + int i = 0; + foreach (var item in newTags) + { + i++; + majorlists.AddRange(planmaptag.Where(x => x.Tag.Contains(item)).Select(x => x.Name)); + majorcolorlists.AddRange(planmaptag.Where(x => x.Tag.Contains(item)).Select(x => new majorlists() + { + MajorName = x.Name, + TagColor = TagcolorName(i).ToString() + })); + } + majorlists = majorlists.Distinct().ToList(); + if (majorlists.Count <= 0) + return new MessageModel>() { success = false, msg = "标签匹配招生计划专业为空..." }; + + var wheres = PredicateBuilder.New(); + + wheres.Start(x => x.IsDelete == false && x.PlanId == planid && majorlists.Contains(x.MajorName) && x.Scoreline <= query.Score && x.UniversityId > 0); + if (query.AreaId != 821 && query.AreaId != 1047 && query.AreaId != 1965) + { + if (query.BatchId > 0) + { + wheres.And(x => x.BatchtypeId == query.BatchId); + } + } + if (query.AreaId == 821) + { + if (query.SubjectClaim == "物") + { + var batch = await t_EnrollmentBatchRepository.Query(x => x.Year == query.Year && x.AreaName == query.AreaName && x.IsDelete == false && x.Type == "理科"); + var batchids = batch.Select(x => x.Id).ToList(); + wheres.And(x => batchids.Contains(x.BatchtypeId)); + } + else if (query.SubjectClaim == "史") + { + var batch = await t_EnrollmentBatchRepository.Query(x => x.Year == query.Year && x.AreaName == query.AreaName && x.IsDelete == false && x.Type == "文科"); + var batchids = batch.Select(x => x.Id).ToList(); + wheres.And(x => batchids.Contains(x.BatchtypeId)); + } + } + else + { + if (!string.IsNullOrWhiteSpace(query.SubjectClaim)) + { + if (query.SubjectClaim.Contains(",")) + { + var cc = query.SubjectClaim.Split(","); + if (cc.Length == 2) + { + var cc1 = cc[0]; + var cc2 = cc[1]; + wheres.And(x => (x.Subjectclaim.Contains("/") && x.Subjectclaim.Contains(cc1)) == true || (x.Subjectclaim.Contains(cc2) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(",") && x.Subjectclaim.Contains(query.SubjectClaim)) == true || (x.Subjectclaim.Contains(query.SubjectClaim)) == true); + } + else if (cc.Length == 3) + { + var cc1 = cc[0]; + var cc2 = cc[1]; + var cc3 = cc[2]; + wheres.And(x => (x.Subjectclaim.Contains("/") && x.Subjectclaim.Contains(cc1)) == true || (x.Subjectclaim.Contains(cc2) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(cc3) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(",") && x.Subjectclaim.Contains(query.SubjectClaim)) == true || (x.Subjectclaim.Contains(query.SubjectClaim) == true)); + } + } + else + { + wheres.And(x => x.Subjectclaim.Contains(query.SubjectClaim) && !x.Subjectclaim.Contains(",")); + } + } + } + + var descinfo = await _dal.Query(wheres); + if (descinfo.Count <= 0) + return new MessageModel>() { success = false, msg = "该标签的对应招生计划为空..." }; + //档位分数处理 自动锁定一个档位 + DTOByTagQuery dTO = new DTOByTagQuery() { }; + var newscore = Convert.ToDecimal(query.Score); + var gearinfo = await t_GearInfo.Query(x => x.IsDelete == false && x.PlanId == planid && x.AreaId == query.AreaId); + var newtagColor = ""; + if (gearinfo.Count > 0) + { + var nowgearinfo = gearinfo.Where(x => x.GearMinScore <= newscore && x.GearMaxScore >= newscore).FirstOrDefault(); + if (nowgearinfo != null) + { + decimal MaxScore = 0; + decimal MinScore = 0; + int sort = 0; + decimal downMaxScore = 0; + decimal downMinScore = 0; + MaxScore = nowgearinfo.GearMaxScore; + MinScore = nowgearinfo.GearMinScore; + sort = nowgearinfo.OrderSort; + //下个排序的档位分数 + int Downsort = sort + 1; + if (Downsort == 12) + { + downMaxScore = MinScore - 1; + downMinScore = 0; + } + else + { + downMaxScore = gearinfo.Where(m => m.OrderSort == Downsort).Select(m => m.GearMaxScore).FirstOrDefault(); + downMinScore = gearinfo.Where(m => m.OrderSort == Downsort).Select(m => m.GearMinScore).FirstOrDefault(); + } + dTO.OnMaxScore = MaxScore + 5; + dTO.OnMinScore = MaxScore + 1; + dTO.MaxScore = MaxScore; + dTO.MinScore = MinScore; + dTO.DownMaxScore = downMaxScore; + dTO.DownMinScore = downMinScore; + } + else + { + newtagColor = "bao"; + } + } + + var universityids = descinfo.OrderByDescending(x => x.Scoreline).Select(x => x.UniversityId).ToList(); + var universityinfo = new List(); + if (!string.IsNullOrWhiteSpace(query.SearchAreaName) && query.SearchAreaName != "全国") + { + universityinfo = await d_UniversityRepository.Query(x => universityids.Contains(x.Id) && x.IsDelete == false && x.Area_Name == query.SearchAreaName, "Rank Asc"); + if (universityinfo.Count <= 0) + return new MessageModel>() { success = false, msg = "所选省份推荐院校数据为空" }; + } + else + { + universityinfo = await d_UniversityRepository.Query(x => universityids.Contains(x.Id) && x.IsDelete == false, "Rank Asc"); + } + if (query.SearchType == 1) + { + List list = new List() { }; + foreach (var item in majorcolorlists) + { + var newdesc = descinfo.Where(x => x.MajorName == item.MajorName).ToList(); + if (newdesc.Count > 0) + { + var newuniversityids = newdesc.Select(x => x.UniversityId).Distinct().ToList(); + var newuniversityinfo = universityinfo.Where(x => newuniversityids.Contains(x.Id)); + + List nowInfo = new List() { }; + foreach (var s in newuniversityinfo) + { + var tagColor = ""; + if (newtagColor == "bao") + { + tagColor = "bao"; + } + else + { + var nowlowscore = newdesc.Where(x => x.UniversityId == s.Id && x.Scoreline > 0).OrderBy(x => x.Scoreline).Select(x => x.Scoreline).FirstOrDefault(); + var nowScoreLine = Convert.ToDecimal(nowlowscore); + if (dTO.OnMinScore != 0 && dTO.OnMaxScore != 0) + { + if (nowScoreLine >= dTO.OnMinScore && nowScoreLine <= dTO.OnMaxScore) + { + tagColor = "chong"; + } + else if (nowScoreLine >= dTO.MinScore && nowScoreLine <= dTO.MaxScore) + { + tagColor = "wen"; + } + else if (nowScoreLine < dTO.MinScore) + { + tagColor = "bao"; + } + } + } + nowInfo.Add(new OtherInfo() + { + Id = s.Id, + Name = s.Name, + Color = tagColor//此处是学校的颜色 + }); + + } + list.Add(new TagEnrollmentPlanResult() + { + Id = 0, + Name = item.MajorName, + Color = item.TagColor, + Info = nowInfo.OrderByDescending(t => t.Color).ToList() + }); + } + } + var datalist = list.OrderBy(x => x.Color).ToList(); + return new MessageModel>() { success = true, msg = "获取成功", response = datalist }; + } + else + { + List list = new List() { }; + foreach (var item in universityinfo) + { + var newdesc = descinfo.Where(x => x.UniversityId == item.Id).ToList(); + if (newdesc.Count > 0) + { + List otherlist = new List() { }; + foreach (var s in newdesc) + { + var color = majorcolorlists.Where(x => x.MajorName == s.MajorName).Select(x => x.TagColor).FirstOrDefault(); + if (string.IsNullOrWhiteSpace(color)) + color = "d"; + otherlist.Add(new OtherInfo() + { + Id = 0, + Name = s.MajorName, + Color = color + }); + } + var newotherlist = otherlist.OrderBy(x => x.Color).ToList(); + var tagColor = ""; + if (newtagColor == "bao") + { + tagColor = "bao"; + } + else + { + var nowscore = newdesc.Where(x => x.Scoreline > 0).Select(x => x.Scoreline).FirstOrDefault(); + var nowScoreLine = Convert.ToDecimal(nowscore); + if (dTO.OnMinScore != 0 && dTO.OnMaxScore != 0) + { + if (nowScoreLine >= dTO.OnMinScore && nowScoreLine <= dTO.OnMaxScore) + { + tagColor = "chong"; + } + else if (nowScoreLine >= dTO.MinScore && nowScoreLine <= dTO.MaxScore) + { + tagColor = "wen"; + } + else if (nowScoreLine < dTO.MinScore) + { + tagColor = "bao"; + } + } + } + list.Add(new TagEnrollmentPlanResult() + { + Id = item.Id, + Name = item.Name,//院校名称 + Color = tagColor,//院校没有颜色 + Info = newotherlist + }); + } + } + return new MessageModel>() { success = true, msg = "获取成功", response = list.OrderByDescending(x => x.Color).ToList() }; + } + } + + /// + /// 设置标签的背景颜色 + /// + /// + /// + public EnumTagColor TagcolorName(int tag) + { + var tagcolor = new EnumTagColor(); + switch (tag) + { + case 1: + tagcolor = EnumTagColor.a; + break; + case 2: + tagcolor = EnumTagColor.b; + break; + case 3: + tagcolor = EnumTagColor.c; + break; + case 4: + tagcolor = EnumTagColor.c; + break; + case 5: + tagcolor = EnumTagColor.d; + break; + case 6: + tagcolor = EnumTagColor.d; + break; + default: + tagcolor = EnumTagColor.d; + break; + } + return tagcolor; + } + + #region old 霍兰德推荐学校专业 + ///// + ///// 霍兰德推荐学校专业 + ///// + ///// + ///// + //public async Task>> GetEnrollmentTagByPage(TagEnrollmentPlaneQuery query) + //{ + + // //学校到专业 专业到学校 + // var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + // if (planinfo == null) + // return new MessageModel>() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + // var planid = planinfo.FirstOrDefault().Id; + // if (string.IsNullOrWhiteSpace(query.Tag)) + // return new MessageModel>() { success = false, msg = "Tag传入为空..." }; + // var newTags = GetTag(query.Tag).Distinct().ToList(); + // var planmaptag = await t_PlanMapTagRepository.Query(x => x.IsDelete == false); + // List majorcolorlists = new List() { }; + // List majorlists = new List() { }; + // int i = 0; + // foreach (var item in newTags) + // { + // i++; + // majorlists.AddRange(planmaptag.Where(x => x.Tag.Contains(item)).Select(x => x.Name)); + // majorcolorlists.AddRange(planmaptag.Where(x => x.Tag.Contains(item)).Select(x => new majorlists() + // { + // MajorName = x.Name, + // TagColor = TagcolorName(i).ToString() + // })); + // } + // majorlists = majorlists.Distinct().ToList(); + // if (majorlists.Count <= 0) + // return new MessageModel>() { success = false, msg = "标签匹配招生计划专业为空..." }; + // var batchinfo = await t_EnrollmentBatchRepository.Query(x => x.Year == query.Year && x.AreaName == query.AreaName && !x.Batch_name.Contains("提前")); + // if (batchinfo.Count <= 0) + // return new MessageModel>() { success = false, msg = "所属年份数据批次为空..." }; + // var batchids = batchinfo.Select(s => s.Id).ToList(); + // var wheres = PredicateBuilder.New(); + + // wheres.Start(x => x.IsDelete == false && x.PlanId == planid && majorlists.Contains(x.MajorName) && x.Scoreline <= query.Score && x.UniversityId > 0 && batchids.Contains(x.BatchtypeId)); + + // if (!string.IsNullOrWhiteSpace(query.SubjectClaim)) + // { + // if (query.SubjectClaim.Contains(",")) + // { + // var cc = query.SubjectClaim.Split(","); + // if (cc.Length == 2) + // { + // var cc1 = cc[0]; + // var cc2 = cc[1]; + // wheres.And(x => (x.Subjectclaim.Contains("/") && x.Subjectclaim.Contains(cc1)) == true || (x.Subjectclaim.Contains(cc2) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(",") && x.Subjectclaim.Contains(query.SubjectClaim)) == true || (x.Subjectclaim.Contains(query.SubjectClaim)) == true); + // } + // else if (cc.Length == 3) + // { + // var cc1 = cc[0]; + // var cc2 = cc[1]; + // var cc3 = cc[2]; + // wheres.And(x => (x.Subjectclaim.Contains("/") && x.Subjectclaim.Contains(cc1)) == true || (x.Subjectclaim.Contains(cc2) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(cc3) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(",") && x.Subjectclaim.Contains(query.SubjectClaim)) == true || (x.Subjectclaim.Contains(query.SubjectClaim) == true)); + // } + // } + // else + // { + // wheres.And(x => x.Subjectclaim.Contains(query.SubjectClaim) && !x.Subjectclaim.Contains(",")); + // } + // } + // var descinfo = await _dal.Query(wheres); + // if (descinfo.Count <= 0) + // return new MessageModel>() { success = false, msg = "该标签的对应招生计划为空..." }; + // var universityids = descinfo.OrderByDescending(x => x.Scoreline).Select(x => x.UniversityId).ToList(); + // var universityinfo = await d_UniversityRepository.Query(x => universityids.Contains(x.Id) && x.IsDelete == false); + + // if (query.SearchType == 1) + // { + // List list = new List() { }; + // foreach (var item in majorcolorlists) + // { + // var newdesc = descinfo.Where(x => x.MajorName == item.MajorName).ToList(); + // if (newdesc.Count > 0) + // { + // var newuniversityids = newdesc.Select(x => x.UniversityId).Distinct().ToList(); + // var newuniversityinfo = universityinfo.Where(x => newuniversityids.Contains(x.Id)); + // list.Add(new TagEnrollmentPlanResult() + // { + // Id = 0, + // Name = item.MajorName, + // Color = item.TagColor, + // Info = newuniversityinfo.Select(x => new OtherInfo() + // { + // Id = x.Id, + // Name = x.Name, + // Color = "" + // }).ToList() + // }); + // } + // } + // var datalist = list.OrderBy(x => x.Color).ToList(); + // return new MessageModel>() { success = true, msg = "获取成功", response = datalist }; + // } + // else + // { + // List list = new List() { }; + // foreach (var item in universityinfo) + // { + // var newdesc = descinfo.Where(x => x.UniversityId == item.Id).ToList(); + // if (newdesc.Count > 0) + // { + // List otherlist = new List() { }; + // foreach (var s in newdesc) + // { + // var color = majorcolorlists.Where(x => x.MajorName == s.MajorName).Select(x => x.TagColor).FirstOrDefault(); + // if (string.IsNullOrWhiteSpace(color)) + // color = "d_low"; + // otherlist.Add(new OtherInfo() + // { + // Id = 0, + // Name = s.MajorName, + // Color = color + // }); + // } + // var newotherlist = otherlist.OrderBy(x => x.Color); + // list.Add(new TagEnrollmentPlanResult() + // { + // Id = item.Id, + // Name = item.Name,//院校名称 + // Color = "",//院校没有颜色 + // Info = otherlist + // }); + // } + + // } + // return new MessageModel>() { success = true, msg = "获取成功", response = list }; + // } + + + // return new MessageModel>() { success = false, msg = "获取失败" }; + //} + + ///// + ///// 霍兰德推荐学校专业 + ///// + ///// + ///// + //public async Task>> GetEnrollmentTagByPage(TagEnrollmentPlaneQuery query) + //{ + // var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + // if (planinfo == null) + // return new MessageModel>() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + // var planid = planinfo.FirstOrDefault().Id; + // if (string.IsNullOrWhiteSpace(query.Tag)) + // return new MessageModel>() { success = false, msg = "Tag传入为空..." }; + // var newTags = GetTag(query.Tag); + // var planmaptag = await t_PlanMapTagRepository.Query(x => x.IsDelete == false); + // List majorlists = new List() { }; + // foreach (var item in newTags) + // { + // majorlists.AddRange(planmaptag.Where(x => x.Tag.Contains(item)).Select(x => x.Name).ToList()); + // } + // majorlists = majorlists.Distinct().ToList(); + // if (majorlists.Count <= 0) + // return new MessageModel>() { success = false, msg = "标签匹配招生计划专业为空..." }; + // var batchinfo = await t_EnrollmentBatchRepository.Query(x => x.Year == query.Year && x.AreaName == query.AreaName && !x.Batch_name.Contains("提前")); + // if (batchinfo.Count <= 0) + // return new MessageModel>() { success = false, msg = "所属年份数据批次为空..." }; + // var batchids = batchinfo.Select(s => s.Id).ToList(); + + // //var descinfoss = await _dal.Query(x => x.IsDelete == false && x.PlanId == planid && majorlists.Contains(x.MajorName) && x.Scoreline <= query.Score && x.UniversityId > 0 && batchids.Contains(x.BatchtypeId)); + // StringBuilder sql = new StringBuilder() { }; + // StringBuilder sqlparams = new StringBuilder() { }; + + // var newmajorlists = ""; + // foreach (var item in majorlists) + // { + // newmajorlists = newmajorlists + "'" + item + "',"; + // } + // newmajorlists = newmajorlists.Substring(0, newmajorlists.Length - 1); + // var newbatchids = string.Join(",", batchids); + // var cc = query.Claim; + // if (!string.IsNullOrWhiteSpace(cc)) + // { + // if (cc.Contains(",")) + // { + // sql.AppendFormat("SELECT Subjectclaim,UniversityId,MajorName,Scoreline FROM `T_EnrollmentPlanedesc` where PlanId={0} and MajorName in ({1}) and Scoreline<={2} and UniversityId>0 and BatchtypeId in ({3}) and Subjectclaim='无限制' or Subjectclaim='无' or Subjectclaim like '%,%' and (", planid, newmajorlists, query.Score, newbatchids); + // var newcc = cc.Split(","); + // foreach (var item in newcc) + // { + // sqlparams.AppendFormat(" Subjectclaim like '%{0}%' or", item); + // } + // sqlparams.AppendFormat(" 1=1)"); + // sql.AppendFormat(sqlparams.ToString()); + // sql.AppendFormat(" union all"); + // sql.AppendFormat(" SELECT Subjectclaim,UniversityId,MajorName,Scoreline FROM `T_EnrollmentPlanedesc` where PlanId={0} and MajorName in ({1}) and Scoreline<={2} and UniversityId>0 and BatchtypeId in ({3}) and Subjectclaim='无限制' or Subjectclaim='无' or Subjectclaim like '%/%' and (", planid, newmajorlists, query.Score, newbatchids); + // sql.AppendFormat(sqlparams.ToString()); + // sql.AppendFormat(" union all"); + // sql.AppendFormat(" SELECT Subjectclaim,UniversityId,MajorName,Scoreline FROM `T_EnrollmentPlanedesc` where PlanId={0} and MajorName in ({1}) and Scoreline<={2} and UniversityId>0 and BatchtypeId in ({3}) and Subjectclaim not like '%,%' and Subjectclaim not like '%/%' and Subjectclaim='无限制' or Subjectclaim='无' and (", planid, newmajorlists, query.Score, newbatchids); + // sql.AppendFormat(sqlparams.ToString()); + // //wheres.And(x => x.Subjectclaim.Contains(cc)); + // } + // else + // { + // sql.AppendFormat("SELECT Subjectclaim,UniversityId,MajorName,Scoreline FROM `T_EnrollmentPlanedesc` where PlanId={0} and MajorName in ({1}) and Scoreline<={2} and UniversityId>0 and BatchtypeId in ({3}) and Subjectclaim='无限制' or Subjectclaim='无' or Subjectclaim like '%{4}%'", planid, newmajorlists, query.Score, newbatchids, cc); + // } + // } + // sql.AppendFormat(" group by Subjectclaim,UniversityId,MajorName,Scoreline"); + // var descinfo = await _dal.QuerySql(sql.ToString()); + // if (descinfo.Count <= 0) + // return new MessageModel>() { success = false, msg = "该标签的对应招生计划为空..." }; + // var universityids = descinfo.OrderByDescending(x => x.Scoreline).Select(x => x.UniversityId).ToList(); + // var universityinfo = await d_UniversityRepository.Query(x => universityids.Contains(x.Id) && x.IsDelete == false); + // List list = new List() { }; + // foreach (var item in majorlists) + // { + // var newdesc = descinfo.Where(x => x.MajorName == item).ToList(); + // if (newdesc.Count > 0) + // { + // var newuniversityids = newdesc.Select(x => x.UniversityId).Distinct().ToList(); + // var newuniversityinfo = universityinfo.Where(x => newuniversityids.Contains(x.Id)); + // list.Add(new TagEnrollmentPlanResult() + // { + // MajorName = item, + // SchoolInfo = newuniversityinfo.Select(x => new SchoolInfo() + // { + // AscriptionName = x.AscriptionName, + // Logo = x.Logo, + // Nhef = x.Nhef, + // Sff = x.Sff, + // Syl = x.Syl, + // UniversityId = x.Id, + // UniversityName = x.Name + // }).ToList() + // }); + // } + // } + + // return new MessageModel>() { success = true, msg = "获取成功", response = list }; + //} + + ///// + ///// 霍兰德推荐学校专业 old2 + ///// + ///// + ///// + //public async Task>> GetEnrollmentTagByPage(TagEnrollmentPlaneQuery query) + //{ + // var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + // if (planinfo == null) + // return new MessageModel>() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + // var planid = planinfo.FirstOrDefault().Id; + // if (string.IsNullOrWhiteSpace(query.Tag)) + // return new MessageModel>() { success = false, msg = "Tag传入为空..." }; + // var newTags = GetTag(query.Tag); + // var planmaptag = await t_PlanMapTagRepository.Query(x => x.IsDelete == false); + // List majorlists = new List() { }; + // foreach (var item in newTags) + // { + // majorlists.AddRange(planmaptag.Where(x => x.Tag.Contains(item)).Select(x => x.Name).ToList()); + // } + // majorlists = majorlists.Distinct().ToList(); + // if (majorlists.Count <= 0) + // return new MessageModel>() { success = false, msg = "标签匹配招生计划专业为空..." }; + // var batchinfo = await t_EnrollmentBatchRepository.Query(x => x.Year == query.Year && x.AreaName == query.AreaName && !x.Batch_name.Contains("提前")); + // if (batchinfo.Count <= 0) + // return new MessageModel>() { success = false, msg = "所属年份数据批次为空..." }; + // var batchids = batchinfo.Select(s => s.Id).ToList(); + // var wheres = PredicateBuilder.New(); + + // wheres.Start(x => x.IsDelete == false && x.PlanId == planid && majorlists.Contains(x.MajorName) && x.Scoreline <= query.Score && x.UniversityId > 0 && batchids.Contains(x.BatchtypeId)); + + // if (!string.IsNullOrWhiteSpace(query.SubjectClaim)) + // { + // if (query.SubjectClaim.Contains(",")) + // { + // var cc = query.SubjectClaim.Split(","); + // if (cc.Length == 2) + // { + // var cc1 = cc[0]; + // var cc2 = cc[1]; + // wheres.And(x => (x.Subjectclaim.Contains("/") && x.Subjectclaim.Contains(cc1)) == true || (x.Subjectclaim.Contains(cc2) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(",") && x.Subjectclaim.Contains(query.SubjectClaim)) == true); + // } + // else if (cc.Length == 3) + // { + // var cc1 = cc[0]; + // var cc2 = cc[1]; + // var cc3 = cc[2]; + // wheres.And(x => (x.Subjectclaim.Contains("/") && x.Subjectclaim.Contains(cc1)) == true || (x.Subjectclaim.Contains(cc2) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(cc3) && x.Subjectclaim.Contains("/")) == true || (x.Subjectclaim.Contains(",") && x.Subjectclaim.Contains(query.SubjectClaim)) == true); + // } + // } + // else + // { + // wheres.And(x => x.Subjectclaim.Contains(query.SubjectClaim) && !x.Subjectclaim.Contains(",")); + // } + // } + // var descinfo = await _dal.Query(wheres); + // if (descinfo.Count <= 0) + // return new MessageModel>() { success = false, msg = "该标签的对应招生计划为空..." }; + // var universityids = descinfo.OrderByDescending(x => x.Scoreline).Select(x => x.UniversityId).ToList(); + // var universityinfo = await d_UniversityRepository.Query(x => universityids.Contains(x.Id) && x.IsDelete == false); + // List list = new List() { }; + // foreach (var item in majorlists) + // { + // var newdesc = descinfo.Where(x => x.MajorName == item).ToList(); + // if (newdesc.Count > 0) + // { + // var newuniversityids = newdesc.Select(x => x.UniversityId).Distinct().ToList(); + // var newuniversityinfo = universityinfo.Where(x => newuniversityids.Contains(x.Id)); + // list.Add(new TagEnrollmentPlanResult() + // { + // MajorName = item, + // SchoolInfo = newuniversityinfo.Select(x => new SchoolInfo() + // { + // AscriptionName = x.AscriptionName, + // Logo = x.Logo, + // Nhef = x.Nhef, + // Sff = x.Sff, + // Syl = x.Syl, + // UniversityId = x.Id, + // UniversityName = x.Name + // }).ToList() + // }); + // } + // } + + // return new MessageModel>() { success = true, msg = "获取成功", response = list }; + //} + #endregion + + + #region old懒人模式 + ///// + ///// 懒人模式 + ///// 办学性质 + ///// 高校级别 + ///// 专业ids + ///// + ///// + ///// + //public async Task>> GetEnrollmentLazyByPage(LazyEnrollmentPlaneQuery query) + //{ + // if (query.Score <= 0) + // return new MessageModel>() { success = false, msg = "分数不能为0..." }; + // var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + // if (planinfo == null) + // return new MessageModel>() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + // //通过传来的专业分类Id 筛选出所选择的专业的ids + // var major = await d_MajorRepository.Query(x => x.IsDelete == false && query.MajorIds.Contains(x.CategoryClass_Id)); + // if (major.Count() <= 0) + // return new MessageModel>() { success = false, msg = "所选专业大类数据完善中..." }; + // var majornames = major.Select(x => x.MajorName).ToList(); + // //通过办学性质和高校级别筛选出学校的ids + // //string sql = ""; + // var stringBuilder = new StringBuilder(); + // stringBuilder.Append("SELECT Id FROM `D_University` where IsDelete=0 "); + // if (query.Nature > 0) + // { + // //sql += " and Nature=" + query.Nature + ""; + // stringBuilder.AppendFormat(" and Nature={0}", query.Nature); + // } + + // if (query.SchoolLevel > 0) + // { + // if (query.SchoolLevel == 1) + // { + // stringBuilder.AppendFormat(" and Nhef=1"); + // //sql += " and Nhef=1"; + // } + // else if (query.SchoolLevel == 2) + // { + // stringBuilder.AppendFormat(" and Sff=1"); + // //sql += " and Sff=1"; + // } + // else + // { + // stringBuilder.AppendFormat(" and Syl=1"); + // //sql += " and Syl=1"; + // } + // } + // var university = await d_UniversityRepository.QuerySql(stringBuilder.ToString()); + // if (university.Count <= 0) + // return new MessageModel>() { success = false, msg = "所选院校数据完善中..." }; + // var universityids = university.Select(x => x.Id).ToList(); + // var batchinfo = await t_EnrollmentBatchRepository.Query(x => x.Year == query.Year && x.AreaName == query.AreaName && !x.Batch_name.Contains("提前")); + // if (batchinfo.Count <= 0) + // return new MessageModel>() { success = false, msg = "所属年份数据批次为空..." }; + // var batchids = batchinfo.Select(s => s.Id).ToList(); + // //通过条件筛选出所有的 + // var wheres = PredicateBuilder.New(); + // wheres.And(x => x.Scoreline <= query.Score && majornames.Contains(x.MajorName) && universityids.Contains(x.UniversityId) && x.PlanId == planinfo.FirstOrDefault().Id && batchids.Contains(x.BatchtypeId)); + // //根据上述所有筛选 求出招生计划 + // var plandesc = await _dal.Query(wheres, "Scoreline desc"); + // if (plandesc.Count <= 0) + // return new MessageModel>() { success = false, msg = "符合条件招生条件为空..." }; + // //招生计划内所有的院校Ids + // var planuniversityids = plandesc.Select(x => x.UniversityId).ToList().Distinct(); + // var ids = string.Join(",", planuniversityids); + // //var info = await d_UniversityRepository.QueryPage(x => planuniversityids.Contains(x.Id), query.PageIndex, query.PageSize); + // var start = query.PageSize * (query.PageIndex - 1); + // var end = query.PageIndex * query.PageSize; + // var stringBuilderinfo = new StringBuilder(); + // stringBuilderinfo.AppendFormat("select Id,Name,Logo,Nhef,Sff,Syl,Area_Name,AscriptionName from D_University where IsDelete=0 and Id in ({0}) limit {1},{2}", ids, start, end); + // var info = await d_UniversityRepository.QuerySql(stringBuilderinfo.ToString()); + // List list = new List() { }; + // foreach (var item in info) + // { + // var planids = plandesc.Where(x => x.UniversityId == item.Id).Select(x => x.Id).ToList(); + // list.Add(new UniversityEnrollmentPlanResult() + // { + // UniversityName = item.Name, + // UniversityId = item.Id, + // Logo = item.Logo, + // Nhef = item.Nhef, + // Sff = item.Sff, + // Syl = item.Syl, + // planCount = plandesc.Where(x => x.UniversityId == item.Id).Sum(x => x.Plancount), + // PlanIds = planids, + // AreaName = item.Area_Name, + // AscriptionName = item.AscriptionName, + // MjaorPlan = plandesc.Count(x => x.UniversityId == item.Id), + // Rank = item.Rank <= 0 ? "-" : item.Rank.ToString() + // }); + // } + // return new MessageModel>() + // { + // success = true, + // msg = "获取成功", + // response = new PageModel() + // { + // data = list, + // dataCount = planuniversityids.Count(), + // page = query.PageIndex, + // PageSize = query.PageSize, + // pageCount = (int)Math.Ceiling(ids.Count() / Convert.ToDecimal(query.PageSize)) + // } + // }; + //} + #endregion + + /// + /// 懒人模式 + /// 办学性质 + /// 高校级别 + /// 专业ids + /// + /// + /// + public async Task>> GetEnrollmentLazyByPage(LazyEnrollmentPlaneQuery query) + { + if (query.Score <= 0) + return new MessageModel>() { success = false, msg = "分数不能为0..." }; + var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + if (planinfo == null) + return new MessageModel>() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + //通过传来的专业分类Id 筛选出所选择的专业的ids + var majorclassinfo = await d_MajorClassRepository.Query(x => query.MajorIds.Contains(x.TradeId) && x.IsDelete == false); + var CategoryClassids = majorclassinfo.Select(x => x.Id).ToList(); + var major = await d_MajorRepository.Query(x => x.IsDelete == false && CategoryClassids.Contains(x.CategoryClass_Id)); + if (major.Count() <= 0) + return new MessageModel>() { success = false, msg = "请选择专业大类,或所选专业大类数据完善中..." }; + var majornames = major.Select(x => x.MajorName).ToList(); + //通过办学性质和高校级别筛选出学校的ids + //string sql = ""; + var stringBuilder = new StringBuilder(); + stringBuilder.Append("SELECT Id FROM `D_University` where IsDelete=0 "); + if (query.Nature != null && query.Nature.Count > 0) + { + var newnature = string.Join(",", query.Nature); + stringBuilder.AppendFormat(" and Nature in ({0})", newnature); + } + if (query.AreaNames != null && query.AreaNames.Count > 0) + { + string areanames = ""; + foreach (var item in query.AreaNames) + { + areanames += "'" + item + "',"; + } + var newnames = areanames.Substring(0, areanames.Length - 1); + stringBuilder.AppendFormat(" and Area_Name in ({0})", newnames); + } + stringBuilder.AppendFormat(" order by rank asc"); + + var university = await d_UniversityRepository.QuerySql(stringBuilder.ToString()); + if (university.Count <= 0) + return new MessageModel>() { success = false, msg = "所选院校数据完善中..." }; + var universityids = university.Select(x => x.Id).ToList(); + var batchinfo = await t_EnrollmentBatchRepository.Query(x => x.Year == query.Year && x.AreaName == query.AreaName && !x.Batch_name.Contains("提前")); + if (batchinfo.Count <= 0) + return new MessageModel>() { success = false, msg = "所属年份数据批次为空..." }; + var batchids = batchinfo.Select(s => s.Id).ToList(); + //通过条件筛选出所有的 + var wheres = PredicateBuilder.New(); + wheres.And(x => x.Scoreline <= query.Score && majornames.Contains(x.MajorName) && universityids.Contains(x.UniversityId) && x.PlanId == planinfo.FirstOrDefault().Id && batchids.Contains(x.BatchtypeId)); + //根据上述所有筛选 求出招生计划 + var plandesc = await _dal.Query(wheres, "Scoreline desc"); + if (plandesc.Count <= 0) + return new MessageModel>() { success = false, msg = "符合条件招生条件为空..." }; + //懒人推荐限制 + //院校数量 + var unum = 0; + //专业数量 + var mnum = 0; + switch (query.AreaId) + { + case 802: + unum = 24; + mnum = 4; + break; + case 821: + unum = 16; + mnum = 6; + break; + case 1047: + unum = 12; + mnum = 6; + break; + case 1376: + unum = 96; + mnum = 1; + break; + case 1965: + unum = 15; + mnum = 6; + break; + } + + //招生计划内所有的院校Ids + var planuniversityids = plandesc.Select(x => x.UniversityId).ToList().Distinct().Take(unum); + var ids = string.Join(",", planuniversityids); + //var info = await d_UniversityRepository.QueryPage(x => planuniversityids.Contains(x.Id), query.PageIndex, query.PageSize); + + var stringBuilderinfo = new StringBuilder(); + stringBuilderinfo.AppendFormat("select Id,Name,Logo,Nhef,Sff,Syl,Area_Name,AscriptionName from D_University where IsDelete=0 and Id in ({0}) order by rank asc", ids); + var info = await d_UniversityRepository.QuerySql(stringBuilderinfo.ToString()); + List list = new List() { }; + foreach (var item in info) + { + var plansinfo = plandesc.Where(x => x.UniversityId == item.Id).ToList().Take(mnum); + list.Add(new UniversityEnrollmentPlanLazyResult() + { + UniversityName = item.Name, + UniversityId = item.Id, + Logo = item.Logo, + Nhef = item.Nhef, + Sff = item.Sff, + Syl = item.Syl, + Infos = plansinfo.Select(x => new PlanInfo() + { + MajorId = x.Id, + Money = x.Tuitionfee, + Year = x.Studyyears, + PlanName = x.MajorName, + PlanNum = x.Plancount, + Scoreline = x.Scoreline + }).ToList(), + AscriptionName = item.AscriptionName, + Rank = item.Rank <= 0 ? "-" : item.Rank.ToString() + }); + } + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = list + }; + //return new MessageModel>() + //{ + // success = true, + // msg = "获取成功", + // response = new PageModel() + // { + // data = list, + // dataCount = planuniversityids.Count(), + // page = query.PageIndex, + // PageSize = query.PageSize, + // pageCount = (int)Math.Ceiling(ids.Count() / Convert.ToDecimal(query.PageSize)) + // } + //}; + } + + /// + /// 根据计划Ids 获取招生计划 + /// + /// + /// + public async Task>> GetPlanByUniversity(PlanDetailQuery query) + { + if (query.PlanIds != null && query.PlanIds.Count <= 0) + return new MessageModel>() { success = false, msg = "传入不能为空" }; + var info = await _dal.QueryPage(x => x.IsDelete == false && query.PlanIds.Contains(x.Id), query.PageIndex, query.PageSize, "Scoreline desc"); + List list = new List() { }; + foreach (var item in info.data) + { + var newname = CheckMajorName(item.MajorName, item.Remark); + var newmoney = string.IsNullOrWhiteSpace(item.Tuitionfee) || item.Tuitionfee == "0" || item.Tuitionfee == "待定" ? "--" : item.Tuitionfee; + var newyear = string.IsNullOrWhiteSpace(item.Studyyears) ? "--" : item.Studyyears; + var count = list.Count(x => x.Name == newname && x.Money == newmoney && x.PlanNum == item.Plancount && x.Scoreline == item.Scoreline); + if (count > 0) + continue; + list.Add(new PlanDescList() + { + Name = newname, + Year = newyear, + Money = newmoney, + PlanNum = item.Plancount, + MajorId = item.Id, + Scoreline = item.Scoreline + //Subject = GetSub(item.Subjectclaim) + }); + } + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = new PageModel() + { + data = list, + dataCount = info.dataCount, + page = info.page, + pageCount = info.pageCount, + PageSize = info.PageSize + } + }; + } + + /// + /// 校验专业名称 + /// + /// + /// + /// + public string CheckMajorName(string name, string remake) + { + return string.IsNullOrWhiteSpace(remake) ? name : remake.Contains("(") || remake.Contains("(") ? name + remake : name + "(" + remake + ")"; + } + + /// + /// 根据年份省份获取批次 + /// + /// + public async Task>> GetBatchByAreaAndYear(BatchQuery query) + { + var info = await t_EnrollmentBatchRepository.Query(x => x.IsDelete == false && x.AreaName == query.AreaName && x.Year == query.Year && !x.Batch_name.Contains("提前") && !x.Batch_name.Contains("零志愿")); + if (info.Count() <= 0) + return new MessageModel>() { success = false, msg = "数据为空" }; + List list = new List() { }; + foreach (var item in info) + { + if (item.Type != "不分文理") + { + list.Add(new IdNameResult() + { + Id = item.Id, + Name = item.Batch_name + "(" + item.Type + ")" + }); + } + else + { + list.Add(new IdNameResult() + { + Id = item.Id, + Name = item.Batch_name + }); + } + } + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = list + }; + + } + + /// + /// 冲稳保获取推荐学校专业 + /// + /// + /// + public async Task>> GetEnrollmentCWBByPage(CWBEnrollmentPlaneQuery query) + { + //所选科目 分数 + if (query.Score <= 0) + return new MessageModel>() { success = false, msg = "分数不能为0..." }; + var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + if (planinfo == null) + return new MessageModel>() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + //筛选符合条件的院校ids + var stringBuilder = new StringBuilder(); + stringBuilder.Append("SELECT Id FROM `D_University` where IsDelete=0 "); + if (query.Nature != null && query.Nature.Count > 0) + { + var newnature = string.Join(",", query.Nature); + stringBuilder.AppendFormat(" and Nature in ({0})", newnature); + } + if (query.UniversityAreaName != null && query.UniversityAreaName.Count > 0) + { + var newname = ""; + foreach (var item in query.UniversityAreaName) + { + newname += "'" + item + "'" + ","; + } + newname = newname.Substring(0, newname.Length - 1); + stringBuilder.AppendFormat(" and Area_Name in ({0})", newname); + } + if (query.SchoolLevel != null && query.SchoolLevel.Count > 0) + { + foreach (var item in query.SchoolLevel) + { + if (item == 1) + { + stringBuilder.AppendFormat(" and Nhef=1"); + } + else if (item == 2) + { + stringBuilder.AppendFormat(" and Sff=1"); + } + else if (item == 3) + { + stringBuilder.AppendFormat(" and Syl=1"); + } + } + } + stringBuilder.AppendFormat(" order by rank asc"); + var university = await d_UniversityRepository.QuerySql(stringBuilder.ToString()); + if (university.Count <= 0) + return new MessageModel>() { success = false, msg = "所选院校数据完善中..." }; + var universityids = university.Select(x => x.Id).ToList(); + //var batchinfo = await t_EnrollmentBatchRepository.Query(x => x.Year == query.Year && x.AreaName == query.AreaName && !x.Batch_name.Contains("提前")); + //if (batchinfo.Count <= 0) + // return new MessageModel>() { success = false, msg = "所属年份数据批次为空..." }; + //var batchids = batchinfo.Select(s => s.Id).ToList(); + + //通过条件筛选出所有的 + var wheres = PredicateBuilder.New(); + wheres.And(x => universityids.Contains(x.UniversityId) && x.IsDelete == false && x.PlanId == planinfo.FirstOrDefault().Id && x.BatchtypeId == query.BatchId && x.UniversityId > 0); + //().Id && batchids.Contains(x.BatchtypeId) && x.UniversityId > 0); + if (query.MajorIds != null && query.MajorIds.Count > 0) + { + //所选专业增加majorids筛选 + //query.MajorIds + var majorclassinfo = await d_MajorClassRepository.Query(x => query.MajorIds.Contains(x.TradeId) && x.IsDelete == false); + var CategoryClassids = majorclassinfo.Select(x => x.Id).ToList(); + var major = await d_MajorRepository.Query(x => x.IsDelete == false && CategoryClassids.Contains(x.CategoryClass_Id)); + if (major.Count() <= 0) + return new MessageModel>() { success = false, msg = "所选专业大类数据完善中..." }; + var majornames = major.Select(x => x.MajorName).ToList(); + wheres.And(x => majornames.Contains(x.MajorName)); + } + //根据上述所有筛选 求出招生计划 + var plandesc = await _dal.Query(wheres, "Scoreline desc"); + if (plandesc.Count <= 0) + return new MessageModel>() { success = false, msg = "符合条件招生条件为空..." }; + List c = new List() { }; + List w = new List() { }; + List b = new List() { }; + var start = query.PageSize * (query.PageIndex - 1); + var end = query.PageIndex * query.PageSize; + List list = new List() { }; + var chonguIds = plandesc.Where(k => k.Scoreline > 0 && (query.Score + 20 >= k.Scoreline && query.Score < k.Scoreline)).Select(e => e.UniversityId).Distinct().ToList(); + list.Add(new CWBEnrollmentPlanResult() + { + Name = "冲", + Count = chonguIds.Count(), + UniversityIds = chonguIds + }); + var wenuIds = plandesc.Where(k => k.Scoreline > 0 && (query.Score >= k.Scoreline && query.Score - 25 <= k.Scoreline)).Select(e => e.UniversityId).Distinct().ToList(); + list.Add(new CWBEnrollmentPlanResult() + { + Name = "稳", + Count = wenuIds.Count(), + UniversityIds = wenuIds + }); + var baouIds = plandesc.Where(k => k.Scoreline > 0 && (query.Score - 26 > k.Scoreline)).Select(e => e.UniversityId).Distinct().ToList(); + list.Add(new CWBEnrollmentPlanResult() + { + Name = "保", + Count = baouIds.Count(), + UniversityIds = baouIds + }); + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = list + }; + } + + /// + /// 冲稳保详情 + /// + /// + /// + public async Task>> GetCWBUniversityDetail(CWBUniversityDetailQuery query) + { + var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + if (planinfo == null) + return new MessageModel>() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + var wheres = PredicateBuilder.New(); + wheres.And(x => query.UniversityIds.Contains(x.UniversityId) && x.IsDelete == false && x.PlanId == planinfo.FirstOrDefault().Id && x.UniversityId > 0); + //此处需加冲稳保 + if (query.AreaId != 821 && query.AreaId != 1047 && query.AreaId != 1965) + { + if (query.BatchId > 0) + { + wheres.And(x => x.BatchtypeId == query.BatchId); + } + } + //wheres.And(x => x.Scoreline > 0 && (query.Score >= x.Scoreline && query.Score - 25 <= x.Scoreline)); + if (query.Type == "冲") + { + wheres.And(x => x.Scoreline > 0 && (query.Score + 20 >= x.Scoreline && query.Score < x.Scoreline)); + } + else if (query.Type == "稳") + { + wheres.And(x => x.Scoreline > 0 && (query.Score >= x.Scoreline && query.Score - 25 <= x.Scoreline)); + } + else if (query.Type == "保") + { + wheres.And(x => x.Scoreline > 0 && (query.Score - 26 > x.Scoreline)); + } + + //().Id && batchids.Contains(x.BatchtypeId) && x.UniversityId > 0); + if (query.MajorIds != null && query.MajorIds.Count > 0) + { + //所选专业增加majorids筛选 + //query.MajorIds + var major = await d_MajorRepository.Query(x => x.IsDelete == false && query.MajorIds.Contains(x.CategoryClass_Id)); + if (major.Count() <= 0) + return new MessageModel>() { success = false, msg = "所选专业大类数据完善中..." }; + var majornames = major.Select(x => x.MajorName).ToList(); + wheres.And(x => majornames.Contains(x.MajorName)); + } + //根据上述所有筛选 求出招生计划 + var plandesc = await _dal.Query(wheres, "Scoreline desc"); + + var start = query.PageSize * (query.PageIndex - 1); + var end = query.PageIndex * query.PageSize; + string ids = string.Join(",", query.UniversityIds); + var stringBuilderinfo = new StringBuilder(); + stringBuilderinfo.AppendFormat("select Rank,Id,Name,Logo,Nhef,Sff,Syl,Area_Name,AscriptionName from D_University where IsDelete=0 and Id in ({0}) limit {1},{2}", ids, start, end); + var sqldata = await d_UniversityRepository.QuerySql(stringBuilderinfo.ToString()); + if (sqldata.Count <= 0) + return new MessageModel>() { success = false, msg = "获取失败,数据为空" }; + var Type = query.Type; + var list = sqldata.Select(item => new UniversityEnrollmentPlanResult() + { + UniversityName = item.Name, + UniversityId = item.Id, + Logo = item.Logo, + Nhef = item.Nhef, + Sff = item.Sff, + Syl = item.Syl, + planCount = plandesc.Where(x => x.UniversityId == item.Id).Sum(x => x.Plancount), + PlanIds = plandesc.Where(x => x.UniversityId == item.Id).Select(x => x.Id).ToList(), + AreaName = item.Area_Name, + AscriptionName = item.AscriptionName, + MjaorPlan = plandesc.Count(x => x.UniversityId == item.Id), + Rank = item.Rank <= 0 ? "-" : item.Rank.ToString(), + Type = Type + }).ToList(); + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = new PageModel() + { + data = list, + dataCount = query.UniversityIds.Count(), + page = query.PageIndex, + PageSize = query.PageSize, + pageCount = (int)Math.Ceiling(query.UniversityIds.Count() / Convert.ToDecimal(query.PageSize)) + } + }; + } + + + #region 转化Tag + /// + /// 转化出标签所有可能 + /// + /// + /// + public List GetTag(string tag) + { + var Nums = new List(); + for (int i = 0; i < tag.Length; i++) + { + Nums.Add(tag[i].ToString()); + } + Permutation(Nums.ToArray(), 0, Nums.ToArray().Length); + + //permut = GetTagExtened(tag, permut); + return permut; + } + + /// + /// 递归实现全排序并输出 + /// + /// 待排序的字符数组 + /// 输出字符数组的起始位置 + /// 输出字符数组的长度 + public void Permutation(string[] nums, int m, int n) + { + int i; + string t; + if (m < n - 1) + { + Permutation(nums, m + 1, n); + for (i = m + 1; i < n; i++) + { + t = nums[m]; + nums[m] = nums[i]; + nums[i] = t; + Permutation(nums, m + 1, n); + t = nums[m]; + nums[m] = nums[i]; + nums[i] = t; + } + } + else + { + string kk = string.Empty; + for (int j = 0; j < nums.Length; j++) + { + kk += nums[j]; + } + permut.Add(kk); + } + } + + ///// + ///// 判断是否为不常见标签,若是则匹配相关联标签 + ///// + ///// + ///// + //public List GetTagExtened(string tag, List taglist) + //{ + // var list = new List(); + // var query = yd_tagExInfo.Get(a => a.Enabled == 1 && a.Tags.Equals(tag)).FirstOrDefault(); + // if (query != null) + // { + // list = JsonConvert.DeserializeObject>(query.tagEx); + // } + // if (list.Any() && list.Count() > 0) + // { + // taglist.AddRange(list.Select(s => s.tag).ToList()); + // } + // return taglist; + //} + #endregion + + /// + /// 获取分析结果录取概率 获取之后保存一下 + /// + /// + /// + public async Task> GetUniversityProbability(UniversityProbabilityQuery query) + { + var universityinfo = await d_UniversityRepository.QueryById(query.UniversityId); + if (universityinfo == null) + return new MessageModel() { success = false, msg = "院校信息不存在" }; + UniversityProbabilityResult model = new UniversityProbabilityResult() { }; + #region 院校信息 + model.Logo = universityinfo.Logo; + model.Name = universityinfo.Name; + model.Nature = universityinfo.Nature; + model.Nhef = universityinfo.Nhef > 0; + model.Sff = universityinfo.Sff > 0; + model.Syl = universityinfo.Syl > 0; + model.AscriptionName = universityinfo.AscriptionName; + model.Rank = universityinfo.Rank; + model.AreaName = universityinfo.Area_Name; + model.SubjectLevel = universityinfo.Subject_Level; + #endregion + var planinfobyarea = await t_EnrollmentPlaneRepository.Query(w => w.Area_Id == query.AreaId); + var planinfo = planinfobyarea.Where(w => w.Years == query.Year); + if (planinfo.Count() <= 0) + return new MessageModel() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + var planallids = planinfobyarea.Select(x => x.Id).ToList(); + var planid = planinfo.Select(x => x.Id).FirstOrDefault(); + var descinfobyuniv = await _dal.Query(x => planallids.Contains(x.PlanId) && x.UniversityId == query.UniversityId && x.IsDelete == false); + float universityminimum = 0; + //省份的80%分数 + var regionscore = (await t_RegionScoreRepository.Query(x => x.IsDelete == false && x.AreaId == query.AreaId && x.Year == query.Year)).FirstOrDefault(); + var descinfo = descinfobyuniv.Where(x => x.PlanId == planid).ToList(); + if (descinfo.Count <= 0) + { + return new MessageModel() + { + success = false, + msg = "此学校最新招生分数线暂未估测成功" + }; + //Random random = new Random() { }; + //var randomcc = random.Next(6, 8); + //var newrendom = randomcc / float.Parse(10.ToString()); ; + //universityminimum = random.Next(6, 8); + } + else + { + universityminimum = descinfo.OrderByDescending(x => x.Scoreline).Select(x => x.Scoreline).FirstOrDefault(); + } + //return new MessageModel() { success = false, msg = "招生计划为空,正在完善中..." }; + var isprobab = await u_ProbabilityHistoryRepository.Query(x => x.CustomerId == query.CustomerId && x.UniversityId == query.UniversityId); + if (isprobab.Count <= 0) + { + //没得话测试 + //院校对该省份的招生最低分 + if (regionscore == null) + return new MessageModel() + { + success = false, + msg = "获取失败,当前省份满分数据为空" + }; + var now80score = regionscore.Score * (float)0.8; + if (universityminimum >= now80score) + { + float num = 50; + if (query.Score >= universityminimum) + { + var cha = query.Score - universityminimum; + var add = cha * 2; + if (add >= 46) + { + num = 96; + } + else + { + num += add; + } + } + else + { + var cha = universityminimum - query.Score; + if (cha >= 49) + { + num = 1; + } + else + { + num -= cha; + } + } + model.Probability = num; + //每 + 0.5分,成功率增加1 %,最高96 % + //每 - 1分,成功率减少1 %,最低1 % + } + else + { + float num = 50; + if (query.Score >= universityminimum) + { + var cha = query.Score - universityminimum; + if (cha >= 46) + { + num = 96; + } + else + { + num += cha; + } + } + else + { + var cha = universityminimum - query.Score; + if (cha >= 49) + { + num = 1; + } + else + { + num -= cha; + } + } + model.Probability = num; + //每 + 1分,成功率增加1 %,最高96 % + //每 - 1分,成功率减少1 %,最低1 % + } + var random = RadomHelper.RandNumZF(1); + model.EstimateScore = universityminimum + float.Parse(random); + + var addresult = await u_ProbabilityHistoryRepository.Add(new U_ProbabilityHistory() + { + CustomerId = query.CustomerId, + EstimateScore = model.EstimateScore, + Probability = Convert.ToInt32(model.Probability), + UniversityId = query.UniversityId, + AreaId = query.AreaId, + Year = query.Year + }); + } + else + { + //有的话从历史数据拿 + var oldinfo = isprobab.FirstOrDefault(); + model.EstimateScore = oldinfo.EstimateScore; + model.Probability = oldinfo.Probability; + } + var batchinfo = await t_EnrollmentBatchRepository.Query(x => x.IsDelete == false); + var YearBatchScores = new List() { }; + foreach (var item in planinfobyarea.OrderByDescending(x => x.Years).ToList()) + { + var lowscore = descinfobyuniv.Where(x => x.PlanId == item.Id).OrderBy(x => x.Scoreline).FirstOrDefault(); + if (lowscore != null && lowscore.Scoreline > 0) + { + YearBatchScores.Add(new YearBatchScore() + { + Year = item.Years, + Score = lowscore.Scoreline, + BatchName = batchinfo.Where(x => x.Id == lowscore.BatchtypeId).Select(x => x.Batch_name).FirstOrDefault() + }); + } + } + model.YearBatchScores = YearBatchScores; + model.Proposal = GetProposal(model.Probability); + return new MessageModel() + { + success = true, + msg = "获取成功", + response = model + }; + } + + #region 获取Proposal建议 + public string GetProposal(float Probability) + { + if (Probability >= 85) + { + return "成功几率很高,建议填报"; + } + else if (Probability >= 65) + { + return "成功几率较好,建议可以填报"; + } + else if (Probability >= 50) + { + return "成功几率较低,建议谨慎考虑"; + } + else if (Probability >= 35) + { + return "风险过高,建议谨慎考虑"; + } + else + { + return "风险过高,不建议填报"; + } + } + #endregion + + /// + /// 获取概率历史记录列表 + /// + /// + public async Task>> GetProbabilityResult(ProbabilityQuery query) + { + var info = await u_ProbabilityHistoryRepository.QueryPage(x => x.IsDelete == false && x.CustomerId == query.CustomerId, query.PageIndex, query.PageSize, "CreateTime desc"); + if (info.data.Count <= 0) + return new MessageModel>() { success = false, msg = "获取失败,暂未测试录取概率" }; + var universityids = info.data.Select(x => x.UniversityId).ToList(); + var universityinfo = await d_UniversityRepository.Query(x => universityids.Contains(x.Id) && x.IsDelete == false, "Rank asc"); + List list = new List() { }; + foreach (var item in info.data) + { + list.Add(new ProbabilityResult() + { + Id = item.Id, + AreaId = item.AreaId, + EstimateScore = item.EstimateScore, + Probability = item.Probability, + UniversityId = item.UniversityId, + UniversityName = universityinfo.Where(x => x.Id == item.UniversityId).Select(x => x.Name).FirstOrDefault(), + Year = item.Year + }); + } + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = new PageModel() + { + data = list, + dataCount = info.dataCount, + page = info.page, + pageCount = info.pageCount, + PageSize = info.PageSize + } + }; + } + + /// + /// 保存志愿表 + /// + /// + /// + public async Task> SaveVolunteerTable(VolunteerTableQuery query) + { + //if (query.TableId > 0) + //{ + + //} + //u_VolunteerTableRepository u_VolunteerTableDetailRepository + var table = await u_VolunteerTableRepository.Query(x => x.IsDelete == false && x.CustomerId == query.CustomerId); + var num = table.Count() + 1; + var TableName = "我的志愿表" + num; + var addtable = await u_VolunteerTableRepository.Add(new U_VolunteerTable() + { + CustomerId = query.CustomerId, + VolunteerTableName = TableName + }); + if (addtable > 0) + { + List list = new List() { }; + foreach (var item in query.details) + { + list.Add(new U_VolunteerTableDetail() + { + PlanMajorIds = string.Join(",", item.PlanMagorIds), + UniversityId = item.UniversityId, + UniversityName = item.UniversityName, + VolunteerTableId = addtable + }); + } + var adddetail = await u_VolunteerTableDetailRepository.Add(list); + if (adddetail > 0) + { + return new MessageModel() { success = true, msg = "保存成功" }; + } + else + { + return new MessageModel() { success = false, msg = "保存失败" }; + } + } + return new MessageModel() { success = true, msg = "保存成功" }; + } + + /// + /// 获取个人志愿列表 传Id + /// + /// + /// + public async Task>> GetVolunteerTableList(IdQuery query) + { + var info = await u_VolunteerTableRepository.Query(x => x.IsDelete == false && x.CustomerId == query.Id); + if (info.Count <= 0) + return new MessageModel>() { success = false, msg = "获取失败,暂无志愿表" }; + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = info.Select(x => new VolunteerTableListResult() + { + Id = x.Id, + Name = x.VolunteerTableName, + CreateTime = x.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") + }).ToList() + }; + } + + /// + /// 获取志愿表详情 传Id + /// + /// + /// + public async Task>> GetVolunteerTableDetail(IdQuery query) + { + var info = await u_VolunteerTableDetailRepository.Query(x => x.IsDelete == false && x.VolunteerTableId == query.Id); + if (info == null) + return new MessageModel>() { success = false, msg = "获取失败,数据不存在" }; + List list = new List() { }; + var planstringids = info.Select(x => x.PlanMajorIds).ToList(); + List PlanIds = new List() { }; + foreach (var item in planstringids) + { + var newids = item.Split(",").Select(x => int.Parse(x)).ToList(); + PlanIds.AddRange(newids); + } + var descinfo = await _dal.Query(x => x.IsDelete == false && PlanIds.Contains(x.Id)); + foreach (var item in info) + { + var planids = item.PlanMajorIds.Split(",").Select(x => int.Parse(x)).ToList(); + var nowdesc = descinfo.Where(x => planids.Contains(x.Id)).ToList(); + if (nowdesc.Count <= 0) + continue; + //此处处理针对于霍兰德推荐的具有相同学校的案例 + var count = list.Where(x => x.UniversityName == item.UniversityName).ToList(); + if (count.Count > 0) + { + var newinfos = nowdesc.Select(x => new PlanInfo() + { + Money = x.Tuitionfee, + Year = x.Studyyears == null ? "-" : x.Studyyears == "" ? "-" : x.Studyyears, + PlanName = x.MajorName, + PlanNum = x.Plancount, + Scoreline = x.Scoreline + }).ToList(); + count.FirstOrDefault().Infos.AddRange(newinfos); + } + else + { + + list.Add(new VolunteerTableResult() + { + UniversityName = item.UniversityName, + Infos = nowdesc.Select(x => new PlanInfo() + { + Money = x.Tuitionfee, + Year = x.Studyyears == null ? "-" : x.Studyyears == "" ? "-" : x.Studyyears, + PlanName = x.MajorName, + PlanNum = x.Plancount, + Scoreline = x.Scoreline + }).ToList() + }); + } + + } + return new MessageModel>() { success = true, msg = "获取成功", response = list }; + } + + /// + /// 删除志愿表 + /// + /// + /// + public async Task> DeleteVolunteerTable(IdQuery query) + { + var info = await u_VolunteerTableRepository.QueryById(query.Id); + if (info == null) + return new MessageModel() { success = false, msg = "删除失败,数据不存在" }; + info.IsDelete = true; + var result = await u_VolunteerTableRepository.Update(info); + if (result) + { + return new MessageModel() { success = true, msg = "删除成功" }; + } + else + { + return new MessageModel() { success = false, msg = "删除失败" }; + } + } + + /// + /// 保存志愿表 霍兰德专用 + /// + /// + /// + public async Task> SaveHollandVolunteer(HollandVolunteerTableQuery query) + { + var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + if (planinfo.Count <= 0) + return new MessageModel() { success = false, msg = "传入年份省份有误" }; + var planid = planinfo.Select(x => x.Id).FirstOrDefault(); + var batchinfo = await t_EnrollmentBatchRepository.Query(x => x.Year == query.Year && x.AreaName == query.AreaName && !x.Batch_name.Contains("提前")); + if (batchinfo.Count <= 0) + return new MessageModel() { success = false, msg = "传入年份省份有误" }; + var batchids = batchinfo.Select(s => s.Id).ToList(); + var majorlists = query.infos.Select(x => x.MajorName).ToList(); + var descinfo = await _dal.Query(x => x.IsDelete == false && x.PlanId == planid && majorlists.Contains(x.MajorName) && x.Scoreline <= query.Score && x.UniversityId > 0 && batchids.Contains(x.BatchtypeId)); + //数据处理添加 + List list = new List() { }; + var table = await u_VolunteerTableRepository.Query(x => x.IsDelete == false && x.CustomerId == query.CustomerId); + var num = table.Count() + 1; + var TableName = "我的志愿表" + num; + var addtable = await u_VolunteerTableRepository.Add(new U_VolunteerTable() + { + CustomerId = query.CustomerId, + VolunteerTableName = TableName + }); + if (addtable > 0) + foreach (var item in query.infos) + { + foreach (var s in item.universitys) + { + var plandescid = descinfo.Where(x => x.UniversityId == s.UniversityId && x.MajorName == item.MajorName).Select(x => x.Id).FirstOrDefault(); + list.Add(new U_VolunteerTableDetail() + { + PlanMajorIds = plandescid.ToString(), + UniversityId = s.UniversityId, + UniversityName = s.UniversityName, + VolunteerTableId = addtable + }); + } + } + return new MessageModel() { success = true, msg = "保存成功" }; + } + + /// + /// 获取一键生成的志愿表 + /// + /// + /// + public async Task>> GetAutoVolunteerTableDetail(VolunteerTableQuery query) + { + if (query.details == null) + return new MessageModel>() { success = false, msg = "选择专业院校为空..." }; + List list = new List() { }; + //var planstringids = query.details.Select(x => x.PlanMagorIds).ToList(); + List PlanIds = new List() { }; + foreach (var item in query.details) + { + PlanIds.AddRange(item.PlanMagorIds); + } + var descinfo = await _dal.Query(x => x.IsDelete == false && PlanIds.Contains(x.Id)); + var universityids = query.details.Select(x => x.UniversityId).ToList(); + var universityinfo = await d_UniversityRepository.Query(x => universityids.Contains(x.Id) && x.IsDelete == false, "Rank asc"); + foreach (var item in query.details) + { + var nowdesc = descinfo.Where(x => item.PlanMagorIds.Contains(x.Id)).ToList(); + if (nowdesc.Count <= 0) + continue; + var nowuniversityinfo = universityinfo.Where(x => x.Id == item.UniversityId).FirstOrDefault(); + if (nowuniversityinfo == null) + continue; + //此处处理针对于霍兰德推荐的具有相同学校的案例 + var count = list.Where(x => x.UniversityName == item.UniversityName).ToList(); + if (count.Count > 0) + { + var newinfos = nowdesc.Select(x => new PlanInfo() + { + MajorId = x.Id, + Money = x.Tuitionfee, + Year = x.Studyyears, + PlanName = x.MajorName, + PlanNum = x.Plancount, + Scoreline = x.Scoreline + }).ToList(); + count.FirstOrDefault().Infos.AddRange(newinfos); + } + else + { + list.Add(new SimuVolunteerTableResult() + { + Logo = nowuniversityinfo.Logo, + Nhef = nowuniversityinfo.Nhef > 0, + Rank = nowuniversityinfo.Rank, + Sff = nowuniversityinfo.Sff > 0, + Syl = nowuniversityinfo.Syl > 0, + UniversityId = item.UniversityId, + UniversityName = item.UniversityName, + Infos = nowdesc.Select(x => new PlanInfo() + { + MajorId = x.Id, + Money = x.Tuitionfee, + Year = x.Studyyears, + PlanName = x.MajorName, + PlanNum = x.Plancount, + Scoreline = x.Scoreline + }).ToList() + }); + } + } + return new MessageModel>() { success = true, msg = "获取成功", response = list }; + } + + /// + /// 获取霍兰德一键生成的志愿表 + /// + /// + /// + public async Task>> GetHollandVolunteerTableDetail(HollandVolunteerTableQuery query) + { + var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + if (planinfo.Count <= 0) + return new MessageModel>() { success = false, msg = "传入年份省份有误" }; + var planid = planinfo.Select(x => x.Id).FirstOrDefault(); + var batchinfo = await t_EnrollmentBatchRepository.Query(x => x.Year == query.Year && x.AreaName == query.AreaName && !x.Batch_name.Contains("提前")); + if (batchinfo.Count <= 0) + return new MessageModel>() { success = false, msg = "传入年份省份有误" }; + var batchids = batchinfo.Select(s => s.Id).ToList(); + var majorlists = query.infos.Select(x => x.MajorName).ToList(); + var descinfo = await _dal.Query(x => x.IsDelete == false && x.PlanId == planid && majorlists.Contains(x.MajorName) && x.Scoreline <= query.Score && x.UniversityId > 0 && batchids.Contains(x.BatchtypeId)); + //数据处理添加 + var universityids = new List() { }; + foreach (var item in query.infos) + { + foreach (var s in item.universitys) + { + universityids.Add(s.UniversityId); + } + } + var universityinfo = await d_UniversityRepository.Query(x => universityids.Contains(x.Id) && x.IsDelete == false, "Rank asc"); + List list = new List() { }; + foreach (var item in query.infos) + { + foreach (var s in item.universitys) + { + var nowuniversityinfo = universityinfo.Where(x => x.Id == s.UniversityId).FirstOrDefault(); + if (nowuniversityinfo == null) + continue; + var plandescid = descinfo.Where(x => x.UniversityId == s.UniversityId && x.MajorName == item.MajorName).Select(x => x.Id).FirstOrDefault(); + var nowdesc = descinfo.Where(x => plandescid == x.Id).ToList(); + var count = list.Where(x => x.UniversityName == s.UniversityName && x.UniversityId == s.UniversityId).ToList(); + if (count.Count > 0) + { + var newinfos = nowdesc.Select(x => new PlanInfo() + { + MajorId = x.Id, + Money = x.Tuitionfee, + Year = x.Studyyears, + PlanName = x.MajorName, + PlanNum = x.Plancount, + Scoreline = x.Scoreline + }).ToList(); + count.FirstOrDefault().Infos.AddRange(newinfos); + } + else + { + list.Add(new SimuVolunteerTableResult() + { + Logo = nowuniversityinfo.Logo, + Nhef = nowuniversityinfo.Nhef > 0, + Rank = nowuniversityinfo.Rank, + Sff = nowuniversityinfo.Sff > 0, + Syl = nowuniversityinfo.Syl > 0, + UniversityId = s.UniversityId, + UniversityName = s.UniversityName, + Infos = nowdesc.Select(x => new PlanInfo() + { + MajorId = x.Id, + Money = x.Tuitionfee, + Year = x.Studyyears, + PlanName = x.MajorName, + PlanNum = x.Plancount, + Scoreline = x.Scoreline + }).ToList() + }); + } + } + } + return new MessageModel>() { success = true, msg = "获取成功", response = list }; + } + + /// + /// 根据标签推荐选科 + /// + /// + /// + public async Task> GetSubjectSelectByTag(ByTagSubjectSelectQuery query) + { + var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + if (planinfo == null) + return new MessageModel() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + var planid = planinfo.FirstOrDefault().Id; + if (string.IsNullOrWhiteSpace(query.Tag)) + return new MessageModel() { success = false, msg = "标签传入为空,请去测试" }; + var newTags = GetTag(query.Tag); + var planmaptag = await t_PlanMapTagRepository.Query(x => x.IsDelete == false); + List majorlists = new List() { }; + foreach (var item in newTags) + { + majorlists.AddRange(planmaptag.Where(x => x.Tag.Contains(item)).Select(x => x.Name).ToList()); + } + majorlists = majorlists.Distinct().ToList(); + var descinfo = await _dal.Query(x => x.IsDelete == false && x.PlanId == planid && majorlists.Contains(x.MajorName) && x.UniversityId > 0); + List list = new List() { }; + list.Add(new IdNameResult() { Name = "物", Id = descinfo.Count(x => x.Subjectclaim.Contains("物")) }); + list.Add(new IdNameResult() { Name = "化", Id = descinfo.Count(x => x.Subjectclaim.Contains("化")) }); + list.Add(new IdNameResult() { Name = "生", Id = descinfo.Count(x => x.Subjectclaim.Contains("生")) }); + list.Add(new IdNameResult() { Name = "政", Id = descinfo.Count(x => x.Subjectclaim.Contains("政")) }); + list.Add(new IdNameResult() { Name = "史", Id = descinfo.Count(x => x.Subjectclaim.Contains("史")) }); + list.Add(new IdNameResult() { Name = "地", Id = descinfo.Count(x => x.Subjectclaim.Contains("地")) }); + + var result = list.OrderByDescending(x => x.Id).Select(x => x.Name).Take(3); + + return new MessageModel() + { + success = true, + msg = "获取成功", + response = string.Join("|", result) + }; + } + + /// + /// 获取喜欢的院校 + /// + /// + /// + public async Task>> GetLikeSchoolMajor(IdQuery query) + { + var table = await u_VolunteerTableRepository.Query(x => x.IsDelete == false && x.CustomerId == query.Id); + if (table.Count <= 0) + return new MessageModel>() { success = false, msg = "未生成志愿表" }; + var tableids = table.Select(x => x.Id).ToList(); + var detail = await u_VolunteerTableDetailRepository.Query(x => x.IsDelete == false && tableids.Contains(x.VolunteerTableId)); + if (detail.Count <= 0) + return new MessageModel>() { success = false, msg = "数据为空" }; + List ids = new List() { }; + foreach (var item in detail) + { + var newplaninfo = item.PlanMajorIds.Split(",").ToList(); + foreach (var s in newplaninfo) + { + int id = Convert.ToInt32(s); + ids.Add(id); + } + } + var info = await _dal.Query(x => x.IsDelete == false && ids.Contains(x.Id)); + List list = new List() { }; + foreach (var item in detail) + { + var newplaninfo = item.PlanMajorIds.Split(",").ToList(); + foreach (var s in newplaninfo) + { + int id = Convert.ToInt32(s); + var planname = info.Where(x => x.Id == id).Select(x => x.MajorName).FirstOrDefault(); + if (string.IsNullOrWhiteSpace(planname)) + continue; + list.Add(new LikeSchoolMajor() + { + SchoolName = item.UniversityName, + MajorName = planname + }); + } + } + return new MessageModel>() { success = true, msg = "获取成功", response = list }; + + } + + /// + /// 专业规划 + /// + /// + public async Task>> GetMajorPlanClaim(CustomerQuery query) + { + //查招生计划 + var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + if (planinfo == null) + return new MessageModel>() { success = false, msg = "招生计划为空" }; + var planid = planinfo.Select(x => x.Id).FirstOrDefault(); + //12 大类 + var majorcate = await d_MajorCategoryRepository.Query(x => x.IsDelete == false && x.Type == 1); + //二级类 + var majorcateids = majorcate.Select(x => x.Id).ToList(); + var majorclass = await d_MajorClassRepository.Query(x => x.IsDelete == false && majorcateids.Contains(x.TradeId)); + //三级类 + var majorclassids = majorclass.Select(x => x.Id).ToList(); + var major = await d_MajorRepository.Query(x => x.IsDelete == false && majorclassids.Contains(x.CategoryClass_Id)); + //通过三级类的名称去匹配 subjectclaim 选科信息 + //没有的话就给个无选科要求 + var batchinfo = await t_EnrollmentBatchRepository.Query(x => x.Year == query.Year && x.AreaName == query.AreaName && !x.Batch_name.Contains("提前")); + if (batchinfo.Count <= 0) + return new MessageModel>() { success = false, msg = "所属年份数据批次为空..." }; + var batchids = batchinfo.Select(s => s.Id).ToList(); + var plandesc = await _dal.Query(x => x.IsDelete == false && x.PlanId == planid && batchids.Contains(x.BatchtypeId) && x.UniversityId > 0, "Scoreline desc"); + List list = new List() { }; + foreach (var item in majorcate) + { + List majors = new List() { }; + var newmajorclassids = majorclass.Where(x => x.TradeId == item.Id).Select(x => x.Id).ToList(); + var newmajorinfo = major.Where(x => newmajorclassids.Contains(x.CategoryClass_Id)); + foreach (var s in newmajorinfo) + { + var claim = plandesc.Where(x => x.MajorName == s.MajorName).Select(x => x.Subjectclaim).FirstOrDefault(); + majors.Add(new MajorClaim() + { + MajorName = s.Name, + Claim = GetClaim(claim) + }); + } + list.Add(new MajorPlanResult() + { + Name = item.Name, + Majors = majors + }); + } + return new MessageModel>() { success = true, msg = "获取成功", response = list }; + } + + /// + /// + /// + /// + /// + public string GetClaim(string claim) + { + var returnclaim = claim; + switch (claim) + { + case "不限": + returnclaim = "无限制"; + break; + case "": + returnclaim = "无限制"; + break; + case null: + returnclaim = "无限制"; + break; + case "无限制": + returnclaim = "无限制"; + break; + default: + returnclaim = claim; + break; + } + return returnclaim; + } + + /// + /// 获取批次 + /// + /// + /// + public async Task>> GetBatchByYearArea(YearAreaQuery query) + { + var info = await t_EnrollmentBatchRepository.Query(x => x.IsDelete == false && x.AreaName == query.AreaName && x.Year == query.Year && !x.Batch_name.Contains("提前") && !x.Batch_name.Contains("零志愿")); + if (info.Count <= 0) + return new MessageModel>() { success = false, msg = "数据为空" }; + + List list = new List() { }; + foreach (var item in info) + { + if (item.Type != "不分文理") + { + list.Add(new IdNameResult() + { + Id = item.Id, + Name = item.Batch_name + "(" + item.Type + ")" + }); + } + else + { + list.Add(new IdNameResult() + { + Id = item.Id, + Name = item.Batch_name + }); + } + } + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = list + }; + } + } +} \ No newline at end of file diff --git a/New_College.Services/T_GearInfoServices.cs b/New_College.Services/T_GearInfoServices.cs new file mode 100644 index 0000000..845d438 --- /dev/null +++ b/New_College.Services/T_GearInfoServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class T_GearInfoServices : BaseServices, IT_GearInfoServices + { + private readonly IBaseRepository _dal; + public T_GearInfoServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/T_LongIdMapServices.cs b/New_College.Services/T_LongIdMapServices.cs new file mode 100644 index 0000000..1430952 --- /dev/null +++ b/New_College.Services/T_LongIdMapServices.cs @@ -0,0 +1,271 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.IRepository; +using New_College.Common.Excel; +using System.Data; +using System.Threading.Tasks; +using System; +using System.Linq; +using System.Collections.Generic; + +namespace New_College.Services +{ + public class T_LongIdMapServices : BaseServices, IT_LongIdMapServices + { + private readonly IBaseRepository _dal; + private readonly IT_EnrollmentBatchRepository t_EnrollmentBatchRepository; + private readonly IT_EnrollmentPlaneRepository t_EnrollmentPlaneRepository; + private readonly IT_EnrollmentPlanedescRepository t_EnrollmentPlanedescRepository; + private readonly ID_LongIdMapRepository d_LongIdMapRepository; + private readonly IT_BatchlineRepository t_BatchlineRepository; + private readonly IT_BatchTypeInfoRepository t_BatchTypeInfoRepository; + + public T_LongIdMapServices(IBaseRepository dal + , IT_EnrollmentBatchRepository IT_EnrollmentBatchRepository + , IT_EnrollmentPlaneRepository IT_EnrollmentPlaneRepository + , IT_EnrollmentPlanedescRepository IT_EnrollmentPlanedescRepository + , ID_LongIdMapRepository ID_LongIdMapRepository + , IT_BatchlineRepository IT_BatchlineRepository + , IT_BatchTypeInfoRepository IT_BatchTypeInfoRepository) + { + this._dal = dal; + t_EnrollmentBatchRepository = IT_EnrollmentBatchRepository; + t_EnrollmentPlaneRepository = IT_EnrollmentPlaneRepository; + t_EnrollmentPlanedescRepository = IT_EnrollmentPlanedescRepository; + d_LongIdMapRepository = ID_LongIdMapRepository; + t_BatchlineRepository = IT_BatchlineRepository; + t_BatchTypeInfoRepository = IT_BatchTypeInfoRepository; + base.BaseDal = dal; + } + + #region EnrollmentBatch + /// + /// EnrollmentBatch + /// + /// + public async Task ImportEnrollmentBatch() + { + var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\志愿填报\\EnrollmentBatch.xlsx"); + if (dataSet.Tables.Count > 0) + { + foreach (DataRow dr in dataSet.Tables[0].Rows) + { + string id = dr["_id"].ToString(); + string areaName = dr["areaName"].ToString(); + string year = dr["year"].ToString(); + string batch_name = dr["batch_name"].ToString(); + string Type = dr["Type"].ToString(); + string subjectlevel = dr["subjectlevel"].ToString(); + var info = await t_EnrollmentBatchRepository.Add(new T_EnrollmentBatch() + { + AreaName = areaName, + Year = Convert.ToInt32(year), + Batch_name = batch_name, + Subjectlevel = Convert.ToInt32(subjectlevel), + Type = Type, + }); + if (info > 0) + { + await _dal.Add(new T_LongIdMap() { longid = id, newid = info, tablename = "EnrollmentBatch" }); + } + } + } + + return true; + } + #endregion + + #region EnrollmentPlane + /// + /// EnrollmentPlane + /// + /// + public async Task ImportEnrollmentPlane() + { + var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\志愿填报\\EnrollmentPlane.xlsx"); + if (dataSet.Tables.Count > 0) + { + foreach (DataRow dr in dataSet.Tables[0].Rows) + { + string id = dr["_id"].ToString(); + string EnrollmentName = dr["EnrollmentName"].ToString(); + string Area_Id = dr["Area_Id"].ToString(); + string Years = dr["Years"].ToString(); + + var info = await t_EnrollmentPlaneRepository.Add(new T_EnrollmentPlane() + { + Area_Id = Convert.ToInt32(Area_Id), + EnrollmentName = EnrollmentName, + Years = Convert.ToInt32(Years), + }); + if (info > 0) + { + await _dal.Add(new T_LongIdMap() { longid = id, newid = info, tablename = "EnrollmentPlane" }); + } + } + } + + return true; + } + #endregion + + #region EnrollmentPlanedesc + /// + /// EnrollmentPlanedesc + /// + /// + public async Task ImportEnrollmentPlanedesc() + { + var dlongidmap = await d_LongIdMapRepository.Query(x => x.IsDelete == false); + var PlanInfo = await _dal.Query(x => x.IsDelete == false && x.tablename == "EnrollmentPlane"); + var BatchInfo = await _dal.Query(x => x.IsDelete == false && x.tablename == "EnrollmentBatch"); + for (int i = 1; i <= 29; i++) + { + var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\志愿填报\\EnrollmentPlanedesc\\" + i + ".xlsx"); + if (dataSet.Tables.Count > 0) + { + List T_LongIdMaplist = new List() { }; + List T_EnrollmentPlanedesclist = new List() { }; + int num = 1; + foreach (DataRow dr in dataSet.Tables[0].Rows) + { + string id = dr["_id"].ToString(); + string Name = dr["Name"].ToString(); + string PlanId = dr["PlanId"].ToString(); + string BatchtypeId = dr["BatchtypeId"].ToString(); + string UniversityId = dr["UniversityId"].ToString(); + string Majorgroup = dr["Majorgroup"].ToString(); + string Subjectclaim = dr["Subjectclaim"].ToString(); + string Plancount = dr["Plancount"].ToString() == "" ? "0" : dr["Plancount"].ToString() == null ? "0" : dr["Plancount"].ToString(); + string Tuitionfee = dr["Tuitionfee"].ToString(); + string Languageclaim = dr["Languageclaim"].ToString(); + string Tags = dr["Tags"].ToString(); + string Scoreline = dr["Scoreline"].ToString() == "" ? "0" : dr["Scoreline"].ToString() == null ? "0" : dr["Scoreline"].ToString(); + string Remark = dr["Remark"].ToString(); + string Studyyears = dr["Studyyears"].ToString(); + string MajorName = dr["MajorName"].ToString(); + var schoollowscore = dr["schoollowscore"].ToString() == "" ? "0" : dr["schoollowscore"].ToString() == null ? "0" : dr["schoollowscore"].ToString(); + string schoolprovinline = dr["schoolprovinline"].ToString() == "" ? "0" : dr["schoolprovinline"].ToString() == null ? "0" : dr["schoolprovinline"].ToString(); + string majoraverage = dr["majoraverage"].ToString() == "" ? "0" : dr["majoraverage"].ToString() == null ? "0" : dr["majoraverage"].ToString(); + string heightscore = dr["heightscore"].ToString() == "" ? "0" : dr["heightscore"].ToString() == null ? "0" : dr["heightscore"].ToString(); + string scorepostion = dr["scorepostion"].ToString() == "" ? "0" : dr["scorepostion"].ToString() == null ? "0" : dr["scorepostion"].ToString(); + + int newid = (i - 1) * 10000 + num; + T_EnrollmentPlanedesclist.Add(new T_EnrollmentPlanedesc() + { + Id = newid, + //Name = Name, + BatchtypeId = BatchInfo.Where(x => x.longid == BatchtypeId).Select(x => x.newid).FirstOrDefault(), + PlanId = PlanInfo.Where(x => x.longid == PlanId).Select(x => x.newid).FirstOrDefault(), + UniversityId = dlongidmap.Where(x => x.longid == UniversityId).Select(x => x.newid).FirstOrDefault(), + //Majorgroup = Majorgroup, + Subjectclaim = Subjectclaim, + Plancount = Convert.ToInt32(Plancount), + Tuitionfee = Tuitionfee, + //Languageclaim = Languageclaim, + Tags = Tags, + Scoreline = float.Parse(Scoreline), + Remark = Remark, + Studyyears = Studyyears, + MajorName = MajorName, + //schoollowscore = float.Parse(schoollowscore), + //schoolprovinline = float.Parse(schoolprovinline), + majoraverage = float.Parse(majoraverage), + //heightscore = float.Parse(heightscore), + scorepostion = float.Parse(scorepostion) + }); + T_LongIdMaplist.Add(new T_LongIdMap() { longid = id, newid = newid, tablename = "EnrollmentPlanedesc" }); + num++; + } + await t_EnrollmentPlanedescRepository.Add(T_EnrollmentPlanedesclist); + await _dal.Add(T_LongIdMaplist); + } + } + + + return true; + } + #endregion + + + #region Batchline + /// + /// Batchline + /// + /// + public async Task ImportBatchline() + { + var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\志愿填报\\Batchline.xlsx"); + if (dataSet.Tables.Count > 0) + { + List list = new List() { }; + foreach (DataRow dr in dataSet.Tables[0].Rows) + { + string id = dr["_id"].ToString(); + string areaName = dr["areaName"].ToString(); + string year = dr["year"].ToString(); + string average = dr["average"].ToString(); + string type_name = dr["type_name"].ToString(); + string batch_name = dr["batch_name"].ToString(); + + var info = await t_BatchlineRepository.Add(new T_Batchline() + { + AreaName = areaName, + Average = Convert.ToInt32(average), + Batch_name = batch_name, + Type_name = type_name, + Year = Convert.ToInt32(year) + }); + if (info > 0) + { + list.Add(new T_LongIdMap() { longid = id, newid = info, tablename = "Batchline" }); + } + } + await _dal.Add(list); + } + + return true; + } + #endregion + + #region BatchTypeInfo + /// + /// BatchTypeInfo + /// + /// + public async Task ImportBatchTypeInfo() + { + var dataSet = ExcelUtil.ReadExcelToDataSet("D:\\Ashuju\\志愿填报\\BatchTypeInfo.xlsx"); + if (dataSet.Tables.Count > 0) + { + List list = new List() { }; + foreach (DataRow dr in dataSet.Tables[0].Rows) + { + string id = dr["_id"].ToString(); + string AreaName = dr["AreaName"].ToString(); + string BatchName = dr["BatchName"].ToString(); + string Year = dr["Year"].ToString(); + + + var info = await t_BatchTypeInfoRepository.Add(new T_BatchTypeInfo() + { + AreaName = AreaName, + Year = Convert.ToInt32(Year), + BatchName=BatchName, + }); + if (info > 0) + { + list.Add(new T_LongIdMap() { longid = id, newid = info, tablename = "BatchTypeInfo" }); + } + } + await _dal.Add(list); + } + + return true; + } + #endregion + } +} \ No newline at end of file diff --git a/New_College.Services/T_PlanMapTagServices.cs b/New_College.Services/T_PlanMapTagServices.cs new file mode 100644 index 0000000..5de3a8a --- /dev/null +++ b/New_College.Services/T_PlanMapTagServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class T_PlanMapTagServices : BaseServices, IT_PlanMapTagServices + { + private readonly IBaseRepository _dal; + public T_PlanMapTagServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/T_RegionScoreServices.cs b/New_College.Services/T_RegionScoreServices.cs new file mode 100644 index 0000000..b95d6cc --- /dev/null +++ b/New_College.Services/T_RegionScoreServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class T_RegionScoreServices : BaseServices, IT_RegionScoreServices + { + private readonly IBaseRepository _dal; + public T_RegionScoreServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/TasksQzServices.cs b/New_College.Services/TasksQzServices.cs new file mode 100644 index 0000000..513aa02 --- /dev/null +++ b/New_College.Services/TasksQzServices.cs @@ -0,0 +1,19 @@ +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; + +namespace New_College.Services +{ + public partial class TasksQzServices : BaseServices, ITasksQzServices + { + IBaseRepository _dal; + public TasksQzServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + } +} + \ No newline at end of file diff --git a/New_College.Services/Test_CategoryInfoServices.cs b/New_College.Services/Test_CategoryInfoServices.cs new file mode 100644 index 0000000..8e91bad --- /dev/null +++ b/New_College.Services/Test_CategoryInfoServices.cs @@ -0,0 +1,112 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using System.Collections.Generic; +using New_College.Model.ViewModels; +using System.Threading.Tasks; +using System.Linq; +using New_College.IRepository; +using New_College.Common.WebApiClients.HttpApis; +using YIJIYI.Core.Common.Helper; +using System; + +namespace New_College.Services +{ + public class Test_CategoryInfoServices : BaseServices, ITest_CategoryInfoServices + { + private readonly IBaseRepository _dal; + private readonly ITest_PsychMeasurementInfoRepository test_PsychMeasurementInfoRepository; + private readonly ITest_CycleTimeInfoRepository test_CycleTimeInfoRepository; + private readonly IV_OrderInfoRepository v_OrderInfoRepository; + + public Test_CategoryInfoServices(IBaseRepository dal + , ITest_PsychMeasurementInfoRepository ITest_PsychMeasurementInfoRepository + , ITest_CycleTimeInfoRepository ITest_CycleTimeInfoRepository + , IV_OrderInfoRepository IV_OrderInfoRepository) + { + this._dal = dal; + test_PsychMeasurementInfoRepository = ITest_PsychMeasurementInfoRepository; + test_CycleTimeInfoRepository = ITest_CycleTimeInfoRepository; + v_OrderInfoRepository = IV_OrderInfoRepository; + base.BaseDal = dal; + } + + /// + /// 获取分类 根绝type + /// + /// + public async Task> GetCateSelectByType(CategoryInfoQuery query) + { + var info = await _dal.Query(x => x.IsDelete == false && x.OrderSort == query.Type); + if (info.Count <= 0) + return new List() { }; + //var orderinfo = await v_OrderInfoRepository.Query(x => x.IsDelete == false); + var ids = info.Select(x => x.Id).ToList(); + var testinfo = await test_PsychMeasurementInfoRepository.Query(x => x.IsDelete == false && ids.Contains(x.CategoryId)); + //var cycleinfo = await test_CycleTimeInfoRepository.Query(x => x.IsDelete == false); + List list = new List() { }; + foreach (var item in info) + { + list.Add(new CategoryInfoResult() + { + Id = item.Id, + Name = item.Name, + Desc = item.Desc, + Detail = item.Detail, + JoinCount = testinfo.Count(x => x.CategoryId == item.Id) + }); + } + return list; + } + + /// + /// 获取测评状态 + /// + /// + /// + public async Task GetTestStatus(CategoryStatusQuery query) + { + var info = await v_OrderInfoRepository.Query(x => x.CustomerId == query.CustomerId && x.IsDelete == false); + if (info.Count <= 0) + return new CategoryStatusResult() { }; + var viptype = info.OrderByDescending(x => x.CreateTime).FirstOrDefault().CardTypeId; + var cycleinfo = await test_CycleTimeInfoRepository.Query(x => x.VipCardTypeId == viptype && x.IsDelete == false && x.CategoryId == query.CategoryId); + if (cycleinfo.Count <= 0) + return new CategoryStatusResult() { }; + var psych = await test_PsychMeasurementInfoRepository.Query(x => x.CategoryId == query.CategoryId && x.StudentId == query.CustomerId); + if (psych.Count <= 0) + return new CategoryStatusResult() + { + CycleTimeId = cycleinfo.FirstOrDefault().Id, + TestNum = 0 + }; + var CycleTimeId = 0; + var TestNum = 0; + DateTime? TopTime = TimeUtil.GetCstDateTime(); + foreach (var item in cycleinfo) + { + if (CycleTimeId > 0) + continue; + var nowinfo = psych.Where(x => x.CycleTimeId == item.Id).FirstOrDefault(); + if (nowinfo != null) + { + TopTime = nowinfo.CreateTime; + TestNum++; + } + else + { + CycleTimeId = item.Id; + } + + } + return new CategoryStatusResult() + { + CycleTimeId = CycleTimeId, + TestNum = TestNum, + TopTime = TopTime + }; + } + } +} \ No newline at end of file diff --git a/New_College.Services/Test_CycleTimeInfoServices.cs b/New_College.Services/Test_CycleTimeInfoServices.cs new file mode 100644 index 0000000..ed2cd52 --- /dev/null +++ b/New_College.Services/Test_CycleTimeInfoServices.cs @@ -0,0 +1,59 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.IRepository; +using System.Threading.Tasks; +using System.Collections.Generic; + +namespace New_College.Services +{ + public class Test_CycleTimeInfoServices : BaseServices, ITest_CycleTimeInfoServices + { + private readonly IBaseRepository _dal; + private readonly IV_VipCardTypeRepository v_VipCardTypeRepository; + private readonly ITest_CategoryInfoRepository test_CategoryInfoRepository; + public Test_CycleTimeInfoServices(IBaseRepository dal + , IV_VipCardTypeRepository IV_VipCardTypeRepository + , ITest_CategoryInfoRepository ITest_CategoryInfoRepository) + { + this._dal = dal; + v_VipCardTypeRepository = IV_VipCardTypeRepository; + test_CategoryInfoRepository = ITest_CategoryInfoRepository; + base.BaseDal = dal; + } + + /// + /// 生成周期 + /// + /// + public async Task AutoCycleTime() + { + var cardtype = await v_VipCardTypeRepository.Query(x => x.IsDelete == false); + var category = await test_CategoryInfoRepository.Query(x => x.IsDelete == false && x.CreateId == 999); + List list = new List() { }; + foreach (var item in cardtype) + { + var num = item.OrderSort; + foreach (var items in category) + { + for (int i = 1; i <= num; i++) + { + var cyclename = "第" + i + "次"; + list.Add(new Test_CycleTimeInfo() + { + CategoryId = items.Id, + CycleName = cyclename, + IsOpen = 1, + VipCardTypeId = item.Id, + OrderSort = i + }); + } + } + } + var result = await _dal.Add(list); + return result > 0 ? true : false; + } + } +} \ No newline at end of file diff --git a/New_College.Services/Test_HollandResultInfoServices.cs b/New_College.Services/Test_HollandResultInfoServices.cs new file mode 100644 index 0000000..94c81b8 --- /dev/null +++ b/New_College.Services/Test_HollandResultInfoServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class Test_HollandResultInfoServices : BaseServices, ITest_HollandResultInfoServices + { + private readonly IBaseRepository _dal; + public Test_HollandResultInfoServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/Test_MBTIMapResultServices.cs b/New_College.Services/Test_MBTIMapResultServices.cs new file mode 100644 index 0000000..02b09e1 --- /dev/null +++ b/New_College.Services/Test_MBTIMapResultServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class Test_MBTIMapResultServices : BaseServices, ITest_MBTIMapResultServices + { + private readonly IBaseRepository _dal; + public Test_MBTIMapResultServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/Test_PsychMeasurementInfoServices.cs b/New_College.Services/Test_PsychMeasurementInfoServices.cs new file mode 100644 index 0000000..d663274 --- /dev/null +++ b/New_College.Services/Test_PsychMeasurementInfoServices.cs @@ -0,0 +1,1250 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using System.Collections.Generic; +using New_College.Model.ViewModels; +using System.Linq; +using Newtonsoft.Json; +using System.Threading.Tasks; +using New_College.Common.Helper; +using New_College.IRepository; +using System.Reflection; +using System; +using System.Text; +using New_College.Model; + +namespace New_College.Services +{ + public class Test_PsychMeasurementInfoServices : BaseServices, ITest_PsychMeasurementInfoServices + { + private readonly IBaseRepository _dal; + private readonly ITest_QuestionTypeInfoRepository _QuestionTypeInfoRepository; + private readonly ITest_MBTIMapResultRepository test_MBTIMapResultRepository; + private readonly ITest_CycleTimeInfoRepository test_CycleTimeInfoRepository; + private readonly IV_SubjectSelectRepository v_SubjectSelectRepository; + private readonly IT_PlanMapTagRepository t_PlanMapTagRepository; + private readonly IT_EnrollmentPlaneRepository t_EnrollmentPlaneRepository; + private readonly IT_EnrollmentPlanedescRepository t_EnrollmentPlanedescRepository; + + public Test_PsychMeasurementInfoServices(IBaseRepository dal + , ITest_QuestionTypeInfoRepository ITest_QuestionTypeInfoRepository + , ITest_MBTIMapResultRepository ITest_MBTIMapResultRepository + , ITest_CycleTimeInfoRepository ITest_CycleTimeInfoRepository + , IV_SubjectSelectRepository IV_SubjectSelectRepository + , IT_PlanMapTagRepository IT_PlanMapTagRepository + , IT_EnrollmentPlaneRepository IT_EnrollmentPlaneRepository + , IT_EnrollmentPlanedescRepository IT_EnrollmentPlanedescRepository) + { + this._dal = dal; + _QuestionTypeInfoRepository = ITest_QuestionTypeInfoRepository; + test_MBTIMapResultRepository = ITest_MBTIMapResultRepository; + test_CycleTimeInfoRepository = ITest_CycleTimeInfoRepository; + v_SubjectSelectRepository = IV_SubjectSelectRepository; + t_PlanMapTagRepository = IT_PlanMapTagRepository; + t_EnrollmentPlaneRepository = IT_EnrollmentPlaneRepository; + t_EnrollmentPlanedescRepository = IT_EnrollmentPlanedescRepository; + base.BaseDal = dal; + } + public List permut = new List(); + /// + /// 获取个人某个维度测评结果 + /// + /// + /// + public async Task> GetPsychListByCateAndCustomerId(PsychMeasurementQuery query) + { + var info = await _dal.Query(x => x.IsDelete == false && x.CategoryId == query.CategoryId && x.StudentId == query.StudentId); + if (info.Count <= 0) + return new List() { }; + var cycids = info.Select(x => x.CycleTimeId).ToList(); + var cycinfo = await test_CycleTimeInfoRepository.Query(x => x.IsDelete == false && cycids.Contains(x.Id)); + List list = new List() { }; + foreach (var item in info) + { + var cycname = cycinfo.Where(x => x.Id == item.CycleTimeId).Select(x => x.CycleName)?.FirstOrDefault(); + if (!string.IsNullOrWhiteSpace(cycname)) + list.Add(new PsychMeasurementListResult() + { + Id = item.Id, + CreateTime = item.CreateTime, + CycleTimeId = item.CycleTimeId, + CycleName = cycname, + IsOpen = item.IsOpen + }); + } + return list; + } + + /// + /// 提交 + /// + /// + public async Task SavePsych(SavePsychQuery query) + { + var IsOpen = 1; + var result = ""; + //if (query.Type == 2) + //{ + // result = JsonConvert.SerializeObject(query.CareerResult); + //} + //else + if (query.Type == 1) + { + if (query.CategoryId == 11) + { + var item = DirectionChangeXXFG(query); + result = JsonConvert.SerializeObject(item); + } + else + { + var ListType = (await _QuestionTypeInfoRepository.Query(x => x.IsDelete == false)).Select(x => x.Name).ToList(); + var item = DirectionChange(query, ListType); + result = JsonConvert.SerializeObject(item); + } + } + else if (query.Type == 3) + { + IsOpen = 0; + if (query.CategoryId == 15) + { + var item = DirectionChangeMENTAL(query); + result = JsonConvert.SerializeObject(item); + } + else + { + var item = PshchDirectionChange(query); + result = JsonConvert.SerializeObject(item); + } + } + else if (query.CategoryId == 20) + { + result = JsonConvert.SerializeObject(query.Result); + } + var info = await _dal.Add(new Test_PsychMeasurementInfo() + { + StudentId = query.StudentId, + CategoryId = query.CategoryId, + CycleTimeId = query.CycleTimeId, + //ClassName = query.ClassName, + //GradeName = query.GradeName, + IsOpen = IsOpen, + Result = result + }); + if (info > 0) + { + ////生涯能力数据处理 + //if (query.Type == 2) + //{ + // #region 能力评估 + // UpdateEval(query.CareerResult, query.CategoryId, query.StudentId); + // #endregion + + // #region 变化反馈 + // UpdateGrow(query.CareerResult, query.CycleTimeId, query.CategoryId, query.StudentId); + // #endregion + //} + return true; + } + else + { + return false; + } + } + + #region 提交 数据处理 + /// + /// 普通 学生发展用 + /// + /// + /// + public List DirectionChange(SavePsychQuery query, List ListType) + { + var Result = new List(); + var QuestionType = query.second.Select(p => p.Tag).Distinct().ToList(); + foreach (var item in QuestionType) + { + if (item != "null" && ListType.Contains(item)) + { + var seconddto = new IntellectJson(); + seconddto.value = query.second.Where(m => m.Tag == item).Sum(p => p.Status); + seconddto.name = item; + Result.Add(seconddto); + } + } + return Result; + } + /// + /// 普通 心理测量用 + /// + /// + /// + public List PshchDirectionChange(SavePsychQuery query) + { + var Result = new List(); + var QuestionType = query.second.Select(p => p.Tag).Distinct().ToList(); + foreach (var item in QuestionType) + { + if (item != "null") + { + var seconddto = new IntellectJson(); + seconddto.value = query.second.Where(m => m.Tag == item).Sum(p => p.Status); + seconddto.name = item; + Result.Add(seconddto); + } + } + return Result; + } + /// + /// 学习风格专用 + /// + /// + /// + /// + private List DirectionChangeXXFG(SavePsychQuery requestDTO) + { + List list = new List() { }; + var json = new IntellectJson(); + var A = 0; + var P = 0; + var R = 0; + var T = 0; + int[] styleA = { 2, 5, 8, 15, 19, 23, 26, 35, 36, 40 }; + int[] styleP = { 4, 7, 9, 14, 20, 24, 27, 31, 34, 37 }; + int[] styleR = { 11, 12, 16, 18, 21, 25, 29, 30, 32, 33 }; + int[] styleT = { 1, 3, 6, 10, 13, 17, 22, 28, 38, 39 }; + foreach (var item in requestDTO.second) + { + if (styleA.Contains(item.Id)) + { + A += item.Status; + } + else if (styleP.Contains(item.Id)) + { + P += item.Status; + } + else if (styleR.Contains(item.Id)) + { + R += item.Status; + } + else if (styleT.Contains(item.Id)) + { + T += item.Status; + } + + } + list.AddRange(new List{new IntellectJson + { + name = "冲动型", + value = A + }, new IntellectJson + { + name = "务实型", + value = P + }, new IntellectJson + { + name = "反思型", + value = R + }, new IntellectJson + { + name = "理论型", + value = T + } }); + + return list;//JsonConvert.SerializeObject(list); + // return "[{\"name\":\"冲动型\",\"value\":" + A + "},{\"name\":\"务实型\",\"value\":" + P + "},{\"name\":\"反思型\",\"value\":" + R + "},{\"name\":\"理论型\",\"value\":" + T + "}]"; + } + /// + /// mht专用 + /// + /// + /// + /// + /// + private List DirectionChangeMENTAL(SavePsychQuery requestDTO) + { + List list = new List() { }; + var xxjl = 0; + var drjl = 0; + var gdqx = 0; + var zzqx = 0; + var gmqx = 0; + var stzz = 0; + var kbqx = 0; + var cdqx = 0; + + int[] xuexijiaolv = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };//学习焦虑 + int[] duirenjiaolv = { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 };//对人焦虑 + int[] guduqingxiang = { 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 };//孤独倾向 + int[] zizeqingxiang = { 36, 37, 38, 39, 40, 41, 42, 43, 44, 45 };//自责倾向 + int[] guomingqingxiang = { 46, 47, 48, 49, 50, 51, 52, 53, 54, 55 };//过敏倾向 + int[] shentizhengzhuang = { 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70 };//身体症状 + int[] kongbuqingxiang = { 71, 72, 73, 74, 75, 76, 77, 78, 79, 80 };//恐怖倾向 + int[] chongdongqingxiang = { 81, 83, 85, 87, 89, 91, 93, 95, 97, 99 };//冲动倾向 + int[] valids = { 82, 84, 86, 88, 90, 92, 94, 96, 98, 100 }; //测谎题 + + foreach (var item in requestDTO.second) + { + if (xuexijiaolv.Contains(item.Id)) + { + xxjl += item.Status; + } + else if (duirenjiaolv.Contains(item.Id)) + { + drjl += item.Status; + } + else if (guduqingxiang.Contains(item.Id)) + { + gdqx += item.Status; + } + else if (zizeqingxiang.Contains(item.Id)) + { + zzqx += item.Status; + } + else if (guomingqingxiang.Contains(item.Id)) + { + gmqx += item.Status; + } + else if (shentizhengzhuang.Contains(item.Id)) + { + stzz += item.Status; + } + + else if (kongbuqingxiang.Contains(item.Id)) + { + kbqx += item.Status; + } + else if (chongdongqingxiang.Contains(item.Id)) + { + cdqx += item.Status; + } + + } + list.AddRange(new List { + new IntellectJson{ name="学习焦虑" , value=xxjl}, + new IntellectJson{ name="对人焦虑" , value=drjl}, + new IntellectJson{ name="孤独倾向" , value=gdqx }, + new IntellectJson{ name="自责倾向" , value=zzqx}, + new IntellectJson{ name="过敏倾向" , value=gmqx}, + new IntellectJson{ name="身体症状" , value=stzz}, + new IntellectJson{ name="恐怖倾向" , value=kbqx}, + new IntellectJson{ name="冲动倾向" , value=cdqx}, + }); + + return list;//"[{\"name\":\"学习焦虑\",\"value\":" + xxjl + "},{\"name\":\"对人焦虑\",\"value\":" + drjl + "},{\"name\":\"孤独倾向\",\"value\":" + gdqx + "},{\"name\":\"自责倾向\",\"value\":" + zzqx + "},{\"name\":\"过敏倾向\",\"value\":" + gmqx + "},{\"name\":\"身体症状\",\"value\":" + stzz + "},{\"name\":\"恐怖倾向\",\"value\":" + kbqx + "},{\"name\":\"冲动倾向\",\"value\":" + cdqx + "}]"; + } + + /// + /// 根据最大值获取职业标签名称 + /// + /// + /// + /// + public string GetFieldName(HollandModel model, int maxnumb, string first, string second) + { + string FieldName = string.Empty; + Type t = typeof(HollandModel); + foreach (PropertyInfo finfo in t.GetProperties()) + { + if (finfo.Name != "Target" && Convert.ToInt32(finfo.GetValue(model)) == maxnumb) + { + if (finfo.Name != first && finfo.Name != second) + { + FieldName = finfo.Name; + break; + } + } + } + return FieldName; + } + /// + /// 获取标签数量 + /// + /// + /// + public Tuple, List> GetCategoriesByHoolandModel(HollandModel model) + { + + var FieldNames = new List(); + var series = new List(); + var serieint = new List(); + + Type t = typeof(HollandModel); + foreach (PropertyInfo finfo in t.GetProperties()) + { + FieldNames.Add(finfo.Name); + serieint.Add(Convert.ToInt32(finfo.GetValue(model))); + } + series.Add(new serie() { data = serieint, name = "霍兰德" }); + return new Tuple, List>(FieldNames, series); + } + #endregion + + + #region 提交/获取 霍兰德和MBTI + /// + /// 提交 霍兰德和MBTI + /// + /// + /// + public async Task SaveHolland(SaveHollandQuery query) + { + StringBuilder tagname = new StringBuilder(); + if (query.CategoryId == 18) + { + var model = JsonConvert.DeserializeObject(query.Tags); + int[] Num = new int[] { model.A, model.C, model.E, model.I, model.R, model.S }; + List Numbers = Num.ToList(); + int first = Numbers.Max(); + Numbers.Remove(first); + int second = Numbers.Max(); + Numbers.Remove(second); + int third = Numbers.Max(); + string firstname = GetFieldName(model, first, "", ""); + string secondname = GetFieldName(model, second, firstname, ""); + string thirdname = GetFieldName(model, third, firstname, secondname); + var result = new TagtestingHollandResult(); + var radars = new Radar(); + var temp = GetCategoriesByHoolandModel(model); + radars.categories = temp.Item1; + radars.series = temp.Item2; + result.TagName = firstname + secondname + thirdname; + result.radar = radars; + tagname.Append(JsonConvert.SerializeObject(result)); + + var info = await _dal.Add(new Test_PsychMeasurementInfo() + { + StudentId = query.StudentId, + CategoryId = query.CategoryId, + CycleTimeId = query.CycleTimeId, + //ClassName = query.ClassName, + //GradeName = query.GradeName, + IsOpen = 1, + Result = tagname.ToString() + }); + return info > 0 ? true : false; + } + else if (query.CategoryId == 19) + { + var model = JsonConvert.DeserializeObject(query.Tags); + tagname.Append(model.E > model.I ? "E" : "I"); + tagname.Append(model.S > model.N ? "S" : "N"); + tagname.Append(model.T > model.F ? "T" : "F"); + tagname.Append(model.J > model.P ? "J" : "P"); + var info = await _dal.Add(new Test_PsychMeasurementInfo() + { + StudentId = query.StudentId, + CategoryId = query.CategoryId, + CycleTimeId = query.CycleTimeId, + //ClassName = query.ClassName, + //GradeName = query.GradeName, + IsOpen = 1, + Result = tagname.ToString() + }); + return info > 0 ? true : false; + } + return false; + } + + /// + /// 获取霍兰德测评结果 + /// + /// + /// + public async Task GetHollandResult(ResultLookQuery query) + { + Test_PsychMeasurementInfo info = new Test_PsychMeasurementInfo() { }; + if (query.CycleTimeId > 0) + { + info = (await _dal.Query(x => x.CategoryId == query.CategoryId && x.StudentId == query.StudentId && x.CycleTimeId == query.CycleTimeId)).FirstOrDefault(); + } + else + { + info = (await _dal.Query(x => x.CategoryId == query.CategoryId && x.StudentId == query.StudentId)).OrderByDescending(x => x.CreateTime).FirstOrDefault(); + } + if (info == null || string.IsNullOrEmpty(info.Result)) + return new TagtestingHollandResult() { }; + return JsonConvert.DeserializeObject(info.Result); + } + + /// + /// 获取MBTI测评结果 + /// + /// + /// + public async Task GetMBTIResult(ResultLookQuery query) + { + var info = await _dal.Query(x => x.CategoryId == query.CategoryId && x.StudentId == query.StudentId && x.CycleTimeId == query.CycleTimeId); + if (info.Count() <= 0 || string.IsNullOrEmpty(info?.FirstOrDefault()?.Result)) + return new UserResult() { }; + var mbtiresult = (await test_MBTIMapResultRepository.Query(x => x.Tag == info.FirstOrDefault().Result))?.FirstOrDefault(); + if (mbtiresult == null) + return new UserResult() { }; + return new UserResult() + { + Advantage = mbtiresult.Advantage, + BlindSpot = mbtiresult.BlindSpot, + Disadvantage = mbtiresult.Disadvantage, + Domain = mbtiresult.Domain, + Feature = mbtiresult.Feature, + Interpretation = mbtiresult.Interpretation, + Recommend = mbtiresult.Recommend, + Tag = mbtiresult.Tag + }; + } + #endregion + + /// + /// 获取学生发展 + /// + /// + /// + public async Task GetPsychDetail(ResultLookQuery query) + { + ShowPsychologicalResult result = new ShowPsychologicalResult() { }; + List BillDatas = new List() { }; + List Billcators = new List() { }; + List Result = new List() { }; + List List = new List() { }; + Test_PsychMeasurementInfo info = new Test_PsychMeasurementInfo() { }; + if (query.CycleTimeId > 0) + { + info = (await _dal.Query(x => x.IsDelete == false && x.StudentId == query.StudentId && x.CategoryId == query.CategoryId && x.CycleTimeId == query.CycleTimeId)).FirstOrDefault(); + } + else + { + info = (await _dal.Query(x => x.IsDelete == false && x.StudentId == query.StudentId && x.CategoryId == query.CategoryId)).OrderByDescending(x => x.CreateTime).FirstOrDefault(); + } + + var Json = JsonConvert.DeserializeObject>(info.Result).Where(w => w.name != null).ToList(); + if (query.CategoryId == 7) + { + var Psyintellectags = ShowPsychological.Psyintellectags; + var Psysuggesttypes = ShowPsychological.Psysuggesttypes; + Json.ForEach(m => + { + BillDatas.Add(m.value); + Billcators.Add(new EvBillcator() { max = 65, text = m.name }); + List.Add(new NameValue() { Name = m.name, Value = m.value }); + var info = Psyintellectags.Where(x => x.name == m.name)?.FirstOrDefault(); + if (info != null) + { + var Suggess = ""; + if (m.value <= 35) + { + Suggess = Psysuggesttypes.Where(x => x.name == m.name).Select(x => x.suggest)?.FirstOrDefault(); + } + Result.Add(new PsyTagDetail() + { + MaxScore = 65, + Score = m.value, + Name = m.name, + Title = info.title, + Content = info.content, + Suggess = Suggess + }); + } + }); + return new ShowPsychologicalResult() + { + Name = "多元智能", + BillDatas = BillDatas, + Billcators = Billcators, + List = List, + Result = Result + }; + } + else if (query.CategoryId == 8) + { + var showsuggesttaggests = ShowMultiDimension.showsuggesttaggests; + Json.ForEach(m => + { + BillDatas.Add(m.value); + Billcators.Add(new EvBillcator() { max = 12, text = m.name }); + List.Add(new NameValue() { Name = m.name, Value = m.value }); + var info = showsuggesttaggests.Where(x => x.name == m.name)?.FirstOrDefault(); + if (info != null) + { + var Suggess = ""; + var Taggess = ""; + if (info.score == 17) + { + if (m.value > info.score) + { + Suggess = info.suggest; + Taggess = info.truetaggest; + } + Taggess = info.falsetaggest; + } + else + { + if (m.value < info.score) + { + Suggess = info.suggest; + Taggess = info.truetaggest; + } + Taggess = info.falsetaggest; + } + Result.Add(new PsyTagDetail() + { + MaxScore = 12, + Score = m.value, + Name = m.name, + //Title = info.title, + Content = Taggess, + Suggess = Suggess + }); + } + }); + return new ShowPsychologicalResult() + { + Name = "学习多维分析", + BillDatas = BillDatas, + Billcators = Billcators, + List = List, + Result = Result + }; + } + else if (query.CategoryId == 9) + { + Json.ForEach(m => + { + Result.Add(new PsyTagDetail() + { + MaxScore = 37, + Score = m.value, + Content = "得分12分以下考试焦虑属较低水平,13分至20分属中等程度,21以上属较高水平。21分以上者的考试焦虑程度较高,建议掌握一些考试减压技巧和应试技巧", + Name = m.name + }); + }); + return new ShowPsychologicalResult() + { + Name = "考试焦虑测试", + Result = Result + }; + } + else if (query.CategoryId == 10) + { + Json.ForEach(m => + { + Result.Add(new PsyTagDetail() + { + MaxScore = 200, + Score = m.value, + Name = m.name, + Title = "任何一个学习者,都有必要培养和提高自己的学习技能。要想提高自己的学习技能,必须全面掌握各个学习环节的具体方法。对于在校学生来说,也就是要掌握预习、听课、复习、作业和应考方法。分数越高,学习技能越强。", + Content = m.value >= 137 ? "学习技能较好(或优秀),建议再接再厉,全面发展!" : "学习技能水平较差(或一般),注意改进学习方法", + Suggess = m.value >= 137 ? "" : "

(一)预习:用快速略读法事先预习极多次,但不要求完全懂。
(二)上课(a)用专心放轻松的方法听讲,保持灵敏的心去听,不主动要求自己全部听懂。(b)除非特殊状况,一定要作笔记,笔记愈整洁明晰愈好(不要为了省钱将笔记记得密密麻麻的),以利日后快、慢速的复习。(c)在老师停顿或转身抄黑板的时候,迅速回想(最好口中默念出来)老师刚刚讲的重点,此种回想又可以叫潜意识迅速转极多次以消化之。
(三)家中复习:复习功课的第一步骤,也是先快速略读多次,有空的时候作一次详读之后(此时要在课本、笔记上划出重点),再多花一点时间回想上课的重点。若因为晚上补习没有足够时间,虽可以省掉详读,但略读和回想一定要作。记住不论如何忙,最多三、五天一定要将老师教过的部份,作过一次详读(没有时间的话,至少要作快速详读)。
(四)做作业:做作业之前(必要时可以找一本比较完整的参考书来做,其作业题通常比课本多很多),要确定有没有先回想重点。
(五)复习以前的功课:每隔三五天最好翻开笔记本,迅速的略读前一两个星期的功课。有空的话,将笔记本上划重点的部份出声念一遍。
(六)考前复习:和家中复习那一项差不多,但要找出时间,针对笔记上的重点发出声音教给一个假想的人或同学。同时也要找一些例题和具有代表性的习题,教一教这个假想人。
(七)考前猜题:想象自己是老师,出一些与重点有关的题目。不一定要真的去作出来(因为是自己出的题目,若题目合理则本来就会做),但可以将这一些题目和课本互相印证,找出某几课中的真正重点和如何应用这些重点。
(八)考前保持感觉最佳状态有二种方式:(a)考前做一些有代表性的例题和习题,从这一些题目中回想重点,回想时若发现忘了重点,翻开笔记看一看那一部份重点就可。(b)将笔记上的重点(或整理出的重点)重复多次地看,虽然不耐烦了还要再看,过度50%。


" + }); + }); + return new ShowPsychologicalResult() + { + Name = "学习技能测试", + Result = Result + }; + } + else if (query.CategoryId == 11) + { + Json.ForEach(m => + { + BillDatas.Add(m.value); + Billcators.Add(new EvBillcator() { max = 50, text = m.name }); + List.Add(new NameValue() { Name = m.name, Value = m.value }); + }); + return new ShowPsychologicalResult() + { + Name = "学习风格测评", + BillDatas = BillDatas, + Billcators = Billcators, + List = List, + }; + } + else if (query.CategoryId == 13) + { + var anxietyInfos = ShowSelfofAnxiety.anxietyInfos; + Json.ForEach(m => + { + var score = 0; + if (m.value >= 70) + { + score = 1; + } + else if (m.value >= 60) + { + score = 2; + } + else if (m.value >= 50) + { + score = 3; + } + else + { + score = 4; + } + var nowinfo = anxietyInfos.Where(x => x.score == score)?.FirstOrDefault(); + if (nowinfo != null) + { + Result.Add(new PsyTagDetail() + { + Score = m.value, + Title = nowinfo.title, + Suggess = nowinfo.suggess + }); + } + }); + return new ShowPsychologicalResult() + { + Name = "SAS测试", + Result = Result + }; + } + else if (query.CategoryId == 14) + { + //sds + var selfofDepressionInfos = ShowSelfofDepression.selfofDepressionInfos; + Json.ForEach(m => + { + var score = 0; + if (m.value < 53) + { + score = 1; + } + else if (m.value <= 62) + { + score = 2; + } + else if (m.value <= 72) + { + score = 3; + } + else + { + score = 4; + } + var nowinfo = selfofDepressionInfos.Where(x => x.score == score)?.FirstOrDefault(); + if (nowinfo != null) + { + Result.Add(new PsyTagDetail() + { + Score = m.value, + Title = nowinfo.title, + Suggess = nowinfo.suggess, + Content = nowinfo.result + }); + } + }); + return new ShowPsychologicalResult() + { + Name = "SDS测试", + Result = Result + }; + } + else if (query.CategoryId == 15) + { + var mentalHealthInfos = ShowMentalHealth.mentalHealthInfos; + Json.ForEach(m => + { + List.Add(new NameValue() { Name = m.name, Value = m.value }); + var nowinfo = mentalHealthInfos.Where(x => x.title == m.name)?.FirstOrDefault(); + var Suggess = ""; + if (nowinfo != null) + { + if (m.value > 8) + { + Suggess = nowinfo.maxsuggest; + } + else if (m.value < 3) + { + Suggess = nowinfo.minsuggest; + } + Result.Add(new PsyTagDetail() + { + Score = m.value, + Title = nowinfo.title, + Suggess = Suggess + }); + } + }); + return new ShowPsychologicalResult() + { + Name = "MHT测试", + Result = Result, + List = List + }; + } + return new ShowPsychologicalResult() { }; + } + + /// + /// 学科探索 结果 + /// + /// + /// + public async Task> SubjectChartRadar(ResultLookQuery query) + { + SubjectEvBillDTO dTO = new SubjectEvBillDTO() { }; + var info = (await _dal.Query(x => x.IsDelete == false && x.StudentId == query.StudentId && x.CategoryId == query.CategoryId && x.CycleTimeId == query.CycleTimeId)).FirstOrDefault(); + if (info == null) + return new MessageModel() { success = false, msg = "未测试" }; + List newlist = new List() { }; + newlist.Add(new IntellectJson() { name = "物理", value = 0 }); + newlist.Add(new IntellectJson() { name = "化学", value = 0 }); + newlist.Add(new IntellectJson() { name = "生物", value = 0 }); + newlist.Add(new IntellectJson() { name = "政治", value = 0 }); + newlist.Add(new IntellectJson() { name = "历史", value = 0 }); + newlist.Add(new IntellectJson() { name = "地理", value = 0 }); + + EvBillDTO subjectinterest = new EvBillDTO() { }; + var chartsinterestvalue = new List(); + var evbillinterest = new List(); + + EvBillDTO subjectability = new EvBillDTO() { }; + var chartsabilitvalue = new List(); + var evbillabilit = new List(); + var result = JsonConvert.DeserializeObject>(info.Result); + var xq = result.Where(w => w.name == "学科兴趣").FirstOrDefault().value; + foreach (var item in xq) + { + switch (item.name) + { + case "物理": + chartsinterestvalue.Add(item.value); + newlist.Where(x => x.name == "物理").FirstOrDefault().value += item.value; + break; + case "化学": + chartsinterestvalue.Add(item.value); + newlist.Where(x => x.name == "化学").FirstOrDefault().value += item.value; + break; + case "生物": + chartsinterestvalue.Add(item.value); + newlist.Where(x => x.name == "生物").FirstOrDefault().value += item.value; + break; + case "政治": + chartsinterestvalue.Add(item.value); + newlist.Where(x => x.name == "政治").FirstOrDefault().value += item.value; + break; + case "历史": + chartsinterestvalue.Add(item.value); + newlist.Where(x => x.name == "历史").FirstOrDefault().value += item.value; + break; + case "地理": + chartsinterestvalue.Add(item.value); + newlist.Where(x => x.name == "地理").FirstOrDefault().value += item.value; + break; + } + } + subjectinterest.BillDatas = chartsinterestvalue; + + var subjectinterestnewsort = xq.OrderByDescending(x => x.value); + subjectinterest.Name = string.Join("|", subjectinterestnewsort.Take(3).Select(x => x.name).ToList()); + + evbillinterest.Add(new EvBillcator() { max = 32, text = "物理" }); + evbillinterest.Add(new EvBillcator() { max = 32, text = "化学" }); + evbillinterest.Add(new EvBillcator() { max = 32, text = "生物" }); + evbillinterest.Add(new EvBillcator() { max = 32, text = "政治" }); + evbillinterest.Add(new EvBillcator() { max = 32, text = "历史" }); + evbillinterest.Add(new EvBillcator() { max = 32, text = "地理" }); + + var nl = result.Where(w => w.name == "学科能力").FirstOrDefault().value; + foreach (var item in nl) + { + switch (item.name) + { + case "物理": + chartsabilitvalue.Add(item.value); + newlist.Where(x => x.name == "物理").FirstOrDefault().value += item.value; + break; + case "化学": + chartsabilitvalue.Add(item.value); + newlist.Where(x => x.name == "化学").FirstOrDefault().value += item.value; + break; + case "生物": + chartsabilitvalue.Add(item.value); + newlist.Where(x => x.name == "生物").FirstOrDefault().value += item.value; + break; + case "政治": + chartsabilitvalue.Add(item.value); + newlist.Where(x => x.name == "政治").FirstOrDefault().value += item.value; + break; + case "历史": + chartsabilitvalue.Add(item.value); + newlist.Where(x => x.name == "历史").FirstOrDefault().value += item.value; + break; + case "地理": + chartsabilitvalue.Add(item.value); + newlist.Where(x => x.name == "地理").FirstOrDefault().value += item.value; + break; + } + } + subjectability.BillDatas = chartsabilitvalue; + + var subjectabilitynewsort = nl.OrderByDescending(x => x.value); + subjectability.Name = string.Join("|", subjectabilitynewsort.Take(3).Select(x => x.name).ToList()); + + evbillabilit.Add(new EvBillcator() { max = 32, text = "物理" }); + evbillabilit.Add(new EvBillcator() { max = 32, text = "化学" }); + evbillabilit.Add(new EvBillcator() { max = 32, text = "生物" }); + evbillabilit.Add(new EvBillcator() { max = 32, text = "政治" }); + evbillabilit.Add(new EvBillcator() { max = 32, text = "历史" }); + evbillabilit.Add(new EvBillcator() { max = 32, text = "地理" }); + + var namelist = newlist.OrderByDescending(x => x.value).Take(3).Select(x => x.name).ToList(); + var Name = string.Join("|", namelist); + return new MessageModel() + { + success = true, + msg = "获取成功", + response = new SubjectEvBillDTO() + { + Name = Name, + subjectability = subjectability, + subjectinterest = subjectinterest + } + }; + } + + /// + /// 传入用户Id 获取霍兰德测评状态 + /// + /// + /// + public async Task> GetHollandStatus(IdQuery query) + { + var info = await _dal.Query(x => x.StudentId == query.Id && x.CategoryId == 18 && x.IsDelete == false); + if (info.Count <= 0) + return new MessageModel() { success = false, msg = "暂未测试霍兰德" }; + var result = info.OrderByDescending(x => x.CreateTime).Select(x => x.Result)?.FirstOrDefault(); + var tag = JsonConvert.DeserializeObject(result).TagName; + return new MessageModel() + { + success = true, + msg = "获取成功", + response = tag + }; + } + + /// + /// 传入用户Id 获取学科探索测评状态 + /// + /// + /// + public async Task> GetSubjectSelectStatus(IdQuery query) + { + var info = await _dal.Query(x => x.StudentId == query.Id && x.CategoryId == 20 && x.IsDelete == false); + if (info.Count <= 0) + return new MessageModel() { success = false, msg = "暂未测试学科探索" }; + return new MessageModel() { success = true, msg = "已测试学科探索" }; + } + + /// + /// 获取测评最新周期Id + /// + /// + /// + public async Task> GetReportCycleInfo(IdQuery query) + { + var info = await _dal.Query(x => x.IsDelete == false && x.StudentId == query.Id); + if (info.Count <= 0) + return new MessageModel() { success = false, msg = "未测评" }; + var nengli = info.Where(x => x.CategoryId == 7).OrderByDescending(x => x.CreateTime).FirstOrDefault(); + if (nengli == null) + return new MessageModel() { success = false, msg = "未测评完全,请先去测试多元智能" }; + var duowei = info.Where(x => x.CategoryId == 8).OrderByDescending(x => x.CreateTime).FirstOrDefault(); + if (duowei == null) + return new MessageModel() { success = false, msg = "未测评完全,请先去测试多维分析" }; + var jiaolv = info.Where(x => x.CategoryId == 9).OrderByDescending(x => x.CreateTime).FirstOrDefault(); + if (jiaolv == null) + return new MessageModel() { success = false, msg = "未测评完全,请先去测试考试焦虑" }; + var jineng = info.Where(x => x.CategoryId == 10).OrderByDescending(x => x.CreateTime).FirstOrDefault(); + if (jineng == null) + return new MessageModel() { success = false, msg = "未测评完全,请先去测评学习技能" }; + var fengge = info.Where(x => x.CategoryId == 11).OrderByDescending(x => x.CreateTime).FirstOrDefault(); + if (fengge == null) + return new MessageModel() { success = false, msg = "未测评完全,请先去测评学习风格" }; + return new MessageModel() + { + success = true, + msg = "获取成功", + response = new CycleInfoResult() + { + nengliCycleId = nengli.CycleTimeId, + duoweiCycleId = duowei.CycleTimeId, + fenggeCycleId = fengge.CycleTimeId, + jiaolvCycleId = jiaolv.CycleTimeId, + jinengCycleId = jineng.CycleTimeId + } + }; + } + + + + /// + /// 获取三种推荐选科 + /// + /// + /// + public async Task>> GetSubjectSelectResult(NewSubjectQuery query) + { + List list = new List() { }; + #region 学科探索 + var info = (await _dal.Query(x => x.IsDelete == false && x.StudentId == query.CustomerId && x.CategoryId == 20 && x.CycleTimeId == 1)).FirstOrDefault(); + if (info == null) + return new MessageModel>() { success = false, msg = "未测试" }; + List newlist = new List() { }; + newlist.Add(new IntellectJson() { name = "物", value = 0 }); + newlist.Add(new IntellectJson() { name = "化", value = 0 }); + newlist.Add(new IntellectJson() { name = "生", value = 0 }); + newlist.Add(new IntellectJson() { name = "政", value = 0 }); + newlist.Add(new IntellectJson() { name = "史", value = 0 }); + newlist.Add(new IntellectJson() { name = "地", value = 0 }); + var result = JsonConvert.DeserializeObject>(info.Result).FirstOrDefault().value; + foreach (var item in result) + { + switch (item.name) + { + case "物理": + newlist.Where(x => x.name == "物").FirstOrDefault().value += item.value; + break; + case "化学": + newlist.Where(x => x.name == "化").FirstOrDefault().value += item.value; + break; + case "生物": + newlist.Where(x => x.name == "生").FirstOrDefault().value += item.value; + break; + case "政治": + newlist.Where(x => x.name == "政").FirstOrDefault().value += item.value; + break; + case "历史": + newlist.Where(x => x.name == "史").FirstOrDefault().value += item.value; + break; + case "地理": + newlist.Where(x => x.name == "地").FirstOrDefault().value += item.value; + break; + } + } + var namelist = newlist.OrderByDescending(x => x.value).Take(3).Select(x => x.name).ToList(); + var subjectName = string.Join("+", namelist); + #endregion + #region 霍兰德 + var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + if (planinfo == null) + return new MessageModel>() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + var planid = planinfo.FirstOrDefault().Id; + if (string.IsNullOrWhiteSpace(query.Tag)) + return new MessageModel>() { success = false, msg = "标签传入为空,请去测试" }; + var newTags = GetTag(query.Tag); + var planmaptag = await t_PlanMapTagRepository.Query(x => x.IsDelete == false); + List majorlists = new List() { }; + foreach (var item in newTags) + { + majorlists.AddRange(planmaptag.Where(x => x.Tag.Contains(item)).Select(x => x.Name).ToList()); + } + majorlists = majorlists.Distinct().ToList(); + var descinfo = await t_EnrollmentPlanedescRepository.Query(x => x.IsDelete == false && x.PlanId == planid && majorlists.Contains(x.MajorName) && x.UniversityId > 0); + List hollandlist = new List() { }; + hollandlist.Add(new IdNameResult() { Name = "物", Id = descinfo.Count(x => x.Subjectclaim.Contains("物")) }); + hollandlist.Add(new IdNameResult() { Name = "化", Id = descinfo.Count(x => x.Subjectclaim.Contains("化")) }); + hollandlist.Add(new IdNameResult() { Name = "生", Id = descinfo.Count(x => x.Subjectclaim.Contains("生")) }); + hollandlist.Add(new IdNameResult() { Name = "政", Id = descinfo.Count(x => x.Subjectclaim.Contains("政")) }); + hollandlist.Add(new IdNameResult() { Name = "史", Id = descinfo.Count(x => x.Subjectclaim.Contains("史")) }); + hollandlist.Add(new IdNameResult() { Name = "地", Id = descinfo.Count(x => x.Subjectclaim.Contains("地")) }); + var hollandresult = hollandlist.OrderByDescending(x => x.Id).Select(x => x.Name).Take(3).ToList(); + var HollandName = string.Join("+", hollandresult); + #endregion + #region 自选 + var Optional = await v_SubjectSelectRepository.Query(x => x.IsDelete == false && x.CustomerId == query.CustomerId && x.Status == 1); + var Optionalresult = Optional.Select(x => x.SubjectSelect).FirstOrDefault().Split(",").ToList(); + var OptionalName = Optional.Select(x => x.SubjectSelect).FirstOrDefault().Replace(",", "+"); + #endregion + // namelist.Contains() hollandresult + #region first + var firstholl = 0; + var firstoptional = 0; + foreach (var item in namelist) + { + if (hollandresult.Count(x => x == item) > 0) + { + firstholl += 33; + } + } + foreach (var item in namelist) + { + if (Optionalresult.Count(x => x == item) > 0) + { + firstoptional += 33; + } + } + list.Add(new SubjectSelectResult() + { + Select = subjectName, + SubjectResult = 100, + HollResult = firstholl == 99 ? 100 : firstholl, + OptionalResult = firstoptional == 99 ? 100 : firstoptional + }); + #endregion + + #region second + var secondsubject = 0; + var secondoptional = 0; + foreach (var item in hollandresult) + { + if (namelist.Count(x => x == item) > 0) + { + secondsubject += 33; + } + } + foreach (var item in hollandresult) + { + if (Optionalresult.Count(x => x == item) > 0) + { + secondoptional += 33; + } + } + list.Add(new SubjectSelectResult() + { + Select = HollandName, + SubjectResult = secondsubject == 99 ? 100 : secondsubject, + HollResult = 100, + OptionalResult = secondoptional == 99 ? 100 : secondoptional + }); + #endregion + + #region three + var threesubject = 0; + var threeholl = 0; + foreach (var item in Optionalresult) + { + if (namelist.Count(x => x == item) > 0) + { + threesubject += 33; + } + } + foreach (var item in Optionalresult) + { + if (hollandresult.Count(x => x == item) > 0) + { + threeholl += 33; + } + } + list.Add(new SubjectSelectResult() + { + Select = OptionalName, + SubjectResult = threesubject == 99 ? 100 : threesubject, + HollResult = threeholl == 99 ? 100 : threeholl, + OptionalResult = 100 + }); + #endregion + return new MessageModel>() { success = true, msg = "获取成功", response = list }; + } + + /// + /// 根绝霍兰德获取推荐选科 + /// + /// + /// + public async Task> GetHollandSubject(HollandSubjectQuery query) + { + var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId); + if (planinfo == null) + return new MessageModel() { success = false, msg = "所选省份年份的招生计划,正在完善中..." }; + var planid = planinfo.FirstOrDefault().Id; + if (string.IsNullOrWhiteSpace(query.Tag)) + return new MessageModel() { success = false, msg = "标签传入为空,请去测试" }; + var newTags = GetTag(query.Tag); + var planmaptag = await t_PlanMapTagRepository.Query(x => x.IsDelete == false); + List majorlists = new List() { }; + foreach (var item in newTags) + { + majorlists.AddRange(planmaptag.Where(x => x.Tag.Contains(item)).Select(x => x.Name).ToList()); + } + majorlists = majorlists.Distinct().ToList(); + var descinfo = await t_EnrollmentPlanedescRepository.Query(x => x.IsDelete == false && x.PlanId == planid && majorlists.Contains(x.MajorName) && x.UniversityId > 0); + List hollandlist = new List() { }; + hollandlist.Add(new IdNameResult() { Name = "物", Id = descinfo.Count(x => x.Subjectclaim.Contains("物")) }); + hollandlist.Add(new IdNameResult() { Name = "化", Id = descinfo.Count(x => x.Subjectclaim.Contains("化")) }); + hollandlist.Add(new IdNameResult() { Name = "生", Id = descinfo.Count(x => x.Subjectclaim.Contains("生")) }); + hollandlist.Add(new IdNameResult() { Name = "政", Id = descinfo.Count(x => x.Subjectclaim.Contains("政")) }); + hollandlist.Add(new IdNameResult() { Name = "史", Id = descinfo.Count(x => x.Subjectclaim.Contains("史")) }); + hollandlist.Add(new IdNameResult() { Name = "地", Id = descinfo.Count(x => x.Subjectclaim.Contains("地")) }); + var hollandresult = hollandlist.OrderByDescending(x => x.Id).Select(x => x.Name).Take(3).ToList(); + var HollandName = string.Join("+", hollandresult); + return new MessageModel() { success = true, msg = "获取成功", response = HollandName }; + } + + + + /// + /// 转化出标签所有可能 + /// + /// + /// + public List GetTag(string tag) + { + var Nums = new List(); + for (int i = 0; i < tag.Length; i++) + { + Nums.Add(tag[i].ToString()); + } + Permutation(Nums.ToArray(), 0, Nums.ToArray().Length); + + //permut = GetTagExtened(tag, permut); + return permut; + } + + /// + /// 递归实现全排序并输出 + /// + /// 待排序的字符数组 + /// 输出字符数组的起始位置 + /// 输出字符数组的长度 + public void Permutation(string[] nums, int m, int n) + { + int i; + string t; + if (m < n - 1) + { + Permutation(nums, m + 1, n); + for (i = m + 1; i < n; i++) + { + t = nums[m]; + nums[m] = nums[i]; + nums[i] = t; + Permutation(nums, m + 1, n); + t = nums[m]; + nums[m] = nums[i]; + nums[i] = t; + } + } + else + { + string kk = string.Empty; + for (int j = 0; j < nums.Length; j++) + { + kk += nums[j]; + } + permut.Add(kk); + } + } + + ///// + ///// 判断是否为不常见标签,若是则匹配相关联标签 + ///// + ///// + ///// + //public List GetTagExtened(string tag, List taglist) + //{ + // var list = new List(); + // var query = yd_tagExInfo.Get(a => a.YD_Enabled == 1 && a.YD_Tags.Equals(tag)).FirstOrDefault(); + // if (query != null) + // { + // list = JsonConvert.DeserializeObject>(query.YD_tagEx); + // } + // if (list.Any() && list.Count() > 0) + // { + // taglist.AddRange(list.Select(s => s.tag).ToList()); + // } + // return taglist; + //} + } +} \ No newline at end of file diff --git a/New_College.Services/Test_QuestionInfoServices.cs b/New_College.Services/Test_QuestionInfoServices.cs new file mode 100644 index 0000000..09220c6 --- /dev/null +++ b/New_College.Services/Test_QuestionInfoServices.cs @@ -0,0 +1,95 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.Model.ViewModels; +using System.Threading.Tasks; +using System.Collections.Generic; +using Newtonsoft.Json; +using New_College.IRepository; +using System.Linq; + +namespace New_College.Services +{ + public class Test_QuestionInfoServices : BaseServices, ITest_QuestionInfoServices + { + private readonly IBaseRepository _dal; + private readonly ITest_QuestionTypeInfoRepository _QuestionTypeInfoRepository; + public Test_QuestionInfoServices(IBaseRepository dal + , ITest_QuestionTypeInfoRepository ITest_QuestionTypeInfoRepository) + { + this._dal = dal; + _QuestionTypeInfoRepository = ITest_QuestionTypeInfoRepository; + base.BaseDal = dal; + } + + /// + /// 获取问题 + /// + /// + /// + public async Task> GetQuestion(appQuestionQuery query) + { + var info = await _dal.Query(x => x.IsDelete == false && x.CategoryId == query.CategoryId); + if (info == null) + return new List() { }; + List list = new List() { }; + if (query.CategoryId == 20) + { + List subject = new List() { "物理", "化学", "生物", "政治", "历史", "地理" }; + int sort = 1; + foreach (var x in subject) + { + foreach (var item in info) + { + list.Add(new appQuestionResult() + { + Id = item.Id, + IsAddScore = item.IsAddScore, + QuestionSort = sort++,// item.OrderSort, + QuestionTag = x, + QuestionTitle = "对于" + x + "," + item.QuestionTitle, + QuestionType = item.QuestionType, + QuestionTypeId = item.QuestionTypeId + }); + } + } + return list; + } + foreach (var item in info) + { + list.Add(new appQuestionResult() + { + Id = item.Id, + IsAddScore = item.IsAddScore, + QuestionSort = item.OrderSort, + QuestionTag = item.QuestionTag, + QuestionTitle = item.QuestionTitle, + QuestionType = item.QuestionType, + QuestionTypeId = item.QuestionTypeId + }); + } + return list; + } + + /// + /// 获取mbti试题 + /// + /// + public async Task> GetQuestionMBTI() + { + var info = await _dal.Query(x => x.IsDelete == false && x.CategoryId == 19); + if (info == null) + return new List() { }; + return info.Select(s => new QuestionMBTI() + { + Answers = JsonConvert.DeserializeObject>(s.QuestionTag), + QuestionSort = s.OrderSort, + QuestionTitle = s.QuestionTitle + }).ToList(); + } + + + } +} \ No newline at end of file diff --git a/New_College.Services/Test_QuestionTypeInfoServices.cs b/New_College.Services/Test_QuestionTypeInfoServices.cs new file mode 100644 index 0000000..98b5a68 --- /dev/null +++ b/New_College.Services/Test_QuestionTypeInfoServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class Test_QuestionTypeInfoServices : BaseServices, ITest_QuestionTypeInfoServices + { + private readonly IBaseRepository _dal; + public Test_QuestionTypeInfoServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/TopicDetailServices.cs b/New_College.Services/TopicDetailServices.cs new file mode 100644 index 0000000..e8578b2 --- /dev/null +++ b/New_College.Services/TopicDetailServices.cs @@ -0,0 +1,30 @@ +using New_College.Common; +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.Services +{ + public class TopicDetailServices : BaseServices, ITopicDetailServices + { + IBaseRepository _dal; + public TopicDetailServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + /// + /// 获取开Bug数据(缓存) + /// + /// + [Caching(AbsoluteExpiration = 10)] + public async Task> GetTopicDetails() + { + return await base.Query(a => !a.tdIsDelete && a.tdSectendDetail == "tbug"); + } + } +} diff --git a/New_College.Services/TopicServices.cs b/New_College.Services/TopicServices.cs new file mode 100644 index 0000000..c047a69 --- /dev/null +++ b/New_College.Services/TopicServices.cs @@ -0,0 +1,32 @@ +using New_College.Common; +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace New_College.Services +{ + public class TopicServices: BaseServices, ITopicServices + { + + IBaseRepository _dal; + public TopicServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + /// + /// 获取开Bug专题分类(缓存) + /// + /// + [Caching(AbsoluteExpiration = 60)] + public async Task> GetTopics() + { + return await base.Query(a => !a.tIsDelete && a.tSectendDetail == "tbug"); + } + + } +} diff --git a/New_College.Services/U_ProbabilityHistoryServices.cs b/New_College.Services/U_ProbabilityHistoryServices.cs new file mode 100644 index 0000000..5736021 --- /dev/null +++ b/New_College.Services/U_ProbabilityHistoryServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class U_ProbabilityHistoryServices : BaseServices, IU_ProbabilityHistoryServices + { + private readonly IBaseRepository _dal; + public U_ProbabilityHistoryServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/U_VolunteerTableDetailServices.cs b/New_College.Services/U_VolunteerTableDetailServices.cs new file mode 100644 index 0000000..8aba3c6 --- /dev/null +++ b/New_College.Services/U_VolunteerTableDetailServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class U_VolunteerTableDetailServices : BaseServices, IU_VolunteerTableDetailServices + { + private readonly IBaseRepository _dal; + public U_VolunteerTableDetailServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/U_VolunteerTableServices.cs b/New_College.Services/U_VolunteerTableServices.cs new file mode 100644 index 0000000..699e361 --- /dev/null +++ b/New_College.Services/U_VolunteerTableServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class U_VolunteerTableServices : BaseServices, IU_VolunteerTableServices + { + private readonly IBaseRepository _dal; + public U_VolunteerTableServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/UserRoleServices.cs b/New_College.Services/UserRoleServices.cs new file mode 100644 index 0000000..72b5e56 --- /dev/null +++ b/New_College.Services/UserRoleServices.cs @@ -0,0 +1,57 @@ +using New_College.Common; +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using System.Linq; +using System.Threading.Tasks; + +namespace New_College.Services +{ + /// + /// UserRoleServices + /// + public class UserRoleServices : BaseServices, IUserRoleServices + { + + IBaseRepository _dal; + public UserRoleServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + /// + /// + /// + /// + /// + /// + public async Task SaveUserRole(int uid, int rid) + { + UserRole userRole = new UserRole(uid, rid); + + UserRole model = new UserRole(); + var userList = await base.Query(a => a.UserId == userRole.UserId && a.RoleId == userRole.RoleId); + if (userList.Count > 0) + { + model = userList.FirstOrDefault(); + } + else + { + var id = await base.Add(userRole); + model = await base.QueryById(id); + } + + return model; + + } + + + + [Caching(AbsoluteExpiration = 30)] + public async Task GetRoleIdByUid(int uid) + { + return ((await base.Query(d => d.UserId == uid)).OrderByDescending(d => d.Id).LastOrDefault()?.RoleId).ObjToInt(); + } + } +} diff --git a/New_College.Services/V_CustomerInfoServices.cs b/New_College.Services/V_CustomerInfoServices.cs new file mode 100644 index 0000000..b3aa5c9 --- /dev/null +++ b/New_College.Services/V_CustomerInfoServices.cs @@ -0,0 +1,385 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.Model.ViewModels; +using System.Threading.Tasks; +using New_College.Common; +using static New_College.Common.AliyunSmsSender; +using System; +using System.Collections.Generic; +using System.Linq; +using New_College.Common.Helper; +using New_College.Model; +using LinqKit; +using New_College.Model.Request; + +namespace New_College.Services +{ + public class V_CustomerInfoServices : BaseServices, IV_CustomerInfoServices + { + private readonly IBaseRepository _dal; + public V_CustomerInfoServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + + + /// + /// 修改用户信息 + /// + /// + /// + public async Task UpdateCustomerInfo(UpdateCustomerQuery query) + { + var info = await _dal.QueryById(query.Id); + if (info == null) + return new CustomerInfoResult() { Status = 3 }; + info.NickName = query.NickName; + //info.Phone = query.Phone; + info.Gender = query.Gender; + info.AvatarUrl = query.AvatarUrl; + if (!string.IsNullOrWhiteSpace(query.UserPwd)) + { + var salt = RadomHelper.RandCode(6); + info.UserPwd = MD5Helper.MD5Encrypt16(query.UserPwd + salt); + } + var result = await _dal.Update(info); + return new CustomerInfoResult() + { + Status = 1, + AvatarUrl = info.AvatarUrl, + Gender = info.Gender, + Id = info.Id, + OpenId = info.OpenId, + NickName = info.NickName, + AreaId = info.AreaId, + AreaName = info.AreaName, + Datainit = info.Datainit, + Expectedscore = info.Expectedscore, + IsVIP = info.IsVIP, + Subject = info.Subject, + Subjectgroup = info.Subjectgroup, + VipCode = info.VipCode, + IsUpdateScore = info.IsUpdateScore, + Year = info.Year + }; + } + + + + + /// + /// 更改分数和学科 + /// + /// + /// + public async Task UpdateScore(UpdateScoreQuery query) + { + var info = await _dal.QueryById(query.StudentId); + if (info == null) + return new CustomerInfoResult() { Status = 3 }; + info.IsUpdateScore += 1; + info.Expectedscore = query.Score; + info.Subject = query.Subject; + info.Subjectgroup = query.Subjectgroup; + var result = await _dal.Update(info); + if (result) + { + return new CustomerInfoResult() + { + Status = 1, + AvatarUrl = info.AvatarUrl, + Gender = info.Gender, + Id = info.Id, + OpenId = info.OpenId, + NickName = info.NickName, + AreaId = info.AreaId, + AreaName = info.AreaName, + Datainit = info.Datainit, + Expectedscore = info.Expectedscore, + IsVIP = info.IsVIP, + Subject = info.Subject, + Subjectgroup = info.Subjectgroup, + VipCode = info.VipCode, + IsUpdateScore = info.IsUpdateScore, + Year = info.Year + }; + } + else + { + return new CustomerInfoResult() { Status = 3 }; + } + } + + /// + /// 完善用户信息 + /// + /// + /// + public async Task UpdateCustomer(CustomerUpdateQuery query) + { + var info = await _dal.QueryById(query.StudentId); + if (info == null) + return new CustomerInfoResult() { Status = 3 }; + info.Datainit = true; + info.AreaId = query.AreaId; + info.AreaName = query.AreaName; + info.Subject = query.Subject; + info.Subjectgroup = query.Subjectgroup; + info.Expectedscore = query.Expectedscore; + info.Year = query.Year; + info.SchoolName = query.SchoolName; + info.ClassName = query.ClassName; + var result = await _dal.Update(info); + if (result) + { + return new CustomerInfoResult() + { + Status = 1, + AvatarUrl = info.AvatarUrl, + Gender = info.Gender, + Id = info.Id, + OpenId = info.OpenId, + NickName = info.NickName, + AreaId = info.AreaId, + AreaName = info.AreaName, + Datainit = info.Datainit, + Expectedscore = info.Expectedscore, + IsVIP = info.IsVIP, + Subject = info.Subject, + Subjectgroup = info.Subjectgroup, + VipCode = info.VipCode, + IsUpdateScore = info.IsUpdateScore, + CustomerType = info.CustomerType, + Phone = info.Phone, + SchoolName = info.SchoolName, + ClassName = info.ClassName, + Year = info.Year + }; + } + else + { + return new CustomerInfoResult() { Status = 3 }; + } + } + + /// + /// 根绝Id获取用户信息 + /// + /// + /// + public async Task> GetCustomerInfoById(IdQuery query) + { + var info = await _dal.QueryById(query.Id); + if (info == null) + return new MessageModel() { success = false, msg = "获取失败,用户信息为空" }; + return new MessageModel() + { + success = true, + msg = "获取成功", + response = new CustomerInfoResult() + { + AvatarUrl = info.AvatarUrl, + Gender = info.Gender, + Id = info.Id, + OpenId = info.OpenId, + NickName = info.NickName, + AreaId = info.AreaId, + AreaName = info.AreaName, + Datainit = info.Datainit, + Expectedscore = info.Expectedscore, + IsVIP = info.IsVIP, + Subject = info.Subject, + Subjectgroup = info.Subjectgroup, + VipCode = info.VipCode, + IsUpdateScore = info.IsUpdateScore, + Year = info.Year + } + }; + } + + /// + /// 查询CustomerInfo表信息 + /// + /// + /// + public async Task>> GetCustomerInfoListByPage(CustomerSeachQuery query) + { + var wheres = PredicateBuilder.New(); + wheres = wheres.And(x => x.IsDelete == false); + if (!string.IsNullOrWhiteSpace(query.Phone)) + wheres = wheres.And(x => x.Phone.Contains(query.Phone)); + if (query.Subject != 2) + wheres = wheres.And(x => (int)x.Subject == query.Subject); + if (!string.IsNullOrWhiteSpace(query.VipCode)) + wheres = wheres.And(x => x.VipCode.Contains(query.VipCode)); + var info = await _dal.QueryPage(wheres, query.PageIndex, query.PageSize); + if (info.data.Count <= 0) + return new MessageModel>() + { + success = false, + msg = "获取失败" + }; + //var regioninfo = await sysRegionRepository.Query(x => x.ParentCode == "100000"); + PageModel pageModel = new PageModel() { }; + List list = new List() { }; + foreach (var item in info.data) + { + list.Add(new CustomerInfoListResult() + { + Id = item.Id, + Phone = item.Phone, + Subject = item.Subject, + Subjectgroup = item.Subjectgroup, + AreaName = item.AreaName, + Expectedscore = item.Expectedscore, + VipCode = item.VipCode, + NickName = item.NickName + }); + } + pageModel.data = list; + pageModel.dataCount = info.dataCount; + pageModel.page = info.page; + pageModel.pageCount = info.pageCount; + pageModel.PageSize = info.PageSize; + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = pageModel + }; + } + + public Weixinauthinfo AuthCode2Session(string Code) + { + var result = WeixinHelper.AuthCode2Session(WeixinConfig.Appid, WeixinConfig.Secret, Code); + return result; + + } + + public string GetWeixinPhone(GetPhoneInfo phoneInfo) + { + string phone = string.Empty; + try + { + phone = WeixinHelper.getPhoneNumber(phoneInfo.encryptedData, phoneInfo.iv, phoneInfo.session_key); + } + catch (Exception ex) + { + } + return phone; + } + + public async Task> Logined(LoginQuery query) + { + + var userinfo = (await _dal.Query(w => w.OpenId == query.openId)).ToList().FirstOrDefault(); + if (userinfo != null) + { + return new Tuple(true, new CustomerInfoResult() + { + AreaId = userinfo.AreaId, + AreaName = userinfo.AreaName, + AvatarUrl = userinfo.AvatarUrl, + CustomerType = userinfo.CustomerType, + NickName = userinfo.NickName, + OpenId = userinfo.OpenId, + Phone = userinfo.Phone, + Gender = userinfo.Gender, + Datainit = userinfo.Datainit, + Expectedscore = userinfo.Expectedscore, + IsVIP = userinfo.IsVIP, + Subject = userinfo.Subject, + Subjectgroup = userinfo.Subjectgroup, + ClassName = userinfo.ClassName, + SchoolName = userinfo.SchoolName, + Year = userinfo.Year + }); + } + else + { + return new Tuple(false, null); + } + } + + public async Task> GetUserInfo(LoginQuery query) + { + var userinfo = (await _dal.Query(w => w.OpenId == query.openId)).ToList().First(); + if (userinfo != null) + { + return new Tuple(true, new CustomerInfoResult() + { + + AreaId = userinfo.AreaId, + AreaName = userinfo.AreaName, + AvatarUrl = userinfo.AvatarUrl, + CustomerType = userinfo.CustomerType, + NickName = userinfo.NickName, + OpenId = userinfo.OpenId, + Phone = userinfo.Phone, + Gender = userinfo.Gender, + Datainit = userinfo.Datainit, + Expectedscore = userinfo.Expectedscore, + IsVIP = userinfo.IsVIP, + Subject = userinfo.Subject, + Subjectgroup = userinfo.Subjectgroup, + Year = userinfo.Year + }); + } + else + { + return new Tuple(false, null); + } + } + + public async Task GetCustomerId(string OpenId) + { + var customerinfo = await _dal.Query(x => x.IsDelete == false && x.OpenId == OpenId); + if (customerinfo.Count == 0) + return -1; + return customerinfo.FirstOrDefault().Id; + } + + public async Task GetOpenId(int CustomerId) + { + var customerinfo = await _dal.QueryById(CustomerId); + if (customerinfo == null) + return ""; + return customerinfo.OpenId; + } + + public async Task CustomerSave(DecryptUserInfoRequest register) + { + var i = await _dal.Add(new V_CustomerInfo() + { + OpenId = register.openid, + CustomerType = CustomerTypeEnum.General + }); + return i; + } + + public Task Login(CustomerInfoQuery query) + { + throw new NotImplementedException(); + } + + public Task SendLogin(PhoneQuery query) + { + throw new NotImplementedException(); + } + + public Task ResetPwd(ResetPwdQuery query) + { + throw new NotImplementedException(); + } + + public Task SendReset(PhoneQuery query) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/New_College.Services/V_ExaminationPolicyServices.cs b/New_College.Services/V_ExaminationPolicyServices.cs new file mode 100644 index 0000000..fcf83b6 --- /dev/null +++ b/New_College.Services/V_ExaminationPolicyServices.cs @@ -0,0 +1,202 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using Microsoft.AspNetCore.Mvc.RazorPages; +using New_College.Model.ViewModels; +using New_College.Model; +using System.Threading.Tasks; +using New_College.IRepository; +using LinqKit; +using System.Collections.Generic; +using System.Linq; + +namespace New_College.Services +{ + public class V_ExaminationPolicyServices : BaseServices, IV_ExaminationPolicyServices + { + private readonly IBaseRepository _dal; + private readonly ISysRegionRepository sysRegionRepository; + public V_ExaminationPolicyServices(IBaseRepository dal + , ISysRegionRepository ISysRegionRepository) + { + this._dal = dal; + sysRegionRepository = ISysRegionRepository; + base.BaseDal = dal; + } + + /// + /// 获取分页 + /// + /// + /// + public async Task>> GetExaminationPolicyByPage(ExaminationPolicySearchQuery query) + { + var wheres = PredicateBuilder.New(); + wheres = wheres.And(x => x.IsDelete == false); + if (query.AreaId > 0) + wheres = wheres.And(x => x.AreaId == query.AreaId); + var info = await _dal.QueryPage(wheres, query.PageIndex, query.PageSize); + if (info.data.Count <= 0) + return new MessageModel>() + { + success = false, + msg = "获取失败" + }; + var regioninfo = await sysRegionRepository.Query(x => x.ParentCode == "100000"); + PageModel pageModel = new PageModel() { }; + List list = new List() { }; + foreach (var item in info.data) + { + list.Add(new ExaminationPolicyResult() + { + Id = item.Id, + Title = item.Title, + AreaName = regioninfo.Where(x => x.KeyId == item.AreaId).Select(x => x.RegionName)?.FirstOrDefault(), + ModifyTime = item.ModifyTime + }); + } + pageModel.data = list; + pageModel.dataCount = info.dataCount; + pageModel.page = info.page; + pageModel.pageCount = info.pageCount; + pageModel.PageSize = info.PageSize; + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = pageModel + }; + } + + /// + /// 获取单个 + /// + /// + /// + public async Task> GetExaminationPolicyOne(IdQuery query) + { + var info = await _dal.QueryById(query.Id); + if (info == null) + return new MessageModel() { success = false, msg = "获取失败" }; + + return new MessageModel() + { + success = true, + msg = "获取成功", + response = new ExaminationPolicyOneResult() + { + Id = info.Id, + Content = info.Content, + Img = info.Img, + AreaId = info.AreaId, + Title = info.Title + } + }; + + } + + /// + /// 添加 + /// + /// + /// + public async Task> AddExaminationPolicy(ExaminationPolicyQuery query) + { + var result = await _dal.Add(new V_ExaminationPolicy() + { + AreaId = query.AreaId, + Content = query.Content, + Img = query.Img, + Title = query.Title, + AreaName = query.AreaName + }); + if (result > 0) + { + return new MessageModel() { success = true, msg = "添加成功", response = true }; + } + else + { + return new MessageModel() { success = false, msg = "添加失败", response = false }; + } + } + + /// + /// 修改 + /// + /// + /// + public async Task> UpdateExaminationPolicy(ExaminationPolicyQuery query) + { + var info = await _dal.QueryById(query.Id); + if (info == null) + return new MessageModel() { success = false, msg = "修改内容不存在", response = false }; + info.AreaId = query.AreaId; + info.Content = query.Content; + info.Img = query.Img; + info.Title = query.Title; + info.AreaName = query.AreaName; + var result = await _dal.Update(info); + if (result) + { + return new MessageModel() { success = true, msg = "修改成功", response = true }; + } + else + { + return new MessageModel() { success = false, msg = "修改失败", response = false }; + } + } + + /// + /// 删除 + /// + /// + /// + public async Task> DeleteExaminationPolicy(IdQuery query) + { + if (query.Ids == null || query.Ids.Count <= 0) + return new MessageModel() { success = false, msg = "传入为空", response = false }; + var info = await _dal.Query(x => x.IsDelete == false && query.Ids.Contains(x.Id)); + if (info.Count <= 0) + return new MessageModel() { success = false, msg = "没有可被删除项", response = false }; + foreach (var item in info) + { + item.IsDelete = true; + } + var result = await _dal.Update(info); + if (result) + { + return new MessageModel() { success = true, msg = "删除成功", response = true }; + } + else + { + return new MessageModel() { success = false, msg = "删除失败", response = false }; + } + } + + /// + /// 获取考试时间 + /// + /// + /// + public async Task> GetExaminationPolicyDetail(ExaminationPolicyAreaQuery query) + { + var info = (await _dal.Query(x => x.IsDelete == false && x.AreaId == query.AreaId)).FirstOrDefault(); + if (info == null) + return new MessageModel() { success = false, msg = "获取失败" }; + return new MessageModel() + { + success = true, + msg = "获取成功", + response = new ExaminationPolicyOneDetail() + { + Id = info.Id, + Content = info.Content, + Img = info.Img, + Title = info.Title + } + }; + } + } +} \ No newline at end of file diff --git a/New_College.Services/V_OrderInfoServices.cs b/New_College.Services/V_OrderInfoServices.cs new file mode 100644 index 0000000..2bec14c --- /dev/null +++ b/New_College.Services/V_OrderInfoServices.cs @@ -0,0 +1,658 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.IRepository.UnitOfWork; +using New_College.Model.ViewModels; +using System.Threading.Tasks; +using New_College.Common; +using New_College.IRepository; +using System.Linq; +using YIJIYI.Core.Common.Helper; +using System; +using New_College.Model; +using New_College.Common.Helper; +using Microsoft.Extensions.Options; +using Essensoft.AspNetCore.Payment.WeChatPay; +using Essensoft.AspNetCore.Payment.Alipay; +using Essensoft.AspNetCore.Payment.WeChatPay.Notify; +using Microsoft.Extensions.Logging; +using Essensoft.AspNetCore.Payment.Alipay.Domain; +using Essensoft.AspNetCore.Payment.Alipay.Request; +using System.Collections.Generic; +using LinqKit; +using System.Collections.Specialized; +using Org.BouncyCastle.Asn1.Ocsp; +using Essensoft.AspNetCore.Payment.WeChatPay.Response; +using Essensoft.AspNetCore.Payment.WeChatPay.Request; +using Microsoft.AspNetCore.Http; + +namespace New_College.Services +{ + public class V_OrderInfoServices : BaseServices, IV_OrderInfoServices + { + private readonly IWeChatPayClient _client; + private readonly IOptions _optionsAccessor; + private readonly IAlipayClient alipayClient; + private readonly IOptions alipayoptions; + + private readonly IBaseRepository _dal; + private readonly IUnitOfWork _unitOfWork; + private readonly IV_CustomerInfoRepository v_CustomerInfoRepository; + private readonly IV_VipCardInfoRepository v_VipCardInfoRepository; + private readonly IV_VipCardTypeRepository v_VipCardTypeRepository; + + private readonly ILogger logger; + + public int Nums = 10; + public V_OrderInfoServices(IWeChatPayClient client, IOptions optionsAccessor + , IAlipayClient IAlipayClient, IOptions alipayopt + , IBaseRepository dal + , IUnitOfWork IUnitOfWork + , IV_CustomerInfoRepository IV_CustomerInfoRepository + , IV_VipCardInfoRepository IV_VipCardInfoRepository + , IV_VipCardTypeRepository IV_VipCardTypeRepository + , ILogger loggers + ) + { + _client = client; + _optionsAccessor = optionsAccessor; + alipayClient = IAlipayClient; + alipayoptions = alipayopt; + this._dal = dal; + _unitOfWork = IUnitOfWork; + v_CustomerInfoRepository = IV_CustomerInfoRepository; + v_VipCardInfoRepository = IV_VipCardInfoRepository; + v_VipCardTypeRepository = IV_VipCardTypeRepository; + logger = loggers; + base.BaseDal = dal; + } + + /// + /// 下订单 + /// + /// + /// + public async Task CreateOrder(UniOrderQuery query) + { + var response = new CreateOrderModel(); + string OrderNo = OrderGenerateHelper.GenerateOrderNo("ZY"); + try + { + _unitOfWork.BeginTran(); + var customer = await v_CustomerInfoRepository.QueryById(query.StudentId); + var createtime = TimeUtil.GetCstDateTime(); + var baseResult = await _dal.Add(new V_OrderInfo + { + //out_trade_no = payNum, + //PayType = 2, + OrderId = OrderNo, + CardTypeId = query.CardTypeId, + Status = EnumOrderType.payment, + CustomerId = customer.Id, + Price = query.total_fee, + PayPrice = query.total_fee, + Name = "志愿好帮手VIP购买", + //CardNo = code, + //CardId = addcard + CreateTime = createtime + }); + if (baseResult > 0) + { + _unitOfWork.CommitTran(); + response.OrderId = OrderNo; + response.Status = EnumOrderType.payment; + response.CreateTime = createtime.ToString("yyyy-MM-dd HH:mm:ss"); + } + } + catch (System.Exception) + { + _unitOfWork.RollbackTran(); + response.msg = "订单创建失败"; + response.success = false; + return response; + } + return response; + } + + /// + /// 订单查询 + /// + /// + /// + public async Task>> GetOrderInfoByPage(SearchOrderQuery query) + { + var wheres = PredicateBuilder.New(); + wheres = wheres.And(x => x.IsDelete == false); + //根据卡号查询 + if (!string.IsNullOrWhiteSpace(query.CardNo)) + wheres = wheres.And(x => x.CardNo.Contains(query.CardNo)); + + //根据支付状态查询 + + // var status = Enum.Parse(typeof(EnumOrderType), query.Status.ToString());// (EnumOrderType)query.Status; + if (query.Status > -2) + { + var status = (EnumOrderType)query.Status; + wheres = wheres.And(x => x.Status == status); + } + + + //根据支付方式查询 + if (query.PayType > -1) + { + var payType = (EnumPayType)query.PayType; + wheres = wheres.And(x => x.PayType == payType); + } + //根据out_trade_no查询 + if (!string.IsNullOrWhiteSpace(query.out_trade_no)) + wheres = wheres.And(x => x.out_trade_no.Contains(query.out_trade_no)); + + + //根据电话查询 + if (!string.IsNullOrWhiteSpace(query.Phone)) + { + var CoustomerId = await v_CustomerInfoRepository.Query(x => x.Phone.Contains(query.Phone)); + var ids = CoustomerId.Select(x => x.Id).ToList(); + if (CoustomerId != null) + wheres = wheres.And(x => ids.Contains(x.CustomerId)); + } + + //根据卡片类别查询 + if (query.CardTypeId > 0) + wheres = wheres.And(x => x.CardTypeId == query.CardTypeId); + + var info = await _dal.QueryPage(wheres, query.PageIndex, query.PageSize); + if (info.data.Count <= 0) + return new MessageModel>() + { + success = false, + msg = "获取失败" + }; + var idsCard = info.data.Select(x => x.CardTypeId).ToList(); + var idsCoustomer = info.data.Select(x => x.CustomerId).ToList(); + var listCard = await v_VipCardTypeRepository.Query(x => idsCard.Contains(x.Id) && x.IsDelete == false); + var listCoustomer = await v_CustomerInfoRepository.Query(x => idsCoustomer.Contains(x.Id) && x.IsDelete == false); + PageModel pageModel = new PageModel() { }; + List list = new List() { }; + foreach (var item in info.data) + { + var CardOne = listCard.Where(x => x.Id == item.CardTypeId).FirstOrDefault(); + if (CardOne == null) + continue; + var CoustomerOne = listCoustomer.Where(x => x.Id == item.CustomerId).FirstOrDefault(); + if (CoustomerOne == null) + continue; + + list.Add(new OrderInfoQuery() + { + CardId = item.Id, + PayPrice = item.PayPrice, + Price = item.Price, + CardNo = item.CardNo, + CardTypeName = CardOne.Name, + OrderId = item.OrderId, + CustomerName = CoustomerOne.NickName, + Name = item.Name, + //支付状态 + StatusName = item.Status.GetDescription(), + out_trade_no = item.out_trade_no, + //支付方式 + PayTypeName = item.PayType.GetDescription(), + + Phone = CoustomerOne.Phone, + }); + } + pageModel.data = list; + pageModel.dataCount = info.dataCount; + pageModel.page = info.page; + pageModel.pageCount = info.pageCount; + pageModel.PageSize = info.PageSize; + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = pageModel + }; + } + + //public async Task> + + /// + /// 支付订单回调修改状态 + /// + /// + /// + /// + public async Task UpdateOrderStatus(string orderNo, EnumPayType payType, string trade_no) + { + bool status = false; + var orderinfo = await _dal.Query(e => e.OrderId == orderNo); + if (orderinfo.Any()) + { + var cardtype = await v_VipCardTypeRepository.QueryById(orderinfo.FirstOrDefault().CardTypeId); + if (cardtype == null) + return false; + var code = RadomHelper.GetGuid(); + try + { + _unitOfWork.BeginTran(); + var addcard = await v_VipCardInfoRepository.Add(new V_VipCardInfo() + { + CardTypeId = cardtype.Id, + CardTypeName = cardtype.Name, + Code = code, + IsBind = 1, + Money = orderinfo.FirstOrDefault().PayPrice, + Day = cardtype.Day, + EndTime = DateTime.Now.AddDays(cardtype.Day) + }); + if (addcard > 0) + { + var model = orderinfo.FirstOrDefault(); + model.PayType = payType; + model.ModifyTime = TimeUtil.GetCstDateTime(); + model.Status = EnumOrderType.payoff; + model.out_trade_no = trade_no; + var cc = await _dal.Update(model); + if (cc) + { + _unitOfWork.CommitTran(); + status = true; + } + } + } + catch (Exception) + { + _unitOfWork.RollbackTran(); + return status; + } + } + return status; + } + + /// + /// 唤醒微信H5支付 + /// + /// + /// + public async Task> WechatPubPay(WeChatPayQuery query) + { + string out_trade_no = DateTime.Now.ToString("yyyyMMddHHmmssfff"); + logger.LogInformation(out_trade_no + "唤醒支付"); + WeChatPayPayRequest viewModel = new WeChatPayPayRequest() { }; + //viewModel.NotifyUrl = string.Format("{0}/api/front/WeixinPay/PayNotify", PayInfoQuery.ApiUrl); + viewModel.NotifyUrl = string.Format("{0}/api/front/HFivePay/WeChartOrderConfirm", PayInfoQuery.ApiUrl); + //viewModel.NotifyUrl = string.Format("{0}/api/front/HFivePay/WeChartOrderConfirm?out_trade_no={1}", PayInfoQuery.ApiUrl, out_trade_no); + viewModel.SpBillCreateIp = PayInfoQuery.CreateIp; + viewModel.OutTradeNo = out_trade_no; + viewModel.TotalFee = Convert.ToInt32(query.Money*100); + viewModel.Body = "壹志愿VIP"; + viewModel.TradeType = "MWEB"; + + var response = await WeChatPay.GetMwebUrl(_client, _optionsAccessor, viewModel); + if (response.ReturnCode == "SUCCESS" && response.ReturnMsg == "OK") + { + try + { + //_unitOfWork.BeginTran(); + var order = await _dal.Add(new V_OrderInfo + { + out_trade_no = out_trade_no, + PayType = EnumPayType.WeiPay, + CardTypeId = query.CardTypeId, + Status = EnumOrderType.payment, + CustomerId = query.CustomerId, + Price = query.Money, + PayPrice = query.Money, + Name = "壹志愿好帮手VIP开通", + CardNo = "0", + CardId = 0 + }); + if (order > 0) + { + logger.LogInformation(out_trade_no + "唤醒成功"); + //_unitOfWork.CommitTran(); + return new MessageModel() + { + success = true, + msg = "成功", + response = string.Format("{0}&redirect_url={1}", response.MwebUrl, string.Format("{0}?out_trade_no={1}", string.Format("{0}/api/front/HFivePay/WeChartOrderConfirm", PayInfoQuery.ApiUrl), out_trade_no)) + }; + } + } + catch (Exception ex) + { + //_unitOfWork.RollbackTran(); + return new MessageModel() { success = false, msg = "唤醒微信失败,请重试" }; + } + + + } + return new MessageModel() { success = false, msg = "唤醒微信失败,请重试" }; + } + + /// + /// 微信订单查询确认 传用户Id + /// + /// + /// + public async Task> WeChatPayStatus(IdQuery query) + { + var orderinfo = await _dal.Query(x => x.CustomerId == query.Id && x.IsDelete == false && x.PayType == EnumPayType.WeiPay); + if (orderinfo.Count <= 0) + return new MessageModel() { success = false, msg = "未查询到用户订单" }; + var result = orderinfo.OrderByDescending(x => x.Id).FirstOrDefault(); + if (result.Status == EnumOrderType.payoff) + { + return new MessageModel() { success = true, msg = "已支付成功" }; + } + var request = new WeChatPayOrderQueryRequest + { + OutTradeNo = result.out_trade_no + }; + //如果订单状态是 + var response = await _client.ExecuteAsync(request, _optionsAccessor.Value); + if (response.TradeState == "NOTPAY") + { + return new MessageModel() { success = false, msg = "您还未支付订单,请重新支付" }; + } + if (response.ReturnCode == "SUCCESS" && response.ReturnMsg == "OK") + { + var payresult = await PaySuccess(result); + if (payresult.success == true) + { + logger.LogInformation("SUCCESS:" + result.out_trade_no); + return new MessageModel() { success = true, msg = "支付成功" }; + } + else + { + return new MessageModel() { success = false, msg = "支付成功,业务处理错误,请联系客服" }; + } + } + return new MessageModel() { success = false, msg = "您还未支付订单,请重新支付或联系客服" }; + } + + /// + /// 支付宝 订单确认 + /// + /// + /// + public async Task> AliPayStatus(IdQuery query) + { + logger.LogInformation("订单确认(支付宝)"); + var orderinfo = await _dal.Query(x => x.CustomerId == query.Id && x.IsDelete == false && x.PayType == EnumPayType.AliPay); + if (orderinfo.Count <= 0) + return new MessageModel() { success = false, msg = "未查询到用户订单" }; + var result = orderinfo.OrderByDescending(x => x.CreateTime).FirstOrDefault(); + if (result.Status == EnumOrderType.payoff) + { + return new MessageModel() { success = true, msg = "已支付成功" }; + } + else + { + return new MessageModel() { success = false, msg = "未支付,如有疑问请联系客服" }; + } + + //var model = new AlipayTradeWapPayModel + //{ + // OutTradeNo = query.out_trade_no, + //}; + //var req = new AlipayTradeWapPayRequest(); + //req.SetBizModel(model); + //var response = await alipayClient.PageExecuteAsync(req, alipayoptions.Value); + //logger.LogInformation(query.out_trade_no + "返回参数" + response.Body); + ////response.Body + ////根绝回调的返回 确认是否支付成功 此处还存在问题---------------------------------- + ////if(response.) + //var payresult = await PaySuccess(result); + //if (payresult.success == true) + //{ + // logger.LogInformation("SUCCESS(支付宝订单确认成功):" + result.out_trade_no); + // return new MessageModel() { success = true, msg = "支付成功" }; + //} + //else + //{ + // return new MessageModel() { success = false, msg = "支付成功,业务处理错误,请联系客服" }; + //} + } + + ///// + ///// 微信订单回调确认 + ///// + ///// + ///// + //public async Task> WeChartOrderConfirm(XmlQuery query) + //{ + // string xmlstr = ""; + // try + // { + // var response = XmlSerializeHelper.XMLToObject(query.xml); + // if (response == null) + // return new MessageModel() { success = false, msg = "订单确认失败", response = xmlstr }; + // var result = (await _dal.Query(x => x.out_trade_no == response.out_trade_no && x.PayType == EnumPayType.WeiPay)).FirstOrDefault(); + // if (result != null && result.Status == EnumOrderType.payoff) + // { + // xmlstr = "< return_code >< ![CDATA[SUCCESS]] >< return_msg >< ![CDATA[OK]] >"; + // return new MessageModel() { success = true, msg = "成功", response = xmlstr }; + // } + // if (response.result_code == "SUCCESS") + // { + // //记录流水 + // var payresult = await PaySuccess(result); + // if (payresult.success == true) + // { + // xmlstr = "< return_code >< ![CDATA[SUCCESS]] >< return_msg >< ![CDATA[OK]] >"; + // return new MessageModel() { success = true, msg = "成功", response = xmlstr }; + // } + // else + // { + // payresult.response = xmlstr; + // return payresult; + // } + + // } + // return new MessageModel() { success = false, msg = "失败", response = xmlstr }; + // } + // catch (Exception ex) + // { + // return new MessageModel() { success = false, msg = "失败", response = xmlstr }; + // } + //} + + /// + /// 支付成功后操作 + /// + /// + /// + public async Task> PaySuccess(V_OrderInfo query) + { + //生成一个卡号 + //修改订单状态 + try + { + var cardinfo = (await v_VipCardInfoRepository.QuerySql("SELECT Code FROM `V_VipCardInfo` where IsDelete=0")).Select(x => x.Code).ToList(); + + var code = GetNumbers(cardinfo, Nums); + + if (string.IsNullOrWhiteSpace(code)) + { + logger.LogWarning("用户Id" + query.CustomerId + "的用户,支付成功,卡号生成失败,请联系客服"); + return new MessageModel() { success = false, msg = "支付成功,卡号生成失败,请联系客服" }; + } + + var cardtype = await v_VipCardTypeRepository.QueryById(query.CardTypeId); + if (cardtype == null) + { + logger.LogWarning("用户Id" + query.CustomerId + "的用户,支付成功,卡类型有误,请联系客服"); + return new MessageModel() { success = false, msg = "支付成功,卡类型有误,请联系客服" }; + } + + _unitOfWork.BeginTran(); + var cardadd = await v_VipCardInfoRepository.Add(new V_VipCardInfo() + { + CardTypeId = cardtype.Id, + CardTypeName = cardtype.Name, + Code = code, + IsBind = 1, + Money = query.PayPrice, + Day = cardtype.Day, + EndTime = DateTime.Now.AddDays(cardtype.Day) + }); + if (cardadd > 0) + { + query.Status = EnumOrderType.payoff; + query.CardNo = code; + query.CardId = cardadd; + var updateorder = await _dal.Update(query); + if (updateorder) + { + //修改用户信息 + var customerinfo = await v_CustomerInfoRepository.QueryById(query.CustomerId); + if (customerinfo == null) + { + _unitOfWork.RollbackTran(); + logger.LogWarning("用户Id" + query.CustomerId + "的用户,支付成功,会员卡创建成功,用户信息不存在"); + return new MessageModel() { success = false, msg = "支付成功,会员卡创建成功,用户信息不存在" }; + } + customerinfo.IsVIP = true; + customerinfo.VipCode = code; + var updateinfo = await v_CustomerInfoRepository.Update(customerinfo); + if (updateinfo) + { + _unitOfWork.CommitTran(); + return new MessageModel() { success = true, msg = "成功" }; + } + else + { + logger.LogWarning("用户Id" + query.CustomerId + "的用户,支付成功,会员卡创建成功,用户信息修改失败"); + _unitOfWork.RollbackTran(); + return new MessageModel() { success = false, msg = "支付成功,会员卡创建成功,用户信息修改失败" }; + } + } + logger.LogWarning("用户Id" + query.CustomerId + "的用户,支付成功,订单修改失败,请联系客服"); + return new MessageModel() { success = false, msg = "支付成功,订单修改失败,请联系客服" }; + } + logger.LogWarning("用户Id" + query.CustomerId + "的用户,支付成功,订单修改失败,请联系客服"); + return new MessageModel() { success = false, msg = "支付成功,会员卡创建失败,请联系客服" }; + } + catch (Exception) + { + _unitOfWork.RollbackTran(); + logger.LogWarning("用户Id" + query.CustomerId + "的用户,支付成功,订单修改失败,请联系客服"); + return new MessageModel() { success = false, msg = "支付成功,订单修改失败,请联系客服" }; + } + } + + /// + /// 生成卡号 失败直接继续生成 + /// + /// + /// + /// + public string GetNumbers(List cardinfo, int Nums) + { + var code = ""; + for (int i = 0; i < 100; i++) + { + var newcode = GenerateCardNumberHelper.GenerateCardNumber("888", Nums); + cardinfo.Add(newcode); + var isUnique = cardinfo.GroupBy(x => x).All(g => g.Count() == 1); + if (isUnique) + { + code = newcode; + break; + } + else + { + Nums += 1; + GetNumbers(cardinfo, Nums); + } + } + return code; + } + + /// + /// 支付宝H5支付 + /// + /// + /// + public async Task> AliH5Pay(WeChatPayQuery query) + { + logger.LogInformation("唤醒支付宝" + query.CustomerId); + AliOrderResult aliOrder = new AliOrderResult(); + try + { + string out_trade_no = query.CustomerId + "1" + DateTime.Now.ToString("yyyyMMddHHmmssfff"); + + AlipayTradeWapPayQuery viewMode = new AlipayTradeWapPayQuery() { }; + string NotifyUrl = string.Format("{0}/api/front/HFivePay/AliOrderConfirm", PayInfoQuery.ApiUrl); + //生成订单 + //或者失败 + var model = new AlipayTradeWapPayModel + { + Body = "壹志愿VIP", + Subject = "壹志愿VIP", + TotalAmount = query.Money.ToString(), + OutTradeNo = out_trade_no, + ProductCode = "QUICK_WAP_WAY", + TimeoutExpress = "90m" + }; + var req = new AlipayTradeWapPayRequest(); + req.SetBizModel(model); + req.SetNotifyUrl(NotifyUrl); + req.SetReturnUrl("https://payment.yrtsedu.cn/alipay.html"); + var response = await alipayClient.PageExecuteAsync(req, alipayoptions.Value); + if (response == null) + { + logger.LogInformation("唤醒失败" + out_trade_no); + return new MessageModel() { success = false, msg = "支付宝唤醒失败" }; + } + logger.LogInformation("唤醒成功" + out_trade_no); + //_unitOfWork.BeginTran(); + var order = await _dal.Add(new V_OrderInfo + { + out_trade_no = out_trade_no, + PayType = EnumPayType.AliPay, + CardTypeId = query.CardTypeId, + Status = EnumOrderType.payment, + CustomerId = query.CustomerId, + Price = query.Money, + PayPrice = query.Money, + Name = "壹志愿好帮手VIP开通", + CardNo = "0", + CardId = 0 + }); + if (order > 0) + { + logger.LogInformation(out_trade_no + "唤醒成功"); + //_unitOfWork.CommitTran(); + return new MessageModel() + { + //?payType='alipay'&&success=true&&customerId=" + query.CustomerId + "&&out_trade_no=" + out_trade_no + success = true, + msg = "获取成功", + response = new AliOrderResult() + { + Body = response.Body, + CustomerId = query.CustomerId, + out_trade_no = out_trade_no, + PayType = "alipay", + Success = true + } + }; + } + return new MessageModel() { success = false, msg = "订单添加失败" }; + } + catch (Exception ex) + { + //_unitOfWork.RollbackTran(); + logger.LogInformation("唤醒异常" + ex.ToString()); + return new MessageModel() { success = false, msg = "支付宝唤醒失败" }; + } + } + + + } +} \ No newline at end of file diff --git a/New_College.Services/V_SubjectSelectServices.cs b/New_College.Services/V_SubjectSelectServices.cs new file mode 100644 index 0000000..4cb26af --- /dev/null +++ b/New_College.Services/V_SubjectSelectServices.cs @@ -0,0 +1,82 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.Model; +using System.Threading.Tasks; +using New_College.Model.ViewModels; +using System.Linq; + +namespace New_College.Services +{ + public class V_SubjectSelectServices : BaseServices, IV_SubjectSelectServices + { + private readonly IBaseRepository _dal; + public V_SubjectSelectServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + /// + /// 获取我的自选科目 + /// + /// + /// + public async Task> GetSubjectSelect(IdQuery query) + { + var info = await _dal.Query(x => x.IsDelete == false && x.CustomerId == query.Id && x.Status == 2); + if (info.Count <= 0) + return new MessageModel() { success = false, msg = "获取失败,暂未选科" }; + return new MessageModel() + { + success = true, + msg = "获取成功", + response = info.FirstOrDefault().SubjectSelect + }; + } + + /// + /// 保存我的选科 + /// + /// + /// + public async Task> SaveSubjectSelect(SubjectSelectQuery query) + { + var info = await _dal.Query(x => x.IsDelete == false && x.CustomerId == query.CustomerId); + if (info.Count <= 0) + { + var result = await _dal.Add(new V_SubjectSelect() + { + CustomerId = query.CustomerId, + SubjectSelect = query.SubjectSelect, + Status = query.Status + }); + if (result > 0) + { + return new MessageModel() { success = true, msg = "操作成功" }; + } + else + { + return new MessageModel() { success = false, msg = "操作失败" }; + } + } + else + { + var oneinfo = info.FirstOrDefault(); + oneinfo.SubjectSelect = query.SubjectSelect; + oneinfo.Status = query.Status; + var result = await _dal.Update(oneinfo); + if (result) + { + return new MessageModel() { success = true, msg = "操作成功" }; + } + else + { + return new MessageModel() { success = false, msg = "操作失败" }; + } + } + } + } +} \ No newline at end of file diff --git a/New_College.Services/V_VipCardInfoServices.cs b/New_College.Services/V_VipCardInfoServices.cs new file mode 100644 index 0000000..4deb9e6 --- /dev/null +++ b/New_College.Services/V_VipCardInfoServices.cs @@ -0,0 +1,419 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.Model; +using System.Threading.Tasks; +using New_College.Model.ViewModels; +using New_College.IRepository; +using System.Linq; +using System; +using LinqKit; +using System.Collections.Generic; +using New_College.Common; +using New_College.Model.ViewModels.Query; + +namespace New_College.Services +{ + public class V_VipCardInfoServices : BaseServices, IV_VipCardInfoServices + { + private readonly IBaseRepository _dal; + private readonly IV_VipCardTypeRepository v_VipCardTypeRepository; + private readonly IV_OrderInfoRepository v_OrderInfoRepository; + private readonly IV_CustomerInfoRepository v_CustomerInfoRepository; + + public V_VipCardInfoServices(IBaseRepository dal + , IV_OrderInfoRepository IV_OrderInfoRepository + , IV_VipCardTypeRepository IV_VipCardTypeRepository + , IV_CustomerInfoRepository IV_CustomerInfoRepository) + { + this._dal = dal; + v_OrderInfoRepository = IV_OrderInfoRepository; + v_VipCardTypeRepository = IV_VipCardTypeRepository; + v_CustomerInfoRepository = IV_CustomerInfoRepository; + base.BaseDal = dal; + } + + /// + /// 绑定卡 + /// + /// + /// + public async Task> BindCardInfo(VipCardQuery query) + { + var info = await v_CustomerInfoRepository.QueryById(query.CustomerId); + if (info == null) + return new MessageModel() { success = false, msg = "用户信息异常,你重新登录" }; + var cardinfo = (await _dal.Query(x => x.IsDelete == false && x.Code == query.CardCode)).FirstOrDefault(); + if (cardinfo == null || cardinfo != null && cardinfo.IsBind == 1) + return new MessageModel() { success = false, msg = "会员卡号有误或已被绑定" }; + cardinfo.IsBind = 1; + cardinfo.EndTime = DateTime.Now.AddDays(cardinfo.Day); + var result = await _dal.Update(cardinfo); + if (result == false) + return new MessageModel() { success = false, msg = "绑定失败" }; + var baseResult = await v_OrderInfoRepository.Add(new V_OrderInfo + { + out_trade_no = query.CustomerId + query.CardCode, + // PayType = 2, + CardTypeId = cardinfo.CardTypeId, + Status = EnumOrderType.payoff, + CustomerId = query.CustomerId, + Price = cardinfo.Money, + PayPrice = cardinfo.Money, + Name = "壹志愿好帮手VIP绑定", + CardNo = query.CardCode, + CardId = cardinfo.Id + }); + if (baseResult > 0) + { + //更改用户信息 + info.IsVIP = true; + info.VipCode = query.CardCode; + var updateresult = await v_CustomerInfoRepository.Update(info); + if (updateresult) + { + return new MessageModel() { success = true, msg = "绑定成功" }; + } + else + { + return new MessageModel() { success = false, msg = "用户信息更新失败" }; + } + } + else + { + return new MessageModel() { success = false, msg = "绑定失败" }; + } + } + + ///// + ///// 绑定卡 添加卡 + ///// + ///// + ///// + //public async Task> BindCardInfo(VipCardQuery query) + //{ + // var cardinfo = (await _dal.Query(x => x.IsDelete == false && x.IsBind == 0 && x.Code == query.CardCode)).FirstOrDefault(); + // if (cardinfo == null) + // return new MessageModel() { success = false, msg = "会员卡号有误或已被绑定" }; + // var endtime = DateTime.Now.AddDays(cardinfo.Day); + // var oldorderinfo = await v_OrderInfoRepository.Query(x => x.CustomerId == query.CustomerId && x.IsDelete == false); + // if (oldorderinfo.Count > 0) + // { + // var card = oldorderinfo.OrderByDescending(x => x.CreateTime).FirstOrDefault(); + // var oldcardinfo = await _dal.Query(x => x.Id == card.CardId && x.EndTime >= DateTime.Now); + // if (oldcardinfo != null) + // { + // var oldendtime = oldcardinfo.OrderByDescending(x => x.CreateTime).Select(x => x.EndTime).FirstOrDefault(); + // endtime = oldendtime.Value.AddDays(cardinfo.Day); + // } + // } + // //重新绑定的话 获取之前的到期时间再加上卡的日期 + // var addcard = await _dal.Add(new V_VipCardInfo() + // { + // CardTypeId = cardinfo.CardTypeId, + // CardTypeName = cardinfo.CardTypeName, + // Code = query.CardCode, + // IsBind = 1, + // Money = cardinfo.Money, + // Day = cardinfo.Day, + // EndTime = endtime + // }); + // if (addcard <= 0) + // return new MessageModel() { success = false, msg = "绑定失败" }; + // var baseResult = await v_OrderInfoRepository.Add(new V_OrderInfo + // { + // out_trade_no = query.CustomerId + query.CardCode, + // // PayType = 2, + // CardTypeId = cardinfo.CardTypeId, + // //Status = 1, + // CustomerId = query.CustomerId, + // Price = cardinfo.Money, + // PayPrice = cardinfo.Money, + // Name = "壹志愿好帮手VIP绑定", + // CardNo = query.CardCode, + // CardId = addcard + // }); + // if (baseResult > 0) + // { + // return new MessageModel() { success = true, msg = "绑定成功" }; + // } + // else + // { + // return new MessageModel() { success = false, msg = "绑定失败" }; + // } + //} + + + /// + /// 获取vip信息 + /// + /// + /// + public async Task> GetVipInfo(IdQuery query) + { + var orderinfo = await v_OrderInfoRepository.Query(x => x.CustomerId == query.Id && x.IsDelete == false); + if (orderinfo.Count <= 0) + return new MessageModel() { success = false, msg = "您还不是Vip" }; + var card = orderinfo.OrderByDescending(x => x.CreateTime).FirstOrDefault(); + var cardinfo = await _dal.QueryById(card.CardId); + if (card.CardNo == cardinfo.Code && DateTime.Now < cardinfo.EndTime) + { + return new MessageModel() + { + success = true, + msg = "获取成功", + response = new VipInfoResult() + { + IsVip = true, + VipCode = cardinfo.Code, + VipEndTime = cardinfo.EndTime, + VipCardTypeId = cardinfo.CardTypeId, + VipCardTypeName = cardinfo.CardTypeName + } + }; + } + else + { + return new MessageModel() + { + success = false, + msg = "卡号信息异常,或会员卡已过期", + response = new VipInfoResult() + { + IsVip = false, + VipCode = cardinfo.Code, + VipEndTime = cardinfo.EndTime + } + }; + } + } + + + /// + /// 生成卡信息 + /// + /// + /// + public async Task>> AutoVipCardInfo(AutoVipInfoQuery query) + { + var typeinfo = await v_VipCardTypeRepository.QueryById(query.VipCardTypeId); + if (typeinfo == null) + return new MessageModel>() { success = false, msg = "卡类型错误" }; + var cardinfo = (await _dal.QuerySql("SELECT Code FROM `V_VipCardInfo` where IsDelete=0")).Select(x => x.Code).ToList(); + List cardNumbers = new List(); + for (int i = 0; i < query.Num; i++) + { + var cn = GenerateCardNumberHelper.GenerateCardNumber(query.Head, query.Length); + cardNumbers.Add(cn); + } + cardinfo.AddRange(cardNumbers); + var isUnique = cardinfo.GroupBy(x => x).All(g => g.Count() == 1); + //Assert.IsTrue(isUnique); + if (isUnique) + { + List addinfo = cardNumbers.Select(x => new V_VipCardInfo() + { + CardTypeId = typeinfo.Id, + CardTypeName = typeinfo.Name, + Code = x, + Day = typeinfo.Day, + EndTime = DateTime.Now.AddDays(typeinfo.Day), + IsBind = 0, + Money = typeinfo.Money + }).ToList(); + var result = await _dal.Add(addinfo); + return new MessageModel>() { success = true, msg = "生成成功", response = cardNumbers }; + } + return new MessageModel>() { success = false, msg = "生成失败", response = cardNumbers }; + } + + #region 生成卡号 + + #endregion + + + /// + /// 获取学生卡信息(分页) vip卡 + /// + /// + /// + public async Task>> GetVipCardInfoByPage(VipCardInfoSearchQuery query) + { + var wheres = PredicateBuilder.New(); + wheres = wheres.And(x => x.IsDelete == false); + if (!string.IsNullOrWhiteSpace(query.IsBind) && query.IsBind!="2") + wheres = wheres.And(x => x.IsBind ==Convert.ToInt32( query.IsBind)); + if (!string.IsNullOrWhiteSpace( query.Code )) + wheres = wheres.And(x => x.Code.Contains(query.Code)); + if (!string.IsNullOrWhiteSpace(query.CardTypeId) && query.CardTypeId != "0") + wheres = wheres.And(x => x.CardTypeId == Convert.ToInt32(query.CardTypeId)); + var info = await _dal.QueryPage(wheres, query.PageIndex, query.PageSize); + if (info.data.Count <= 0) + return new MessageModel>() + { + success = false, + msg = "获取失败" + }; + //var regioninfo = await sysRegionRepository.Query(x => x.ParentCode == "100000"); + PageModel pageModel = new PageModel() { }; + List list = new List() { }; + foreach (var item in info.data) + { + list.Add(new VipCardInfoResult() + { + Id = item.Id, + Code = item.Code, + CardTypeName = item.CardTypeName, + IsBind = item.IsBind, + IsBindName = item.IsBind == 0 ? "绑定" : "未绑定", + Day = item.Day, + Money = item.Money + }); + } + pageModel.data = list; + pageModel.dataCount = info.dataCount; + pageModel.page = info.page; + pageModel.pageCount = info.pageCount; + pageModel.PageSize = info.PageSize; + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = pageModel + }; + } + + /// + /// 获取单个学生卡信息 + /// + /// + /// + public async Task> GetVipCardInfoOne(IdQuery query) + { + var info = await _dal.QueryById(query.Id); + if (info == null) + return new MessageModel() { success = false, msg = "获取失败" }; + + return new MessageModel() + { + success = true, + msg = "获取成功", + response = new VipCardInfoResultOne() + { + Id = info.Id, + Code = info.Code, + CardTypeId = info.CardTypeId, + CardTypeName = info.CardTypeName, + IsBind = info.IsBind, + Day = info.Day, + Money = info.Money + } + }; + + } + + /// + /// 添加学生卡 + /// + /// + /// + public async Task> AddVipCardInfo(VipCardInfoQuery query) + { + //首先获取选择对应的CardType信息 + var wheres = PredicateBuilder.New(); + wheres = wheres.And(x => x.IsDelete == false); + if (query.CardTypeId>0) + wheres = wheres.And(x => x.Id==query.CardTypeId); + var info = await v_VipCardTypeRepository.Query(wheres); + var CardTypeList = info.Select(x => x.Id).ToList(); + var listCard = await v_VipCardTypeRepository.Query(x => query.CardTypeId==x.Id && x.IsDelete == false); + var CardTypeOne = listCard.Where(x => x.Id == query.CardTypeId).FirstOrDefault(); + + + var result = await _dal.Add(new V_VipCardInfo() + { + Code = query.Code, + Day = CardTypeOne.Day, + Money = CardTypeOne.Money, + CardTypeId = CardTypeOne.Id, + CardTypeName= CardTypeOne.Name, + }); + + if (result > 0) + { + return new MessageModel() { success = true, msg = "添加成功", response = true }; + } + else + { + return new MessageModel() { success = false, msg = "添加失败", response = false }; + } + } + + + + /// + /// 更新学生卡 + /// + /// + /// + public async Task> UpdateVipCardInfo(VipCardInfoQuery query) + { + //首先获取选择对应的CardType信息 + var wheres = PredicateBuilder.New(); + wheres = wheres.And(x => x.IsDelete == false); + if (query.CardTypeId > 0) + wheres = wheres.And(x => x.Id == query.CardTypeId); + var info = await v_VipCardTypeRepository.Query(wheres); + var CardTypeList = info.Select(x => x.Id).ToList(); + var listCard = await v_VipCardTypeRepository.Query(x => query.CardTypeId == x.Id && x.IsDelete == false); + var CardTypeOne = listCard.Where(x => x.Id == query.CardTypeId).FirstOrDefault(); + + var infoCard = await _dal.QueryById(query.Id); + if (infoCard == null) + return new MessageModel() { success = false, msg = "修改内容不存在", response = false }; + infoCard.Code = query.Code; + //infoCard.IsBind = query.IsBind; + infoCard.Day = CardTypeOne.Day; + infoCard.Money = CardTypeOne.Money; + infoCard.CardTypeId = CardTypeOne.Id; + infoCard.CardTypeName = CardTypeOne.Name; + var result = await _dal.Update(infoCard); + if (result) + { + return new MessageModel() { success = true, msg = "修改成功", response = true }; + } + else + { + return new MessageModel() { success = false, msg = "修改失败", response = false }; + } + } + /// + /// 删除学生卡 + /// + /// + /// + public async Task> DeleteVipCardInfo(IdQuery query) + { + if (query.Ids == null || query.Ids.Count <= 0) + return new MessageModel() { success = false, msg = "传入为空", response = false }; + var info = await _dal.Query(x => x.IsDelete == false && query.Ids.Contains(x.Id)); + if (info.Count <= 0) + return new MessageModel() { success = false, msg = "没有可被删除项", response = false }; + foreach (var item in info) + { + item.IsDelete = true; + } + var result = await _dal.Update(info); + if (result) + { + return new MessageModel() { success = true, msg = "删除成功", response = true }; + } + else + { + return new MessageModel() { success = false, msg = "删除失败", response = false }; + } + } + } +} \ No newline at end of file diff --git a/New_College.Services/V_VipCardTypeServices.cs b/New_College.Services/V_VipCardTypeServices.cs new file mode 100644 index 0000000..1d75ea3 --- /dev/null +++ b/New_College.Services/V_VipCardTypeServices.cs @@ -0,0 +1,59 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; +using System.Collections.Generic; +using System.Threading.Tasks; +using New_College.Model.ViewModels; +using System.Linq; +using New_College.Model; +using New_College.Model.ViewModels.Query; +using LinqKit; + +namespace New_College.Services +{ + public class V_VipCardTypeServices : BaseServices, IV_VipCardTypeServices + { + private readonly IBaseRepository _dal; + public V_VipCardTypeServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + + /// + /// 获取Vip卡列表 + /// + /// + public async Task> GetVipCardTypeList() + { + var info = await _dal.Query(x => x.IsDelete == false, "OrderSort desc"); + return info.Select(x => new VipCardTypeResult() + { + Id = x.Id, + Name = x.Name, + Money = x.Money, + Desc = x.Desc, + Day = x.Day + }).ToList(); + } + + /// + /// 获取Vip卡列表 + /// + /// + public async Task> GetVipCardType() + { + var info = await _dal.Query(x => x.IsDelete == false, "OrderSort desc"); + return info.Select(x => new VipCardTypeQuery() + { + Id = x.Id, + Name = x.Name, + Money = x.Money, + Desc = x.Desc, + Day = x.Day + }).ToList(); + } + } +} diff --git a/New_College.Services/sysUserInfoServices.cs b/New_College.Services/sysUserInfoServices.cs new file mode 100644 index 0000000..15c2013 --- /dev/null +++ b/New_College.Services/sysUserInfoServices.cs @@ -0,0 +1,78 @@ +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using System.Linq; +using System.Threading.Tasks; + +namespace New_College.FrameWork.Services +{ + /// + /// sysUserInfoServices + /// + public class SysUserInfoServices : BaseServices, ISysUserInfoServices + { + + IBaseRepository _dal; + IUserRoleServices _userRoleServices; + IBaseRepository _roleRepository; + public SysUserInfoServices(IBaseRepository dal, IUserRoleServices userRoleServices, IBaseRepository roleRepository) + { + this._dal = dal; + this._userRoleServices = userRoleServices; + this._roleRepository = roleRepository; + base.BaseDal = dal; + } + /// + /// + /// + /// + /// + /// + public async Task SaveUserInfo(string loginName, string loginPwd) + { + sysUserInfo sysUserInfo = new sysUserInfo(loginName, loginPwd); + sysUserInfo model = new sysUserInfo(); + var userList = await base.Query(a => a.uLoginName == sysUserInfo.uLoginName && a.uLoginPWD == sysUserInfo.uLoginPWD); + if (userList.Count > 0) + { + model = userList.FirstOrDefault(); + } + else + { + var id = await base.Add(sysUserInfo); + model = await base.QueryById(id); + } + + return model; + + } + + /// + /// + /// + /// + /// + /// + public async Task GetUserRoleNameStr(string loginName, string loginPwd) + { + string roleName = ""; + var user = (await base.Query(a => a.uLoginName == loginName && a.uLoginPWD == loginPwd)).FirstOrDefault(); + var roleList = await _roleRepository.Query(a => a.IsDeleted==false); + if (user != null) + { + var userRoles = await _userRoleServices.Query(ur => ur.UserId == user.uID); + if (userRoles.Count > 0) + { + var arr = userRoles.Select(ur => ur.RoleId.ObjToString()).ToList(); + var roles = roleList.Where(d => arr.Contains(d.Id.ObjToString())); + + roleName = string.Join(',', roles.Select(r => r.Name).ToArray()); + } + } + return roleName; + } + } +} + +//----------sysUserInfo结束---------- diff --git a/New_College.System.Architecture.png b/New_College.System.Architecture.png new file mode 100644 index 0000000..994a1e2 Binary files /dev/null and b/New_College.System.Architecture.png differ diff --git a/New_College.Tasks/HostedService/Job1TimedService.cs b/New_College.Tasks/HostedService/Job1TimedService.cs new file mode 100644 index 0000000..4f4b88b --- /dev/null +++ b/New_College.Tasks/HostedService/Job1TimedService.cs @@ -0,0 +1,60 @@ +using New_College.Common.Helper; +using New_College.IServices; +using Microsoft.Extensions.Hosting; +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace New_College.Tasks +{ + public class Job1TimedService : IHostedService, IDisposable + { + private Timer _timer; + private readonly IBlogArticleServices _blogArticleServices; + + // 这里可以注入 + public Job1TimedService(IBlogArticleServices blogArticleServices) + { + _blogArticleServices = blogArticleServices; + } + + public Task StartAsync(CancellationToken cancellationToken) + { + Console.WriteLine("Job 1 is starting."); + + _timer = new Timer(DoWork, null, TimeSpan.Zero, + TimeSpan.FromSeconds(60 * 60));//一个小时 + + return Task.CompletedTask; + } + + private async void DoWork(object state) + { + try + { + var model = await _blogArticleServices.GetBlogDetails(1); + Console.WriteLine($"Job 1 启动成功,获取id=1的博客title为:{model?.btitle}"); + } + catch (Exception ex) + { + Console.WriteLine($"Error:{ex.Message}"); + } + + ConsoleHelper.WriteSuccessLine($"Job 1: {DateTime.Now}"); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + Console.WriteLine("Job 1 is stopping."); + + _timer?.Change(Timeout.Infinite, 0); + + return Task.CompletedTask; + } + + public void Dispose() + { + _timer?.Dispose(); + } + } +} diff --git a/New_College.Tasks/HostedService/Job2TimedService.cs b/New_College.Tasks/HostedService/Job2TimedService.cs new file mode 100644 index 0000000..b0421d1 --- /dev/null +++ b/New_College.Tasks/HostedService/Job2TimedService.cs @@ -0,0 +1,47 @@ +using New_College.Common.Helper; +using Microsoft.Extensions.Hosting; +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace New_College.Tasks +{ + public class Job2TimedService : IHostedService, IDisposable + { + private Timer _timer; + + // 这里可以注入 + public Job2TimedService() + { + } + + public Task StartAsync(CancellationToken cancellationToken) + { + Console.WriteLine("Job 2 is starting."); + + _timer = new Timer(DoWork, null, TimeSpan.Zero, + TimeSpan.FromSeconds(60 * 60 * 2));//两个小时 + + return Task.CompletedTask; + } + + private void DoWork(object state) + { + ConsoleHelper.WriteWarningLine($"Job 2: {DateTime.Now}"); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + Console.WriteLine("Job 2 is stopping."); + + _timer?.Change(Timeout.Infinite, 0); + + return Task.CompletedTask; + } + + public void Dispose() + { + _timer?.Dispose(); + } + } +} diff --git a/New_College.Tasks/New_College.Tasks.csproj b/New_College.Tasks/New_College.Tasks.csproj new file mode 100644 index 0000000..16f34ee --- /dev/null +++ b/New_College.Tasks/New_College.Tasks.csproj @@ -0,0 +1,15 @@ + + + + netcoreapp3.1 + + + + + + + + + + + diff --git a/New_College.Tasks/QuartzNet/ISchedulerCenter.cs b/New_College.Tasks/QuartzNet/ISchedulerCenter.cs new file mode 100644 index 0000000..1ebf990 --- /dev/null +++ b/New_College.Tasks/QuartzNet/ISchedulerCenter.cs @@ -0,0 +1,44 @@ +using New_College.Model; +using New_College.Model.Models; +using System.Threading.Tasks; + +namespace New_College.Tasks +{ + /// + /// 服务调度接口 + /// + public interface ISchedulerCenter + { + + /// + /// 开启任务调度 + /// + /// + Task> StartScheduleAsync(); + /// + /// 停止任务调度 + /// + /// + Task> StopScheduleAsync(); + /// + /// + /// + /// + /// + Task> AddScheduleJobAsync(TasksQz sysSchedule); + /// + /// 停止一个任务 + /// + /// + /// + Task> StopScheduleJobAsync(TasksQz sysSchedule); + /// + /// 恢复一个任务 + /// + /// + /// + Task> ResumeJob(TasksQz sysSchedule); + + } + +} diff --git a/New_College.Tasks/QuartzNet/JobFactory.cs b/New_College.Tasks/QuartzNet/JobFactory.cs new file mode 100644 index 0000000..a1aacca --- /dev/null +++ b/New_College.Tasks/QuartzNet/JobFactory.cs @@ -0,0 +1,50 @@ +using Microsoft.Extensions.DependencyInjection; +using Quartz; +using Quartz.Spi; +using System; + +namespace New_College.Tasks +{ + public class JobFactory : IJobFactory + { + /// + /// 注入反射获取依赖对象 + /// + private readonly IServiceProvider _serviceProvider; + public JobFactory(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + /// + /// 实现接口Job + /// + /// + /// + /// + public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler) + { + try + { + var serviceScope = _serviceProvider.CreateScope(); + var job = serviceScope.ServiceProvider.GetService(bundle.JobDetail.JobType) as IJob; + return job; + + } + catch (Exception e) + { + throw e; + } + } + + public void ReturnJob(IJob job) + { + var disposable = job as IDisposable; + if (disposable != null) + { + disposable.Dispose(); + } + + } + } + +} diff --git a/New_College.Tasks/QuartzNet/Jobs/JobBase.cs b/New_College.Tasks/QuartzNet/Jobs/JobBase.cs new file mode 100644 index 0000000..f068f0e --- /dev/null +++ b/New_College.Tasks/QuartzNet/Jobs/JobBase.cs @@ -0,0 +1,44 @@ +using Quartz; +using System; +using System.Diagnostics; +using System.Threading.Tasks; + +namespace New_College.Tasks +{ + public class JobBase + { + /// + /// 执行指定任务 + /// + /// + /// + public async Task ExecuteJob(IJobExecutionContext context, Func func) + { + string jobHistory = $"【{DateTime.Now}】执行任务【Id:{context.JobDetail.Key.Name},组别:{context.JobDetail.Key.Group}】"; + try + { + var s = context.Trigger.Key.Name; + //记录Job时间 + Stopwatch stopwatch = new Stopwatch(); + stopwatch.Start(); + await func();//执行任务 + stopwatch.Stop(); + jobHistory += $",【执行成功】,完成时间:{stopwatch.Elapsed.TotalMilliseconds.ToString("00")}毫秒"; + //SerilogServer.WriteLog(context.Trigger.Key.Name.Replace("-", ""), $"{context.Trigger.Key.Name}定时任务运行一切OK", "任务结束"); + } + catch (Exception ex) + { + JobExecutionException e2 = new JobExecutionException(ex); + //true 是立即重新执行任务 + e2.RefireImmediately = true; + //SerilogServer.WriteErrorLog(context.Trigger.Key.Name.Replace("-", ""), $"{context.Trigger.Key.Name}任务运行异常", ex); + + jobHistory += $",【执行失败】,异常日志:{ex.Message}"; + } + + Console.Out.WriteLine(jobHistory); + return jobHistory; + } + } + +} diff --git a/New_College.Tasks/QuartzNet/Jobs/Job_Blogs_Quartz.cs b/New_College.Tasks/QuartzNet/Jobs/Job_Blogs_Quartz.cs new file mode 100644 index 0000000..793aec7 --- /dev/null +++ b/New_College.Tasks/QuartzNet/Jobs/Job_Blogs_Quartz.cs @@ -0,0 +1,70 @@ +using New_College.Common.Helper; +using New_College.IServices; +using Quartz; +using System; +using System.Threading.Tasks; + +/// +/// 这里要注意下,命名空间和程序集是一样的,不然反射不到 +/// +namespace New_College.Tasks +{ + public class Job_Blogs_Quartz : JobBase, IJob + { + private readonly IBlogArticleServices _blogArticleServices; + private readonly ITasksQzServices _tasksQzServices; + + public Job_Blogs_Quartz(IBlogArticleServices blogArticleServices, ITasksQzServices tasksQzServices) + { + _blogArticleServices = blogArticleServices; + _tasksQzServices = tasksQzServices; + } + public async Task Execute(IJobExecutionContext context) + { + + //var param = context.MergedJobDataMap; + // 可以直接获取 JobDetail 的值 + var jobKey = context.JobDetail.Key; + var jobId = jobKey.Name; + + var executeLog = await ExecuteJob(context, async () => await Run(context, jobId.ObjToInt())); + + // 也可以通过数据库配置,获取传递过来的参数 + JobDataMap data = context.JobDetail.JobDataMap; + //int jobId = data.GetInt("JobParam"); + + //var model = await _tasksQzServices.QueryById(jobId); + //if (model != null) + //{ + // model.RunTimes += 1; + // model.Remark += $"{executeLog}
"; + // await _tasksQzServices.Update(model); + //} + + } + public async Task Run(IJobExecutionContext context, int jobid) + { + var list = await _blogArticleServices.Query(); + + if (jobid > 0) + { + var model = await _tasksQzServices.QueryById(jobid); + if (model != null) + { + model.RunTimes += 1; + var separator = "
"; + model.Remark = + $"【{DateTime.Now}】执行任务【Id:{context.JobDetail.Key.Name},组别:{context.JobDetail.Key.Group}】【执行成功】{separator}" + + string.Join(separator, StringHelper.GetTopDataBySeparator(model.Remark, separator, 9)); + + await _tasksQzServices.Update(model); + } + } + + await Console.Out.WriteLineAsync("博客总数量" + list.Count.ToString()); + } + } + + + +} diff --git a/New_College.Tasks/QuartzNet/SchedulerCenterServer.cs b/New_College.Tasks/QuartzNet/SchedulerCenterServer.cs new file mode 100644 index 0000000..20c5a91 --- /dev/null +++ b/New_College.Tasks/QuartzNet/SchedulerCenterServer.cs @@ -0,0 +1,308 @@ +using New_College.Model; +using New_College.Model.Models; +using Quartz; +using Quartz.Impl; +using Quartz.Spi; +using System; +using System.Collections.Specialized; +using System.Reflection; +using System.Threading.Tasks; + +namespace New_College.Tasks +{ + /// + /// 任务调度管理中心 + /// + public class SchedulerCenterServer : ISchedulerCenter + { + private Task _scheduler; + private readonly IJobFactory _iocjobFactory; + public SchedulerCenterServer(IJobFactory jobFactory) + { + _iocjobFactory = jobFactory; + _scheduler = GetSchedulerAsync(); + } + private Task GetSchedulerAsync() + { + if (_scheduler != null) + return this._scheduler; + else + { + // 从Factory中获取Scheduler实例 + NameValueCollection collection = new NameValueCollection + { + { "quartz.serializer.type", "binary" }, + }; + StdSchedulerFactory factory = new StdSchedulerFactory(collection); + return _scheduler = factory.GetScheduler(); + } + } + + /// + /// 开启任务调度 + /// + /// + public async Task> StartScheduleAsync() + { + var result = new MessageModel(); + try + { + this._scheduler.Result.JobFactory = this._iocjobFactory; + if (!this._scheduler.Result.IsStarted) + { + //等待任务运行完成 + await this._scheduler.Result.Start(); + await Console.Out.WriteLineAsync("任务调度开启!"); + result.success = true; + result.msg = $"任务调度开启成功"; + return result; + } + else + { + result.success = false; + result.msg = $"任务调度已经开启"; + return result; + } + } + catch (Exception) + { + throw; + } + } + + /// + /// 停止任务调度 + /// + /// + public async Task> StopScheduleAsync() + { + var result = new MessageModel(); + try + { + if (!this._scheduler.Result.IsShutdown) + { + //等待任务运行完成 + await this._scheduler.Result.Shutdown(); + await Console.Out.WriteLineAsync("任务调度停止!"); + result.success = true; + result.msg = $"任务调度停止成功"; + return result; + } + else + { + result.success = false; + result.msg = $"任务调度已经停止"; + return result; + } + } + catch (Exception) + { + throw; + } + } + + /// + /// 添加一个计划任务(映射程序集指定IJob实现类) + /// + /// + /// + /// + public async Task> AddScheduleJobAsync(TasksQz tasksQz) + { + var result = new MessageModel(); + + if (tasksQz != null) + { + try + { + JobKey jobKey = new JobKey(tasksQz.Id.ToString(), tasksQz.JobGroup); + if (await _scheduler.Result.CheckExists(jobKey)) + { + result.success = false; + result.msg = $"该任务计划已经在执行:【{tasksQz.Name}】,请勿重复启动!"; + return result; + } + #region 设置开始时间和结束时间 + + if (tasksQz.BeginTime == null) + { + tasksQz.BeginTime = DateTime.Now; + } + DateTimeOffset starRunTime = DateBuilder.NextGivenSecondDate(tasksQz.BeginTime, 1);//设置开始时间 + if (tasksQz.EndTime == null) + { + tasksQz.EndTime = DateTime.MaxValue.AddDays(-1); + } + DateTimeOffset endRunTime = DateBuilder.NextGivenSecondDate(tasksQz.EndTime, 1);//设置暂停时间 + + #endregion + + #region 通过反射获取程序集类型和类 + + Assembly assembly = Assembly.Load(new AssemblyName(tasksQz.AssemblyName)); + Type jobType = assembly.GetType(tasksQz.AssemblyName + "." + tasksQz.ClassName); + + #endregion + //判断任务调度是否开启 + if (!_scheduler.Result.IsStarted) + { + await StartScheduleAsync(); + } + + //传入反射出来的执行程序集 + IJobDetail job = new JobDetailImpl(tasksQz.Id.ToString(), tasksQz.JobGroup, jobType); + job.JobDataMap.Add("JobParam", tasksQz.JobParams); + ITrigger trigger; + + #region 泛型传递 + //IJobDetail job = JobBuilder.Create() + // .WithIdentity(sysSchedule.Name, sysSchedule.JobGroup) + // .Build(); + #endregion + + if (tasksQz.Cron != null && CronExpression.IsValidExpression(tasksQz.Cron) && tasksQz.TriggerType > 0) + { + trigger = CreateCronTrigger(tasksQz); + } + else + { + trigger = CreateSimpleTrigger(tasksQz); + } + // 告诉Quartz使用我们的触发器来安排作业 + await _scheduler.Result.ScheduleJob(job, trigger); + //await Task.Delay(TimeSpan.FromSeconds(120)); + //await Console.Out.WriteLineAsync("关闭了调度器!"); + //await _scheduler.Result.Shutdown(); + result.success = true; + result.msg = $"启动任务:【{tasksQz.Name}】成功"; + return result; + } + catch (Exception ex) + { + result.success = false; + result.msg = $"任务计划异常:【{ex.Message}】"; + return result; + } + } + else + { + result.success = false; + result.msg = $"任务计划不存在:【{tasksQz.Name}】"; + return result; + } + } + + /// + /// 暂停一个指定的计划任务 + /// + /// + public async Task> StopScheduleJobAsync(TasksQz sysSchedule) + { + var result = new MessageModel(); + try + { + JobKey jobKey = new JobKey(sysSchedule.Id.ToString(), sysSchedule.JobGroup); + if (!await _scheduler.Result.CheckExists(jobKey)) + { + result.success = false; + result.msg = $"未找到要暂停的任务:【{sysSchedule.Name}】"; + return result; + } + else + { + await this._scheduler.Result.PauseJob(jobKey); + result.success = true; + result.msg = $"暂停任务:【{sysSchedule.Name}】成功"; + return result; + } + } + catch (Exception) + { + throw; + } + } + + /// + /// 恢复指定的计划任务 + /// + /// + /// + public async Task> ResumeJob(TasksQz sysSchedule) + { + var result = new MessageModel(); + try + { + JobKey jobKey = new JobKey(sysSchedule.Id.ToString(), sysSchedule.JobGroup); + if (!await _scheduler.Result.CheckExists(jobKey)) + { + result.success = false; + result.msg = $"未找到要重新的任务:【{sysSchedule.Name}】,请先选择添加计划!"; + return result; + } + await this._scheduler.Result.ResumeJob(jobKey); + result.success = true; + result.msg = $"恢复计划任务:【{sysSchedule.Name}】成功"; + return result; + } + catch (Exception) + { + throw; + } + } + + #region 创建触发器帮助方法 + + /// + /// 创建SimpleTrigger触发器(简单触发器) + /// + /// + /// + /// + /// + private ITrigger CreateSimpleTrigger(TasksQz sysSchedule) + { + if (sysSchedule.RunTimes > 0) + { + ITrigger trigger = TriggerBuilder.Create() + .WithIdentity(sysSchedule.Id.ToString(), sysSchedule.JobGroup) + .StartAt(sysSchedule.BeginTime.Value) + .EndAt(sysSchedule.EndTime.Value) + .WithSimpleSchedule(x => + x.WithIntervalInSeconds(sysSchedule.IntervalSecond) + .WithRepeatCount(sysSchedule.RunTimes)).ForJob(sysSchedule.Id.ToString(), sysSchedule.JobGroup).Build(); + return trigger; + } + else + { + ITrigger trigger = TriggerBuilder.Create() + .WithIdentity(sysSchedule.Id.ToString(), sysSchedule.JobGroup) + .StartAt(sysSchedule.BeginTime.Value) + .EndAt(sysSchedule.EndTime.Value) + .WithSimpleSchedule(x => + x.WithIntervalInSeconds(sysSchedule.IntervalSecond) + .RepeatForever()).ForJob(sysSchedule.Id.ToString(), sysSchedule.JobGroup).Build(); + return trigger; + } + // 触发作业立即运行,然后每10秒重复一次,无限循环 + + } + /// + /// 创建类型Cron的触发器 + /// + /// + /// + private ITrigger CreateCronTrigger(TasksQz sysSchedule) + { + // 作业触发器 + return TriggerBuilder.Create() + .WithIdentity(sysSchedule.Id.ToString(), sysSchedule.JobGroup) + .StartAt(sysSchedule.BeginTime.Value)//开始时间 + .EndAt(sysSchedule.EndTime.Value)//结束数据 + .WithCronSchedule(sysSchedule.Cron)//指定cron表达式 + .ForJob(sysSchedule.Id.ToString(), sysSchedule.JobGroup)//作业名称 + .Build(); + } + #endregion + + } +} diff --git a/New_College.Tests/Controller_Test/BlogController_Should.cs b/New_College.Tests/Controller_Test/BlogController_Should.cs new file mode 100644 index 0000000..5d803df --- /dev/null +++ b/New_College.Tests/Controller_Test/BlogController_Should.cs @@ -0,0 +1,70 @@ +using New_College.Common; +using New_College.Controllers; +using New_College.IServices; +using New_College.Model.Models; +using Moq; +using Xunit; +using System; +using Microsoft.Extensions.Logging; +using Autofac; + +namespace New_College.Tests +{ + public class BlogController_Should + { + Mock mockBlogSev = new Mock(); + Mock mockRedisMag = new Mock(); + Mock> mockLogger = new Mock>(); + BlogController blogController; + + private IBlogArticleServices blogArticleServices; + DI_Test dI_Test = new DI_Test(); + + + + public BlogController_Should() + { + mockBlogSev.Setup(r => r.Query()); + + + var container = dI_Test.DICollections(); + blogArticleServices = container.Resolve(); + blogController = new BlogController(blogArticleServices, mockLogger.Object); + } + + [Fact] + public void TestEntity() + { + BlogArticle blogArticle = new BlogArticle(); + + Assert.True(blogArticle.bID >= 0); + } + [Fact] + public async void GetBlogsTest() + { + object blogs =await blogController.Get(1); + + Assert.NotNull(blogs); + } + + [Fact] + public async void PostTest() + { + BlogArticle blogArticle = new BlogArticle() + { + bCreateTime = DateTime.Now, + bUpdateTime = DateTime.Now, + btitle = "xuint :test controller addEntity", + + }; + + var res = await blogController.Post(blogArticle); + + Assert.True(res.success); + + var data = res.response; + + Assert.NotNull(data); + } + } +} diff --git a/New_College.Tests/Controller_Test/LoginController_Should.cs b/New_College.Tests/Controller_Test/LoginController_Should.cs new file mode 100644 index 0000000..3064d31 --- /dev/null +++ b/New_College.Tests/Controller_Test/LoginController_Should.cs @@ -0,0 +1,74 @@ +using New_College.Controllers; +using New_College.IServices; +using Xunit; +using Autofac; +using New_College.AuthHelper; + +namespace New_College.Tests +{ + public class LoginController_Should + { + LoginController loginController; + + private readonly ISysUserInfoServices _sysUserInfoServices; + private readonly IUserRoleServices _userRoleServices; + private readonly IRoleServices _roleServices; + private readonly PermissionRequirement _requirement; + private readonly IRoleModulePermissionServices _roleModulePermissionServices; + + DI_Test dI_Test = new DI_Test(); + + + + public LoginController_Should() + { + var container = dI_Test.DICollections(); + _sysUserInfoServices = container.Resolve(); + _userRoleServices = container.Resolve(); + _roleServices = container.Resolve(); + _requirement = container.Resolve(); + _roleModulePermissionServices = container.Resolve(); + loginController = new LoginController(_sysUserInfoServices,_userRoleServices,_roleServices,_requirement, _roleModulePermissionServices); + } + + [Fact] + public void GetJwtStrTest() + { + var data = loginController.GetJwtStr("test", "test"); + + Assert.NotNull(data); + } + [Fact] + public void GetJwtStrForNuxtTest() + { + object blogs = loginController.GetJwtStrForNuxt("test", "test"); + + Assert.NotNull(blogs); + } + + [Fact] + public async void GetJwtToken3Test() + { + + var res = await loginController.GetJwtToken3("test", "test"); + + Assert.NotNull(res); + } + + [Fact] + public async void RefreshTokenTest() + { + var res = await loginController.RefreshToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoidGVzdCIsImp0aSI6IjgiLCJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL2V4cGlyYXRpb24iOiIyMDE5LzEwLzE4IDIzOjI2OjQ5IiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiQWRtaW5UZXN0IiwibmJmIjoxNTcxNDA4ODA5LCJleHAiOjE1NzE0MTI0MDksImlzcyI6IkJsb2cuQ29yZSIsImF1ZCI6IndyIn0.oz-SPz6UCL78fM09bUecw5rmjcNYEY9dWGtuPs2gdBg"); + + Assert.NotNull(res); + } + + [Fact] + public void Md5PasswordTest() + { + var res = loginController.Md5Password("test"); + + Assert.NotNull(res); + } + } +} diff --git a/New_College.Tests/DependencyInjection/DI_Test.cs b/New_College.Tests/DependencyInjection/DI_Test.cs new file mode 100644 index 0000000..4704ed1 --- /dev/null +++ b/New_College.Tests/DependencyInjection/DI_Test.cs @@ -0,0 +1,193 @@ +using Autofac; +using Autofac.Extensions.DependencyInjection; +using Autofac.Extras.DynamicProxy; +using AutoMapper; +using New_College.AuthHelper; +using New_College.Common; +using New_College.Common.AppConfig; +using New_College.Common.DB; +using New_College.Common.LogHelper; +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Seed; +using New_College.Repository.Base; +using New_College.Services; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.IdentityModel.Tokens; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Security.Claims; +using System.Text; +using Xunit; + +namespace New_College.Tests +{ + public class DI_Test + { + + [Fact] + public void DI_Connet_Test() + { + var basePath = Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.ApplicationBasePath; + + IServiceCollection services = new ServiceCollection(); + services.AddAutoMapper(typeof(Startup)); + + services.AddScoped(o => + { + return new SqlSugar.SqlSugarClient(new SqlSugar.ConnectionConfig() + { + ConnectionString = GetMainConnectionDb().Connection,//必填, 数据库连接字符串 + DbType = (SqlSugar.DbType)GetMainConnectionDb().DbType,//必填, 数据库类型 + IsAutoCloseConnection = true,//默认false, 时候知道关闭数据库连接, 设置为true无需使用using或者Close操作 + IsShardSameThread = true,//共享线程 + InitKeyType = SqlSugar.InitKeyType.SystemTable//默认SystemTable, 字段信息读取, 如:该属性是不是主键,标识列等等信息 + }); + }); + + //services.AddSingleton(new Appsettings(Env)); + + + //实例化 AutoFac 容器 + var builder = new ContainerBuilder(); + builder.RegisterType().As(); + + //指定已扫描程序集中的类型注册为提供所有其实现的接口。 + //var assemblysServices = Assembly.Load("New_College.Services"); + //builder.RegisterAssemblyTypes(assemblysServices).AsImplementedInterfaces(); + //var assemblysRepository = Assembly.Load("New_College.Repository"); + //builder.RegisterAssemblyTypes(assemblysRepository).AsImplementedInterfaces(); + + var servicesDllFile = Path.Combine(basePath, "New_College.Services.dll"); + var assemblysServices = Assembly.LoadFrom(servicesDllFile); + builder.RegisterAssemblyTypes(assemblysServices) + .AsImplementedInterfaces() + .InstancePerLifetimeScope() + .EnableInterfaceInterceptors(); + + var repositoryDllFile = Path.Combine(basePath, "New_College.Repository.dll"); + var assemblysRepository = Assembly.LoadFrom(repositoryDllFile); + builder.RegisterAssemblyTypes(assemblysRepository).AsImplementedInterfaces(); + + //将services填充到Autofac容器生成器中 + builder.Populate(services); + + //使用已进行的组件登记创建新容器 + var ApplicationContainer = builder.Build(); + + var blogservice = ApplicationContainer.Resolve(); + + Assert.True(ApplicationContainer.ComponentRegistry.Registrations.Count() > 0); + } + + + /// + /// 连接字符串 + /// New_College + /// + public static MutiDBOperate GetMainConnectionDb() + { + var mainConnetctDb = BaseDBConfig.MutiConnectionString.Item1.Find(x => x.ConnId == MainDb.CurrentDbConnId); + if (BaseDBConfig.MutiConnectionString.Item1.Count > 0) + { + if (mainConnetctDb == null) + { + mainConnetctDb = BaseDBConfig.MutiConnectionString.Item1[0]; + } + } + else + { + throw new Exception("请确保appsettigns.json中配置连接字符串,并设置Enabled为true;"); + } + + return mainConnetctDb; + } + + public IContainer DICollections() + { + var basePath = Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.ApplicationBasePath; + + IServiceCollection services = new ServiceCollection(); + services.AddAutoMapper(typeof(Startup)); + + services.AddSingleton(new Appsettings(basePath)); + services.AddSingleton(new LogLock(basePath)); + services.AddSingleton(); + services.AddScoped(); + services.AddScoped(); + + //读取配置文件 + var symmetricKeyAsBase64 = AppSecretConfig.Audience_Secret_String; + var keyByteArray = Encoding.ASCII.GetBytes(symmetricKeyAsBase64); + var signingKey = new SymmetricSecurityKey(keyByteArray); + + + var signingCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256); + + var permission = new List(); + + var permissionRequirement = new PermissionRequirement( + "/api/denied", + permission, + ClaimTypes.Role, + Appsettings.app(new string[] { "Audience", "Issuer" }), + Appsettings.app(new string[] { "Audience", "Audience" }), + signingCredentials,//签名凭据 + expiration: TimeSpan.FromSeconds(60 * 60)//接口的过期时间 + ); + services.AddSingleton(permissionRequirement); + + //【授权】 + services.AddAuthorization(options => + { + options.AddPolicy(Permissions.Name, + policy => policy.Requirements.Add(permissionRequirement)); + }); + + + + services.AddScoped(o => + { + return new SqlSugar.SqlSugarClient(new SqlSugar.ConnectionConfig() + { + ConnectionString = GetMainConnectionDb().Connection,//必填, 数据库连接字符串 + DbType = (SqlSugar.DbType)GetMainConnectionDb().DbType,//必填, 数据库类型 + IsAutoCloseConnection = true,//默认false, 时候知道关闭数据库连接, 设置为true无需使用using或者Close操作 + IsShardSameThread = true,//共享线程 + InitKeyType = SqlSugar.InitKeyType.SystemTable//默认SystemTable, 字段信息读取, 如:该属性是不是主键,标识列等等信息 + }); + }); + + //实例化 AutoFac 容器 + var builder = new ContainerBuilder(); + //builder.RegisterType().As(); + + //指定已扫描程序集中的类型注册为提供所有其实现的接口。 + + builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IBaseRepository<>)).InstancePerDependency();//注册仓储 + + + var servicesDllFile = Path.Combine(basePath, "New_College.Services.dll"); + var assemblysServices = Assembly.LoadFrom(servicesDllFile); + builder.RegisterAssemblyTypes(assemblysServices) + .AsImplementedInterfaces() + .InstancePerLifetimeScope() + .EnableInterfaceInterceptors(); + + var repositoryDllFile = Path.Combine(basePath, "New_College.Repository.dll"); + var assemblysRepository = Assembly.LoadFrom(repositoryDllFile); + builder.RegisterAssemblyTypes(assemblysRepository).AsImplementedInterfaces(); + + //将services填充到Autofac容器生成器中 + builder.Populate(services); + + //使用已进行的组件登记创建新容器 + var ApplicationContainer = builder.Build(); + + return ApplicationContainer; + } + } +} diff --git a/New_College.Tests/New_College.Tests.csproj b/New_College.Tests/New_College.Tests.csproj new file mode 100644 index 0000000..15964b1 --- /dev/null +++ b/New_College.Tests/New_College.Tests.csproj @@ -0,0 +1,37 @@ + + + + netcoreapp3.1 + + false + + + + + + + + + Always + PreserveNewest + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + diff --git a/New_College.Tests/Redis_Test/Redis_Should.cs b/New_College.Tests/Redis_Test/Redis_Should.cs new file mode 100644 index 0000000..12c7f29 --- /dev/null +++ b/New_College.Tests/Redis_Test/Redis_Should.cs @@ -0,0 +1,26 @@ +using Xunit; + +namespace New_College.Tests +{ + public class Redis_Should + { + DI_Test dI_Test = new DI_Test(); + + public Redis_Should() + { + //var container = dI_Test.DICollections(); + //_redisCacheManager = container.Resolve(); + + } + + [Fact] + public void Connect_Redis_Test() + { + + //var redisBlogCache = _redisCacheManager.Get("Redis.Blog"); + + //Assert.Null(redisBlogCache); + } + + } +} diff --git a/New_College.Tests/Repository_Test/Repository_Base_Should.cs b/New_College.Tests/Repository_Test/Repository_Base_Should.cs new file mode 100644 index 0000000..c1bb4fd --- /dev/null +++ b/New_College.Tests/Repository_Test/Repository_Base_Should.cs @@ -0,0 +1,81 @@ +using New_College.Model.Models; +using Xunit; +using System; +using System.Linq; +using Autofac; +using New_College.IRepository.Base; + +namespace New_College.Tests +{ + public class Repository_Base_Should + { + private IBaseRepository baseRepository; + DI_Test dI_Test = new DI_Test(); + + public Repository_Base_Should() + { + + var container = dI_Test.DICollections(); + + baseRepository = container.Resolve>(); + + //DbContext.Init(BaseDBConfig.ConnectionString,(DbType)BaseDBConfig.DbType); + } + + + [Fact] + public async void Get_Blogs_Test() + { + var data = await baseRepository.Query(); + + Assert.NotNull(data); + } + + [Fact] + public async void Add_Blog_Test() + { + BlogArticle blogArticle = new BlogArticle() + { + bCreateTime = DateTime.Now, + bUpdateTime = DateTime.Now, + btitle = "xuint test title", + bcontent = "xuint test content", + bsubmitter = "xuint: test repositoryBase add blog", + }; + + var BId = await baseRepository.Add(blogArticle); + Assert.True(BId > 0); + } + + + [Fact] + public async void Update_Blog_Test() + { + var IsUpd = false; + var updateModel = (await baseRepository.Query(d => d.btitle == "xuint test title")).FirstOrDefault(); + + Assert.NotNull(updateModel); + + updateModel.bcontent = "xuint: test repositoryBase content update"; + updateModel.bCreateTime = DateTime.Now; + updateModel.bUpdateTime = DateTime.Now; + + IsUpd = await baseRepository.Update(updateModel); + + Assert.True(IsUpd); + } + + [Fact] + public async void Delete_Blog_Test() + { + var IsDel = false; + var deleteModel = (await baseRepository.Query(d => d.btitle == "xuint test title")).FirstOrDefault(); + + Assert.NotNull(deleteModel); + + IsDel = await baseRepository.Delete(deleteModel); + + Assert.True(IsDel); + } + } +} diff --git a/New_College.Tests/Service_Test/BlogArticleService_Should.cs b/New_College.Tests/Service_Test/BlogArticleService_Should.cs new file mode 100644 index 0000000..d1f2d27 --- /dev/null +++ b/New_College.Tests/Service_Test/BlogArticleService_Should.cs @@ -0,0 +1,72 @@ +using New_College.IServices; +using New_College.Model.Models; +using Xunit; +using System; +using System.Linq; +using Autofac; + +namespace New_College.Tests +{ + public class BlogArticleService_Should + { + + private IBlogArticleServices blogArticleServices; + DI_Test dI_Test = new DI_Test(); + + + public BlogArticleService_Should() + { + //mockBlogRep.Setup(r => r.Query()); + + var container = dI_Test.DICollections(); + + blogArticleServices = container.Resolve(); + + } + + + [Fact] + public void BlogArticleServices_Test() + { + Assert.NotNull(blogArticleServices); + } + + + [Fact] + public async void Get_Blogs_Test() + { + var data = await blogArticleServices.GetBlogs(); + + Assert.True(data.Any()); + } + + [Fact] + public async void Add_Blog_Test() + { + BlogArticle blogArticle = new BlogArticle() + { + bCreateTime = DateTime.Now, + bUpdateTime = DateTime.Now, + btitle = "xuint test title", + bcontent = "xuint test content", + bsubmitter = "xuint test submitter", + }; + + var BId = await blogArticleServices.Add(blogArticle); + + Assert.True(BId > 0); + } + + [Fact] + public async void Delete_Blog_Test() + { + var deleteModel = (await blogArticleServices.Query(d => d.btitle == "xuint test title")).FirstOrDefault(); + + Assert.NotNull(deleteModel); + + var IsDel = await blogArticleServices.Delete(deleteModel); + + Assert.True(IsDel); + } + } +} diff --git a/New_College.Tests/appsettings.json b/New_College.Tests/appsettings.json new file mode 100644 index 0000000..f8ddfd2 --- /dev/null +++ b/New_College.Tests/appsettings.json @@ -0,0 +1,183 @@ +{ + "Logging": { + "IncludeScopes": false, + "Debug": { + "LogLevel": { + "Default": "Warning" + } + }, + "Console": { + "LogLevel": { + "Default": "Warning", + "Microsoft.Hosting.Lifetime": "Debug" + } + }, + "Log4Net": { + "Name": "New_College" + } + }, + //"urls": "http://localhost:8081",// IIS 部署,注释掉 + "AllowedHosts": "*", + "AppSettings": { + "RedisCachingAOP": { + "Enabled": false, + "ConnectionString": "127.0.0.1:6319" + }, + "MemoryCachingAOP": { + "Enabled": true + }, + "LogAOP": { + "Enabled": false + }, + "TranAOP": { + "Enabled": false + }, + "SqlAOP": { + "Enabled": false + }, + "Date": "2018-08-28", + "SeedDBEnabled": true, //只生成表结构 + "SeedDBDataEnabled": true, //生成表,并初始化数据 + "Author": "New_College" + }, + + // 请配置MainDB为你想要的主库的ConnId值,并设置对应的Enabled为true; + // *** 单库操作,把 MutiDBEnabled 设为false ***; + // *** 多库操作,把 MutiDBEnabled 设为true,其他的从库Enabled也为true **; + // 具体配置看视频:https://www.bilibili.com/video/BV1BJ411B7mn?p=6 + + "MainDB": "WMBLOG_SQLITE", //当前项目的主库,所对应的连接字符串的Enabled必须为true + "MutiDBEnabled": false, //是否开启多库模式 + "CQRSEnabled": false, //是否开启读写分离模式,必须是单库模式,且数据库类型一致,比如都是SqlServer + "DBS": [ + /* + 对应下边的 DBType + MySql = 0, + SqlServer = 1, + Sqlite = 2, + Oracle = 3, + PostgreSQL = 4 + */ + { + "ConnId": "WMBLOG_SQLITE", + "DBType": 2, + "Enabled": true, + "HitRate": 50, // 值越大,优先级越高 + "Connection": "WMBlog.db" //sqlite只写数据库名就行 + }, + { + "ConnId": "WMBLOG_MSSQL_1", + "DBType": 1, + "Enabled": true, + "HitRate": 40, + "Connection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=WMBLOG_MSSQL_1;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + "ProviderName": "System.Data.SqlClient" + }, + { + "ConnId": "WMBLOG_MSSQL_2", + "DBType": 1, + "Enabled": true, + "HitRate": 30, + "Connection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=WMBLOG_MSSQL_2;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", + "ProviderName": "System.Data.SqlClient" + }, + { + "ConnId": "WMBLOG_MYSQL", + "DBType": 0, + "Enabled": true, + "HitRate": 20, + "Connection": "Server=localhost; Port=3306;Stmt=; Database=wmblogdb; Uid=root; Pwd=456;" + }, + { + "ConnId": "WMBLOG_ORACLE", + "DBType": 3, + "Enabled": false, + "HitRate": 10, + "Connection": "Provider=OraOLEDB.Oracle; Data Source=WMBlogDB; User Id=sss; Password=789;", + "OracleConnection_other1": "User ID=sss;Password=789;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.8.65)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME = orcl)))" + } + ], + "Audience": { + "Secret": "sdfsdfsrty45634kkhllghtdgdfss345t678fs", //不要太短,16位+ + "SecretFile": "C:\\my-file\\new_college.audience.secret.txt", //安全。内容就是Secret + "Issuer": "New_College", + "Audience": "wr" + }, + "Startup": { + "Cors": { + "IPs": "http://127.0.0.1:2364,http://localhost:2364,http://localhost:8080,http://localhost:8021,http://localhost:1818" + }, + "AppConfigAlert": { + "Enabled": true + }, + "ApiName": "New_College", + "IdentityServer4": { + "Enabled": false, // 这里默认是false,表示使用jwt,如果设置为true,则表示系统使用Ids4模式 + "AuthorizationUrl": "https://ids.neters.club", // 认证中心域名 + "ApiName": "new_college.api" // 资源服务器 + } + }, + "Middleware": { + "RequestResponseLog": { + "Enabled": false + }, + "IPLog": { + "Enabled": true + }, + "RecordAccessLogs": { + "Enabled": true + }, + "SignalR": { + "Enabled": false + }, + "QuartzNetJob": { + "Enabled": true + }, + "Consul": { + "Enabled": false + }, + "IpRateLimit": { + "Enabled": true + } + }, + "IpRateLimiting": { + "EnableEndpointRateLimiting": true, //False: globally executed, true: executed for each + "StackBlockedRequests": false, //False: Number of rejections should be recorded on another counter + "RealIpHeader": "X-Real-IP", + "ClientIdHeader": "X-ClientId", + "IpWhitelist": [], //白名单 + "EndpointWhitelist": [ "get:/api/xxx", "*:/api/yyy" ], + "ClientWhitelist": [ "dev-client-1", "dev-client-2" ], + "HttpStatusCode": 429, //返回状态码 + "GeneralRules": [ //api规则,结尾一定要带* + { + "Endpoint": "*:/api/blog*", + "Period": "1m", + "Limit": 20 + }, + { + "Endpoint": "*/api/*", + "Period": "1s", + "Limit": 3 + }, + { + "Endpoint": "*/api/*", + "Period": "1m", + "Limit": 30 + }, + { + "Endpoint": "*/api/*", + "Period": "12h", + "Limit": 500 + } + ] + + }, + "ConsulSetting": { + "ServiceName": "BlogCoreService", + "ServiceIP": "localhost", + "ServicePort": "8081", + "ServiceHealthCheck": "/healthcheck", + "ConsulAddress": "http://localhost:8500" + } +} diff --git a/New_College.sln b/New_College.sln new file mode 100644 index 0000000..7211122 --- /dev/null +++ b/New_College.sln @@ -0,0 +1,91 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "New_College.Api", "New_College.Api\New_College.Api.csproj", "{6F47A41A-085E-4422-BB73-5A2CBAA07D9F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "New_College.Model", "New_College.Model\New_College.Model.csproj", "{E725F0A1-0B03-406F-B84B-0F486C6137FC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "New_College.Repository", "New_College.Repository\New_College.Repository.csproj", "{8D651E7F-49D3-4D27-8486-ADCF000BB24D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "New_College.IServices", "New_College.IServices\New_College.IServices.csproj", "{37BB8600-94DA-4A2C-9230-DE93EA1EB0BD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "New_College.Services", "New_College.Services\New_College.Services.csproj", "{A2EFEFFC-39AD-48D2-8337-E6840B26023B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "New_College.Common", "New_College.Common\New_College.Common.csproj", "{97D32A49-994C-44C5-A167-51E71D173B6F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "New_College.FrameWork", "New_College.FrameWork\New_College.FrameWork.csproj", "{44A2006E-3EFC-4179-B400-866178C66556}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "New_College.Tests", "New_College.Tests\New_College.Tests.csproj", "{69A9CD28-39CE-415E-8150-A4A876E708FD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "New_College.Tasks", "New_College.Tasks\New_College.Tasks.csproj", "{F8E9FA1F-4079-4F62-B717-E389BC0014E8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "New_College.Extensions", "New_College.Extensions\New_College.Extensions.csproj", "{558F1B39-07E4-4FAB-BE7E-5B6104607064}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "New_College.ConsoleApp", "New_College.ConsoleApp\New_College.ConsoleApp.csproj", "{BB9FBBDF-B112-44F2-ABB7-9C31CFB619FE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "New_College.AdminMvc", "New_College.AdminMvc\New_College.AdminMvc.csproj", "{06D885F3-6352-4BF6-B826-DEA742DFFBD7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6F47A41A-085E-4422-BB73-5A2CBAA07D9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F47A41A-085E-4422-BB73-5A2CBAA07D9F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F47A41A-085E-4422-BB73-5A2CBAA07D9F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F47A41A-085E-4422-BB73-5A2CBAA07D9F}.Release|Any CPU.Build.0 = Release|Any CPU + {E725F0A1-0B03-406F-B84B-0F486C6137FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E725F0A1-0B03-406F-B84B-0F486C6137FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E725F0A1-0B03-406F-B84B-0F486C6137FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E725F0A1-0B03-406F-B84B-0F486C6137FC}.Release|Any CPU.Build.0 = Release|Any CPU + {8D651E7F-49D3-4D27-8486-ADCF000BB24D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8D651E7F-49D3-4D27-8486-ADCF000BB24D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D651E7F-49D3-4D27-8486-ADCF000BB24D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8D651E7F-49D3-4D27-8486-ADCF000BB24D}.Release|Any CPU.Build.0 = Release|Any CPU + {37BB8600-94DA-4A2C-9230-DE93EA1EB0BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {37BB8600-94DA-4A2C-9230-DE93EA1EB0BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {37BB8600-94DA-4A2C-9230-DE93EA1EB0BD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {37BB8600-94DA-4A2C-9230-DE93EA1EB0BD}.Release|Any CPU.Build.0 = Release|Any CPU + {A2EFEFFC-39AD-48D2-8337-E6840B26023B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A2EFEFFC-39AD-48D2-8337-E6840B26023B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A2EFEFFC-39AD-48D2-8337-E6840B26023B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A2EFEFFC-39AD-48D2-8337-E6840B26023B}.Release|Any CPU.Build.0 = Release|Any CPU + {97D32A49-994C-44C5-A167-51E71D173B6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97D32A49-994C-44C5-A167-51E71D173B6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97D32A49-994C-44C5-A167-51E71D173B6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97D32A49-994C-44C5-A167-51E71D173B6F}.Release|Any CPU.Build.0 = Release|Any CPU + {44A2006E-3EFC-4179-B400-866178C66556}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44A2006E-3EFC-4179-B400-866178C66556}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44A2006E-3EFC-4179-B400-866178C66556}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44A2006E-3EFC-4179-B400-866178C66556}.Release|Any CPU.Build.0 = Release|Any CPU + {69A9CD28-39CE-415E-8150-A4A876E708FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69A9CD28-39CE-415E-8150-A4A876E708FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69A9CD28-39CE-415E-8150-A4A876E708FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69A9CD28-39CE-415E-8150-A4A876E708FD}.Release|Any CPU.Build.0 = Release|Any CPU + {F8E9FA1F-4079-4F62-B717-E389BC0014E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F8E9FA1F-4079-4F62-B717-E389BC0014E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F8E9FA1F-4079-4F62-B717-E389BC0014E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F8E9FA1F-4079-4F62-B717-E389BC0014E8}.Release|Any CPU.Build.0 = Release|Any CPU + {558F1B39-07E4-4FAB-BE7E-5B6104607064}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {558F1B39-07E4-4FAB-BE7E-5B6104607064}.Debug|Any CPU.Build.0 = Debug|Any CPU + {558F1B39-07E4-4FAB-BE7E-5B6104607064}.Release|Any CPU.ActiveCfg = Release|Any CPU + {558F1B39-07E4-4FAB-BE7E-5B6104607064}.Release|Any CPU.Build.0 = Release|Any CPU + {BB9FBBDF-B112-44F2-ABB7-9C31CFB619FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB9FBBDF-B112-44F2-ABB7-9C31CFB619FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB9FBBDF-B112-44F2-ABB7-9C31CFB619FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB9FBBDF-B112-44F2-ABB7-9C31CFB619FE}.Release|Any CPU.Build.0 = Release|Any CPU + {06D885F3-6352-4BF6-B826-DEA742DFFBD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {06D885F3-6352-4BF6-B826-DEA742DFFBD7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {06D885F3-6352-4BF6-B826-DEA742DFFBD7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {06D885F3-6352-4BF6-B826-DEA742DFFBD7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AB40D0C5-E3EA-4A9B-86C2-38F0BB33FC04} + EndGlobalSection +EndGlobal diff --git a/PaymentSDK/AliPay/AliPayConfig.cs b/PaymentSDK/AliPay/AliPayConfig.cs new file mode 100644 index 0000000..192bacc --- /dev/null +++ b/PaymentSDK/AliPay/AliPayConfig.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace PaymentSDK +{ + public static class AliPayConfig + { + public static string APP_ID { get; set; } + + public static string APP_PRIVATE_KEY { get; set; } + + public static string ALIPAY_PUBLIC_KEY { get; set; } + + public static string CHARSET { get; set; } + + public static string NotifyUrl { get; set; } + + } +} diff --git a/PaymentSDK/AliPay/AliPayHelper.cs b/PaymentSDK/AliPay/AliPayHelper.cs new file mode 100644 index 0000000..80cf9a8 --- /dev/null +++ b/PaymentSDK/AliPay/AliPayHelper.cs @@ -0,0 +1,35 @@ +using Aop.Api; +using Aop.Api.Domain; +using Aop.Api.Request; +using Aop.Api.Response; +using System; +using System.Collections.Generic; +using System.Text; + +namespace PaymentSDK +{ + public class AliPayHelper + { + + public string UnifiedOrder(AlipayTradeAppPayModel alipay) + { + IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", AliPayConfig.APP_ID, AliPayConfig.APP_PRIVATE_KEY, "json", "1.0", "RSA2", AliPayConfig.ALIPAY_PUBLIC_KEY, AliPayConfig.CHARSET, false); + // 实 例 化 具 体 API 对 应 的 request 类 , 类 名 称 和 接 口 名 称 对 应 , 当 前 调 用 接 口 名 称 如 : alipay .trade .app .pay + AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); + // SDK 已 经 封 装 掉 了 公 共 参 数 , 这 里 只 需 要 传 入 业 务 参 数 。 以 下 方 法 为 sdk 的 model 入 参 方 式 ( model 和 biz_content 同 时 存 在 的 情 况 下 取 biz_content ) 。 + request.SetBizModel(alipay); + request.SetNotifyUrl(AliPayConfig.NotifyUrl); + // 这 里 和 普 通 的 接 口 调 用 不 同 , 使 用 的 是 sdkExecute + AlipayTradeAppPayResponse response = client.SdkExecute(request); + // HttpUtility .HtmlEncode 是 为 了 输 出 到 页 面 时 防 止 被 浏 览 器 将 关 键 参 数 html 转 义 , 实 际 打 印 到 日 志 以 及 http 传 输 不 会 有 这 个 问 题 + + // 页 面 输 出 的 response .Body 就 是 orderString 可 以 直 接 给 客 户 端 请 求 , 无 需 再 做 处 理 。 + return response.Body; + } + + + + + + } +} diff --git a/PaymentSDK/AliPay/AlipayConstants.cs b/PaymentSDK/AliPay/AlipayConstants.cs new file mode 100644 index 0000000..ef2d7cc --- /dev/null +++ b/PaymentSDK/AliPay/AlipayConstants.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Aop.Api +{ + public class AlipayConstants + { + public const string APP_ID = "app_id"; + public const string FORMAT = "format"; + public const string METHOD = "method"; + public const string TIMESTAMP = "timestamp"; + public const string VERSION = "version"; + public const string SIGN_TYPE = "sign_type"; + public const string ACCESS_TOKEN = "auth_token"; + public const string APP_AUTH_TOKEN = "app_auth_token"; + public const string TARGET_APP_ID = "target_app_id"; + public const string SIGN = "sign"; + public const string TERMINAL_TYPE = "terminal_type"; + public const string TERMINAL_INFO = "terminal_info"; + public const string PROD_CODE = "prod_code"; + public const string NOTIFY_URL = "notify_url"; + public const string CHARSET = "charset"; + public const string ENCRYPT_TYPE = "encrypt_type"; + public const string BIZ_CONTENT = "biz_content"; + public const string RETURN_URL = "return_url"; + public const string APP_CERT_SN = "app_cert_sn"; + public const string ALIPAY_CERT_SN = "alipay_cert_sn"; + public const string ALIPAY_ROOT_CERT_SN = "alipay_root_cert_sn"; + public const string ALIPAY_SDK = "alipay_sdk"; + + public const string RESPONSE_SUFFIX = "_response"; + public const string ERROR_RESPONSE = "error_response"; + public const string ENCRYPT_NODE_NAME = "response_encrypted"; + } +} diff --git a/PaymentSDK/AliPay/AlipayMobilePublicMultiMediaClient.cs b/PaymentSDK/AliPay/AlipayMobilePublicMultiMediaClient.cs new file mode 100644 index 0000000..329c84b --- /dev/null +++ b/PaymentSDK/AliPay/AlipayMobilePublicMultiMediaClient.cs @@ -0,0 +1,249 @@ +using System; +using System.IO; +using System.Text; +using Aop.Api.Parser; +using Aop.Api.Util; +using System.Net; + +namespace Aop.Api +{ + public class AlipayMobilePublicMultiMediaClient : IAopClient + { + private string version; + private string format; + private string serverUrl; + private string appId; + private string privateKeyPem; + private string signType = "RSA"; + private string charset; + private bool keyFromFile = true; + + private WebUtils webUtils; + + public string Version + { + get { return version != null ? version : "1.0"; } + set { version = value; } + } + + public string Format + { + get { return format != null ? format : "json"; } + set { format = value; } + } + + //该构造函数默认从文件读取privateKey,privateKeyPem参数请指定私钥文件路径 + public AlipayMobilePublicMultiMediaClient(string serverUrl, string appId, string privateKeyPem, string format, string charset) + { + this.appId = appId; + this.privateKeyPem = privateKeyPem; + this.serverUrl = serverUrl; + this.webUtils = new WebUtils(); + this.format = format; + this.charset = charset; + } + + //当指定不从文件读取privateKey时(即指定keyFromFile=false),privateKeyPem参数可以直接传私钥字符串,此时私钥内容请清除-----BEGIN RSA PRIVATE KEY-----头和-----END RSA PRIVATE KEY-----尾 + public AlipayMobilePublicMultiMediaClient(string serverUrl, string appId, string privateKeyPem, bool keyFromFile, string format, string charset) + : this(serverUrl, appId, privateKeyPem, format, charset) + { + this.keyFromFile = keyFromFile; + } + + //该构造函数默认从文件读取privateKey,privateKeyPem参数请指定私钥文件路径 + public AlipayMobilePublicMultiMediaClient(string serverUrl, string appId, string privateKeyPem, string format, string charset, string version, string signType) + : this(serverUrl, appId, privateKeyPem, format, charset) + { + this.version = version; + this.signType = signType; + } + + //当指定不从文件读取privateKeyPem时(即指定keyFromFile=false),privateKeyPem参数可以直接传私钥字符串,此时私钥内容请清除-----BEGIN RSA PRIVATE KEY-----头和-----END RSA PRIVATE KEY-----尾 + public AlipayMobilePublicMultiMediaClient(string serverUrl, string appId, string privateKeyPem, bool keyFromFile, string format, string charset, string version, string signType) + : this(serverUrl, appId, privateKeyPem, keyFromFile, format, charset) + { + this.version = version; + this.signType = signType; + } + + public void SetTimeout(int timeout) + { + webUtils.Timeout = timeout; + } + + public T Execute(IAopRequest request) where T : AopResponse + { + return Execute(request, null); + } + + public T Execute(IAopRequest request, string accessToken) where T : AopResponse + { + + return Execute(request, accessToken, null); + } + + public T Execute(IAopRequest request, string accessToken, string appAuthToken) where T : AopResponse + { + AlipayMobilePublicMultiMediaDownloadRequest multiMediaDownloadRequest = ((AlipayMobilePublicMultiMediaDownloadRequest)request); + // 添加协议级请求参数 + AopDictionary txtParams = new AopDictionary(request.GetParameters()); + txtParams.Add(AlipayConstants.METHOD, request.GetApiName()); + txtParams.Add(AlipayConstants.VERSION, Version); + txtParams.Add(AlipayConstants.APP_ID, appId); + txtParams.Add(AlipayConstants.FORMAT, format); + txtParams.Add(AlipayConstants.TIMESTAMP, DateTime.Now); + txtParams.Add(AlipayConstants.ACCESS_TOKEN, accessToken); + txtParams.Add(AlipayConstants.SIGN_TYPE, signType); + txtParams.Add(AlipayConstants.TERMINAL_TYPE, request.GetTerminalType()); + txtParams.Add(AlipayConstants.TERMINAL_INFO, request.GetTerminalInfo()); + txtParams.Add(AlipayConstants.PROD_CODE, request.GetProdCode()); + + if (!string.IsNullOrEmpty(appAuthToken)) + { + txtParams.Add(AlipayConstants.APP_AUTH_TOKEN, appAuthToken); + } + + + // 添加签名参数 + txtParams.Add(AlipayConstants.SIGN, AopUtils.SignAopRequest(txtParams, privateKeyPem, charset, keyFromFile, signType)); + + Stream outStream = multiMediaDownloadRequest.stream; + AopResponse rsp = DoGet(txtParams, outStream); + + return (T)rsp; + + } + + private AopResponse DoGet(AopDictionary parameters, Stream outStream) + { + AlipayMobilePublicMultiMediaDownloadResponse response = null; + + string url = this.serverUrl; + System.Console.WriteLine(url); + if (parameters != null && parameters.Count > 0) + { + if (url.Contains("?")) + { + url = url + "&" + WebUtils.BuildQuery(parameters, charset); + } + else + { + url = url + "?" + WebUtils.BuildQuery(parameters, charset); + } + } + + HttpWebRequest req = webUtils.GetWebRequest(url, "GET"); + req.ContentType = "application/x-www-form-urlencoded;charset=" + charset; + + HttpWebResponse rsp = (HttpWebResponse)req.GetResponse(); + if (rsp.StatusCode == HttpStatusCode.OK) + { + if (rsp.ContentType.ToLower().Contains("text/plain")) + { + Encoding encoding = Encoding.GetEncoding(rsp.CharacterSet); + string body = webUtils.GetResponseAsString(rsp, encoding); + IAopParser tp = new AopJsonParser(); + response = tp.Parse(body, charset); + } + else + { + GetResponseAsStream(outStream, rsp); + response = new AlipayMobilePublicMultiMediaDownloadResponse(); + } + } + return response; + } + + /// + /// 把响应流转换为文本。 + /// + /// 响应流对象 + /// 编码方式 + /// 响应文本 + public void GetResponseAsStream(Stream outStream, HttpWebResponse rsp) + { + StringBuilder result = new StringBuilder(); + Stream stream = null; + StreamReader reader = null; + BinaryWriter writer = null; + + try + { + // 以字符流的方式读取HTTP响应 + stream = rsp.GetResponseStream(); + reader = new StreamReader(stream); + + writer = new BinaryWriter(outStream); + + //stream.CopyTo(outStream); + int length = Convert.ToInt32(rsp.ContentLength); + byte[] buffer = new byte[length]; + int rc = 0; + while ((rc = stream.Read(buffer, 0, length)) > 0) + { + outStream.Write(buffer, 0, rc); + } + outStream.Flush(); + outStream.Close(); + + } + finally + { + // 释放资源 + if (reader != null) reader.Close(); + if (stream != null) stream.Close(); + if (rsp != null) rsp.Close(); + } + } + + public T pageExecute(IAopRequest request) where T : AopResponse + { + throw new NotImplementedException(); + } + + public T pageExecute(IAopRequest request, string accessToken, string reqMethod) where T : AopResponse + { + throw new NotImplementedException(); + } + + public T pageExecute(IAopRequest request, string accessToken, string appAuthToken, string reqMethod) where T : AopResponse + { + throw new NotImplementedException(); + } + + public T SdkExecute(IAopRequest request) where T : AopResponse + { + throw new NotImplementedException(); + } + + public T SdkExecute(IAopRequest request, string appAuthToken) where T : AopResponse + { + throw new NotImplementedException(); + } + + public T CertificateExecute(IAopRequest request) where T : AopResponse + { + return CertificateExecute(request, null, null); + } + + public T CertificateExecute(IAopRequest request, string accessToken) where T : AopResponse + { + return CertificateExecute(request, accessToken, null); + } + + public T CertificateExecute(IAopRequest request, string accessToken, string appAuthToken) where T : AopResponse + { + throw new NotImplementedException(); + } + + public T Execute(IAopRequest request, string accessToken, string appAuthToken, string targetAppId) where T : AopResponse + { + throw new NotImplementedException(); + } + + public T CertificateExecute(IAopRequest request, string accessToken, string appAuthToken, string targetAppId) where T : AopResponse + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/PaymentSDK/AliPay/AlipayMobilePublicMultiMediaDownloadRequest.cs b/PaymentSDK/AliPay/AlipayMobilePublicMultiMediaDownloadRequest.cs new file mode 100644 index 0000000..0a90358 --- /dev/null +++ b/PaymentSDK/AliPay/AlipayMobilePublicMultiMediaDownloadRequest.cs @@ -0,0 +1,117 @@ +using System.Collections.Generic; +using System.IO; + +namespace Aop.Api +{ + public class AlipayMobilePublicMultiMediaDownloadRequest : IAopRequest + { + + public string BizContent { get; set; } + public Stream stream { set; get; } + + #region IAopRequest Members + private string apiVersion = "1.0"; + private string terminalType; + private string terminalInfo; + private string prodCode; + private string notifyUrl; + private string returnUrl; + private bool needEncrypt = false; + private AopObject bizModel; + + public void SetNeedEncrypt(bool needEncrypt) + { + this.needEncrypt = needEncrypt; + } + + + public bool GetNeedEncrypt() + { + return this.needEncrypt; + } + + public void SetNotifyUrl(string notifyUrl) + { + this.notifyUrl = notifyUrl; + } + + public string GetNotifyUrl() + { + return this.notifyUrl; + } + + public void SetReturnUrl(string returnUrl) + { + this.returnUrl = returnUrl; + } + + public string GetReturnUrl() + { + return this.returnUrl; + } + + public void SetApiVersion(string apiVersion) + { + this.apiVersion = apiVersion; + } + + public string GetApiVersion() + { + return this.apiVersion; + } + + public void SetTerminalType(string terminalType) + { + this.terminalType = terminalType; + } + + public string GetTerminalType() + { + return this.terminalType; + } + + public void SetTerminalInfo(string terminalInfo) + { + this.terminalInfo = terminalInfo; + } + + public string GetTerminalInfo() + { + return this.terminalInfo; + } + + public void SetProdCode(string prodCode) + { + this.prodCode = prodCode; + } + + public string GetProdCode() + { + return this.prodCode; + } + + public string GetApiName() + { + return "alipay.mobile.public.multimedia.download"; + } + + public IDictionary GetParameters() + { + AopDictionary parameters = new AopDictionary(); + parameters.Add("biz_content", this.BizContent); + return parameters; + } + + public AopObject GetBizModel() + { + return this.bizModel; + } + + public void SetBizModel(AopObject bizModel) + { + this.bizModel = bizModel; + } + + #endregion + } +} diff --git a/PaymentSDK/AliPay/AlipayMobilePublicMultiMediaDownloadResponse.cs b/PaymentSDK/AliPay/AlipayMobilePublicMultiMediaDownloadResponse.cs new file mode 100644 index 0000000..0e266d2 --- /dev/null +++ b/PaymentSDK/AliPay/AlipayMobilePublicMultiMediaDownloadResponse.cs @@ -0,0 +1,9 @@ +namespace Aop.Api +{ + /// + /// AlipayMobilePublicMultiMediaDownloadResponse. + /// + public class AlipayMobilePublicMultiMediaDownloadResponse : AopResponse + { + } +} diff --git a/PaymentSDK/AliPay/AlipayOpenAppAlipaycertDownloadRequest.cs b/PaymentSDK/AliPay/AlipayOpenAppAlipaycertDownloadRequest.cs new file mode 100644 index 0000000..80c07c8 --- /dev/null +++ b/PaymentSDK/AliPay/AlipayOpenAppAlipaycertDownloadRequest.cs @@ -0,0 +1,111 @@ +using System.Collections.Generic; + +namespace Aop.Api +{ + public class AlipayOpenAppAlipaycertDownloadRequest : IAopRequest + { + public string BizContent { get; set; } + + private string apiVersion = "1.0"; + private string terminalType; + private string terminalInfo; + private string prodCode; + private string notifyUrl; + private string returnUrl; + private bool needEncrypt = false; + private AopObject bizModel; + + public void SetNeedEncrypt(bool needEncrypt) + { + this.needEncrypt = needEncrypt; + } + + + public bool GetNeedEncrypt() + { + return this.needEncrypt; + } + + public void SetNotifyUrl(string notifyUrl) + { + this.notifyUrl = notifyUrl; + } + + public string GetNotifyUrl() + { + return this.notifyUrl; + } + + public void SetReturnUrl(string returnUrl) + { + this.returnUrl = returnUrl; + } + + public string GetReturnUrl() + { + return this.returnUrl; + } + + public void SetApiVersion(string apiVersion) + { + this.apiVersion = apiVersion; + } + + public string GetApiVersion() + { + return this.apiVersion; + } + + public void SetTerminalType(string terminalType) + { + this.terminalType = terminalType; + } + + public string GetTerminalType() + { + return this.terminalType; + } + + public void SetTerminalInfo(string terminalInfo) + { + this.terminalInfo = terminalInfo; + } + + public string GetTerminalInfo() + { + return this.terminalInfo; + } + + public void SetProdCode(string prodCode) + { + this.prodCode = prodCode; + } + + public string GetProdCode() + { + return this.prodCode; + } + + public string GetApiName() + { + return "alipay.open.app.alipaycert.download"; + } + + public IDictionary GetParameters() + { + AopDictionary parameters = new AopDictionary(); + parameters.Add("biz_content", this.BizContent); + return parameters; + } + + public AopObject GetBizModel() + { + return this.bizModel; + } + + public void SetBizModel(AopObject bizModel) + { + this.bizModel = bizModel; + } + } +} diff --git a/PaymentSDK/AliPay/AlipayOpenAppAlipaycertDownloadResponse.cs b/PaymentSDK/AliPay/AlipayOpenAppAlipaycertDownloadResponse.cs new file mode 100644 index 0000000..f4eaebd --- /dev/null +++ b/PaymentSDK/AliPay/AlipayOpenAppAlipaycertDownloadResponse.cs @@ -0,0 +1,9 @@ +using System.Xml.Serialization; + +namespace Aop.Api +{ + public class AlipayOpenAppAlipaycertDownloadResponse : AopResponse + { + [XmlElement("alipay_cert_content")] public string AlipayCertContent { get; set; } + } +} diff --git a/PaymentSDK/AliPay/AopDictionary.cs b/PaymentSDK/AliPay/AopDictionary.cs new file mode 100644 index 0000000..4c9d71b --- /dev/null +++ b/PaymentSDK/AliPay/AopDictionary.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using Aop.Api.Parser; +using Newtonsoft.Json; + +namespace Aop.Api +{ + /// + /// 符合AOP习惯的纯字符串字典结构。 + /// + public class AopDictionary : Dictionary + { + private const string DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; + + public AopDictionary() { } + + public AopDictionary(IDictionary dictionary) + : base(dictionary) + { } + + /// + /// 添加一个新的键值对。空键或者空值的键值对将会被忽略。 + /// + /// 键名称 + /// 键对应的值,目前支持:string, int, long, double, bool, DateTime类型 + public void Add(string key, object value) + { + string strValue; + + if (value == null) + { + strValue = null; + } + else if (value is string) + { + strValue = (string)value; + } + else if (value is Nullable) + { + Nullable dateTime = value as Nullable; + strValue = dateTime.Value.ToString(DATE_TIME_FORMAT); + } + else if (value is Nullable) + { + strValue = (value as Nullable).Value.ToString(); + } + else if (value is Nullable) + { + strValue = (value as Nullable).Value.ToString(); + } + else if (value is Nullable) + { + strValue = (value as Nullable).Value.ToString(); + } + else if (value is Nullable) + { + strValue = (value as Nullable).Value.ToString().ToLower(); + } + else if (value is ICollection) + { + AopModelParser parser = new AopModelParser(); + object jo = parser.serializeArrayValue(value as ICollection); + + JsonSerializerSettings jsetting = new JsonSerializerSettings(); + jsetting.NullValueHandling = NullValueHandling.Ignore; + strValue = JsonConvert.SerializeObject(jo, Formatting.None, jsetting); + } + else if (value is AopObject) + { + AopModelParser parser = new AopModelParser(); + object jo = parser.serializeAopObject(value as AopObject); + + JsonSerializerSettings jsetting = new JsonSerializerSettings(); + jsetting.NullValueHandling = NullValueHandling.Ignore; + strValue = JsonConvert.SerializeObject(jo, Formatting.None, jsetting); + } + else + { + strValue = value.ToString(); + } + + this.Add(key, strValue); + } + + public new void Add(string key, string value) + { + if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value)) + { + base.Add(key, value); + } + } + } +} diff --git a/PaymentSDK/AliPay/AopException.cs b/PaymentSDK/AliPay/AopException.cs new file mode 100644 index 0000000..11b8043 --- /dev/null +++ b/PaymentSDK/AliPay/AopException.cs @@ -0,0 +1,41 @@ +using System; +using System.Runtime.Serialization; + +namespace Aop.Api +{ + /// + /// AOP客户端异常。 + /// + public class AopException : Exception + { + public AopException() + { + } + + public AopException(string message) + : base(message) + { + } + + protected AopException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + + public AopException(string message, Exception innerException) + : base(message, innerException) + { + } + + public AopException(string errorCode, string errorMsg) + : base(errorCode + ":" + errorMsg) + { + this.ErrorCode = errorCode; + this.ErrorMsg = errorMsg; + } + + public string ErrorCode { get; set; } + + public string ErrorMsg { get; set; } + } +} diff --git a/PaymentSDK/AliPay/AopObject.cs b/PaymentSDK/AliPay/AopObject.cs new file mode 100644 index 0000000..823ad0f --- /dev/null +++ b/PaymentSDK/AliPay/AopObject.cs @@ -0,0 +1,12 @@ +using System; + +namespace Aop.Api +{ + /// + /// 基础对象。 + /// + [Serializable] + public abstract class AopObject + { + } +} diff --git a/PaymentSDK/AliPay/AopResponse.cs b/PaymentSDK/AliPay/AopResponse.cs new file mode 100644 index 0000000..fced561 --- /dev/null +++ b/PaymentSDK/AliPay/AopResponse.cs @@ -0,0 +1,79 @@ +using System; +using System.Xml.Serialization; + +namespace Aop.Api +{ + [Serializable] + public abstract class AopResponse + { + private string code; + private string msg; + private string subCode; + private string subMsg; + private string body; + + /// + /// 错误码 + /// 对应 ErrCode + /// + [XmlElement("code")] + public string Code + { + get { return code; } + set { code = value; } + } + + /// + /// 错误信息 + /// 对应 ErrMsg + /// + [XmlElement("msg")] + public string Msg + { + get { return msg; } + set { msg = value; } + } + + /// + /// 子错误码 + /// 对应 SubErrCode + /// + [XmlElement("sub_code")] + public string SubCode + { + get { return subCode; } + set { subCode = value; } + } + + /// + /// 子错误信息 + /// 对应 SubErrMsg + /// + [XmlElement("sub_msg")] + public string SubMsg + { + get { return subMsg; } + set { subMsg = value; } + } + + /// + /// 响应原始内容 + /// + public string Body + { + get { return body; } + set { body = value; } + } + + /// + /// 响应结果是否错误 + /// + public bool IsError + { + get + { + return !string.IsNullOrEmpty(this.SubCode); + } + } + } +} diff --git a/PaymentSDK/AliPay/CertParams.cs b/PaymentSDK/AliPay/CertParams.cs new file mode 100644 index 0000000..9d486d8 --- /dev/null +++ b/PaymentSDK/AliPay/CertParams.cs @@ -0,0 +1,20 @@ +namespace Aop.Api +{ + public class CertParams + { + /// + /// 商户证书储存本地路径 + /// + public string AppCertPath { get; set; } + + /// + /// 支付宝公钥证书储存本地路径 + /// + public string AlipayPublicCertPath { get; set; } + + /// + /// 支付宝根证书储存本地路径 + /// + public string RootCertPath { get; set; } + } +} \ No newline at end of file diff --git a/PaymentSDK/AliPay/DefaultAopClient.cs b/PaymentSDK/AliPay/DefaultAopClient.cs new file mode 100644 index 0000000..5f5e6d6 --- /dev/null +++ b/PaymentSDK/AliPay/DefaultAopClient.cs @@ -0,0 +1,853 @@ +using System; +using System.Collections.Generic; +using Aop.Api.Parser; +using Aop.Api.Util; +using System.Text; +using System.Web; +using Org.BouncyCastle.X509; +using Newtonsoft.Json; + +namespace Aop.Api +{ + /// + /// AOP客户端。 + /// + public class DefaultAopClient : IAopClient + { + private string version; + private string format; + private string serverUrl; + private string appId; + private string privateKeyPem; + private string signType = "RSA"; + private string charset; + private string alipayPublicKey; + private bool keyFromFile = false; + public string return_url; + + public string notify_url; + + /// + /// 当前SDK版本号,SDK打包发布时会自动修改该值 + /// + public const string SDK_VERSION = "alipay-sdk-net-4.3.0"; + + private CertEnvironment certEnvironment; + + private string encyptKey; + private string encyptType = "AES"; + + private WebUtils webUtils; + + public string Version + { + get { return version != null ? version : "1.0"; } + set { version = value; } + } + + public string Format + { + get { return format != null ? format : "json"; } + set { format = value; } + } + + public string AppId + { + get { return appId; } + set { appId = value; } + } + + + + public DefaultAopClient(string serverUrl, string appId, string privateKeyPem) + { + this.appId = appId; + this.privateKeyPem = privateKeyPem; + this.serverUrl = serverUrl; + this.webUtils = new WebUtils(); + } + + public DefaultAopClient(string serverUrl, string appId, string privateKeyPem, bool keyFromFile) + { + this.appId = appId; + this.privateKeyPem = privateKeyPem; + this.serverUrl = serverUrl; + this.keyFromFile = keyFromFile; + this.webUtils = new WebUtils(); + } + + public DefaultAopClient(string serverUrl, string appId, string privateKeyPem, string format) + { + this.appId = appId; + this.privateKeyPem = privateKeyPem; + this.serverUrl = serverUrl; + this.format = format; + this.webUtils = new WebUtils(); + } + + public DefaultAopClient(string serverUrl, string appId, string privateKeyPem, string format, string charset) + : this(serverUrl, appId, privateKeyPem, format) + { + this.charset = charset; + } + + public DefaultAopClient(string serverUrl, string appId, string privateKeyPem, string format, string version, string signType) + : this(serverUrl, appId, privateKeyPem) + { + this.format = format; + this.version = version; + this.signType = signType; + } + + public DefaultAopClient(string serverUrl, string appId, string privateKeyPem, string format, string version, string signType, string alipayPulicKey) + : this(serverUrl, appId, privateKeyPem, format, version, signType) + { + this.alipayPublicKey = alipayPulicKey; + } + + public DefaultAopClient(string serverUrl, string appId, string privateKeyPem, string format, string version, string signType, string alipayPulicKey, string charset) + : this(serverUrl, appId, privateKeyPem, format, version, signType, alipayPulicKey) + { + this.charset = charset; + } + + public DefaultAopClient(string serverUrl, string appId, string privateKeyPem, string format, string version, string signType, string alipayPulicKey, string charset, bool keyFromFile) + : this(serverUrl, appId, privateKeyPem, format, version, signType, alipayPulicKey) + { + this.keyFromFile = keyFromFile; + this.charset = charset; + } + + public DefaultAopClient(string serverUrl, string appId, string privateKeyPem, string format, string version, string signType, string charset, bool keyFromFile, CertParams certParams) + : this(serverUrl, appId, privateKeyPem, format, version, signType, null, charset, keyFromFile) + { + this.certEnvironment = new CertEnvironment(certParams, signType); + } + + public DefaultAopClient(string serverUrl, string appId, string privateKeyPem, string format, string version, string signType, string alipayPulicKey, string charset, string encyptKey) + : this(serverUrl, appId, privateKeyPem, format, version, signType, alipayPulicKey, charset) + { + this.encyptKey = encyptKey; + this.encyptType = "AES"; + } + + public DefaultAopClient(string serverUrl, string appId, string privateKeyPem, string format, string version, string signType, string charset, string encyptKey, CertParams certParams) + : this(serverUrl, appId, privateKeyPem, format, version, signType, null, charset, encyptKey) + { + this.certEnvironment = new CertEnvironment(certParams, signType); + } + + public void SetTimeout(int timeout) + { + webUtils.Timeout = timeout; + } + + public T Execute(IAopRequest request) where T : AopResponse + { + return Execute(request, null); + } + + public T Execute(IAopRequest request, string accessToken) where T : AopResponse + { + + return Execute(request, accessToken, null); + } + + public T Execute(IAopRequest request, string accessToken, string appAuthToken) where T : AopResponse + { + return Execute(request, accessToken, appAuthToken, null); + } + + public T Execute(IAopRequest request, string accessToken, string appAuthToken, string targetAppId) where T : AopResponse + { + ArgumentValidator.EnsureNull(certEnvironment, "检测到证书相关参数已初始化,证书模式下请改为调用CertificateExecute。"); + + if (string.IsNullOrEmpty(this.charset)) + { + this.charset = "utf-8"; + } + + string apiVersion = null; + + if (!string.IsNullOrEmpty(request.GetApiVersion())) + { + apiVersion = request.GetApiVersion(); + } + else + { + apiVersion = Version; + } + + // 添加协议级请求参数 + AopDictionary txtParams = new AopDictionary(request.GetParameters()); + + // 序列化BizModel + txtParams = SerializeBizModel(txtParams, request); + + txtParams.Add(AlipayConstants.METHOD, request.GetApiName()); + txtParams.Add(AlipayConstants.VERSION, apiVersion); + txtParams.Add(AlipayConstants.ALIPAY_SDK, SDK_VERSION); + txtParams.Add(AlipayConstants.APP_ID, appId); + txtParams.Add(AlipayConstants.FORMAT, format); + txtParams.Add(AlipayConstants.TIMESTAMP, DateTime.Now); + txtParams.Add(AlipayConstants.ACCESS_TOKEN, accessToken); + txtParams.Add(AlipayConstants.SIGN_TYPE, signType); + txtParams.Add(AlipayConstants.TERMINAL_TYPE, request.GetTerminalType()); + txtParams.Add(AlipayConstants.TERMINAL_INFO, request.GetTerminalInfo()); + txtParams.Add(AlipayConstants.PROD_CODE, request.GetProdCode()); + txtParams.Add(AlipayConstants.CHARSET, charset); + + + if (!string.IsNullOrEmpty(request.GetNotifyUrl())) + { + txtParams.Add(AlipayConstants.NOTIFY_URL, request.GetNotifyUrl()); + } + + if (!string.IsNullOrEmpty(appAuthToken)) + { + txtParams.Add(AlipayConstants.APP_AUTH_TOKEN, appAuthToken); + } + + if (!string.IsNullOrEmpty(targetAppId)) + { + txtParams.Add(AlipayConstants.TARGET_APP_ID, targetAppId); + } + + if (request.GetNeedEncrypt()) + { + + if (string.IsNullOrEmpty(txtParams[AlipayConstants.BIZ_CONTENT])) + { + + throw new AopException("api request Fail ! The reason: encrypt request is not supported!"); + } + + if (string.IsNullOrEmpty(this.encyptKey) || string.IsNullOrEmpty(this.encyptType)) + { + throw new AopException("encryptType or encryptKey must not null!"); + } + + if (!"AES".Equals(this.encyptType)) + { + throw new AopException("api only support Aes!"); + + } + + string encryptContent = AopUtils.AesEncrypt(this.encyptKey, txtParams[AlipayConstants.BIZ_CONTENT], this.charset); + txtParams.Remove(AlipayConstants.BIZ_CONTENT); + txtParams.Add(AlipayConstants.BIZ_CONTENT, encryptContent); + txtParams.Add(AlipayConstants.ENCRYPT_TYPE, this.encyptType); + } + + // 添加签名参数 + txtParams.Add(AlipayConstants.SIGN, AopUtils.SignAopRequest(txtParams, privateKeyPem, charset, this.keyFromFile, signType)); + + // 是否需要上传文件 + string body; + + + if (request is IAopUploadRequest) + { + IAopUploadRequest uRequest = (IAopUploadRequest)request; + IDictionary fileParams = AopUtils.CleanupDictionary(uRequest.GetFileParameters()); + body = webUtils.DoPost(this.serverUrl + "?" + AlipayConstants.CHARSET + "=" + this.charset, txtParams, fileParams, this.charset); + } + else + { + body = webUtils.DoPost(this.serverUrl + "?" + AlipayConstants.CHARSET + "=" + this.charset, txtParams, this.charset); + } + + T rsp; + IAopParser parser; + if ("xml".Equals(format)) + { + parser = new AopXmlParser(); + rsp = parser.Parse(body, charset); + } + else + { + parser = new AopJsonParser(); + rsp = parser.Parse(body, charset); + } + + ResponseParseItem item = ParseRespItem(request, body, parser, this.encyptKey, this.encyptType, charset); + rsp = parser.Parse(item.RealContent, charset); + + CheckResponseSign(request, item.RespContent, rsp.IsError, parser); + + return rsp; + } + + public T CertificateExecute(IAopRequest request) where T : AopResponse + { + return CertificateExecute(request, null); + } + + public T CertificateExecute(IAopRequest request, string accessToken) where T : AopResponse + { + + return CertificateExecute(request, accessToken, null); + } + + public T CertificateExecute(IAopRequest request, string accessToken, string appAuthToken) where T : AopResponse + { + return CertificateExecute(request, accessToken, appAuthToken, null); + } + + public T CertificateExecute(IAopRequest request, string accessToken, string appAuthToken, String targetAppId) where T : AopResponse + { + ArgumentValidator.CheckNotNull(certEnvironment, "检测到证书相关参数未初始化,非证书模式下请改为调用Execute。"); + + if (string.IsNullOrEmpty(this.charset)) + { + this.charset = "utf-8"; + } + + string apiVersion = null; + + if (!string.IsNullOrEmpty(request.GetApiVersion())) + { + apiVersion = request.GetApiVersion(); + } + else + { + apiVersion = Version; + } + + // 添加协议级请求参数 + AopDictionary txtParams = new AopDictionary(request.GetParameters()); + + // 序列化BizModel + txtParams = SerializeBizModel(txtParams, request); + + txtParams.Add(AlipayConstants.METHOD, request.GetApiName()); + txtParams.Add(AlipayConstants.VERSION, apiVersion); + txtParams.Add(AlipayConstants.ALIPAY_SDK, SDK_VERSION); + txtParams.Add(AlipayConstants.APP_ID, appId); + txtParams.Add(AlipayConstants.FORMAT, format); + txtParams.Add(AlipayConstants.TIMESTAMP, DateTime.Now); + txtParams.Add(AlipayConstants.ACCESS_TOKEN, accessToken); + txtParams.Add(AlipayConstants.SIGN_TYPE, signType); + txtParams.Add(AlipayConstants.TERMINAL_TYPE, request.GetTerminalType()); + txtParams.Add(AlipayConstants.TERMINAL_INFO, request.GetTerminalInfo()); + txtParams.Add(AlipayConstants.PROD_CODE, request.GetProdCode()); + txtParams.Add(AlipayConstants.CHARSET, charset); + + txtParams.Add(AlipayConstants.APP_CERT_SN, certEnvironment.AppCertSN); + txtParams.Add(AlipayConstants.ALIPAY_ROOT_CERT_SN, certEnvironment.RootCertSN); + + + if (!string.IsNullOrEmpty(request.GetNotifyUrl())) + { + txtParams.Add(AlipayConstants.NOTIFY_URL, request.GetNotifyUrl()); + } + + if (!string.IsNullOrEmpty(appAuthToken)) + { + txtParams.Add(AlipayConstants.APP_AUTH_TOKEN, appAuthToken); + } + + if (!string.IsNullOrEmpty(targetAppId)) + { + txtParams.Add(AlipayConstants.TARGET_APP_ID, targetAppId); + } + + if (request.GetNeedEncrypt()) + { + if (string.IsNullOrEmpty(txtParams[AlipayConstants.BIZ_CONTENT])) + { + + throw new AopException("api request Fail ! The reason: encrypt request is not supported!"); + } + + if (string.IsNullOrEmpty(this.encyptKey) || string.IsNullOrEmpty(this.encyptType)) + { + throw new AopException("encryptType or encryptKey must not null!"); + } + + if (!"AES".Equals(this.encyptType)) + { + throw new AopException("api only support Aes!"); + + } + + string encryptContent = AopUtils.AesEncrypt(this.encyptKey, txtParams[AlipayConstants.BIZ_CONTENT], this.charset); + txtParams.Remove(AlipayConstants.BIZ_CONTENT); + txtParams.Add(AlipayConstants.BIZ_CONTENT, encryptContent); + txtParams.Add(AlipayConstants.ENCRYPT_TYPE, this.encyptType); + } + + // 添加签名参数 + txtParams.Add(AlipayConstants.SIGN, AopUtils.SignAopRequest(txtParams, privateKeyPem, charset, this.keyFromFile, signType)); + + // 是否需要上传文件 + string body; + + + if (request is IAopUploadRequest) + { + IAopUploadRequest uRequest = (IAopUploadRequest)request; + IDictionary fileParams = AopUtils.CleanupDictionary(uRequest.GetFileParameters()); + body = webUtils.DoPost(this.serverUrl + "?" + AlipayConstants.CHARSET + "=" + this.charset, txtParams, fileParams, this.charset); + } + else + { + body = webUtils.DoPost(this.serverUrl + "?" + AlipayConstants.CHARSET + "=" + this.charset, txtParams, this.charset); + } + + T rsp; + IAopParser parser; + if ("xml".Equals(format)) + { + parser = new AopXmlParser(); + rsp = parser.Parse(body, charset); + } + else + { + parser = new AopJsonParser(); + rsp = parser.Parse(body, charset); + } + + ResponseParseItem item = ParseRespItem(request, body, parser, this.encyptKey, this.encyptType, charset); + rsp = parser.Parse(item.RealContent, charset); + + + CheckResponseCertSign(request, item.RespContent, rsp.IsError, parser); + + return rsp; + } + + public T pageExecute(IAopRequest request) where T : AopResponse + { + return pageExecute(request, null, null, "POST"); + } + + + public T pageExecute(IAopRequest request, string accessToken, string reqMethod) where T : AopResponse + { + return pageExecute(request, accessToken, null, reqMethod); + } + + + public T pageExecute(IAopRequest request, string accessToken, string appAuthToken, string reqMethod) where T : AopResponse + { + if (string.IsNullOrEmpty(this.charset)) + { + this.charset = "utf-8"; + } + + string apiVersion = null; + + if (!string.IsNullOrEmpty(request.GetApiVersion())) + { + apiVersion = request.GetApiVersion(); + } + else + { + apiVersion = Version; + } + + AopDictionary txtParams = new AopDictionary(request.GetParameters()); + + // 序列化BizModel + txtParams = SerializeBizModel(txtParams, request); + + // 添加协议级请求参数 + txtParams.Add(AlipayConstants.METHOD, request.GetApiName()); + txtParams.Add(AlipayConstants.VERSION, apiVersion); + txtParams.Add(AlipayConstants.ALIPAY_SDK, SDK_VERSION); + txtParams.Add(AlipayConstants.APP_ID, appId); + txtParams.Add(AlipayConstants.FORMAT, format); + txtParams.Add(AlipayConstants.TIMESTAMP, DateTime.Now); + txtParams.Add(AlipayConstants.ACCESS_TOKEN, accessToken); + txtParams.Add(AlipayConstants.APP_AUTH_TOKEN, appAuthToken); + txtParams.Add(AlipayConstants.SIGN_TYPE, signType); + txtParams.Add(AlipayConstants.TERMINAL_TYPE, request.GetTerminalType()); + txtParams.Add(AlipayConstants.TERMINAL_INFO, request.GetTerminalInfo()); + txtParams.Add(AlipayConstants.PROD_CODE, request.GetProdCode()); + txtParams.Add(AlipayConstants.NOTIFY_URL, request.GetNotifyUrl()); + txtParams.Add(AlipayConstants.CHARSET, this.charset); + txtParams.Add(AlipayConstants.RETURN_URL, request.GetReturnUrl()); + if (certEnvironment != null) + { + txtParams.Add(AlipayConstants.ALIPAY_ROOT_CERT_SN, certEnvironment.RootCertSN); + txtParams.Add(AlipayConstants.APP_CERT_SN, certEnvironment.AppCertSN); + } + //字典排序 + IDictionary sortedTxtParams = new SortedDictionary(txtParams, StringComparer.Ordinal); + txtParams = new AopDictionary(sortedTxtParams); + + // 排序返回字典类型添加签名参数 + txtParams.Add(AlipayConstants.SIGN, AopUtils.SignAopRequest(sortedTxtParams, privateKeyPem, this.charset, this.keyFromFile, this.signType)); + + // 是否需要上传文件 + string body; + + if (request is IAopUploadRequest) + { + IAopUploadRequest uRequest = (IAopUploadRequest)request; + IDictionary fileParams = AopUtils.CleanupDictionary(uRequest.GetFileParameters()); + body = webUtils.DoPost(this.serverUrl + "?" + AlipayConstants.CHARSET + "=" + this.charset, txtParams, fileParams, this.charset); + } + else + { + + if (reqMethod.Equals("GET")) + { + //拼接get请求的url + string tmpUrl = serverUrl; + if (txtParams != null && txtParams.Count > 0) + { + if (tmpUrl.Contains("?")) + { + tmpUrl = tmpUrl + "&" + WebUtils.BuildQuery(txtParams, charset); + } + else + { + tmpUrl = tmpUrl + "?" + WebUtils.BuildQuery(txtParams, charset); + } + } + body = tmpUrl; + } + else + { + //输出post表单 + body = BuildHtmlRequest(txtParams, reqMethod, reqMethod); + } + } + + T rsp = null; + IAopParser parser = null; + if ("xml".Equals(format)) + { + parser = new AopXmlParser(); + rsp = parser.Parse(body, charset); + } + else + { + parser = new AopJsonParser(); + rsp = parser.Parse(body, charset); + } + + return rsp; + } + + private static ResponseParseItem ParseRespItem(IAopRequest request, string respBody, IAopParser parser, string encryptKey, string encryptType, string charset) where T : AopResponse + { + string realContent; + if (request.GetNeedEncrypt()) + { + realContent = parser.EncryptSourceData(request, respBody, encryptType, encryptKey, charset); + } + else + { + realContent = respBody; + } + + ResponseParseItem item = new ResponseParseItem + { + RealContent = realContent, + RespContent = respBody + }; + + return item; + + } + + private void CheckResponseCertSign(IAopRequest request, string responseBody, bool isError, IAopParser parser) where T : AopResponse + { + if (request.GetApiName().Equals("alipay.open.app.alipaycert.download")) + { + return; + } + + CertItem certItem = parser.GetCertItem(request, responseBody); + if (certItem == null) + { + throw new AopException("sign check fail: Body is Empty!"); + } + + if (!isError || (isError && !string.IsNullOrEmpty(certItem.Sign))) + { + + String currentAlipayPublicKey = LoadAlipayPublicKey(certItem); + + bool rsaCheckContent = AlipaySignature.RSACheckContent(certItem.SignSourceDate, certItem.Sign, currentAlipayPublicKey, charset, signType, false); + if (!rsaCheckContent) + { + if (!string.IsNullOrEmpty(certItem.SignSourceDate) && certItem.SignSourceDate.Contains("\\/")) + { + string sourceData = certItem.SignSourceDate.Replace("\\/", "/"); + bool jsonCheck = AlipaySignature.RSACheckContent(sourceData, certItem.Sign, currentAlipayPublicKey, charset, signType, false); + if (!jsonCheck) + { + throw new AopException("sign check fail: check Sign and Data Fail JSON also"); + } + } + else + { + throw new AopException("sign check fail: check Sign and Data Fail!"); + } + } + } + } + + private String LoadAlipayPublicKey(CertItem certItem) + { + //如果响应的支付宝公钥证书序号已经缓存过,则直接使用缓存的公钥 + if (certEnvironment.ContainsAlipayPublicKey(certItem.CertSN)) + { + return certEnvironment.GetAlipayPublicKey(certItem.CertSN); + } + + //否则重新下载新的支付宝公钥证书并更新缓存 + AlipayOpenAppAlipaycertDownloadRequest request = new AlipayOpenAppAlipaycertDownloadRequest + { + BizContent = "{\"alipay_cert_sn\":\"" + certItem.CertSN + "\"}" + }; + AlipayOpenAppAlipaycertDownloadResponse response = CertificateExecute(request); + if (response.IsError) + { + throw new AopException("支付宝公钥证书校验失败,请确认是否为支付宝签发的有效公钥证书"); + } + string alipayCertBase64 = response.AlipayCertContent; + byte[] alipayCertBytes = Convert.FromBase64String(alipayCertBase64); + string alipayCertContent = Encoding.UTF8.GetString(alipayCertBytes); + if (!AntCertificationUtil.IsTrusted(alipayCertContent, certEnvironment.RootCertContent)) + { + throw new AopException("支付宝公钥证书校验失败,请确认是否为支付宝签发的有效公钥证书"); + } + + X509Certificate alipayCert = AntCertificationUtil.ParseCert(alipayCertContent); + String alipayCertSN = AntCertificationUtil.GetCertSN(alipayCert); + string newAlipayPublicKey = AntCertificationUtil.ExtractPemPublicKeyFromCert(alipayCert); + certEnvironment.AddNewAlipayPublicKey(alipayCertSN, newAlipayPublicKey); + + return newAlipayPublicKey; + } + + private void CheckResponseSign(IAopRequest request, string responseBody, bool isError, IAopParser parser) where T : AopResponse + { + if (string.IsNullOrEmpty(alipayPublicKey) || string.IsNullOrEmpty(charset)) + { + return; + } + + SignItem signItem = parser.GetSignItem(request, responseBody); + if (signItem == null) + { + throw new AopException("sign check fail: Body is Empty!"); + } + + if (!isError || + (isError && !string.IsNullOrEmpty(signItem.Sign))) + { + bool rsaCheckContent = AlipaySignature.RSACheckContent(signItem.SignSourceDate, signItem.Sign, alipayPublicKey, charset, signType, keyFromFile); + if (!rsaCheckContent) + { + if (!string.IsNullOrEmpty(signItem.SignSourceDate) && signItem.SignSourceDate.Contains("\\/")) + { + string srouceData = signItem.SignSourceDate.Replace("\\/", "/"); + bool jsonCheck = AlipaySignature.RSACheckContent(srouceData, signItem.Sign, alipayPublicKey, charset, signType, keyFromFile); + if (!jsonCheck) + { + throw new AopException( + "sign check fail: check Sign and Data Fail JSON also"); + } + } + else + { + throw new AopException( + "sign check fail: check Sign and Data Fail!"); + } + } + + } + } + + public string BuildHtmlRequest(IDictionary sParaTemp, string strMethod, string strButtonValue) + { + //待请求参数数组 + IDictionary dicPara = new Dictionary(); + dicPara = sParaTemp; + + StringBuilder sbHtml = new StringBuilder(); + //sbHtml.Append(""); + + sbHtml.Append("