first commit init

develop
易大师 2021-01-29 13:00:03 +08:00
commit ef69cb5d5b
7880 changed files with 445265 additions and 0 deletions

25
.dockerignore Normal file
View File

@ -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

View File

@ -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'
]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -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的用户角色
```

View File

@ -0,0 +1,54 @@
# 框架压测报告
## 1、测试工具
使用 `JMeter` 进行压力测试。
测试时间2020年7月1日 13点14分。
服务器报告:
<img src="https://img.neters.club/doc/serverreport.png" >
## 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信息请求管理器
响应断言:无
<img src="https://img.neters.club/doc/ycconfig.png" >
## 项目配置
目前采用 `New_College` 默认的配置,
开启了内存 `AOP` 和日志 `AOP`
其他的都是默认的,然后也把任务调度也关闭了,
最后注意要把 `IP限流`给关闭,不然压测没效果,因为限流了:
<img src="https://img.neters.club/doc/appconfig.png" >
## 压测结果
1、为了显示正确性我用动图来显示日志生成情况整个阶段无任何异常
<img src="https://img.neters.club/doc/ddd.gif" >
2、内存方面`100*10000` 的压测过程中,项目保证所占内存在 `160~220m` 之间:
<img src="https://img.neters.club/doc/ycr.png" >
## 压测配置文件下载
[配置文件](https://img.neters.club/doc/new_collegetest.jmx)
下载后,导入到工具里,可以直接测试,察看结果树。
## Docker 镜像
已经提交到 `docker hub` 自行拉取操作即可:
```
docker pull laozhangisphi/apkimg:latest
```

View File

@ -0,0 +1,11 @@
## QQ 群
<img src="https://img.neters.club/doc/NETCore-VUE.png" alt="群1" width="200" >
<img src="https://img.neters.club/doc/NETCore-VUE-2.png" alt="群2" width="200" >
## 微信公众号
<img src="https://img.neters.club/doc/WeChat%20Screenshot_20200624194936.png" alt="公众号" width="600" >

14
.docs/contents/README.md Normal file
View File

@ -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-老张的哲学
---

View File

@ -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<T>` [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限流防止过多刷数据

View File

@ -0,0 +1,89 @@
# J 介绍
最新的前后端完全分离框架【 ASP.NET Core 3.1 Api + Vue 2.x + ele】。
ASP.NET Core 3.1 教程前后端分离的后端接口vue教程的姊妹篇。
BCVPNew_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

View File

@ -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` 包:
```
<PackageReference Include="AspNetCoreRateLimit" Version="3.0.5" />
```
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<string, string> {
{
"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` 中,配置登录授权:
<img src="http://apk.neters.club/images/20200507213830.png" alt="swagger" width="600" >
## 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
{
/// <summary>
/// 配置构造函数,用来创建关系映射
/// </summary>
public CustomProfile()
{
CreateMap<BlogArticle, BlogViewModels>();
CreateMap<BlogViewModels, BlogArticle>();
}
}
// 比如如何使用
models = _mapper.Map<BlogViewModels>(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、引用依赖包
```
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="4.5.0" />
```
主要是第一个 `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<AdvertisementServices>().As<IAdvertisementServices>();
#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<Type>();
if (Appsettings.app(new string[] { "AppSettings", "RedisCachingAOP", "Enabled" }).ObjToBool())
{
builder.RegisterType<BlogRedisCacheAOP>();
cacheType.Add(typeof(BlogRedisCacheAOP));
}
if (Appsettings.app(new string[] { "AppSettings", "MemoryCachingAOP", "Enabled" }).ObjToBool())
{
builder.RegisterType<BlogCacheAOP>();
cacheType.Add(typeof(BlogCacheAOP));
}
if (Appsettings.app(new string[] { "AppSettings", "TranAOP", "Enabled" }).ObjToBool())
{
builder.RegisterType<BlogTranAOP>();
cacheType.Add(typeof(BlogTranAOP));
}
if (Appsettings.app(new string[] { "AppSettings", "LogAOP", "Enabled" }).ObjToBool())
{
builder.RegisterType<BlogLogAOP>();
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<IHttpContextAccessor, HttpContextAccessor>();
// 注入权限处理器
services.AddScoped<IAuthorizationHandler, PermissionHandler>();
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<T>` 接口,实现对日志的管控,引用 `nuget``Microsoft.Extensions.Logging.Log4Net.AspNetCore`:
Program.cs
```
webBuilder
.UseStartup<Startup>()
.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<UserController> 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` 管理器中,搜索到:
<img src="http://apk.neters.club/images/20200507223058.png" alt="nuget" width="600" >
## 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<string> GetUserInfoFromToken(string ClaimType);`
```
public string GetToken()
{
return _accessor.HttpContext.Request.Headers["Authorization"].ObjToString().Replace("Bearer ", "");
}
public List<string> 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<string>() { };
}
}
```

View File

@ -0,0 +1,471 @@
# H 核心功能一览表
## 一、表结构解析
`New_College` 项目共包含四部分的数据库表结构,分别是:用户角色管理部分、接口菜单权限管理部分、博客文章管理部分、以及其他不重要部分。
> 注意:目前不提供与维护数据库数据,直接通过 `SeedData` 生成种子数据;
### 1、用户角色管理部分[必须]
主要是三个表:分别对应用户表(sysUserInfo)、角色表(Role)、用户角色关系表(UserRole)。
<img src="http://img.neters.club/doc/usermanager.png" alt="usermanager" >
### 2、接口菜单权限管理部分[必须]
主要是四个表:分别对应接口表(Module)、菜单表(Permission)、接口菜单关系表(ModulePermission)暂时没用到、角色接口菜单关系表(RoleModulePermission)。
<img src="http://img.neters.club/doc/permissionmanager.png" alt="permissionmanager" >
### 3、博客文章管理部分[可选]
主要是三个表:分别对应博客表(BlogArticle)、Bug专题表(Topic)、Bug内容表(TopicDetail)。
<img src="http://img.neters.club/doc/blogmanager.png" alt="blogmanager" >
### 4、其他不重要部分
主要是三个表分别对应Job调度表(TasksQz)、密码库表(PasswordLib)、操作日志表(OperateLog)、广告表(Advertisement)、公告表(Guestbook)。
<img src="http://img.neters.club/doc/othersmanager.png" alt="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 )
## 三、控制台信息展示
<img src="http://apk.neters.club/images/2020-05-09_182758.png" alt="配置" width="800" >
## 四、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;
}
}
```

View File

@ -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、如果你想多库操作需要配置
```
aMainDB 设置为主库的 ConnId
bMutiDBEnabled设置为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` 文件,就生成了最新的模板了;

12
.docs/package.json Normal file
View File

@ -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"
}

4
.editorconfig Normal file
View File

@ -0,0 +1,4 @@
[*.cs]
# IDE0005: Using 指令是不需要的。
dotnet_diagnostic.IDE0005.severity = warning

12
.github/FUNDING.yml vendored Normal file
View File

@ -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

22
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -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.
请在此创建其他类型问题。

17
.github/workflows/dotnetcore.yml vendored Normal file
View File

@ -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

353
.gitignore vendored Normal file
View File

@ -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

23
CreateYourProject.bat Normal file
View File

@ -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

201
LICENSE Normal file
View File

@ -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.

View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -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<Startup>();
});
}
}

View File

@ -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"
}
}
}
}

View File

@ -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!");
});
});
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "3.1.9",
"commands": [
"dotnet-ef"
]
}
}
}

View File

@ -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
///// <summary>
///// 生成周期
///// </summary>
///// <returns></returns>
//[HttpPost]
//public async Task<MessageModel<bool>> AutoCycleTime()
//{
// var result = await test_CycleTimeInfoServices.AutoCycleTime();
// return new MessageModel<bool>()
// {
// success = result,
// response = result,
// msg = result == true ? "成功" : "失败"
// };
//}
///// <summary>
/////
///// </summary>
///// <returns></returns>
//[HttpPost]
//public async Task<MessageModel<bool>> Import()
//{
// var result = await d_LongIdMapServices.Import();
// return new MessageModel<bool>()
// {
// success = true,
// msg = "成功",
// response = result
// };
//}
#endregion
#region new T
///// <summary>
///// EnrollmentBatch
///// </summary>
///// <returns></returns>
//[HttpPost]
//public async Task<MessageModel<bool>> ImportEnrollmentBatch()
//{
// return new MessageModel<bool>()
// {
// success = true,
// msg = "成功",
// response = await t_LongIdMapServices.ImportEnrollmentBatch()
// };
//}
///// <summary>
///// EnrollmentPlane
///// </summary>
///// <returns></returns>
//[HttpPost]
//public async Task<MessageModel<bool>> ImportEnrollmentPlane()
//{
// return new MessageModel<bool>()
// {
// success = true,
// msg = "成功",
// response = await t_LongIdMapServices.ImportEnrollmentPlane()
// };
//}
///// <summary>
///// EnrollmentPlanedesc
///// </summary>
///// <returns></returns>
//[HttpPost]
//public async Task<MessageModel<bool>> ImportEnrollmentPlanedesc()
//{
// return new MessageModel<bool>()
// {
// success = true,
// msg = "成功",
// response = await t_LongIdMapServices.ImportEnrollmentPlanedesc()
// };
//}
///// <summary>
///// Batchline
///// </summary>
///// <returns></returns>
//[HttpPost]
//public async Task<MessageModel<bool>> ImportBatchline()
//{
// return new MessageModel<bool>()
// {
// success = true,
// msg = "成功",
// response = await t_LongIdMapServices.ImportBatchline()
// };
//}
///// <summary>
///// BatchTypeInfo
///// </summary>
///// <returns></returns>
//[HttpPost]
//public async Task<MessageModel<bool>> ImportBatchTypeInfo()
//{
// return new MessageModel<bool>()
// {
// success = true,
// msg = "成功",
// response = await t_LongIdMapServices.ImportBatchTypeInfo()
// };
//}
#endregion
///// <summary>
///// 2019上海招生分数更新
///// </summary>
///// <returns></returns>
//[HttpPost]
//public async Task<MessageModel<bool>> Import()
//{
// var result = await t_EnrollmentPlaneServices.Import();
// return new MessageModel<bool>() { success = true };
//}
///// <summary>
///// 下载图片
///// </summary>
///// <returns></returns>
//[HttpPost]
//public async Task<MessageModel<bool>> SaveImg()
//{
// var result = await d_UniversityServices.SaveImg();
// return new MessageModel<bool>() { success = true, msg = "成功" };
//}
///// <summary>
///// 专业薪酬
///// </summary>
///// <returns></returns>
//[HttpPost]
//public async Task<bool> Import()
//{
// return await d_MajorSalaryServices.Import();
//}
}
}

View File

@ -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;
}
/// <summary>
/// 获取分页
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<CustomerInfoListResult>>> GetCustomerInfoListByPage([FromQuery] CustomerSeachQuery query)
{
return await v_CustomerInfoServices.GetCustomerInfoListByPage(query);
}
}
}

View File

@ -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;
}
/// <summary>
/// 获取分页
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<ExaminationPolicyResult>>> GetExaminationPolicyByPage([FromQuery] ExaminationPolicySearchQuery query)
{
return await iV_ExaminationPolicyServices.GetExaminationPolicyByPage(query);
}
/// <summary>
/// 获取单个
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<ExaminationPolicyOneResult>> GetExaminationPolicyOne([FromQuery] IdQuery query)
{
return await iV_ExaminationPolicyServices.GetExaminationPolicyOne(query);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<bool>> AddExaminationPolicy([FromBody] ExaminationPolicyQuery query)
{
return await iV_ExaminationPolicyServices.AddExaminationPolicy(query);
}
/// <summary>
/// 修改
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPut]
public async Task<MessageModel<bool>> UpdateExaminationPolicy(ExaminationPolicyQuery query)
{
return await iV_ExaminationPolicyServices.UpdateExaminationPolicy(query);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<bool>> DeleteExaminationPolicy([FromBody] IdQuery query)
{
return await iV_ExaminationPolicyServices.DeleteExaminationPolicy(query);
}
}
}

View File

@ -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;
}
/// <summary>
/// 获取分页
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<OrderInfoQuery>>> GetVipCardInfoByPage([FromQuery] SearchOrderQuery query)
{
return await v_OrderInfoServices.GetOrderInfoByPage(query);
}
/// <summary>
/// 获取分页
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<OrderInfoQuery>>> GetOrderInfoList([FromQuery] SearchOrderQuery query)
{
return await v_OrderInfoServices.GetOrderInfoByPage(query);
}
}
}

View File

@ -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;
}
/// <summary>
/// 生成卡信息
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<List<string>>> AutoVipCardInfo([FromBody] AutoVipInfoQuery query)
{
return await iV_VipCardInfoServices.AutoVipCardInfo(query);
}
/// <summary>
/// 获取分页
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<VipCardInfoResult>>> GetVipCardInfoByPage([FromQuery] VipCardInfoSearchQuery query)
{
return await iV_VipCardInfoServices.GetVipCardInfoByPage(query);
}
/// <summary>
/// 获取单个
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<VipCardInfoResultOne>> GetVipCardInfoOne([FromQuery] IdQuery query)
{
return await iV_VipCardInfoServices.GetVipCardInfoOne(query);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<bool>> AddVipCardInfo([FromBody] VipCardInfoQuery query)
{
return await iV_VipCardInfoServices.AddVipCardInfo(query);
}
/// <summary>
/// 修改
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPut]
public async Task<MessageModel<bool>> UpdateVipCardInfo(VipCardInfoQuery query)
{
return await iV_VipCardInfoServices.UpdateVipCardInfo(query);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<bool>> DeleteVipCardInfo([FromBody] IdQuery query)
{
return await iV_VipCardInfoServices.DeleteVipCardInfo(query);
}
/// <summary>
/// 获取vipcardTypeList
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<List<VipCardTypeQuery>> GetVipCardType()
{
return await iV_VipCardTypeServices.GetVipCardType();
}
}
}

View File

@ -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
{
/// <summary>
/// 博客管理
/// </summary>
[Produces("application/json")]
[Route("api/Blog")]
public class BlogController : Controller
{
readonly IBlogArticleServices _blogArticleServices;
private readonly ILogger<BlogController> _logger;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="blogArticleServices"></param>
/// <param name="logger"></param>
public BlogController(IBlogArticleServices blogArticleServices, ILogger<BlogController> logger)
{
_blogArticleServices = blogArticleServices;
_logger = logger;
}
/// <summary>
/// 获取博客列表【无权限】
/// </summary>
/// <param name="id"></param>
/// <param name="page"></param>
/// <param name="bcategory"></param>
/// <param name="key"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<BlogArticle>>> Get(int id, int page = 1, string bcategory = "技术博文", string key = "")
{
int intPageSize = 6;
if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
{
key = "";
}
Expression<Func<BlogArticle, bool>> 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<PageModel<BlogArticle>>()
{
success = true,
msg = "获取成功",
response = new PageModel<BlogArticle>()
{
page = page,
dataCount = pageModelBlog.dataCount,
data = pageModelBlog.data,
pageCount = pageModelBlog.pageCount,
}
};
}
/// <summary>
/// 获取博客详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("{id}")]
[Authorize(Policy = "Scope_BlogModule_Policy")]
public async Task<MessageModel<BlogViewModels>> Get(int id)
{
return new MessageModel<BlogViewModels>()
{
msg = "获取成功",
success = true,
response = await _blogArticleServices.GetBlogDetails(id)
};
}
/// <summary>
/// 获取详情【无权限】
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("DetailNuxtNoPer")]
public async Task<MessageModel<BlogViewModels>> DetailNuxtNoPer(int id)
{
_logger.LogInformation("xxxxxxxxxxxxxxxxxxx");
return new MessageModel<BlogViewModels>()
{
msg = "获取成功",
success = true,
response = await _blogArticleServices.GetBlogDetails(id)
};
}
[HttpGet]
[Route("GoUrl")]
public async Task<IActionResult> 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<MessageModel<List<BlogArticle>>> 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<List<BlogArticle>>()
{
msg = "获取成功",
success = true,
response = blogs
};
}
return new MessageModel<List<BlogArticle>>() { };
}
[HttpGet]
[Route("GetBlogByIdForMVP")]
public async Task<MessageModel<BlogArticle>> GetBlogByIdForMVP(int id = 0)
{
if (id > 0)
{
return new MessageModel<BlogArticle>()
{
msg = "获取成功",
success = true,
response = await _blogArticleServices.QueryById(id)
};
}
return new MessageModel<BlogArticle>() { };
}
/// <summary>
/// 获取博客测试信息 v2版本
/// </summary>
/// <returns></returns>
[HttpGet]
////MVC自带特性 对 api 进行组管理
//[ApiExplorerSettings(GroupName = "v2")]
////路径 如果以 / 开头,表示绝对路径,反之相对 controller 的想u地路径
//[Route("/api/v2/blog/Blogtest")]
//和上边的版本控制以及路由地址都是一样的
[CustomRoute(ApiVersions.V2, "Blogtest")]
public MessageModel<string> V2_Blogtest()
{
return new MessageModel<string>()
{
msg = "获取成功",
success = true,
response = "我是第二版的博客信息"
};
}
/// <summary>
/// 添加博客【无权限】
/// </summary>
/// <param name="blogArticle"></param>
/// <returns></returns>
[HttpPost]
[Authorize(Policy = "Scope_BlogModule_Policy")]
public async Task<MessageModel<string>> Post([FromBody] BlogArticle blogArticle)
{
var data = new MessageModel<string>();
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;
}
/// <summary>
///
/// </summary>
/// <param name="blogArticle"></param>
/// <returns></returns>
[HttpPost]
[Route("AddForMVP")]
[Authorize(Permissions.Name)]
public async Task<MessageModel<string>> AddForMVP([FromBody] BlogArticle blogArticle)
{
var data = new MessageModel<string>();
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;
}
/// <summary>
/// 更新博客信息
/// </summary>
/// <param name="BlogArticle"></param>
/// <returns></returns>
// PUT: api/User/5
[HttpPut]
[Route("Update")]
[Authorize(Permissions.Name)]
public async Task<MessageModel<string>> Put([FromBody] BlogArticle BlogArticle)
{
var data = new MessageModel<string>();
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;
}
/// <summary>
/// 删除博客
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpDelete]
[Authorize(Permissions.Name)]
[Route("Delete")]
public async Task<MessageModel<string>> Delete(int id)
{
var data = new MessageModel<string>();
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;
}
/// <summary>
/// apache jemeter 压力测试
/// 更新接口
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("ApacheTestUpdate")]
public async Task<MessageModel<bool>> ApacheTestUpdate()
{
return new MessageModel<bool>()
{
success = true,
msg = "更新成功",
response = await _blogArticleServices.Update(new { bsubmitter = $"laozhang{DateTime.Now.Millisecond}", bID = 1 })
};
}
}
}

View File

@ -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;
/// <summary>
/// 构造函数
/// </summary>
public DbFirstController(ISqlSugarClient sqlSugarClient, IWebHostEnvironment env)
{
_sqlSugarClient = sqlSugarClient as SqlSugarClient;
Env = env;
}
/// <summary>
/// 获取 整体框架 文件
/// </summary>
/// <returns></returns>
[HttpGet]
public MessageModel<string> GetFrameFiles()
{
var data = new MessageModel<string>() { 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;
}
/// <summary>
/// 根据数据库表名 生成整体框架
/// 仅针对通过CodeFirst生成表的情况
/// </summary>
/// <param name="ConnID">数据库链接名称</param>
/// <param name="tableNames">需要生成的表名</param>
/// <returns></returns>
[HttpPost]
public MessageModel<string> 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<string>() { 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;
}
/// <summary>
/// DbFrist 根据数据库表名 生成整体框架,包含Model层
/// </summary>
/// <param name="ConnID">数据库链接名称</param>
/// <param name="tableNames">需要生成的表名</param>
/// <returns></returns>
[HttpPost]
public MessageModel<string> 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<string>() { 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;
}
}
}

View File

@ -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;
}
/// <summary>
/// 获取权限部分Map数据从库
/// 迁移到新库(主库)
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<string>> DataMigrateFromOld2New()
{
var data = new MessageModel<string>() { 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;
}
/// <summary>
/// 权限数据库导出tsv
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<string>> SaveData2TsvAsync()
{
var data = new MessageModel<string>() { 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;
}
}
}

View File

@ -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;
}
/// <summary>
/// 获取微信openid
/// </summary>
/// <param name="login"></param>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public MessageModel<CustomerInfoResult> 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<CustomerInfoResult>()
{
success = true,
msg = "success",
response = response
};
}
else
{
return new MessageModel<CustomerInfoResult>()
{
success = false,
response = response
};
}
}
catch (Exception ex)
{
return new MessageModel<CustomerInfoResult>()
{
msg = ex.ToString(),
success = false,
response = response
};
}
}
/// <summary>
/// 解密手机号同时保存用户信息
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<bool>> 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<bool>()
{
msg = result ? "修改成功" : "保存失败",
response = result,
success = result
};
}
/// <summary>
///用户获取用户信息有OpenId 调用此接口
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<CustomerInfoResult>> GetUserInfo([FromQuery] LoginQuery query)
{
var result = await _services.GetUserInfo(query);
return new MessageModel<CustomerInfoResult>()
{
response = result.Item2,
success = result.Item1,
msg = result.Item1 ? "登陆成功" : "用户不存在"
};
}
/// <summary>
/// 更改分数
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<CustomerInfoResult>> 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<CustomerInfoResult>()
{
success = result.Status == 1,
msg = result.Status == 1 ? "修改成功" : "修改失败",
response = result
};
}
/// <summary>
/// 完善用户信息
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<CustomerInfoResult>> 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<CustomerInfoResult>()
{
success = result.Status == 1,
msg = result.Status == 1 ? "成功" : "失败",
response = result
};
}
/// <summary>
/// 根绝Id获取用户信息
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<CustomerInfoResult>> GetCustomerInfoById([FromQuery] IdQuery query)
{
return await _services.GetCustomerInfoById(query);
}
}
}

View File

@ -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;
}
/// <summary>
/// 获取考试时间
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<ExaminationPolicyOneDetail>> GetExaminationPolicyDetail([FromQuery] ExaminationPolicyAreaQuery query)
{
return await iV_ExaminationPolicyServices.GetExaminationPolicyDetail(query);
}
}
}

View File

@ -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;
}
/// <summary>
/// 获取院校库
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<UniversityResult>>> GetUniversitys([FromQuery] UniversityQuery query)
{
var result = await iD_LongIdMapServices.GetUniversitys(query);
if (result.data == null || result.data.Count <= 0)
{
return new MessageModel<PageModel<UniversityResult>>()
{
success = false,
msg = "获取失败",
};
}
else
{
return new MessageModel<PageModel<UniversityResult>>()
{
success = true,
msg = "获取成功",
response = result
};
}
}
/// <summary>
/// 专业库 一级二级列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<uniMajorInfoResult>>> uniGetMajorInfo([FromQuery] MajorcategoryQuery query)
{
var result = await iD_LongIdMapServices.uniGetMajorInfo(query);
return new MessageModel<List<uniMajorInfoResult>>()
{
success = result.Count <= 0 ? false : true,
msg = result.Count <= 0 ? "获取失败" : "获取成功",
response = result
};
}
/// <summary>
/// 获取推荐职业
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<OccupationResult>>> GetRecommendOccupation()
{
var result = await iD_LongIdMapServices.GetRecommendOccupation();
return new MessageModel<List<OccupationResult>>()
{
success = result.Count <= 0 ? false : true,
msg = result.Count <= 0 ? "获取失败" : "获取成功",
response = result
};
}
/// <summary>
/// 职业库 一级二级列表
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<uniMajorInfoResult>>> uniGetOccupationInfo()
{
var result = await iD_LongIdMapServices.uniGetOccupationInfo();
return new MessageModel<List<uniMajorInfoResult>>()
{
success = result.Count <= 0 ? false : true,
msg = result.Count <= 0 ? "获取失败" : "获取成功",
response = result
};
}
/// <summary>
/// 获取职业第三级
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<IdNameResult>>> GetOccupationThree([FromQuery] IdQuery query)
{
return await iD_LongIdMapServices.GetOccupationThree(query);
}
/// <summary>
/// 院校详情
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<UniversityDetailResponse>> GetUniversityDetails([FromQuery] IdQuery query)
{
var result = await iD_LongIdMapServices.GetUniversityDetails(query);
return new MessageModel<UniversityDetailResponse>()
{
success = result.Status == 1 ? true : false,
msg = result.Status == 1 ? "获取成功" : "获取失败",
response = result
};
}
/// <summary>
/// 获取专业介绍
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<MajorDetail>> GetMajorDetail([FromQuery] MajorQuery query)
{
var result = await iD_LongIdMapServices.GetMajorDetail(query);
return new MessageModel<MajorDetail>()
{
success = result.id > 0 ? true : false,
msg = result.id > 0 ? "获取成功" : "获取失败",
response = result
};
}
/// <summary>
/// 相关院校
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<UniversityResult>>> GetRelevantSchool([FromQuery] MajorSchoolQuery query)
{
var result = await iD_LongIdMapServices.GetRelevantSchool(query);
return new MessageModel<PageModel<UniversityResult>>()
{
success = (result.data == null || result.data.Count <= 0) == true ? false : true,
msg = (result.data == null || result.data.Count <= 0) == true ? "获取失败" : "获取成功",
response = result
};
}
/// <summary>
/// 获取专业就业前景
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<CareerProspects>> GetCareerProspects([FromQuery] MajorCareerQuery query)
{
var result = await iD_LongIdMapServices.GetCareerProspects(query);
return new MessageModel<CareerProspects>()
{
success = true,
msg = "获取成功",
response = result
};
}
/// <summary>
/// 获取第三级
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<uniMajorInfo>>> uniGetMajorThree([FromQuery] ManageMajorQuery query)
{
return await iD_LongIdMapServices.uniGetMajorThree(query);
}
/// <summary>
/// 根据标签推荐专业
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<uniMajorInfo>>> GetMajorThreeByTag([FromQuery] MajorThreeByTagQuery query)
{
return await iD_LongIdMapServices.GetMajorThreeByTag(query);
}
/// <summary>
/// 获取职业详情-职业介绍
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<OccupationDetailResult>> GetRecommendIntroduce([FromQuery] IdQuery query)
{
var result = await iD_LongIdMapServices.GetRecommendIntroduce(query);
return new MessageModel<OccupationDetailResult>()
{
success = result.Status == 1 ? true : false,
msg = result.Status == 1 ? "获取成功" : "获取失败",
response = result
};
}
/// <summary>
/// 院校相关专业专用
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<uniMajorInfoResult>>> GetUniversityMajor([FromQuery] IdQuery query)
{
var result = await iD_LongIdMapServices.GetUniversityMajor(query);
return new MessageModel<List<uniMajorInfoResult>>()
{
success = true,
msg = "获取成功",
response = result
};
}
/// <summary>
/// 查学校省份的 年份批次
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<BatchYear>> GetBatchYearBySchoolId([FromQuery] PlanYearQuery query)
{
var result = await iD_LongIdMapServices.GetBatchYearBySchoolId(query);
return new MessageModel<BatchYear>()
{
success = result != null,
msg = result != null ? "获取成功" : "获取失败",
response = result
};
}
/// <summary>
/// 获取招生计划 院校详情
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<NewPlanDescList>>> GetPlanBySchollId([FromQuery] PlanQuery query)
{
var result = await iD_LongIdMapServices.GetPlanBySchollId(query);
if (result == null || result.Count() <= 0)
{
return new MessageModel<List<NewPlanDescList>>()
{
success = false,
msg = "获取失败"
};
}
else
{
return new MessageModel<List<NewPlanDescList>>()
{
success = true,
msg = "获取成功",
response = result
};
}
}
/// <summary>
/// 获取院校排名
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<UniversityRankList>>> GetUniversityRank([FromQuery] UniversityRankQuery query)
{
var result = await iD_LongIdMapServices.GetUniversityRank(query);
return new MessageModel<List<UniversityRankList>>()
{
success = result.Count > 0,
msg = result.Count > 0 ? "获取成功" : "获取失败",
response = result
};
}
/// <summary>
/// 专业搜索
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<IdNameResult>>> uniGetSearchMajor([FromQuery] NameBaseQuery query)
{
return await iD_LongIdMapServices.uniGetSearchMajor(query);
}
/// <summary>
/// 获取招生简章列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<RequestEnrollmentinproductionResult>>> GetRequestEnrollmentinproductionResult([FromQuery] UniversityIdQuery query)
{
return await iD_LongIdMapServices.GetRequestEnrollmentinproductionResult(query);
}
/// <summary>
/// 获取招生简介详情
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<RequestEnrollmentinproductionDetailResult>> GetRequestEnrollmentinproductionDetailResult([FromQuery] StringIdQuery query)
{
return await iD_LongIdMapServices.GetRequestEnrollmentinproductionDetailResult(query);
}
}
}

View File

@ -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;
}
/// <summary>
/// 获取高薪推荐
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<MajorSalaryResult>>> GetMajorSalaryResult([FromQuery] MajorSalaryQuery query)
{
return await iD_MajorSalaryServices.GetMajorSalaryResult(query);
}
}
}

View File

@ -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;
}
/// <summary>
/// 下订单
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<CreateOrderModel>> CreateOrder(UniOrderQuery query)
{
var result = await v_OrderInfoServices.CreateOrder(query);
return new MessageModel<CreateOrderModel>()
{
success = result.success,
msg = result.msg,
response = result
};
}
}
}

View File

@ -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;
}
/// <summary>
/// 获取省市区
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<SysRegionResult>>> GetRegionList([FromQuery] SysRegionQuery query)
{
List<SysRegionResult> list = new List<SysRegionResult>() { };
list.Add(new SysRegionResult() { Id = 0, Code = "0", Name = "全国" });
var result = await sysRegionServices.GetRegionList(query);
list.AddRange(result);
return new MessageModel<List<SysRegionResult>>()
{
success = true,
msg = "成功",
response = list
};
}
}
}

View File

@ -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;
}
/// <summary>
/// 获取分类 根绝type
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<CategoryInfoResult>>> GetCateSelectByType([FromQuery] CategoryInfoQuery query)
{
var result = await test_CategoryInfoServices.GetCateSelectByType(query);
return new MessageModel<List<CategoryInfoResult>>()
{
success = true,
msg = "获取成功",
response = result
};
}
/// <summary>
/// 获取个人某个维度测评结果
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<List<PsychMeasurementListResult>>> GetPsychListByCateAndCustomerId([FromQuery] PsychMeasurementQuery query)
{
var result = await test_PsychMeasurementInfoServices.GetPsychListByCateAndCustomerId(query);
return new MessageModel<List<PsychMeasurementListResult>>()
{
msg = "获取成功",
success = true,
response = result
};
}
/// <summary>
/// 获取测评状态
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<CategoryStatusResult>> GetTestStatus([FromQuery] CategoryStatusQuery query)
{
var result = await test_CategoryInfoServices.GetTestStatus(query);
return new MessageModel<CategoryStatusResult>()
{
msg = "获取成功",
success = true,
response = result
};
}
/// <summary>
/// 获取问题
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<List<appQuestionResult>>> GetQuestion([FromQuery] appQuestionQuery query)
{
var result = await test_QuestionInfoServices.GetQuestion(query);
return new MessageModel<List<appQuestionResult>>()
{
success = true,
msg = "获取成功",
response = result
};
}
/// <summary>
/// 获取mbti试题
/// </summary>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<List<QuestionMBTI>>> GetQuestionMBTI()
{
var result = await test_QuestionInfoServices.GetQuestionMBTI();
return new MessageModel<List<QuestionMBTI>>()
{
success = true,
msg = "获取成功",
response = result
};
}
/// <summary>
/// 提交
/// </summary>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<MessageModel<bool>> SavePsych([FromBody] SavePsychQuery query)
{
var result = await test_PsychMeasurementInfoServices.SavePsych(query);
return new MessageModel<bool>()
{
success = result,
msg = result == true ? "提交成功" : "提交失败",
response = result
};
}
/// <summary>
/// 提交 霍兰德和MBTI
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<MessageModel<bool>> SaveHolland(SaveHollandQuery query)
{
var result = await test_PsychMeasurementInfoServices.SaveHolland(query);
return new MessageModel<bool>()
{
success = result,
msg = result == true ? "提交成功" : "提交失败",
response = result
};
}
/// <summary>
/// 获取学生发展
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<ShowPsychologicalResult>> GetPsychDetail([FromQuery] ResultLookQuery query)
{
var result = await test_PsychMeasurementInfoServices.GetPsychDetail(query);
return new MessageModel<ShowPsychologicalResult>()
{
success = true,
msg = "获取成功",
response = result
};
}
/// <summary>
/// 获取霍兰德测评结果
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<TagtestingHollandResult>> GetHollandResult([FromQuery] ResultLookQuery query)
{
var result = await test_PsychMeasurementInfoServices.GetHollandResult(query);
return new MessageModel<TagtestingHollandResult>()
{
success = true,
msg = "获取成功",
response = result
};
}
/// <summary>
/// 获取MBTI测评结果
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<UserResult>> GetMBTIResult([FromQuery] ResultLookQuery query)
{
var result = await test_PsychMeasurementInfoServices.GetMBTIResult(query);
return new MessageModel<UserResult>()
{
success = true,
msg = "获取成功",
response = result
};
}
/// <summary>
/// 学科探索 结果
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<SubjectEvBillDTO>> SubjectChartRadar([FromQuery] ResultLookQuery query)
{
return await test_PsychMeasurementInfoServices.SubjectChartRadar(query);
}
/// <summary>
/// 传入用户Id 获取霍兰德测评状态
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<string>> GetHollandStatus([FromQuery] IdQuery query)
{
return await test_PsychMeasurementInfoServices.GetHollandStatus(query);
}
/// <summary>
/// 传入用户Id 获取学科探索测评状态
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<bool>> GetSubjectSelectStatus([FromQuery] IdQuery query)
{
return await test_PsychMeasurementInfoServices.GetSubjectSelectStatus(query);
}
/// <summary>
/// 获取我的自选科目
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<string>> GetSubjectSelect([FromQuery] IdQuery query)
{
return await v_SubjectSelectServices.GetSubjectSelect(query);
}
/// <summary>
/// 保存我的选科
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<MessageModel<bool>> SaveSubjectSelect([FromBody] SubjectSelectQuery query)
{
return await v_SubjectSelectServices.SaveSubjectSelect(query);
}
/// <summary>
/// 根据标签推荐选科
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<string>> GetSubjectSelectByTag([FromQuery] ByTagSubjectSelectQuery query)
{
return await t_EnrollmentPlanedescServices.GetSubjectSelectByTag(query);
}
/// <summary>
/// 获取测评最新周期Id
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<CycleInfoResult>> GetReportCycleInfo([FromQuery] IdQuery query)
{
return await test_PsychMeasurementInfoServices.GetReportCycleInfo(query);
}
/// <summary>
/// 获取三种推荐选科
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
//[Authorize]
public async Task<MessageModel<List<SubjectSelectResult>>> GetSubjectSelectResult([FromQuery] NewSubjectQuery query)
{
return await test_PsychMeasurementInfoServices.GetSubjectSelectResult(query);
}
/// <summary>
/// 根绝霍兰德获取推荐选科
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
//[Authorize]
public async Task<MessageModel<string>> GetHollandSubject([FromQuery]HollandSubjectQuery query)
{
return await test_PsychMeasurementInfoServices.GetHollandSubject(query);
}
}
}

View File

@ -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;
}
/// <summary>
/// 获取收藏和对比
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<UniversityCollectionResult>>> GetUniversityCollection([FromQuery] UniversityCollectionQuery query)
{
return await d_UniversityCollectionServices.GetUniversityCollection(query);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<bool>> DeleteCollection(UniversityCollectionAddQuery query)
{
return await d_UniversityCollectionServices.DeleteCollection(query);
}
/// <summary>
/// 添加收藏、对比
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<bool>> AddCollection([FromBody] UniversityCollectionAddQuery query)
{
return await d_UniversityCollectionServices.AddCollection(query);
}
/// <summary>
/// 获取院校对比结果 传Ids
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<List<UniversitycontrastResult>>> GetUniversityContrasts([FromBody] IdQuery query)
{
return await d_UniversityCollectionServices.GetUniversityContrasts(query);
}
/// <summary>
/// 获取搜索学校
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<IdNameResult>>> GetUniversitList([FromQuery] NameQuery query)
{
return await d_UniversityServices.GetUniversitList(query);
}
/// <summary>
/// 报告 获取我喜欢的院校
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<UniversityCollectionByMapResult>>> GetUniversityMap([FromQuery] IdQuery query)
{
return await d_UniversityCollectionServices.GetUniversityMap(query);
}
}
}

View File

@ -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;
}
/// <summary>
/// 获取Vip卡列表
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<VipCardTypeResult>>> GetVipCardTypeList()
{
var result = await v_VipCardTypeServices.GetVipCardTypeList();
return new MessageModel<List<VipCardTypeResult>>()
{
success = true,
msg = "获取成功",
response = result
};
}
/// <summary>
/// 绑定卡
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<MessageModel<bool>> BindCardInfo(VipCardQuery query)
{
return await v_VipCardInfoServices.BindCardInfo(query);
}
/// <summary>
/// 获取vip信息 传用户Id
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
[Authorize]
public async Task<MessageModel<VipInfoResult>> GetVipInfo([FromQuery] IdQuery query)
{
return await v_VipCardInfoServices.GetVipInfo(query);
}
}
}

View File

@ -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;
}
/// <summary>
/// 专业分类列表(二级) 传Id 1本科 2 专科
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<IdNameResult>>> GetMajorClassListByType([FromQuery] IdQuery query)
{
var result = await d_MajorClassServices.GetMajorClassListByType(query);
return new MessageModel<List<IdNameResult>>()
{
success = result.Count > 0,
msg = result.Count > 0 ? "获取成功" : "获取失败",
response = result
};
}
/// <summary>
/// 根据分数获取个性推荐学校
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<UniversityResult>>> GetRecommendUniversity([FromQuery] RecommendUniversityQuery query)
{
var result = await t_EnrollmentPlanedescServices.GetRecommendUniversity(query);
return new MessageModel<PageModel<UniversityResult>>()
{
response = result,
success = true,
msg = "获取成功"
};
}
/// <summary>
/// 懒人模式
/// 办学性质
/// 高校级别
/// 专业ids
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<List<UniversityEnrollmentPlanLazyResult>>> GetEnrollmentLazyByPage([FromBody] LazyEnrollmentPlaneQuery query)
{
return await t_EnrollmentPlanedescServices.GetEnrollmentLazyByPage(query);
}
/// <summary>
/// 根据计划Ids 获取招生计划
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<PageModel<PlanDescList>>> GetPlanByUniversity([FromBody] PlanDetailQuery query)
{
return await t_EnrollmentPlanedescServices.GetPlanByUniversity(query);
}
/// <summary>
/// 根据年份省份获取批次
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<IdNameResult>>> GetBatchByAreaAndYear([FromQuery] BatchQuery query)
{
return await t_EnrollmentPlanedescServices.GetBatchByAreaAndYear(query);
}
/// <summary>
/// 冲稳保获取推荐学校专业
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<List<CWBEnrollmentPlanResult>>> GetEnrollmentCWBByPage([FromBody] CWBEnrollmentPlaneQuery query)
{
return await t_EnrollmentPlanedescServices.GetEnrollmentCWBByPage(query);
}
/// <summary>
/// 冲稳保详情
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<PageModel<UniversityEnrollmentPlanResult>>> GetCWBUniversityDetail([FromBody] CWBUniversityDetailQuery query)
{
return await t_EnrollmentPlanedescServices.GetCWBUniversityDetail(query);
}
/// <summary>
/// 霍兰德推荐学校专业
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<List<TagEnrollmentPlanResult>>> GetEnrollmentTagByPage([FromBody] TagEnrollmentPlaneQuery query)
{
return await t_EnrollmentPlanedescServices.GetEnrollmentTagByPage(query);
}
/// <summary>
/// 获取分析结果录取概率 获取之后保存一下
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<UniversityProbabilityResult>> GetUniversityProbability([FromQuery] UniversityProbabilityQuery query)
{
return await t_EnrollmentPlanedescServices.GetUniversityProbability(query);
}
/// <summary>
/// 获取概率历史记录列表
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<ProbabilityResult>>> GetProbabilityResult([FromQuery] ProbabilityQuery query)
{
return await t_EnrollmentPlanedescServices.GetProbabilityResult(query);
}
/// <summary>
/// 保存志愿表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<bool>> SaveVolunteerTable([FromBody] VolunteerTableQuery query)
{
return await t_EnrollmentPlanedescServices.SaveVolunteerTable(query);
}
/// <summary>
/// 获取个人志愿列表 传Id
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<VolunteerTableListResult>>> GetVolunteerTableList([FromQuery] IdQuery query)
{
return await t_EnrollmentPlanedescServices.GetVolunteerTableList(query);
}
/// <summary>
/// 获取志愿表详情 传Id
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<VolunteerTableResult>>> GetVolunteerTableDetail([FromQuery] IdQuery query)
{
return await t_EnrollmentPlanedescServices.GetVolunteerTableDetail(query);
}
/// <summary>
/// 删除志愿表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<bool>> DeleteVolunteerTable([FromBody] IdQuery query)
{
return await t_EnrollmentPlanedescServices.DeleteVolunteerTable(query);
}
///// <summary>
///// 保存志愿表 霍兰德专用 弃用
///// </summary>
///// <param name="query"></param>
///// <returns></returns>
//[HttpPost]
//public async Task<MessageModel<bool>> SaveHollandVolunteer([FromBody] HollandVolunteerTableQuery query)
//{
// return await t_EnrollmentPlanedescServices.SaveHollandVolunteer(query);
//}
/// <summary>
/// 获取一键生成的志愿表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<List<SimuVolunteerTableResult>>> GetAutoVolunteerTableDetail([FromBody] VolunteerTableQuery query)
{
return await t_EnrollmentPlanedescServices.GetAutoVolunteerTableDetail(query);
}
/// <summary>
/// 获取霍兰德一键生成的志愿表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<List<SimuVolunteerTableResult>>> GetHollandVolunteerTableDetail([FromBody] HollandVolunteerTableQuery query)
{
return await t_EnrollmentPlanedescServices.GetHollandVolunteerTableDetail(query);
}
/// <summary>
/// 获取喜欢的院校
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<LikeSchoolMajor>>> GetLikeSchoolMajor([FromQuery] IdQuery query)
{
return await t_EnrollmentPlanedescServices.GetLikeSchoolMajor(query);
}
/// <summary>
/// 专业规划
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<MajorPlanResult>>> GetMajorPlanClaim([FromQuery] CustomerQuery query)
{
return await t_EnrollmentPlanedescServices.GetMajorPlanClaim(query);
}
/// <summary>
/// 获取批次
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<List<IdNameResult>>> GetBatchByYearArea([FromBody] YearAreaQuery query)
{
return await t_EnrollmentPlanedescServices.GetBatchByYearArea(query);
}
}
}

View File

@ -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<V_OrderInfo> logger;
public WeixinPayController(IV_OrderInfoRepository IV_OrderInfoRepository
, IV_CustomerInfoRepository IV_CustomerInfoRepository
, IV_VipCardInfoRepository IV_VipCardInfoRepository
, IV_VipCardTypeRepository IV_VipCardTypeRepository
, ILogger<V_OrderInfo> loggers)
{
v_OrderInfoRepository = IV_OrderInfoRepository;
v_CustomerInfoRepository = IV_CustomerInfoRepository;
v_VipCardInfoRepository = IV_VipCardInfoRepository;
v_VipCardTypeRepository = IV_VipCardTypeRepository;
logger = loggers;
}
/// <summary>
/// 下订单
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<WeixinPayResult> 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;
}
/// <summary>
/// 支付返回值
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<IActionResult> 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("统一支付接口中缺少必填参数openidtrade_type为JSAPI时openid为必填参数");
}
if (inputObj.GetValue("trade_type").ToString() == "NATIVE" && !inputObj.IsSet("product_id"))
{
throw new Exception("统一支付接口中缺少必填参数product_idtrade_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;
}
/// <summary>
/// 生成随机数
/// </summary>
/// <returns></returns>
public static string GenerateNonceStr()
{
return Guid.NewGuid().ToString().Replace("-", "");
}
/// <summary>
/// POST请求
/// </summary>
/// <param name="postData"></param>
/// <param name="url"></param>
/// <param name="contentType">application/xml、application/json、application/text、application/x-www-form-urlencoded</param>
/// <param name="timeOut"></param>
/// <param name="headers"></param>
/// <returns></returns>
public static string HttpPost(string postData, string url, string contentType = null, int timeOut = 30, Dictionary<string, string> 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;
}
}
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.AspNetCore.Mvc;
namespace New_College.Controllers
{
/// <summary>
/// 健康检查
/// </summary>
[Route("[controller]")]
[ApiController]
public class HealthCheckController : ControllerBase
{
/// <summary>
/// 健康检查接口
/// </summary>
/// <returns></returns>
[HttpGet]
public IActionResult Get()
{
return Ok();
}
}
}

View File

@ -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
{
/// <summary>
/// 图片管理
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class ImgController : Controller
{
// GET: api/Download
/// <summary>
/// 下载图片(支持中文字符)
/// </summary>
/// <param name="environment"></param>
/// <returns></returns>
[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);
}
/// <summary>
/// 上传图片,多文件,可以使用 postman 测试,
/// 如果是单文件,可以 参数写 IFormFile file1
/// </summary>
/// <param name="environment"></param>
/// <returns></returns>
[HttpPost]
[Authorize]
[Route("/images/Upload/Pic")]
public async Task<MessageModel<string>> InsertPicture([FromServices]IWebHostEnvironment environment)
{
var data = new MessageModel<string>();
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<string>()
{
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)
{
}
/// <summary>
/// 上传图片
/// </summary>
/// <param name="environment"></param>
/// <returns></returns>
[HttpPost("UploadImg")]
public async Task<MessageModel<string>> UploadImg([FromServices] IWebHostEnvironment environment)
{
var data = new MessageModel<string>();
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<string>()
{
response = reportImage,
msg = "上传失败",
success = false,
};
}
data = new MessageModel<string>()
{
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;
}
}
}

View File

@ -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
{
/// <summary>
/// 登录管理【无权限】
/// </summary>
[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;
/// <summary>
/// 构造函数注入
/// </summary>
/// <param name="sysUserInfoServices"></param>
/// <param name="userRoleServices"></param>
/// <param name="roleServices"></param>
/// <param name="requirement"></param>
/// <param name="roleModulePermissionServices"></param>
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种方法
/// <summary>
/// 获取JWT的方法1
/// </summary>
/// <param name="name"></param>
/// <param name="pass"></param>
/// <returns></returns>
[HttpGet]
[Route("Token")]
public async Task<MessageModel<string>> 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<string>()
{
success = suc,
msg = suc ? "获取成功" : "获取失败",
response = jwtStr
};
}
/// <summary>
/// 获取JWT的方法2给Nuxt提供
/// </summary>
/// <param name="name"></param>
/// <param name="pass"></param>
/// <returns></returns>
[HttpGet]
[Route("GetTokenNuxt")]
public MessageModel<string> 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<string>()
{
success = suc,
msg = suc ? "获取成功" : "获取失败",
response = jwtStr
};
}
#endregion
/// <summary>
/// 获取JWT的方法3整个系统主要方法
/// </summary>
/// <param name="name"></param>
/// <param name="pass"></param>
/// <returns></returns>
[HttpGet]
[Route("JWTToken3.0")]
public async Task<MessageModel<TokenInfoViewModel>> GetJwtToken3(string name = "", string pass = "")
{
string jwtStr = string.Empty;
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(pass))
{
return new MessageModel<TokenInfoViewModel>()
{
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<Claim> {
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<TokenInfoViewModel>()
{
success = true,
msg = "获取成功",
response = token
};
}
else
{
return new MessageModel<TokenInfoViewModel>()
{
success = false,
msg = "认证失败",
};
}
}
/// <summary>
/// 请求刷新Token以旧换新
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
[HttpGet]
[Route("RefreshToken")]
public async Task<MessageModel<TokenInfoViewModel>> RefreshToken(string token = "")
{
string jwtStr = string.Empty;
if (string.IsNullOrEmpty(token))
{
return new MessageModel<TokenInfoViewModel>()
{
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<Claim> {
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<TokenInfoViewModel>()
{
success = true,
msg = "获取成功",
response = refreshToken
};
}
}
return new MessageModel<TokenInfoViewModel>()
{
success = false,
msg = "认证失败!",
};
}
/// <summary>
/// 获取JWT的方法4给 JSONP 测试
/// </summary>
/// <param name="callBack"></param>
/// <param name="id"></param>
/// <param name="sub"></param>
/// <param name="expiresSliding"></param>
/// <param name="expiresAbsoulute"></param>
/// <returns></returns>
[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);
}
/// <summary>
/// 测试 MD5 加密字符串
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
[HttpGet]
[Route("Md5Password")]
public string Md5Password(string password = "")
{
return MD5Helper.MD5Encrypt32(password);
}
}
}

View File

@ -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
{
/// <summary>
/// 接口管理
/// </summary>
[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;
}
/// <summary>
/// 获取全部接口api
/// </summary>
/// <param name="page"></param>
/// <param name="key"></param>
/// <returns></returns>
// GET: api/User
[HttpGet]
public async Task<MessageModel<PageModel<Modules>>> Get(int page = 1, string key = "")
{
if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
{
key = "";
}
int intPageSize = 50;
Expression<Func<Modules, bool>> 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<PageModel<Modules>>()
{
msg = "获取成功",
success = data.dataCount >= 0,
response = data
};
}
// GET: api/User/5
[HttpGet("{id}")]
public string Get(string id)
{
return "value";
}
/// <summary>
/// 添加一条接口信息
/// </summary>
/// <param name="module"></param>
/// <returns></returns>
// POST: api/User
[HttpPost]
public async Task<MessageModel<string>> Post([FromBody] Modules module)
{
var data = new MessageModel<string>();
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;
}
/// <summary>
/// 更新接口信息
/// </summary>
/// <param name="module"></param>
/// <returns></returns>
// PUT: api/User/5
[HttpPut]
public async Task<MessageModel<string>> Put([FromBody] Modules module)
{
var data = new MessageModel<string>();
if (module != null && module.Id > 0)
{
data.success = await _moduleServices.Update(module);
if (data.success)
{
data.msg = "更新成功";
data.response = module?.Id.ObjToString();
}
}
return data;
}
/// <summary>
/// 删除一条接口
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// DELETE: api/ApiWithActions/5
[HttpDelete]
public async Task<MessageModel<string>> Delete(int id)
{
var data = new MessageModel<string>();
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;
}
}
}

View File

@ -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<ChatHub> _hubContext;
private readonly IWebHostEnvironment _env;
public MonitorController(IHubContext<ChatHub> hubContext, IWebHostEnvironment env)
{
_hubContext = hubContext;
_env = env;
}
/// <summary>
/// 服务器配置信息
/// </summary>
/// <returns></returns>
[HttpGet]
public MessageModel<ServerViewModel> Server()
{
return new MessageModel<ServerViewModel>()
{
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)
}
};
}
/// <summary>
/// SignalR send data
/// </summary>
/// <returns></returns>
// GET: api/Logs
[HttpGet]
public MessageModel<List<LogInfo>> Get()
{
_hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()).Wait();
return new MessageModel<List<LogInfo>>()
{
msg = "获取成功",
success = true,
response = null
};
}
[HttpGet]
public MessageModel<RequestApiWeekView> GetRequestApiinfoByWeek()
{
return new MessageModel<RequestApiWeekView>()
{
msg = "获取成功",
success = true,
response = LogLock.RequestApiinfoByWeek()
};
}
[HttpGet]
public MessageModel<AccessApiDateView> GetAccessApiByDate()
{
return new MessageModel<AccessApiDateView>()
{
msg = "获取成功",
success = true,
response = LogLock.AccessApiByDate()
};
}
[HttpGet]
public MessageModel<AccessApiDateView> GetAccessApiByHour()
{
return new MessageModel<AccessApiDateView>()
{
msg = "获取成功",
success = true,
response = LogLock.AccessApiByHour()
};
}
[HttpGet]
public MessageModel<List<UserAccessModel>> GetAccessLogs([FromServices]IWebHostEnvironment environment)
{
var Logs = JsonConvert.DeserializeObject<List<UserAccessModel>>("[" + 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<List<UserAccessModel>>()
{
msg = "获取成功",
success = true,
response = Logs
};
}
}
}

View File

@ -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
{
/// <summary>
/// 菜单管理
/// </summary>
[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;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="permissionServices"></param>
/// <param name="moduleServices"></param>
/// <param name="roleModulePermissionServices"></param>
/// <param name="userRoleServices"></param>
/// <param name="httpContext"></param>
/// <param name="user"></param>
/// <param name="requirement"></param>
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;
}
/// <summary>
/// 获取菜单
/// </summary>
/// <param name="page"></param>
/// <param name="key"></param>
/// <returns></returns>
// GET: api/User
[HttpGet]
public async Task<MessageModel<PageModel<Permission>>> Get(int page = 1, string key = "")
{
PageModel<Permission> permissions = new PageModel<Permission>();
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<int> pidarr = new List<int>
{
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<PageModel<Permission>>()
{
msg = "获取成功",
success = permissions.dataCount >= 0,
response = permissions
};
}
/// <summary>
/// 查询树形 Table
/// </summary>
/// <param name="f">父节点</param>
/// <param name="key">关键字</param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task<MessageModel<List<Permission>>> GetTreeTable(int f = 0, string key = "")
{
List<Permission> permissions = new List<Permission>();
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<int> pidarr = new List<int> { };
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<List<Permission>>()
{
msg = "获取成功",
success = permissions.Count >= 0,
response = permissions
};
}
// GET: api/User/5
[HttpGet("{id}")]
public string Get(string id)
{
return "value";
}
/// <summary>
/// 添加一个菜单
/// </summary>
/// <param name="permission"></param>
/// <returns></returns>
// POST: api/User
[HttpPost]
public async Task<MessageModel<string>> Post([FromBody] Permission permission)
{
var data = new MessageModel<string>();
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;
}
/// <summary>
/// 保存菜单权限分配
/// </summary>
/// <param name="assignView"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<string>> Assign([FromBody] AssignView assignView)
{
var data = new MessageModel<string>();
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;
}
/// <summary>
/// 获取菜单树
/// </summary>
/// <param name="pid"></param>
/// <param name="needbtn"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PermissionTree>> GetPermissionTree(int pid = 0, bool needbtn = false)
{
var data = new MessageModel<PermissionTree>();
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;
}
/// <summary>
/// 获取路由树
/// </summary>
/// <param name="uid"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<NavigationBar>> GetNavigationBar(int uid)
{
var data = new MessageModel<NavigationBar>();
var uidInHttpcontext1 = 0;
var roleIds = new List<int>();
// 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;
}
/// <summary>
/// 通过角色获取菜单【无权限】
/// </summary>
/// <param name="rid"></param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task<MessageModel<AssignShow>> GetPermissionIdByRoleId(int rid = 0)
{
var data = new MessageModel<AssignShow>();
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<string> assignbtns = new List<string>();
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;
}
/// <summary>
/// 更新菜单
/// </summary>
/// <param name="permission"></param>
/// <returns></returns>
// PUT: api/User/5
[HttpPut]
public async Task<MessageModel<string>> Put([FromBody] Permission permission)
{
var data = new MessageModel<string>();
if (permission != null && permission.Id > 0)
{
data.success = await _permissionServices.Update(permission);
if (data.success)
{
data.msg = "更新成功";
data.response = permission?.Id.ObjToString();
}
}
return data;
}
/// <summary>
/// 删除菜单
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// DELETE: api/ApiWithActions/5
[HttpDelete]
public async Task<MessageModel<string>> Delete(int id)
{
var data = new MessageModel<string>();
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<int> pids { get; set; }
public int rid { get; set; }
}
public class AssignShow
{
public List<int> permissionids { get; set; }
public List<string> assignbtns { get; set; }
}
}

View File

@ -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
{
/// <summary>
/// 角色管理
/// </summary>
[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;
}
/// <summary>
/// 获取全部角色
/// </summary>
/// <param name="page"></param>
/// <param name="key"></param>
/// <returns></returns>
// GET: api/User
[HttpGet]
public async Task<MessageModel<PageModel<Role>>> 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<PageModel<Role>>()
{
msg = "获取成功",
success = data.dataCount >= 0,
response = data
};
}
// GET: api/User/5
[HttpGet("{id}")]
public string Get(string id)
{
return "value";
}
/// <summary>
/// 添加角色
/// </summary>
/// <param name="role"></param>
/// <returns></returns>
// POST: api/User
[HttpPost]
public async Task<MessageModel<string>> Post([FromBody] Role role)
{
var data = new MessageModel<string>();
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;
}
/// <summary>
/// 更新角色
/// </summary>
/// <param name="role"></param>
/// <returns></returns>
// PUT: api/User/5
[HttpPut]
public async Task<MessageModel<string>> Put([FromBody] Role role)
{
var data = new MessageModel<string>();
if (role != null && role.Id > 0)
{
data.success = await _roleServices.Update(role);
if (data.success)
{
data.msg = "更新成功";
data.response = role?.Id.ObjToString();
}
}
return data;
}
/// <summary>
/// 删除角色
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// DELETE: api/ApiWithActions/5
[HttpDelete]
public async Task<MessageModel<string>> Delete(int id)
{
var data = new MessageModel<string>();
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;
}
}
}

View File

@ -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;
/// <summary>
/// 省市区操作类
/// </summary>
public SysRegionController(ISysRegionServices sysRegionRepository, IUnitOfWork unitOf, IMapper mapper)
{
this._regionRepository = sysRegionRepository;
this._unitOfWork = unitOf;
this._mapper = mapper;
}
/// <summary>
/// 根据ID获取
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<SysRegion>> GetSingle(int id)
{
try
{
var regions = (await this._regionRepository.QueryById(id));
return new MessageModel<SysRegion>()
{
msg = "success",
success = true,
//url = "",
response = regions
};
}
catch (Exception ex)
{
return new MessageModel<SysRegion>()
{
success = false,
msg = "Error",
status = 500
};
}
}
/// <summary>
/// 根据level和parentId获取省市区列表信息
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<SysRegionView>>> GetListByParentId(string Id)
{
try
{
var regionlist = (await _regionRepository.GetListByParentId(Id));
return new MessageModel<List<SysRegionView>>()
{
msg = "success",
success = true,
response = _mapper.Map<List<SysRegionView>>(regionlist.ToList())
};
}
catch (Exception ex)
{
return new MessageModel<List<SysRegionView>>()
{
msg = "error",
success = false
};
}
}
/// <summary>
/// 获取省市区
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<List<SysRegionResult>>> GetRegionList([FromQuery] SysRegionQuery query)
{
try
{
var regionlist = (await _regionRepository.GetRegionList(query));
return new MessageModel<List<SysRegionResult>>()
{
msg = "success",
success = true,
response = _mapper.Map<List<SysRegionResult>>(regionlist.ToList())
};
}
catch (Exception ex)
{
return new MessageModel<List<SysRegionResult>>()
{
msg = "error",
success = false
};
}
}
}
}

View File

@ -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;
}
/// <summary>
/// 分页获取
/// </summary>
/// <param name="page"></param>
/// <param name="key"></param>
/// <returns></returns>
// GET: api/Buttons/5
[HttpGet]
public async Task<MessageModel<PageModel<TasksQz>>> Get(int page = 1, string key = "")
{
if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
{
key = "";
}
int intPageSize = 50;
Expression<Func<TasksQz, bool>> 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<PageModel<TasksQz>>()
{
msg = "获取成功",
success = data.dataCount >= 0,
response = data
};
}
/// <summary>
/// 添加计划任务
/// </summary>
/// <param name="tasksQz"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<string>> Post([FromBody] TasksQz tasksQz)
{
var data = new MessageModel<string>();
var id = (await _tasksQzServices.Add(tasksQz));
data.success = id > 0;
if (data.success)
{
data.response = id.ObjToString();
data.msg = "添加成功";
}
return data;
}
/// <summary>
/// 修改计划任务
/// </summary>
/// <param name="tasksQz"></param>
/// <returns></returns>
[HttpPut]
public async Task<MessageModel<string>> Put([FromBody] TasksQz tasksQz)
{
var data = new MessageModel<string>();
if (tasksQz != null && tasksQz.Id > 0)
{
data.success = await _tasksQzServices.Update(tasksQz);
if (data.success)
{
data.msg = "更新成功";
data.response = tasksQz?.Id.ObjToString();
}
}
return data;
}
/// <summary>
/// 启动计划任务
/// </summary>
/// <param name="jobId"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<string>> StartJob(int jobId)
{
var data = new MessageModel<string>();
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;
}
/// <summary>
/// 停止一个计划任务
/// </summary>
/// <param name="jobId"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<string>> StopJob(int jobId)
{
var data = new MessageModel<string>();
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;
}
/// <summary>
/// 重启一个计划任务
/// </summary>
/// <param name="jobId"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<string>> ReCovery(int jobId)
{
var data = new MessageModel<string>();
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;
}
}
}

View File

@ -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
{
/// <summary>
/// 类别管理【无权限】
/// </summary>
[Route("api/[controller]")]
[ApiController]
[AllowAnonymous]
public class TopicController : ControllerBase
{
readonly ITopicServices _topicServices;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="topicServices"></param>
public TopicController(ITopicServices topicServices)
{
_topicServices = topicServices;
}
/// <summary>
/// 获取Tibug所有分类
/// </summary>
/// <returns></returns>
// GET: api/Topic
[HttpGet]
public async Task<MessageModel<List<Topic>>> Get()
{
var data = new MessageModel<List<Topic>> {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)
{
}
}
}

View File

@ -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
{
/// <summary>
/// Tibug 管理
/// </summary>
[Route("api/[controller]/[action]")]
[ApiController]
[Authorize(Permissions.Name)]
public class TopicDetailController : ControllerBase
{
readonly ITopicServices _topicServices;
readonly ITopicDetailServices _topicDetailServices;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="topicServices"></param>
/// <param name="topicDetailServices"></param>
public TopicDetailController(ITopicServices topicServices, ITopicDetailServices topicDetailServices)
{
_topicServices = topicServices;
_topicDetailServices = topicDetailServices;
}
/// <summary>
/// 获取Bug数据列表带分页
/// 【无权限】
/// </summary>
/// <param name="page">页数</param>
/// <param name="tname">专题类型</param>
/// <param name="key">关键字</param>
/// <param name="intPageSize"></param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task<MessageModel<PageModel<TopicDetail>>> 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<PageModel<TopicDetail>>()
{
msg = "获取成功",
success = data.dataCount >= 0,
response = data
};
}
/// <summary>
/// 获取详情【无权限】
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// GET: api/TopicDetail/5
[HttpGet("{id}")]
[AllowAnonymous]
public async Task<MessageModel<TopicDetail>> Get(int id)
{
var data = new MessageModel<TopicDetail>();
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;
}
/// <summary>
/// 添加一个 BUG 【无权限】
/// </summary>
/// <param name="topicDetail"></param>
/// <returns></returns>
// POST: api/TopicDetail
[HttpPost]
[AllowAnonymous]
public async Task<MessageModel<string>> Post([FromBody] TopicDetail topicDetail)
{
var data = new MessageModel<string>();
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;
}
/// <summary>
/// 更新 bug
/// </summary>
/// <param name="topicDetail"></param>
/// <returns></returns>
// PUT: api/TopicDetail/5
[HttpPut]
public async Task<MessageModel<string>> Update([FromBody] TopicDetail topicDetail)
{
var data = new MessageModel<string>();
if (topicDetail != null && topicDetail.Id > 0)
{
data.success = await _topicDetailServices.Update(topicDetail);
if (data.success)
{
data.msg = "更新成功";
data.response = topicDetail?.Id.ObjToString();
}
}
return data;
}
/// <summary>
/// 删除 bug
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// DELETE: api/ApiWithActions/5
[HttpDelete]
public async Task<MessageModel<string>> Delete(int id)
{
var data = new MessageModel<string>();
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;
}
}
}

View File

@ -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<MessageModel<IEnumerable<string>>> Get()
{
List<string> returnMsg = new List<string>() { };
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<IEnumerable<string>>()
{
success = true,
msg = "操作完成",
response = returnMsg
};
}
// GET: api/Transaction/5
[HttpGet("{id}")]
public async Task<MessageModel<string>> 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)
{
}
/// <summary>
/// 测试事务在AOP中的使用
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpDelete("{id}")]
public async Task<bool> Delete(int id)
{
return await _guestbookServices.TestTranInRepositoryAOP();
}
}
}

View File

@ -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
{
/// <summary>
/// 用户管理
/// </summary>
[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<UserController> _logger;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="unitOfWork"></param>
/// <param name="sysUserInfoServices"></param>
/// <param name="userRoleServices"></param>
/// <param name="roleServices"></param>
/// <param name="user"></param>
/// <param name="logger"></param>
public UserController(IUnitOfWork unitOfWork, ISysUserInfoServices sysUserInfoServices, IUserRoleServices userRoleServices, IRoleServices roleServices, IUser user, ILogger<UserController> logger)
{
_unitOfWork = unitOfWork;
_sysUserInfoServices = sysUserInfoServices;
_userRoleServices = userRoleServices;
_roleServices = roleServices;
_user = user;
_logger = logger;
}
/// <summary>
/// 获取全部用户
/// </summary>
/// <param name="page"></param>
/// <param name="key"></param>
/// <returns></returns>
// GET: api/User
[HttpGet]
public async Task<MessageModel<PageModel<sysUserInfo>>> 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<PageModel<sysUserInfo>>()
{
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
/// <summary>
/// 获取用户详情根据token
/// 【无权限】
/// </summary>
/// <param name="token">令牌</param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task<MessageModel<sysUserInfo>> GetInfoByToken(string token)
{
var data = new MessageModel<sysUserInfo>();
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;
}
/// <summary>
/// 添加一个用户
/// </summary>
/// <param name="sysUserInfo"></param>
/// <returns></returns>
// POST: api/User
[HttpPost]
public async Task<MessageModel<string>> Post([FromBody] sysUserInfo sysUserInfo)
{
var data = new MessageModel<string>();
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;
}
/// <summary>
/// 更新用户与角色
/// </summary>
/// <param name="sysUserInfo"></param>
/// <returns></returns>
// PUT: api/User/5
[HttpPut]
public async Task<MessageModel<string>> Put([FromBody] sysUserInfo sysUserInfo)
{
// 这里使用事务处理
var data = new MessageModel<string>();
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<UserRole>();
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;
}
/// <summary>
/// 删除用户
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// DELETE: api/ApiWithActions/5
[HttpDelete]
public async Task<MessageModel<string>> Delete(int id)
{
var data = new MessageModel<string>();
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;
}
}
}

View File

@ -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
{
/// <summary>
/// 用户角色关系
/// </summary>
[Produces("application/json")]
[Route("api/[controller]/[action]")]
[ApiController]
[Authorize(Permissions.Name)]
public class UserRoleController : Controller
{
readonly ISysUserInfoServices _sysUserInfoServices;
readonly IUserRoleServices _userRoleServices;
readonly IRoleServices _roleServices;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="sysUserInfoServices"></param>
/// <param name="userRoleServices"></param>
/// <param name="roleServices"></param>
public UserRoleController(ISysUserInfoServices sysUserInfoServices, IUserRoleServices userRoleServices, IRoleServices roleServices)
{
this._sysUserInfoServices = sysUserInfoServices;
this._userRoleServices = userRoleServices;
this._roleServices = roleServices;
}
/// <summary>
/// 新建用户
/// </summary>
/// <param name="loginName"></param>
/// <param name="loginPwd"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<sysUserInfo>> AddUser(string loginName, string loginPwd)
{
return new MessageModel<sysUserInfo>()
{
success = true,
msg = "添加成功",
response = await _sysUserInfoServices.SaveUserInfo(loginName, loginPwd)
};
}
/// <summary>
/// 新建Role
/// </summary>
/// <param name="roleName"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<Role>> AddRole(string roleName)
{
return new MessageModel<Role>()
{
success = true,
msg = "添加成功",
response = await _roleServices.SaveRole(roleName)
};
}
/// <summary>
/// 新建用户角色关系
/// </summary>
/// <param name="uid"></param>
/// <param name="rid"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<UserRole>> AddUserRole(int uid, int rid)
{
return new MessageModel<UserRole>()
{
success = true,
msg = "添加成功",
response = await _userRoleServices.SaveUserRole(uid, rid)
};
}
}
}

View File

@ -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
{
/// <summary>
/// Values控制器
/// </summary>
[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;
/// <summary>
/// ValuesController
/// </summary>
/// <param name="blogArticleServices"></param>
/// <param name="mapper"></param>
/// <param name="advertisementServices"></param>
/// <param name="love"></param>
/// <param name="roleModulePermissionServices"></param>
/// <param name="user"></param>
/// <param name="passwordLibServices"></param>
/// <param name="blogApi"></param>
/// <param name="doubanApi"></param>
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;
}
/// <summary>
/// Get方法
/// </summary>
/// <returns></returns>
// GET api/values
[HttpGet]
[AllowAnonymous]
public async Task<MessageModel<ResponseEnum>> Get()
{
var data = new MessageModel<ResponseEnum>();
/*
* sql
*/
var queryBySql = await _blogArticleServices.QuerySql("SELECT bsubmitter,btitle,bcontent,bCreateTime FROM BlogArticle WHERE bID>5");
/*
* sql
*
* SQL@bID:5
* @bsubmitter:laozhang619
* @IsDeleted:False
* SQLUPDATE `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;
}
/// <summary>
/// Get(int id)方法
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
// GET api/values/5
[HttpGet("{id}")]
[AllowAnonymous]
//[TypeFilter(typeof(DeleteSubscriptionCache),Arguments =new object[] { "1"})]
[TypeFilter(typeof(UseServiceDIAttribute), Arguments = new object[] { "laozhang" })]
public ActionResult<string> Get(int id)
{
var loveu = _love.SayLoveU();
return "value";
}
/// <summary>
/// 测试参数是必填项
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("/api/values/RequiredPara")]
public string RequiredP([Required]string id)
{
return id;
}
/// <summary>
/// 通过 HttpContext 获取用户信息
/// </summary>
/// <param name="ClaimType">声明类型,默认 jti </param>
/// <returns></returns>
[HttpGet]
[Route("/api/values/UserInfo")]
public MessageModel<List<string>> GetUserInfo(string ClaimType = "jti")
{
var getUserInfoByToken = _user.GetUserInfoFromToken(ClaimType);
return new MessageModel<List<string>>()
{
success = _user.IsAuthenticated(),
msg = _user.IsAuthenticated() ? _user.Name.ObjToString() : "未登录",
response = _user.GetClaimValueByType(ClaimType)
};
}
/// <summary>
/// to redirect by route template name.
/// </summary>
[HttpGet("/api/custom/go-destination")]
[AllowAnonymous]
public void Source()
{
var url = Url.RouteUrl("Destination_Route");
Response.Redirect(url);
}
/// <summary>
/// route with template name.
/// </summary>
/// <returns></returns>
[HttpGet("/api/custom/destination", Name = "Destination_Route")]
[AllowAnonymous]
public string Destination()
{
return "555";
}
/// <summary>
/// 测试 post 一个对象 + 独立参数
/// </summary>
/// <param name="blogArticle">model实体类参数</param>
/// <param name="id">独立参数</param>
[HttpPost]
[AllowAnonymous]
public object Post([FromBody] BlogArticle blogArticle, int id)
{
return Ok(new { success = true, data = blogArticle, id = id });
}
/// <summary>
/// 测试 post 参数
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
[HttpPost]
[Route("TestPostPara")]
[AllowAnonymous]
public object TestPostPara(string name)
{
return Ok(new { success = true, name = name });
}
/// <summary>
/// 测试http请求 RestSharp Get
/// </summary>
/// <returns></returns>
[HttpGet("RestsharpGet")]
[AllowAnonymous]
public TestRestSharpGetDto RestsharpGet()
{
return HttpHelper.GetApi<TestRestSharpGetDto>("http://apk.neters.club/", "api/Blog/DetailNuxtNoPer", "id=1");
}
/// <summary>
/// 测试http请求 RestSharp Post
/// </summary>
/// <returns></returns>
[HttpGet("RestsharpPost")]
[AllowAnonymous]
public TestRestSharpPostDto RestsharpPost()
{
return HttpHelper.PostApi<TestRestSharpPostDto>("http://apk.neters.club/api/Values/TestPostPara?name=老张", new { age = 18 });
}
/// <summary>
/// 测试多库连接
/// </summary>
/// <returns></returns>
[HttpGet("TestMutiDBAPI")]
[AllowAnonymous]
public async Task<object> 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
};
}
/// <summary>
/// 测试http请求 WebApiClient Get
/// </summary>
/// <returns></returns>
[HttpGet("WebApiClientGetAsync")]
[AllowAnonymous]
public async Task<object> WebApiClientGetAsync()
{
int id = 1;
string isbn = "9787544270878";
var doubanVideoDetail = await _doubanApi.VideoDetailAsync(isbn);
return await _blogApi.DetailNuxtNoPerAsync(id);
}
/// <summary>
/// Put方法
/// </summary>
/// <param name="id"></param>
/// <param name="value"></param>
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
/// <summary>
/// Delete方法
/// </summary>
/// <param name="id"></param>
// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}

View File

@ -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<string> Get()
{
return new string[] { "第一版的 apbs" };
}
}
}

View File

@ -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<string> Get()
{
return new string[] { "第二版的 apbs" };
}
}
}

View File

@ -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"]

View File

@ -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
{
/// <summary>
/// 自定义路由 /api/{version}/[controler]/[action]
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class CustomRouteAttribute : RouteAttribute, IApiDescriptionGroupNameProvider
{
/// <summary>
/// 分组名称,是来实现接口 IApiDescriptionGroupNameProvider
/// </summary>
public string GroupName { get; set; }
/// <summary>
/// 自定义路由构造函数,继承基类路由
/// </summary>
/// <param name="actionName"></param>
public CustomRouteAttribute(string actionName = "[action]") : base("/api/{version}/[controller]/" + actionName)
{
}
/// <summary>
/// 自定义版本+路由构造函数,继承基类路由
/// </summary>
/// <param name="actionName"></param>
/// <param name="version"></param>
public CustomRouteAttribute(ApiVersions version, string actionName = "") : base($"/api/{version.ToString()}/[controller]/{actionName}")
{
GroupName = version.ToString();
}
}
}

View File

@ -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>
/// Summary:全局路由权限公约
/// Remarks:目的是针对不同的路由,采用不同的授权过滤器
/// 如果 controller 上不加 [Authorize] 特性,默认都是 Permission 策略
/// 否则,如果想特例其他授权机制的话,需要在 controller 上带上 [Authorize]然后再action上自定义授权即可比如 [Authorize(Roles = "Admin")]
/// </summary>
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] ,根据情况进行权限认证
}
}
}
}
/// <summary>
/// 全局权限过滤器【无效】
/// </summary>
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);
}
}
}

View File

@ -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
{
/// <summary>
/// 全局异常错误日志
/// </summary>
public class GlobalExceptionsFilter : IExceptionFilter
{
private readonly IWebHostEnvironment _env;
private readonly IHubContext<ChatHub> _hubContext;
private readonly ILogger<GlobalExceptionsFilter> _loggerHelper;
public GlobalExceptionsFilter(IWebHostEnvironment env, ILogger<GlobalExceptionsFilter> loggerHelper, IHubContext<ChatHub> 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();
}
/// <summary>
/// 自定义返回格式
/// </summary>
/// <param name="throwMsg"></param>
/// <param name="ex"></param>
/// <returns></returns>
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
{
/// <summary>
/// 生产环境的消息
/// </summary>
public string Message { get; set; }
/// <summary>
/// 开发环境的消息
/// </summary>
public string DevelopmentMessage { get; set; }
}
}

View File

@ -0,0 +1,51 @@
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using Microsoft.AspNetCore.Mvc.Routing;
using System.Linq;
namespace New_College.Filter
{
/// <summary>
/// 全局路由前缀公约
/// </summary>
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;
}
}
}
}
}
}

View File

@ -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<UseServiceDIAttribute> _logger;
private readonly IBlogArticleServices _blogArticleServices;
private readonly string _name;
public UseServiceDIAttribute(ILogger<UseServiceDIAttribute> 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");
}
}
}
}

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<!-- 将日志以回滚文件的形式写到文件中 -->
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
<!--Error-->
<appender name="ErrorLog" type="log4net.Appender.RollingFileAppender">
<file value="Log/"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
<datePattern value="&quot;GlobalExceptionLogs_&quot;yyyyMMdd&quot;.log&quot;" />
<!--日志文件名是否为静态-->
<StaticLogFileName value="false"/>
<!--多线程时采用最小锁定-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<!--布局(向用户显示最后经过格式化的输出信息)-->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date| %-5level %newline%message%newline--------------------------------%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="ERROR" />
<levelMax value="FATAL" />
</filter>
</appender>
<!--Error-->
<!--Info-->
<appender name="InfoLog" type="log4net.Appender.RollingFileAppender">
<!--定义文件存放位置-->
<file value="Log/"/>
<appendToFile value="true" />
<rollingStyle value="Date" />
<!--日志文件名是否为静态-->
<StaticLogFileName value="false"/>
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
<datePattern value="&quot;GlobalInfoLogs_&quot;yyyyMMdd&quot;.log&quot;" />
<!--多线程时采用最小锁定-->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<!--布局(向用户显示最后经过格式化的输出信息)-->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date| %-5level%c %newline%message%newline--------------------------------%newline" />
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="DEBUG" />
<levelMax value="WARN" />
</filter>
</appender>
<!--Info-->
<root>
<!-- 控制级别由低到高ALL|DEBUG|INFO|WARN|ERROR|FATAL|OFF -->
<!-- 比如定义级别为INFO则INFO级别向下的级别比如DEBUG日志将不会被记录 -->
<!-- 如果没有定义LEVEL的值则缺省为DEBUG -->
<level value="ALL" />
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
<appender-ref ref="ErrorLog" />
<appender-ref ref="InfoLog" />
</root>
</log4net>

View File

@ -0,0 +1,93 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<!--<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>-->
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<UserSecretsId>9dd21652-c528-44ce-9a01-f33c5d3edab8</UserSecretsId>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>..\New_College.Api\New_College.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>..\New_College\New_College.xml</DocumentationFile>
<NoWarn>1701;1702;1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Controllers\Web\**" />
<Compile Remove="Extensions\**" />
<Compile Remove="Hubs\**" />
<Compile Remove="Middlewares\**" />
<Content Remove="Controllers\Web\**" />
<Content Remove="Extensions\**" />
<Content Remove="Hubs\**" />
<Content Remove="Middlewares\**" />
<EmbeddedResource Remove="Controllers\Web\**" />
<EmbeddedResource Remove="Extensions\**" />
<EmbeddedResource Remove="Hubs\**" />
<EmbeddedResource Remove="Middlewares\**" />
<EntityDeploy Remove="Controllers\Web\**" />
<None Remove="Controllers\Web\**" />
<None Remove="Extensions\**" />
<None Remove="Hubs\**" />
<None Remove="Middlewares\**" />
</ItemGroup>
<ItemGroup>
<None Remove="index.html" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="LinqKit" Version="1.1.17" />
<PackageReference Include="Microsoft.Graph.Core" Version="1.23.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\New_College.Extensions\New_College.Extensions.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
<None Include="wwwroot\BlogCore.Data.json\BlogArticle.tsv" />
<None Include="wwwroot\BlogCore.Data.json\Modules.tsv" />
<None Include="wwwroot\BlogCore.Data.json\Permission.tsv" />
<None Include="wwwroot\BlogCore.Data.json\Role.tsv" />
<None Include="wwwroot\BlogCore.Data.json\RoleModulePermission.tsv" />
<None Include="wwwroot\BlogCore.Data.json\sysUserInfo.tsv" />
<None Include="wwwroot\BlogCore.Data.json\Topic.tsv" />
<None Include="wwwroot\BlogCore.Data.json\TopicDetail.tsv" />
<None Include="wwwroot\BlogCore.Data.json\UserRole.tsv" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="index.html" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Update="Dockerfile">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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
{
/// <summary>
/// 加载配置文件构建IConfigurationRoot
/// </summary>
private static readonly IConfigurationBuilder ConfigurationBuilder = new ConfigurationBuilder();
/// <summary>
/// 获取配置文件中的内容继承自IConfiguration
/// </summary>
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<Startup>()
.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();
}
}
}

View File

@ -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
}
}
}

226
New_College.Api/Startup.cs Normal file
View File

@ -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<IRedisCacheManager, RedisCacheManager>();
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<WeChatPayOptions>(Configuration.GetSection("WeChatPay"));
//services.Configure<AlipayOptions>(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<UseServiceDIAttribute>();
services.Configure<KestrelServerOptions>(x => x.AllowSynchronousIO = true)
.Configure<IISServerOptions>(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<ChatHub>("/api2/chatHub");
});
// 生成种子数据
app.UseSeedDataMildd(myContext, Env.WebRootPath);
// 开启QuartzNetJob调度服务
app.UseQuartzJobMildd(tasksQzServices, schedulerCenter);
//服务注册
app.UseConsulMildd(Configuration, lifetime);
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}

View File

@ -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"
},
// MainDBConnId,Enabledtrue
// *** MutiDBEnabled false ***
// *** MutiDBEnabled trueEnabledtrue **
// https://www.bilibili.com/video/BV1BJ411B7mn?p=6
"MainDB": "WMBLOG_MYSQL", //Enabledtrue
"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使jwttrue使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"
}
}

137
New_College.Api/index.html Normal file
View File

@ -0,0 +1,137 @@
<!--<script async="async" id="mini-profiler" src="/profiler/includes.min.js?v=4.1.0+c940f0f28d"
data-version="4.1.0+c940f0f28d" data-path="/profiler/"
data-current-id="" data-ids="" data-position="Left"
data-authorized="true" data-max-traces="15" data-toggle-shortcut="Alt+P"
data-trivial-milliseconds="2.0" data-ignored-duplicate-execute-types="Open,OpenAsync,Close,CloseAsync">
</script>-->
<!--1、版本号要与nuget包一致2、id不能为空-->
<script async="async" id="mini-profiler" src="/profiler/includes.min.js?v=4.1.0+c940f0f28d"
data-version="4.1.0+c940f0f28d" data-path="/profiler/"
data-current-id="4ec7c742-49d4-4eaf-8281-3c1e0efa8888" data-ids="4ec7c742-49d4-4eaf-8281-3c1e0efa8888"
data-position="Left"
data-authorized="true" data-max-traces="5" data-toggle-shortcut="Alt+P"
data-trivial-milliseconds="2.0" data-ignored-duplicate-execute-types="Open,OpenAsync,Close,CloseAsync">
</script>
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>%(DocumentTitle)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./swagger-ui.css">
<link rel="icon" type="image/png" href="./logo/favicon-32x32.png" sizes="32x32" />
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<style>
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
background: #fafafa;
}
.qqgroup {
float: right;
}
.info {
float: left;
}
.download-contents {
display: none;
}
</style>
%(HeadContent)
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
<defs>
<symbol viewBox="0 0 20 20" id="unlocked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
</symbol>
<symbol viewBox="0 0 20 20" id="locked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z" />
</symbol>
<symbol viewBox="0 0 20 20" id="close">
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z" />
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow">
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z" />
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow-down">
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z" />
</symbol>
<symbol viewBox="0 0 24 24" id="jump-to">
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z" />
</symbol>
<symbol viewBox="0 0 24 24" id="expand">
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z" />
</symbol>
</defs>
</svg>
<div id="swagger-ui"></div>
<!-- Workaround for https://github.com/swagger-api/swagger-editor/issues/1371 -->
<script>
if (window.navigator.userAgent.indexOf("Edge") > -1) {
console.log("Removing native Edge fetch in favor of swagger-ui's polyfill")
window.fetch = undefined;
}
</script>
<script src="./swagger-ui-bundle.js"></script>
<script src="./swagger-ui-standalone-preset.js"></script>
<script>
var int = null;
window.onload = function () {
var configObject = JSON.parse('%(ConfigObject)');
var oauthConfigObject = JSON.parse('%(OAuthConfigObject)');
// Apply mandatory parameters
configObject.dom_id = "#swagger-ui";
configObject.presets = [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset];
configObject.layout = "StandaloneLayout";
// If oauth2RedirectUrl isn't specified, use the built-in default
if (!configObject.hasOwnProperty("oauth2RedirectUrl"))
configObject.oauth2RedirectUrl = window.location.href.replace("index.html", "oauth2-redirect.html");
// Build a system
const ui = SwaggerUIBundle(configObject);
// Apply OAuth config
ui.initOAuth(oauthConfigObject);
int = setInterval(function () {
getData();
}, 1000);
$("img").attr("src", "./logo/favicon-32x32.png");
}
function getData() {
if ($(".qqgroup").length <= 0) {
$('.info').after("<div class='qqgroup'><img src='https://images.cnblogs.com/cnblogs_com/laozhang-is-phi/1284763/o_WeChat%20Screenshot_20191021142452.png' alt='QQ二维码' style='width: 450px;'><div style=\"margin-left: 16px;color: #4990e2;\"><a href=\"../allservices\" target=\"_blank\" rel=\"noopener noreferrer\" class=\"link\">查看所有注册的服务</a></div></div><div style='clear: both;'></div>");
console.log(2);
clearInterval(int);
}
}
</script>
</body>
</html>

View File

@ -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": " <p>问题:</p><h1><a href=\"https://www.cnblogs.com/yipeng-yu/p/6210380.html\">The requested page cannot be accessed because the related configuration data for the page is invalid.</a></h1><p>HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.</p><p>Detailed Error Information:</p><p>Module IIS Web Core</p><p>Notification Unknown</p><p>Handler Not yet determined</p><p>Error Code 0x80070003</p><p>Config Error Cannot read configuration file</p><p>Config File \\?\\D:\\Projects\\...\\web.config</p><p>Requested URL http:// localhost:8080/</p><p>Physical Path</p><p>Logon Method Not yet determined</p><p>Logon User Not yet determined</p><p>Request Tracing Directory C:\\Users\\...\\TraceLogFiles\\</p><p>Config Source:</p><p>Answer:</p><p>1find the site's application pools</p><p>2,\"Advanced Settings\" ==&gt; Indentity ==&gt;&nbsp; Custom account</p><p><br></p><p><br></p>",
"btraffic": 127,
"bcommentNum": 1,
"bUpdateTime": "\/Date(1546272000000+0800)\/",
"bCreateTime": "\/Date(1546272000000+0800)\/",
"bRemark": null,
"IsDeleted": "0"
}
]
Can't render this file because it contains an unexpected character in line 3 and column 5.

View File

@ -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
}
]
Can't render this file because it contains an unexpected character in line 3 and column 5.

File diff suppressed because it is too large Load Diff

View File

@ -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
}
]
Can't render this file because it contains an unexpected character in line 3 and column 5.

File diff suppressed because it is too large Load Diff

View File

@ -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
}
]
Can't render this file because it contains an unexpected character in line 3 and column 5.

View File

@ -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
}
]
Can't render this file because it contains an unexpected character in line 3 and column 5.

File diff suppressed because one or more lines are too long

View File

@ -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
}
]
Can't render this file because it contains an unexpected character in line 3 and column 5.

View File

@ -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"
}
]
Can't render this file because it contains an unexpected character in line 3 and column 5.

View File

@ -0,0 +1,100 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>New_College</title>
<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
<style>
div {
margin: 10px;
word-wrap: break-word;
}
</style>
<script>
$(document).ready(function () {
$("#jsonp").click(function () {
$.getJSON("http://localhost:8081/api/Login/jsonp?callBack=?", function (data) {
$("#data-jsonp").html("数据: " + data.value);
});
});
$("#cors").click(function () {
$.get("http://localhost:8081/api/Login/Token", function (data, status) {
console.log(data);
$("#status-cors").html("状态: " + status);
$("#data-cors").html("数据: " + data? data.token:"失败");
});
});
$("#cors-post").click(function () {
let postdata = {
"bID": 10,
"bsubmitter": "222",
"btitle": "33333",
"bcategory": "4444",
"bcontent": "5555",
"btraffic": 0,
"bcommentNum": 0,
"bUpdateTime": "2018-11-08T02:36:26.557Z",
"bCreateTime": "2018-11-08T02:36:26.557Z",
"bRemark": "string"
};
$.ajax({
type: 'post',
url: 'http://localhost:8081/api/Values',
contentType: 'application/json',
data: JSON.stringify(postdata),
success: function (data, status) {
console.log(data);
$("#status-cors-post").html("状态: " + status);
$("#data-cors-post").html("数据: " + JSON.stringify(data));
}
});
//$.ajax({
// type: "POST",
// url: "/api/Values",
// success: function (data, status) {
// console.log(data);
// $("#status-cors-post").html("状态: " + status);
// $("#data-cors-post").html("数据: " + data);
// }
//});
});
});
</script>
</head>
<body>
<h3>通过JsonP实现跨域请求</h3>
<button id="jsonp">发送一个 GET </button>
<div id="status-jsonp"></div>
<div id="data-jsonp"></div>
<hr />
<h3>添加请求头实现跨域</h3>
<hr />
<h3>通过CORS实现跨域请求另需要在服务器段配置CORE</h3>
<button id="cors">发送一个 GET </button>
<div id="status-cors"></div>
<div id="data-cors"></div>
<hr />
<button id="cors-post">发送一个 POST </button>
<div id="status-cors-post"></div>
<div id="data-cors-post"></div>
<hr />
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,42 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>默认首页</title>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script>
let postdata = {
"bID": 10,
"bsubmitter": "222",
"btitle": "33333",
"bcategory": "4444",
"bcontent": "5555",
"btraffic": 0,
"bcommentNum": 0,
"bUpdateTime": "2018-11-08T02:36:26.557Z",
"bCreateTime": "2018-11-08T02:36:26.557Z",
"bRemark": "string"
};
$.ajax({
url: "http://localhost:8081/api/Values",
type: "POST",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(postdata),
dataType: 'json',
success: function (data) {
alert(JSON.stringify(data));
}
});
</script>
</head>
<body>
<button id="btn">点击我请求数据</button>
<div id="requestMsg"></div>
<form id="sub1" method="post" action="http://localhost:8081/api/Values">
<input name="name" type="text" />
<input type="submit" value="提交吧" />
</form>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Some files were not shown because too many files have changed in this diff Show More