From d2e299f50bd5e7591498c21aea177131ddd5fcbe Mon Sep 17 00:00:00 2001
From: Coldairarrow <862520575@qq.com>
Date: Mon, 30 Nov 2020 21:55:32 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=AD=BE=E5=90=8D=20?=
=?UTF-8?q?=E6=B3=A8=E9=87=8A=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Base_Manage/Base_ActionController.cs | 2 ++
.../Base_Manage/Base_AppSecretController.cs | 2 ++
.../Base_Manage/Base_DbLinkController.cs | 4 +++-
.../Base_Manage/Base_DepartmentController.cs | 5 +++++
.../Base_Manage/Base_RoleController.cs | 4 +++-
.../Base_Manage/Base_UserController.cs | 2 ++
.../Base_Manage/Base_UserLogController.cs | 2 ++
.../Base_Manage/BuildCodeController.cs | 2 ++
.../Controllers/Base_Manage/HomeController.cs | 2 ++
.../Base_Manage/UploadController.cs | 2 ++
.../CheckSignAttribute.cs" | 3 +--
src/Coldairarrow.Web/.env | 6 +++++-
.../src/config/defaultSettings.js | 4 +++-
.../src/utils/plugin/axios-plugin.js | 19 +++++++++++++++++++
14 files changed, 53 insertions(+), 6 deletions(-)
diff --git a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_ActionController.cs b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_ActionController.cs
index cee43718..ac4f2e40 100644
--- a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_ActionController.cs
+++ b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_ActionController.cs
@@ -3,6 +3,7 @@
using Coldairarrow.Entity.Base_Manage;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
+using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -13,6 +14,7 @@ namespace Coldairarrow.Api.Controllers.Base_Manage
///
///
[Route("/Base_Manage/[controller]/[action]")]
+ [OpenApiTag("系统权限")]
public class Base_ActionController : BaseApiController
{
#region DI
diff --git a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_AppSecretController.cs b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_AppSecretController.cs
index 5457b81d..5abc8491 100644
--- a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_AppSecretController.cs
+++ b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_AppSecretController.cs
@@ -2,6 +2,7 @@
using Coldairarrow.Entity.Base_Manage;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
+using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -12,6 +13,7 @@ namespace Coldairarrow.Api.Controllers.Base_Manage
///
///
[Route("/Base_Manage/[controller]/[action]")]
+ [OpenApiTag("应用密钥")]
public class Base_AppSecretController : BaseApiController
{
#region DI
diff --git a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_DbLinkController.cs b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_DbLinkController.cs
index e4857dd7..54448c3d 100644
--- a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_DbLinkController.cs
+++ b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_DbLinkController.cs
@@ -2,16 +2,18 @@
using Coldairarrow.Entity.Base_Manage;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
+using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Coldairarrow.Api.Controllers.Base_Manage
{
///
- /// 应用密钥
+ /// 数据库连接
///
///
[Route("/Base_Manage/[controller]/[action]")]
+ [OpenApiTag("数据库连接")]
public class Base_DbLinkController : BaseApiController
{
#region DI
diff --git a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_DepartmentController.cs b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_DepartmentController.cs
index 888c66e2..4d71d79f 100644
--- a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_DepartmentController.cs
+++ b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_DepartmentController.cs
@@ -2,12 +2,17 @@
using Coldairarrow.Entity.Base_Manage;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
+using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Coldairarrow.Api.Controllers.Base_Manage
{
+ ///
+ /// 部门
+ ///
[Route("/Base_Manage/[controller]/[action]")]
+ [OpenApiTag("部门")]
public class Base_DepartmentController : BaseApiController
{
#region DI
diff --git a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_RoleController.cs b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_RoleController.cs
index 42deb262..fe55c2b5 100644
--- a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_RoleController.cs
+++ b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_RoleController.cs
@@ -1,16 +1,18 @@
using Coldairarrow.Business.Base_Manage;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
+using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Coldairarrow.Api.Controllers.Base_Manage
{
///
- /// 应用密钥
+ /// 系统角色
///
///
[Route("/Base_Manage/[controller]/[action]")]
+ [OpenApiTag("系统角色")]
public class Base_RoleController : BaseApiController
{
#region DI
diff --git a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_UserController.cs b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_UserController.cs
index 8b5c86d4..6452ab2f 100644
--- a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_UserController.cs
+++ b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_UserController.cs
@@ -2,12 +2,14 @@
using Coldairarrow.Entity;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
+using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Coldairarrow.Api.Controllers.Base_Manage
{
[Route("/Base_Manage/[controller]/[action]")]
+ [OpenApiTag("系统用户")]
public class Base_UserController : BaseApiController
{
#region DI
diff --git a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_UserLogController.cs b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_UserLogController.cs
index adf61b91..7842ab36 100644
--- a/src/Coldairarrow.Api/Controllers/Base_Manage/Base_UserLogController.cs
+++ b/src/Coldairarrow.Api/Controllers/Base_Manage/Base_UserLogController.cs
@@ -2,12 +2,14 @@
using Coldairarrow.Entity.Base_Manage;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
+using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Coldairarrow.Api.Controllers.Base_Manage
{
[Route("/Base_Manage/[controller]/[action]")]
+ [OpenApiTag("审计日志")]
public class Base_UserLogController : BaseApiController
{
#region DI
diff --git a/src/Coldairarrow.Api/Controllers/Base_Manage/BuildCodeController.cs b/src/Coldairarrow.Api/Controllers/Base_Manage/BuildCodeController.cs
index 6817d0e0..5cc2dca2 100644
--- a/src/Coldairarrow.Api/Controllers/Base_Manage/BuildCodeController.cs
+++ b/src/Coldairarrow.Api/Controllers/Base_Manage/BuildCodeController.cs
@@ -2,11 +2,13 @@
using Coldairarrow.Entity.Base_Manage;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
+using NSwag.Annotations;
using System.Collections.Generic;
namespace Coldairarrow.Api.Controllers.Base_Manage
{
[Route("/Base_Manage/[controller]/[action]")]
+ [OpenApiTag("代码生成")]
public class BuildCodeController : BaseApiController
{
#region DI
diff --git a/src/Coldairarrow.Api/Controllers/Base_Manage/HomeController.cs b/src/Coldairarrow.Api/Controllers/Base_Manage/HomeController.cs
index a752284f..75b63b91 100644
--- a/src/Coldairarrow.Api/Controllers/Base_Manage/HomeController.cs
+++ b/src/Coldairarrow.Api/Controllers/Base_Manage/HomeController.cs
@@ -4,6 +4,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
+using NSwag.Annotations;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
@@ -17,6 +18,7 @@ namespace Coldairarrow.Api.Controllers.Base_Manage
/// 首页控制器
///
[Route("/Base_Manage/[controller]/[action]")]
+ [OpenApiTag("主页")]
public class HomeController : BaseApiController
{
readonly IHomeBusiness _homeBus;
diff --git a/src/Coldairarrow.Api/Controllers/Base_Manage/UploadController.cs b/src/Coldairarrow.Api/Controllers/Base_Manage/UploadController.cs
index e0230381..90eea0ca 100644
--- a/src/Coldairarrow.Api/Controllers/Base_Manage/UploadController.cs
+++ b/src/Coldairarrow.Api/Controllers/Base_Manage/UploadController.cs
@@ -1,6 +1,7 @@
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
+using NSwag.Annotations;
using System;
using System.IO;
using System.Linq;
@@ -8,6 +9,7 @@
namespace Coldairarrow.Api.Controllers.Base_Manage
{
[Route("/Base_Manage/[controller]/[action]")]
+ [OpenApiTag("上传")]
public class UploadController : BaseApiController
{
readonly IConfiguration _configuration;
diff --git "a/src/Coldairarrow.Api/Filters/\345\257\271\345\244\226\346\216\245\345\217\243\347\255\276\345\220\215\346\240\241\351\252\214/CheckSignAttribute.cs" "b/src/Coldairarrow.Api/Filters/\345\257\271\345\244\226\346\216\245\345\217\243\347\255\276\345\220\215\346\240\241\351\252\214/CheckSignAttribute.cs"
index bbc38521..3a040bc9 100644
--- "a/src/Coldairarrow.Api/Filters/\345\257\271\345\244\226\346\216\245\345\217\243\347\255\276\345\220\215\346\240\241\351\252\214/CheckSignAttribute.cs"
+++ "b/src/Coldairarrow.Api/Filters/\345\257\271\345\244\226\346\216\245\345\217\243\347\255\276\345\220\215\346\240\241\351\252\214/CheckSignAttribute.cs"
@@ -42,8 +42,7 @@ namespace Coldairarrow.Api
3: 在header中携带上述的appId、time、guid、sign即可
详细使用Demo请看:
-HttpHelper.SafeSignRequest
-/Demo/ApiSignDemo
+src\Coldairarrow.Web\src\utils\plugin\axios-plugin.js
*/
///
/// 校验签名、十分严格
diff --git a/src/Coldairarrow.Web/.env b/src/Coldairarrow.Web/.env
index d0833239..6f3300e1 100644
--- a/src/Coldairarrow.Web/.env
+++ b/src/Coldairarrow.Web/.env
@@ -11,4 +11,8 @@ VUE_APP_LocalRootUrl=http://localhost:5000
#接口超时时间ms
VUE_APP_ApiTimeout=10000
#本地开发启动端口
-VUE_APP_DevPort=5001
\ No newline at end of file
+VUE_APP_DevPort=5001
+#接口签名appId
+VUE_APP_AppId=PcAdmin
+#接口签名appSecret
+VUE_APP_AppSecret=wtMaiTRPTT3hrf5e
\ No newline at end of file
diff --git a/src/Coldairarrow.Web/src/config/defaultSettings.js b/src/Coldairarrow.Web/src/config/defaultSettings.js
index 4d3371c7..3843795f 100644
--- a/src/Coldairarrow.Web/src/config/defaultSettings.js
+++ b/src/Coldairarrow.Web/src/config/defaultSettings.js
@@ -35,5 +35,7 @@ export default {
publishRootUrl: process.env.VUE_APP_PublishRootUrl,//发布后接口根地址
localRootUrl: process.env.VUE_APP_LocalRootUrl,//本地调试接口根地址
apiTimeout: parseInt(process.env.VUE_APP_ApiTimeout),//接口超时时间ms
- devPort: parseInt(process.env.VUE_APP_DevPort) //本地开发启动端口
+ devPort: parseInt(process.env.VUE_APP_DevPort), //本地开发启动端口
+ appId: process.env.VUE_APP_AppId,
+ appSecret: process.env.VUE_APP_AppSecret
}
\ No newline at end of file
diff --git a/src/Coldairarrow.Web/src/utils/plugin/axios-plugin.js b/src/Coldairarrow.Web/src/utils/plugin/axios-plugin.js
index db48ad16..36fba6be 100644
--- a/src/Coldairarrow.Web/src/utils/plugin/axios-plugin.js
+++ b/src/Coldairarrow.Web/src/utils/plugin/axios-plugin.js
@@ -2,6 +2,9 @@ import axios from 'axios'
import TokenCache from '@/utils/cache/TokenCache'
import defaultSettings from '@/config/defaultSettings'
import ProcessHelper from '@/utils/helper/ProcessHelper'
+import moment from 'moment'
+var uuid = require('node-uuid')
+var md5 = require("md5")
const rootUrl = () => {
if (ProcessHelper.isProduction() || ProcessHelper.isPreview()) {
@@ -26,6 +29,22 @@ Axios.interceptors.request.use(config => {
// config.data = formData
// }
+ //CheckSign签名检验
+ let appId = defaultSettings.appId
+ let appSecret = defaultSettings.appSecret
+ let guid = uuid.v4()
+ let time = moment().format("YYYY-MM-DD HH:mm:ss")
+ let body = ''
+ if (config.data) {
+ body = JSON.stringify(config.data)
+ }
+ let sign = md5(appId + time + guid + body + appSecret)
+
+ config.headers.appId = appId;
+ config.headers.time = time;
+ config.headers.guid = guid;
+ config.headers.sign = sign;
+
//携带token
if (TokenCache.getToken()) {
config.headers.Authorization = 'Bearer ' + TokenCache.getToken()