From 572b3b102b9b75f3048dbe3d783a1c8d6d61a3b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Mon, 21 Mar 2022 21:26:50 +0800
Subject: [PATCH 01/10] =?UTF-8?q?fix=20=E6=96=87=E4=BB=B6=E4=B8=8A?=
=?UTF-8?q?=E4=BC=A0=E4=B9=8B=E5=90=8E=E6=96=87=E4=BB=B6id=E6=9F=A5?=
=?UTF-8?q?=E8=AF=A2=E6=96=87=E4=BB=B6bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ZR.Admin.WebApi/Controllers/CommonController.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ZR.Admin.WebApi/Controllers/CommonController.cs b/ZR.Admin.WebApi/Controllers/CommonController.cs
index 7295ea0..e4120fd 100644
--- a/ZR.Admin.WebApi/Controllers/CommonController.cs
+++ b/ZR.Admin.WebApi/Controllers/CommonController.cs
@@ -146,7 +146,7 @@ namespace ZR.Admin.WebApi.Controllers
{
url = uploadType == 1 ? finalFilePath : accessPath,
fileName,
- fileId
+ fileId = fileId.ToString()
});
}
From 971c22ce470e6fa2611b491044ece5b194f0af53 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Tue, 22 Mar 2022 11:34:23 +0800
Subject: [PATCH 02/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=9D=9E=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E5=91=98=E8=B4=A6=E5=8F=B7=E4=B8=80=E4=BA=9B=E6=93=8D?=
=?UTF-8?q?=E4=BD=9C=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../System/monitor/SysLogininforController.cs | 12 ++++++++++--
.../System/monitor/SysOperlogController.cs | 18 +++++++++++-------
.../Extensions/HttpContextExtension.cs | 6 ++++++
3 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs b/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs
index 0df0ade..b56b80e 100644
--- a/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs
@@ -1,14 +1,14 @@
using Infrastructure;
using Infrastructure.Attribute;
using Infrastructure.Enums;
+using Infrastructure.Model;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
-using System.Linq.Expressions;
+using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Common;
using ZR.Model;
using ZR.Model.System;
-using ZR.Model.Vo;
using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.monitor
@@ -52,6 +52,10 @@ namespace ZR.Admin.WebApi.Controllers.monitor
[HttpDelete("clean")]
public IActionResult CleanLoginInfo()
{
+ if (!HttpContextExtension.IsAdmin(HttpContext))
+ {
+ return ToResponse(ApiResult.Error("操作失败"));
+ }
sysLoginService.TruncateLogininfo();
return SUCCESS(1);
}
@@ -66,6 +70,10 @@ namespace ZR.Admin.WebApi.Controllers.monitor
[ActionPermissionFilter(Permission = "monitor:logininfor:remove")]
public IActionResult Remove(string infoIds)
{
+ if (!HttpContextExtension.IsAdmin(HttpContext))
+ {
+ return ToResponse(ApiResult.Error("操作失败"));
+ }
long[] infoIdss = Tools.SpitLongArrary(infoIds);
return SUCCESS(sysLoginService.DeleteLogininforByIds(infoIdss));
}
diff --git a/ZR.Admin.WebApi/Controllers/System/monitor/SysOperlogController.cs b/ZR.Admin.WebApi/Controllers/System/monitor/SysOperlogController.cs
index c71ef7d..3bf7224 100644
--- a/ZR.Admin.WebApi/Controllers/System/monitor/SysOperlogController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/monitor/SysOperlogController.cs
@@ -1,19 +1,14 @@
using Infrastructure.Attribute;
using Infrastructure.Enums;
using Infrastructure.Model;
+using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
+using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Common;
using ZR.Model;
using ZR.Model.System.Dto;
-using ZR.Model.System;
-using ZR.Model.Vo;
using ZR.Service.System.IService;
-using System;
-using System.IO;
-using OfficeOpenXml;
-using Microsoft.AspNetCore.Hosting;
-using System.Collections.Generic;
namespace ZR.Admin.WebApi.Controllers.monitor
{
@@ -40,6 +35,7 @@ namespace ZR.Admin.WebApi.Controllers.monitor
{
PagerInfo pagerInfo = new(sysOperLog.pageNum, sysOperLog.PageSize);
+ sysOperLog.operName = !HttpContextExtension.IsAdmin(HttpContext) ? HttpContextExtension.GetName(HttpContext) : sysOperLog.operName;
var list = sysOperLogService.SelectOperLogList(sysOperLog, pagerInfo);
return SUCCESS(list, "MM/dd HH:mm");
@@ -55,6 +51,10 @@ namespace ZR.Admin.WebApi.Controllers.monitor
[HttpDelete("{operIds}")]
public IActionResult Remove(string operIds)
{
+ if (!HttpContextExtension.IsAdmin(HttpContext))
+ {
+ return ToResponse(ApiResult.Error("操作失败"));
+ }
long[] operIdss = Tools.SpitLongArrary(operIds);
return SUCCESS(sysOperLogService.DeleteOperLogByIds(operIdss));
}
@@ -68,6 +68,10 @@ namespace ZR.Admin.WebApi.Controllers.monitor
[HttpDelete("clean")]
public ApiResult ClearOperLog()
{
+ if (!HttpContextExtension.IsAdmin(HttpContext))
+ {
+ return ApiResult.Error("操作失败");
+ }
sysOperLogService.CleanOperLog();
return ToJson(1);
diff --git a/ZR.Admin.WebApi/Extensions/HttpContextExtension.cs b/ZR.Admin.WebApi/Extensions/HttpContextExtension.cs
index 535d9d8..2df4734 100644
--- a/ZR.Admin.WebApi/Extensions/HttpContextExtension.cs
+++ b/ZR.Admin.WebApi/Extensions/HttpContextExtension.cs
@@ -79,6 +79,12 @@ namespace ZR.Admin.WebApi.Extensions
return uid;
}
+ public static bool IsAdmin(this HttpContext context)
+ {
+ long id = GetUId(context);
+ return id == 1;
+ }
+
///
/// ClaimsIdentity
///
From 04acf820f711c18bd710841ebc05f32d7e8d67f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Tue, 22 Mar 2022 17:24:51 +0800
Subject: [PATCH 03/10] =?UTF-8?q?=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A0=E9=A2=84=E8=A7=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ZR.Vue/src/views/tool/file/index.vue | 50 ++++++++++++++++------------
1 file changed, 29 insertions(+), 21 deletions(-)
diff --git a/ZR.Vue/src/views/tool/file/index.vue b/ZR.Vue/src/views/tool/file/index.vue
index 0cc75e0..49c2a54 100644
--- a/ZR.Vue/src/views/tool/file/index.vue
+++ b/ZR.Vue/src/views/tool/file/index.vue
@@ -2,14 +2,14 @@
-
+
-
+
-
+
@@ -34,13 +34,10 @@
-
-
+
+
-
- {{ scope.row.fileName }}
-
+ {{ scope.row.fileName }}
@@ -56,7 +53,7 @@
-
+
查看
@@ -71,37 +68,40 @@
-
+
-
-
-
-
-
+
+
+
+ {{item.dictLabel}}
+
+
-
+
-
+
-
+
@@ -133,6 +133,11 @@
{{formView.fileUrl}}
+
+
+
+
+
{{formView.accessUrl}}
Date: Tue, 22 Mar 2022 17:26:53 +0800
Subject: [PATCH 04/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E4=B8=8A=E4=BC=A0=E3=80=81=E6=96=B0=E5=A2=9E=E5=8A=A0=E6=98=AF?=
=?UTF-8?q?=E5=90=A6=E8=87=AA=E5=8A=A8=E4=B8=8A=E4=BC=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Infrastructure/Helper/FileUtil.cs | 11 ++-----
.../Controllers/CommonController.cs | 1 +
ZR.Model/JsonDateConverter.cs | 15 ---------
ZR.Tasks/TaskSchedulerServer.cs | 2 +-
ZR.Vue/src/components/FileUpload/index.vue | 31 ++++++++++++-------
5 files changed, 24 insertions(+), 36 deletions(-)
delete mode 100644 ZR.Model/JsonDateConverter.cs
diff --git a/Infrastructure/Helper/FileUtil.cs b/Infrastructure/Helper/FileUtil.cs
index d9bbb0a..de8c701 100644
--- a/Infrastructure/Helper/FileUtil.cs
+++ b/Infrastructure/Helper/FileUtil.cs
@@ -16,16 +16,11 @@ namespace Infrastructure
public static string GetdirPath(string path = "")
{
DateTime date = DateTime.Now;
- int year = date.Year;
- int month = date.Month;
- int day = date.Day;
- int hour = date.Hour;
-
- string timeDir = $"{year}{month}{day}/";// date.ToString("yyyyMM/dd/HH/");
+ string timeDir = Path.Combine(date.ToString("yyyyMMdd"));// date.ToString("yyyyMM/dd/HH/");
if (!string.IsNullOrEmpty(path))
{
- timeDir = $"{path}/{timeDir}/";
+ timeDir = Path.Combine(path, timeDir);
}
return timeDir;
}
@@ -41,7 +36,7 @@ namespace Infrastructure
{
str = Guid.NewGuid().ToString();
}
- MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
+ MD5CryptoServiceProvider md5 = new();
return BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(str)), 4, 8).Replace("-", "");
}
}
diff --git a/ZR.Admin.WebApi/Controllers/CommonController.cs b/ZR.Admin.WebApi/Controllers/CommonController.cs
index e4120fd..ce579ef 100644
--- a/ZR.Admin.WebApi/Controllers/CommonController.cs
+++ b/ZR.Admin.WebApi/Controllers/CommonController.cs
@@ -9,6 +9,7 @@ using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Snowflake.Core;
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
diff --git a/ZR.Model/JsonDateConverter.cs b/ZR.Model/JsonDateConverter.cs
deleted file mode 100644
index 70ca6c8..0000000
--- a/ZR.Model/JsonDateConverter.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using Newtonsoft.Json.Converters;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace ZR.Model
-{
- public class JsonDateConverter: IsoDateTimeConverter
- {
- public JsonDateConverter()
- {
- DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
- }
- }
-}
diff --git a/ZR.Tasks/TaskSchedulerServer.cs b/ZR.Tasks/TaskSchedulerServer.cs
index 8570680..681c405 100644
--- a/ZR.Tasks/TaskSchedulerServer.cs
+++ b/ZR.Tasks/TaskSchedulerServer.cs
@@ -262,7 +262,7 @@ namespace ZR.Tasks
List jobKeys = _scheduler.Result.GetJobKeys(GroupMatcher.GroupEquals(tasksQz.JobGroup)).Result.ToList();
if (jobKeys == null || jobKeys.Count == 0)
{
- return new ApiResult(110, $"未找到分组[{ tasksQz.JobGroup }]");
+ await AddTaskScheduleAsync(tasksQz);
}
var triggers = await _scheduler.Result.GetTriggersOfJob(jobKey);
diff --git a/ZR.Vue/src/components/FileUpload/index.vue b/ZR.Vue/src/components/FileUpload/index.vue
index 6523b74..14d85de 100644
--- a/ZR.Vue/src/components/FileUpload/index.vue
+++ b/ZR.Vue/src/components/FileUpload/index.vue
@@ -1,11 +1,12 @@
-
- 将文件拖到此处,或点击上传
-
+ :on-exceed="handleExceed" :on-success="handleUploadSuccess" :show-file-list="true" :data="data" :headers="headers" :drag="drag" ref="upload"
+ :auto-upload="autoUpload">
+
+
+ 将文件拖到此处,或点击上传
+
选取文件
@@ -23,7 +24,7 @@
{{ getFileName(file.name) }}
- 删除
+ 删除
@@ -73,6 +74,11 @@ export default {
drag: {
type: Boolean,
default: false
+ },
+ // 自动上传
+ autoUpload: {
+ type: Boolean,
+ default: true
}
},
data() {
@@ -181,10 +187,6 @@ export default {
res.data
)
},
- // 上传进度
- uploadProcess(event, file, fileList) {
- // console.log("上传进度" + file.percentage);
- },
// 删除文件
handleDelete(index) {
this.fileList.splice(index, 1)
@@ -206,6 +208,11 @@ export default {
strs += list[i].url + separator
}
return strs != '' ? strs.substr(0, strs.length - 1) : ''
+ },
+ // 提交上传
+ submitUpload() {
+ console.log(this.fileList)
+ this.$refs.upload.submit()
}
}
}
@@ -228,7 +235,7 @@ export default {
margin-right: 10px;
}
::v-deep .el-upload-dragger {
- width: 270px;
- height: 150px;
+ width: 270px;
+ height: 150px;
}
\ No newline at end of file
From 899bbe3ffb682dbed2b0c0bd1fd80808db2689c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Tue, 22 Mar 2022 17:49:16 +0800
Subject: [PATCH 05/10] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=97=A5=E5=BF=97?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=97=B6=E9=97=B4=E8=BD=B4=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ZR.Vue/src/views/monitor/job/index.vue | 32 ++++++++++++++++++++++----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/ZR.Vue/src/views/monitor/job/index.vue b/ZR.Vue/src/views/monitor/job/index.vue
index 2809c55..325f32c 100644
--- a/ZR.Vue/src/views/monitor/job/index.vue
+++ b/ZR.Vue/src/views/monitor/job/index.vue
@@ -28,7 +28,7 @@
导出
- 日志
+ 日志
@@ -52,8 +52,9 @@
-
- 日志
+
+ 日志
+
运行
@@ -148,6 +149,15 @@
确 定
+
+
+
+
+ {{item.jobMessage}}
+ {{item.exception}}
+
+
+
@@ -162,6 +172,8 @@ import {
runTasks,
exportTasks
} from '@/api/monitor/job'
+import { listJobLog } from '@/api/monitor/jobLog'
+
export default {
name: 'job',
data() {
@@ -210,6 +222,7 @@ export default {
}
}
return {
+ drawer: false,
// 选中数组
ids: [],
// 非单个禁用
@@ -240,6 +253,8 @@ export default {
},
// 计划任务列表
dataTasks: [],
+ // 任务日志列表
+ jobLogList: [],
// 任务状态字典
isStartOptions: [
{ dictLabel: '运行中', dictValue: 'true' },
@@ -289,7 +304,7 @@ export default {
// 时间的选择
pickerOptions: {
disabledDate(time) {
- return time.getTime() < Date.now() - 8.64e7;
+ return time.getTime() < Date.now() - 8.64e7
}
}
}
@@ -346,7 +361,14 @@ export default {
},
/** 任务日志列表查询 */
handleJobLog(param) {
- this.$router.push({ path: 'job/log', params: param })
+ if (param == undefined) {
+ this.$router.push({ path: 'job/log' })
+ } else {
+ this.drawer = true
+ listJobLog({ id: param }).then((response) => {
+ this.jobLogList = response.data.result
+ })
+ }
},
// 启动按钮
handleStart(row) {
From 6c376d5b0df252a8dd9c1e98ed7932dc65c5ec35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Tue, 22 Mar 2022 17:49:16 +0800
Subject: [PATCH 06/10] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=97=A5=E5=BF=97?=
=?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=97=B6=E9=97=B4=E8=BD=B4=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ZR.Vue/src/views/monitor/job/index.vue | 38 ++++++++++++++++++++++----
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/ZR.Vue/src/views/monitor/job/index.vue b/ZR.Vue/src/views/monitor/job/index.vue
index 2809c55..40315b0 100644
--- a/ZR.Vue/src/views/monitor/job/index.vue
+++ b/ZR.Vue/src/views/monitor/job/index.vue
@@ -28,7 +28,7 @@
导出
- 日志
+ 日志
@@ -52,8 +52,9 @@
-
- 日志
+
+ 日志
+
运行
@@ -148,6 +149,16 @@
确 定
+
+
+
+
+ {{item.jobMessage}}
+ {{item.exception}}
+
+
+
+
@@ -162,6 +173,8 @@ import {
runTasks,
exportTasks
} from '@/api/monitor/job'
+import { listJobLog } from '@/api/monitor/jobLog'
+
export default {
name: 'job',
data() {
@@ -210,6 +223,7 @@ export default {
}
}
return {
+ drawer: false,
// 选中数组
ids: [],
// 非单个禁用
@@ -240,6 +254,9 @@ export default {
},
// 计划任务列表
dataTasks: [],
+ // 任务日志列表
+ jobLogList: [],
+ logTitle: "",
// 任务状态字典
isStartOptions: [
{ dictLabel: '运行中', dictValue: 'true' },
@@ -289,7 +306,7 @@ export default {
// 时间的选择
pickerOptions: {
disabledDate(time) {
- return time.getTime() < Date.now() - 8.64e7;
+ return time.getTime() < Date.now() - 8.64e7
}
}
}
@@ -345,8 +362,17 @@ export default {
this.title = '修改计划任务'
},
/** 任务日志列表查询 */
- handleJobLog(param) {
- this.$router.push({ path: 'job/log', params: param })
+ handleJobLog(id, title) {
+ if (id == undefined) {
+ this.$router.push({ path: 'job/log' })
+ } else {
+ this.drawer = true
+ this.jobLogList = []
+ this.logTitle = title
+ listJobLog({ JobId: id }).then((response) => {
+ this.jobLogList = response.data.result
+ })
+ }
},
// 启动按钮
handleStart(row) {
From c23b69a883b43570732ff81779f9f182e2736253 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Tue, 22 Mar 2022 22:01:47 +0800
Subject: [PATCH 07/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9C=AC=E5=9C=B0?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Infrastructure/Enums/StoreType.cs | 34 +++++++++++++++++++
Infrastructure/Helper/FileUtil.cs | 4 +--
.../Controllers/CommonController.cs | 31 ++++-------------
ZR.Model/System/SysFile.cs | 13 +++++++
ZR.Vue/src/views/tool/file/index.vue | 15 +++++---
5 files changed, 66 insertions(+), 31 deletions(-)
create mode 100644 Infrastructure/Enums/StoreType.cs
diff --git a/Infrastructure/Enums/StoreType.cs b/Infrastructure/Enums/StoreType.cs
new file mode 100644
index 0000000..4dea7eb
--- /dev/null
+++ b/Infrastructure/Enums/StoreType.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Infrastructure.Enums
+{
+ ///
+ /// 文件存储位置
+ ///
+ public enum StoreType
+ {
+ ///
+ /// 本地
+ ///
+ [Description("本地")]
+ LOCAL = 1,
+
+ ///
+ /// 阿里云
+ ///
+ [Description("阿里云")]
+ ALIYUN = 2,
+
+ ///
+ /// 腾讯云
+ ///
+ [Description("腾讯云")]
+ TENCENT = 3,
+
+ }
+}
diff --git a/Infrastructure/Helper/FileUtil.cs b/Infrastructure/Helper/FileUtil.cs
index de8c701..8448ba2 100644
--- a/Infrastructure/Helper/FileUtil.cs
+++ b/Infrastructure/Helper/FileUtil.cs
@@ -16,7 +16,7 @@ namespace Infrastructure
public static string GetdirPath(string path = "")
{
DateTime date = DateTime.Now;
- string timeDir = Path.Combine(date.ToString("yyyyMMdd"));// date.ToString("yyyyMM/dd/HH/");
+ string timeDir = date.ToString("yyyyMMdd");// date.ToString("yyyyMM/dd/HH/");
if (!string.IsNullOrEmpty(path))
{
@@ -28,7 +28,7 @@ namespace Infrastructure
///
/// 取文件名的MD5值(16位)
///
- /// 文件名,不包括扩展名
+ /// 文件名,不包括扩展名
///
public static string HashFileName(string str = null)
{
diff --git a/ZR.Admin.WebApi/Controllers/CommonController.cs b/ZR.Admin.WebApi/Controllers/CommonController.cs
index ce579ef..28daeb1 100644
--- a/ZR.Admin.WebApi/Controllers/CommonController.cs
+++ b/ZR.Admin.WebApi/Controllers/CommonController.cs
@@ -110,13 +110,12 @@ namespace ZR.Admin.WebApi.Controllers
{
if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "上传文件不能为空");
string fileExt = Path.GetExtension(formFile.FileName);
- string hashFileName = FileUtil.HashFileName(Guid.NewGuid().ToString()).ToLower();
+ string hashFileName = FileUtil.HashFileName();
fileName = (fileName.IsEmpty() ? hashFileName : fileName) + fileExt;
fileDir = fileDir.IsEmpty() ? "uploads" : fileDir;
string filePath = FileUtil.GetdirPath(fileDir);
string finalFilePath = Path.Combine(WebHostEnvironment.WebRootPath, filePath, fileName);
- finalFilePath = finalFilePath.Replace("\\", "/").Replace("//", "/");
- double fileSize = formFile.Length / 1024;
+ double fileSize = formFile.Length / 1024.0;
if (!Directory.Exists(Path.GetDirectoryName(finalFilePath)))
{
@@ -128,18 +127,10 @@ namespace ZR.Admin.WebApi.Controllers
formFile.CopyTo(stream);
}
- string accessPath = $"{OptionsSetting.Upload.UploadUrl}/{filePath.Replace("\\", " /")}{fileName}";
- SysFile file = new()
+ string accessPath = string.Concat(OptionsSetting.Upload.UploadUrl, "/", filePath.Replace("\\", "/"), "/", fileName);
+ SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", filePath, accessPath, HttpContext.GetName())
{
- AccessUrl = accessPath,
- Create_by = HttpContext.GetName(),
- FileExt = fileExt,
- FileName = fileName,
- FileSize = fileSize + "kb",
- StoreType = 1,
- FileUrl = finalFilePath,
- RealName = formFile.FileName,
- Create_time = DateTime.Now,
+ StoreType = (int)Infrastructure.Enums.StoreType.LOCAL,
FileType = formFile.ContentType
};
long fileId = SysFileService.InsertFile(file);
@@ -183,17 +174,9 @@ namespace ZR.Admin.WebApi.Controllers
{
result = SysFileService.SaveFile(fileDir, formFile, fileName, "");
});
- long id = SysFileService.InsertFile(new SysFile()
+ long id = SysFileService.InsertFile(new(formFile.FileName, fileName, fileExt, fileSize + "kb", "", result.Item2, HttpContext.GetName())
{
- AccessUrl = result.Item2,
- Create_by = HttpContext.GetName(),
- FileExt = fileExt,
- FileName = result.Item3,
- FileSize = fileSize + "kb",
- StoreType = 2,
- StorePath = fileDir,
- RealName = formFile.FileName,
- Create_time = DateTime.Now,
+ StoreType = (int)Infrastructure.Enums.StoreType.ALIYUN,
FileType = formFile.ContentType
});
return SUCCESS(new
diff --git a/ZR.Model/System/SysFile.cs b/ZR.Model/System/SysFile.cs
index f229cab..08a2fd4 100644
--- a/ZR.Model/System/SysFile.cs
+++ b/ZR.Model/System/SysFile.cs
@@ -70,5 +70,18 @@ namespace ZR.Model.System
/// 空值 : true
///
public string AccessUrl { get; set; }
+
+ public SysFile() { }
+ public SysFile(string realName, string fileName, string ext, string fileSize, string storePath, string accessUrl,string create_by)
+ {
+ StorePath = storePath;
+ RealName = realName;
+ FileName = fileName;
+ FileExt = ext;
+ FileSize = fileSize;
+ AccessUrl = accessUrl;
+ Create_by = create_by;
+ Create_time = DateTime.Now;
+ }
}
}
\ No newline at end of file
diff --git a/ZR.Vue/src/views/tool/file/index.vue b/ZR.Vue/src/views/tool/file/index.vue
index 49c2a54..c061328 100644
--- a/ZR.Vue/src/views/tool/file/index.vue
+++ b/ZR.Vue/src/views/tool/file/index.vue
@@ -113,7 +113,12 @@
{{formView.id}}
- {{formView.fileExt}}
+ {{formView.fileType}}
+
+
+
+ {{formView.fileExt}}
+
{{formView.realName}}
@@ -130,12 +135,9 @@
{{formView.create_by}}
-
- {{formView.fileUrl}}
-
-
+
@@ -146,6 +148,9 @@
+
+ {{formView.fileUrl}}
+
From b943a516e1b0692a6a77f0ae1725cbf7bc919737 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Wed, 23 Mar 2022 10:22:25 +0800
Subject: [PATCH 08/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E4=B8=8A=E4=BC=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/CommonController.cs | 47 +++-------------
ZR.Service/System/IService/ISysFileService.cs | 12 ++--
ZR.Service/System/SysFileService.cs | 56 ++++++++++++++-----
ZR.Vue/src/views/tool/file/index.vue | 31 +++++-----
4 files changed, 76 insertions(+), 70 deletions(-)
diff --git a/ZR.Admin.WebApi/Controllers/CommonController.cs b/ZR.Admin.WebApi/Controllers/CommonController.cs
index 28daeb1..9abc60c 100644
--- a/ZR.Admin.WebApi/Controllers/CommonController.cs
+++ b/ZR.Admin.WebApi/Controllers/CommonController.cs
@@ -39,16 +39,6 @@ namespace ZR.Admin.WebApi.Controllers
OptionsSetting = options.Value;
}
- ///
- /// 心跳
- ///
- ///
- [HttpGet]
- public IActionResult Health()
- {
- return SUCCESS(true);
- }
-
///
/// hello
///
@@ -106,39 +96,16 @@ namespace ZR.Admin.WebApi.Controllers
[HttpPost()]
[Verify]
[ActionPermissionFilter(Permission = "common")]
- public IActionResult UploadFile([FromForm(Name = "file")] IFormFile formFile, string fileName = "", string fileDir = "uploads", int uploadType = 0)
+ public async Task UploadFile([FromForm(Name = "file")] IFormFile formFile, string fileName = "", string fileDir = "uploads", int uploadType = 0)
{
if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "上传文件不能为空");
- string fileExt = Path.GetExtension(formFile.FileName);
- string hashFileName = FileUtil.HashFileName();
- fileName = (fileName.IsEmpty() ? hashFileName : fileName) + fileExt;
- fileDir = fileDir.IsEmpty() ? "uploads" : fileDir;
- string filePath = FileUtil.GetdirPath(fileDir);
- string finalFilePath = Path.Combine(WebHostEnvironment.WebRootPath, filePath, fileName);
- double fileSize = formFile.Length / 1024.0;
- if (!Directory.Exists(Path.GetDirectoryName(finalFilePath)))
- {
- Directory.CreateDirectory(Path.GetDirectoryName(finalFilePath));
- }
-
- using (var stream = new FileStream(finalFilePath, FileMode.Create))
- {
- formFile.CopyTo(stream);
- }
-
- string accessPath = string.Concat(OptionsSetting.Upload.UploadUrl, "/", filePath.Replace("\\", "/"), "/", fileName);
- SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", filePath, accessPath, HttpContext.GetName())
- {
- StoreType = (int)Infrastructure.Enums.StoreType.LOCAL,
- FileType = formFile.ContentType
- };
- long fileId = SysFileService.InsertFile(file);
+ SysFile file = await SysFileService.SaveFileLocal(WebHostEnvironment.WebRootPath, fileName, fileDir, HttpContext.GetName(), formFile);
return SUCCESS(new
{
- url = uploadType == 1 ? finalFilePath : accessPath,
+ url = uploadType == 1 ? file.FileUrl : file.AccessUrl,
fileName,
- fileId = fileId.ToString()
+ fileId = file.Id.ToString()
});
}
@@ -174,7 +141,11 @@ namespace ZR.Admin.WebApi.Controllers
{
result = SysFileService.SaveFile(fileDir, formFile, fileName, "");
});
- long id = SysFileService.InsertFile(new(formFile.FileName, fileName, fileExt, fileSize + "kb", "", result.Item2, HttpContext.GetName())
+ if (!result.Item1)
+ {
+ return ToResponse(ApiResult.Error("阿里云连接失败"));
+ }
+ long id = await SysFileService.InsertFile(new(formFile.FileName, fileName, fileExt, fileSize + "kb", "", result.Item2, HttpContext.GetName())
{
StoreType = (int)Infrastructure.Enums.StoreType.ALIYUN,
FileType = formFile.ContentType
diff --git a/ZR.Service/System/IService/ISysFileService.cs b/ZR.Service/System/IService/ISysFileService.cs
index 62b4f6e..aa40fee 100644
--- a/ZR.Service/System/IService/ISysFileService.cs
+++ b/ZR.Service/System/IService/ISysFileService.cs
@@ -1,5 +1,6 @@
using Infrastructure.Attribute;
using Microsoft.AspNetCore.Http;
+using System.Threading.Tasks;
using ZR.Model.Models;
using ZR.Model.System;
@@ -7,15 +8,18 @@ namespace ZR.Service.System.IService
{
public interface ISysFileService : IBaseService
{
- long InsertFile(SysFile file);
+ Task InsertFile(SysFile file);
///
/// 上传文件
///
- ///
+ ///
+ ///
///
- /// 结果、地址、文件名
- (bool, string, string) SaveFile(string picdir, IFormFile formFile);
+ ///
+ ///
+ /// 文件对象
+ Task SaveFileLocal(string rootPath, string fileName, string fileDir, string userName, IFormFile formFile);
(bool, string, string) SaveFile(string picdir, IFormFile formFile, string customFileName, string bucketName);
///
/// 按时间来创建文件夹
diff --git a/ZR.Service/System/SysFileService.cs b/ZR.Service/System/SysFileService.cs
index e3991b1..7f3c1ab 100644
--- a/ZR.Service/System/SysFileService.cs
+++ b/ZR.Service/System/SysFileService.cs
@@ -11,6 +11,8 @@ using System.Net;
using ZR.Model.System;
using ZR.Repository.System;
using Infrastructure.Extensions;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Options;
namespace ZR.Service.System
{
@@ -22,26 +24,50 @@ namespace ZR.Service.System
{
private string domainUrl = AppSettings.GetConfig("ALIYUN_OSS:domainUrl");
private readonly SysFileRepository SysFileRepository;
-
- public SysFileService(SysFileRepository repository)
+ private OptionsSetting OptionsSetting;
+ public SysFileService(SysFileRepository repository, IOptions options)
{
SysFileRepository = repository;
+ OptionsSetting = options.Value;
+ }
+
+ ///
+ /// 存储本地
+ ///
+ ///
+ public async Task SaveFileLocal(string rootPath, string fileName, string fileDir, string userName, IFormFile formFile)
+ {
+ string fileExt = Path.GetExtension(formFile.FileName);
+ string hashFileName = FileUtil.HashFileName();
+ fileName = (fileName.IsEmpty() ? hashFileName : fileName) + fileExt;
+ fileDir = fileDir.IsEmpty() ? "uploads" : fileDir;
+ string filePath = FileUtil.GetdirPath(fileDir);
+ string finalFilePath = Path.Combine(rootPath, filePath, fileName);
+ double fileSize = Math.Round(formFile.Length / 1024.0, 2);
+
+ if (!Directory.Exists(Path.GetDirectoryName(finalFilePath)))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(finalFilePath));
+ }
+
+ using (var stream = new FileStream(finalFilePath, FileMode.Create))
+ {
+ await formFile.CopyToAsync(stream);
+ }
+ string accessPath = string.Concat(OptionsSetting.Upload.UploadUrl, "/", filePath.Replace("\\", "/"), "/", fileName);
+ SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", filePath, accessPath, userName)
+ {
+ StoreType = (int)Infrastructure.Enums.StoreType.LOCAL,
+ FileType = formFile.ContentType,
+ FileUrl = finalFilePath
+ };
+ file.Id = await InsertFile(file);
+ return file;
}
///
/// 上传文件到阿里云
///
- ///
- ///
- ///
- public (bool, string, string) SaveFile(string picdir, IFormFile formFile)
- {
- return SaveFile(picdir, formFile, "", "");
- }
-
- ///
- /// 存储文件
- ///
/// 文件夹
///
/// 自定义文件名
@@ -87,11 +113,11 @@ namespace ZR.Service.System
return BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(str)), 4, 8).Replace("-", "");
}
- public long InsertFile(SysFile file)
+ public Task InsertFile(SysFile file)
{
try
{
- return Insertable(file).ExecuteReturnSnowflakeId();//单条插入返回雪花ID;
+ return Insertable(file).ExecuteReturnSnowflakeIdAsync();//单条插入返回雪花ID;
}
catch (Exception ex)
{
diff --git a/ZR.Vue/src/views/tool/file/index.vue b/ZR.Vue/src/views/tool/file/index.vue
index c061328..0deb2db 100644
--- a/ZR.Vue/src/views/tool/file/index.vue
+++ b/ZR.Vue/src/views/tool/file/index.vue
@@ -73,7 +73,7 @@
-
+
{{item.dictLabel}}
@@ -113,16 +113,18 @@
{{formView.id}}
- {{formView.fileType}}
+ {{formView.realName}}
+
+
+
+ {{formView.fileType}}
+
{{formView.fileExt}}
-
- {{formView.realName}}
-
{{formView.fileName}}
@@ -230,6 +232,17 @@ export default {
// 列表数据查询
this.getList()
},
+ watch: {
+ 'form.storeType': {
+ handler: function(val) {
+ if (val == 1) {
+ this.uploadUrl = '/common/uploadFile'
+ } else if (val == 2) {
+ this.uploadUrl = '/common/UploadFileAliyun'
+ }
+ }
+ }
+ },
methods: {
// 查询数据
getList() {
@@ -326,14 +339,6 @@ export default {
storeTypeFormat(row, column) {
return this.selectDictLabel(this.storeTypeOptions, row.storeType)
},
- handleSelectStore(val) {
- this.queryParams.storeType = val
- if (val == 1) {
- this.uploadUrl = '/common/uploadFile'
- } else if (val == 2) {
- this.uploadUrl = '/common/UploadFileAliyun'
- }
- },
/** 复制代码成功 */
clipboardSuccess() {
this.msgSuccess('复制成功')
From 25bead7cab9c4be845c4e9f7bc332663d2a19a6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Wed, 23 Mar 2022 14:01:45 +0800
Subject: [PATCH 09/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E5=AD=98=E5=82=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/CommonController.cs | 29 ++++------
ZR.Model/System/Dto/SysFileQueryDto.cs | 57 +++++++++++++++++++
ZR.Model/System/SysFile.cs | 12 ++--
ZR.Service/System/IService/ISysFileService.cs | 10 ++--
ZR.Service/System/SysFileService.cs | 51 +++++++++--------
ZR.Vue/src/views/tool/file/index.vue | 18 ++++--
6 files changed, 119 insertions(+), 58 deletions(-)
diff --git a/ZR.Admin.WebApi/Controllers/CommonController.cs b/ZR.Admin.WebApi/Controllers/CommonController.cs
index 9abc60c..d36dff1 100644
--- a/ZR.Admin.WebApi/Controllers/CommonController.cs
+++ b/ZR.Admin.WebApi/Controllers/CommonController.cs
@@ -100,7 +100,7 @@ namespace ZR.Admin.WebApi.Controllers
{
if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "上传文件不能为空");
- SysFile file = await SysFileService.SaveFileLocal(WebHostEnvironment.WebRootPath, fileName, fileDir, HttpContext.GetName(), formFile);
+ SysFile file = await SysFileService.SaveFileToLocal(WebHostEnvironment.WebRootPath, fileName, fileDir, HttpContext.GetName(), formFile);
return SUCCESS(new
{
url = uploadType == 1 ? file.FileUrl : file.AccessUrl,
@@ -121,10 +121,9 @@ namespace ZR.Admin.WebApi.Controllers
[ActionPermissionFilter(Permission = "common")]
public async Task UploadFileAliyun([FromForm(Name = "file")] IFormFile formFile, string fileName = "", string fileDir = "")
{
- if (fileDir.IsEmpty()) fileDir = "uploads";
if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "上传文件不能为空");
string fileExt = Path.GetExtension(formFile.FileName);//文件后缀
- double fileSize = formFile.Length / 1024.0;//文件大小KB
+ double fileSize = Math.Round(formFile.Length / 1024.0, 2);//文件大小KB
string[] NotAllowedFileExtensions = new string[] { ".bat", ".exe", ".jar", ".js" };
int MaxContentLength = 15;
if (NotAllowedFileExtensions.Contains(fileExt))
@@ -135,26 +134,20 @@ namespace ZR.Admin.WebApi.Controllers
{
return ToResponse(ResultCode.CUSTOM_ERROR, "上传文件过大,不能超过 " + MaxContentLength + " MB");
}
-
- (bool, string, string) result = new();
- await Task.Run(() =>
- {
- result = SysFileService.SaveFile(fileDir, formFile, fileName, "");
- });
- if (!result.Item1)
- {
- return ToResponse(ApiResult.Error("阿里云连接失败"));
- }
- long id = await SysFileService.InsertFile(new(formFile.FileName, fileName, fileExt, fileSize + "kb", "", result.Item2, HttpContext.GetName())
+ SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", fileDir, "", HttpContext.GetName())
{
StoreType = (int)Infrastructure.Enums.StoreType.ALIYUN,
FileType = formFile.ContentType
- });
+ };
+ file = await SysFileService.SaveFileToAliyun(file, formFile);
+
+ if (file.Id <= 0) { return ToResponse(ApiResult.Error("阿里云连接失败")); }
+
return SUCCESS(new
{
- url = result.Item2,
- fileName = result.Item3,
- fileId = id
+ url = file.AccessUrl,
+ fileName = file.FileName,
+ fileId = file.Id.ToString()
});
}
#endregion
diff --git a/ZR.Model/System/Dto/SysFileQueryDto.cs b/ZR.Model/System/Dto/SysFileQueryDto.cs
index fc860f8..b251f1e 100644
--- a/ZR.Model/System/Dto/SysFileQueryDto.cs
+++ b/ZR.Model/System/Dto/SysFileQueryDto.cs
@@ -10,15 +10,72 @@ namespace ZR.Model.System.Dto
public class SysFileDto
{
public long Id { get; set; }
+ ///
+ /// 文件原名
+ ///
+ public string RealName { get; set; }
+ ///
+ /// 文件类型
+ ///
+ public string FileType { get; set; }
+ ///
+ /// 描述 : 存储文件名
+ /// 空值 : true
+ ///
public string FileName { get; set; }
+ ///
+ /// 描述 : 文件存储地址 eg:/uploads/20220202
+ /// 空值 : true
+ ///
public string FileUrl { get; set; }
+ ///
+ /// 描述 : 仓库位置 eg:/uploads
+ /// 空值 : true
+ ///
public string StorePath { get; set; }
+ ///
+ /// 描述 : 文件大小
+ /// 空值 : true
+ ///
public string FileSize { get; set; }
+ ///
+ /// 描述 : 文件扩展名
+ /// 空值 : true
+ ///
public string FileExt { get; set; }
+ ///
+ /// 描述 : 创建人
+ /// 空值 : true
+ ///
public string Create_by { get; set; }
+ ///
+ /// 描述 : 上传时间
+ /// 空值 : true
+ ///
public DateTime? Create_time { get; set; }
+ ///
+ /// 描述 : 存储类型
+ /// 空值 : true
+ ///
public int? StoreType { get; set; }
+ ///
+ /// 描述 : 访问路径
+ /// 空值 : true
+ ///
public string AccessUrl { get; set; }
+
+ public SysFileDto() { }
+ public SysFileDto(string originFileName, string fileName, string ext, string fileSize, string storePath, string accessUrl, string create_by)
+ {
+ StorePath = storePath;
+ RealName = originFileName;
+ FileName = fileName;
+ FileExt = ext;
+ FileSize = fileSize;
+ AccessUrl = accessUrl;
+ Create_by = create_by;
+ Create_time = DateTime.Now;
+ }
}
public class SysFileQueryDto : PagerInfo
{
diff --git a/ZR.Model/System/SysFile.cs b/ZR.Model/System/SysFile.cs
index 08a2fd4..501b9c0 100644
--- a/ZR.Model/System/SysFile.cs
+++ b/ZR.Model/System/SysFile.cs
@@ -18,7 +18,7 @@ namespace ZR.Model.System
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
///
- /// 文件真实名
+ /// 文件原名
///
public string RealName { get; set; }
///
@@ -26,17 +26,17 @@ namespace ZR.Model.System
///
public string FileType { get; set; }
///
- /// 描述 : 文件名
+ /// 描述 : 存储文件名
/// 空值 : true
///
public string FileName { get; set; }
///
- /// 描述 : 文件存储地址
+ /// 描述 : 文件存储地址 eg:/uploads/20220202
/// 空值 : true
///
public string FileUrl { get; set; }
///
- /// 描述 : 仓库位置
+ /// 描述 : 仓库位置 eg:/uploads
/// 空值 : true
///
public string StorePath { get; set; }
@@ -72,10 +72,10 @@ namespace ZR.Model.System
public string AccessUrl { get; set; }
public SysFile() { }
- public SysFile(string realName, string fileName, string ext, string fileSize, string storePath, string accessUrl,string create_by)
+ public SysFile(string originFileName, string fileName, string ext, string fileSize, string storePath, string accessUrl,string create_by)
{
StorePath = storePath;
- RealName = realName;
+ RealName = originFileName;
FileName = fileName;
FileExt = ext;
FileSize = fileSize;
diff --git a/ZR.Service/System/IService/ISysFileService.cs b/ZR.Service/System/IService/ISysFileService.cs
index aa40fee..2482bc7 100644
--- a/ZR.Service/System/IService/ISysFileService.cs
+++ b/ZR.Service/System/IService/ISysFileService.cs
@@ -19,19 +19,21 @@ namespace ZR.Service.System.IService
///
///
/// 文件对象
- Task SaveFileLocal(string rootPath, string fileName, string fileDir, string userName, IFormFile formFile);
- (bool, string, string) SaveFile(string picdir, IFormFile formFile, string customFileName, string bucketName);
+ Task SaveFileToLocal(string rootPath, string fileName, string fileDir, string userName, IFormFile formFile);
+
+ Task SaveFileToAliyun(SysFile file, IFormFile formFile);
///
/// 按时间来创建文件夹
///
///
+ ///
/// eg: 2020/11/3
- string GetdirPath(string path = "");
+ string GetdirPath(string path = "", bool byTimeStore = true);
///
/// 取文件名的MD5值(16位)
///
- /// 文件名,不包括扩展名
+ /// 文件名,不包括扩展名
///
string HashFileName(string str = null);
}
diff --git a/ZR.Service/System/SysFileService.cs b/ZR.Service/System/SysFileService.cs
index 7f3c1ab..415a21e 100644
--- a/ZR.Service/System/SysFileService.cs
+++ b/ZR.Service/System/SysFileService.cs
@@ -35,13 +35,12 @@ namespace ZR.Service.System
/// 存储本地
///
///
- public async Task SaveFileLocal(string rootPath, string fileName, string fileDir, string userName, IFormFile formFile)
+ public async Task SaveFileToLocal(string rootPath, string fileName, string fileDir, string userName, IFormFile formFile)
{
string fileExt = Path.GetExtension(formFile.FileName);
- string hashFileName = FileUtil.HashFileName();
- fileName = (fileName.IsEmpty() ? hashFileName : fileName) + fileExt;
+ fileName = (fileName.IsEmpty() ? HashFileName() : fileName) + fileExt;
fileDir = fileDir.IsEmpty() ? "uploads" : fileDir;
- string filePath = FileUtil.GetdirPath(fileDir);
+ string filePath = GetdirPath(fileDir);
string finalFilePath = Path.Combine(rootPath, filePath, fileName);
double fileSize = Math.Round(formFile.Length / 1024.0, 2);
@@ -68,37 +67,39 @@ namespace ZR.Service.System
///
/// 上传文件到阿里云
///
- /// 文件夹
+ ///
///
- /// 自定义文件名
- /// 存储桶
///
- public (bool, string, string) SaveFile(string picdir, IFormFile formFile, string customFileName, string bucketName)
+ public async Task SaveFileToAliyun(SysFile file, IFormFile formFile)
{
- // eg: uploads/2020/08/18
- //string dir = GetdirPath(picdir.ToString());
+ file.FileName = (file.FileName.IsEmpty() ? HashFileName() : file.FileName) + file.FileExt;
+ file.StorePath = GetdirPath(file.StorePath);
+ string finalPath = Path.Combine(file.StorePath, file.FileName);
+ HttpStatusCode statusCode = AliyunOssHelper.PutObjectFromFile(formFile.OpenReadStream(), finalPath, "");
+ if (statusCode != HttpStatusCode.OK) return file;
- string tempName = customFileName.IsEmpty() ? HashFileName() : customFileName;
- string fileExt = Path.GetExtension(formFile.FileName);
- string fileName = tempName + fileExt;
- string webUrl = string.Concat(domainUrl, "/", picdir, "/", fileName);
+ file.StorePath = file.StorePath;
+ file.FileUrl = finalPath;
+ file.AccessUrl = string.Concat(domainUrl, "/", file.StorePath.Replace("\\", "/"), "/", file.FileName);
+ file.Id = await InsertFile(file);
- HttpStatusCode statusCode = AliyunOssHelper.PutObjectFromFile(formFile.OpenReadStream(), Path.Combine(picdir, fileName), bucketName);
-
- return (statusCode == HttpStatusCode.OK, webUrl, fileName);
+ return file;
}
- public string GetdirPath(string path = "")
+
+ ///
+ /// 获取文件存储目录
+ ///
+ ///
+ /// 是否按年月日存储
+ ///
+ public string GetdirPath(string storePath = "", bool byTimeStore = true)
{
DateTime date = DateTime.Now;
- int year = date.Year;
- int month = date.Month;
- int day = date.Day;
- //int hour = date.Hour;
+ string timeDir = date.ToString("yyyyMMdd");
- string timeDir = $"{year}/{month}/{day}";// date.ToString("yyyyMM/dd/HH/");
- if (!string.IsNullOrEmpty(path))
+ if (!string.IsNullOrEmpty(storePath))
{
- timeDir = path + "/" + timeDir;
+ timeDir = Path.Combine(storePath, timeDir);
}
return timeDir;
}
diff --git a/ZR.Vue/src/views/tool/file/index.vue b/ZR.Vue/src/views/tool/file/index.vue
index 0deb2db..d5b2f4c 100644
--- a/ZR.Vue/src/views/tool/file/index.vue
+++ b/ZR.Vue/src/views/tool/file/index.vue
@@ -68,11 +68,11 @@
-
-
+
+
-
+
{{item.dictLabel}}
@@ -80,13 +80,21 @@
+
-
+
-
+
From 7dcf13237977303e4d9fe65c106c6118e43fa11e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Wed, 23 Mar 2022 15:26:43 +0800
Subject: [PATCH 10/10] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A0cron=E8=A1=A8?=
=?UTF-8?q?=E8=BE=BE=E5=BC=8F=E7=BB=84=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ZR.Vue/src/components/Crontab/day.vue | 161 +++++++
ZR.Vue/src/components/Crontab/hour.vue | 114 +++++
ZR.Vue/src/components/Crontab/index.vue | 389 ++++++++++++++++
ZR.Vue/src/components/Crontab/min.vue | 116 +++++
ZR.Vue/src/components/Crontab/month.vue | 114 +++++
ZR.Vue/src/components/Crontab/result.vue | 569 +++++++++++++++++++++++
ZR.Vue/src/components/Crontab/second.vue | 117 +++++
ZR.Vue/src/components/Crontab/week.vue | 202 ++++++++
ZR.Vue/src/components/Crontab/year.vue | 131 ++++++
ZR.Vue/src/views/login.vue | 2 +-
ZR.Vue/src/views/monitor/job/index.vue | 39 +-
11 files changed, 1948 insertions(+), 6 deletions(-)
create mode 100644 ZR.Vue/src/components/Crontab/day.vue
create mode 100644 ZR.Vue/src/components/Crontab/hour.vue
create mode 100644 ZR.Vue/src/components/Crontab/index.vue
create mode 100644 ZR.Vue/src/components/Crontab/min.vue
create mode 100644 ZR.Vue/src/components/Crontab/month.vue
create mode 100644 ZR.Vue/src/components/Crontab/result.vue
create mode 100644 ZR.Vue/src/components/Crontab/second.vue
create mode 100644 ZR.Vue/src/components/Crontab/week.vue
create mode 100644 ZR.Vue/src/components/Crontab/year.vue
diff --git a/ZR.Vue/src/components/Crontab/day.vue b/ZR.Vue/src/components/Crontab/day.vue
new file mode 100644
index 0000000..fe3eaf0
--- /dev/null
+++ b/ZR.Vue/src/components/Crontab/day.vue
@@ -0,0 +1,161 @@
+
+
+
+
+ 日,允许的通配符[, - * ? / L W]
+
+
+
+
+
+ 不指定
+
+
+
+
+
+ 周期从
+ -
+ 日
+
+
+
+
+
+ 从
+ 号开始,每
+ 日执行一次
+
+
+
+
+
+ 每月
+ 号最近的那个工作日
+
+
+
+
+
+ 本月最后一天
+
+
+
+
+
+ 指定
+
+ {{item}}
+
+
+
+
+
+
+
diff --git a/ZR.Vue/src/components/Crontab/hour.vue b/ZR.Vue/src/components/Crontab/hour.vue
new file mode 100644
index 0000000..4b1f1fc
--- /dev/null
+++ b/ZR.Vue/src/components/Crontab/hour.vue
@@ -0,0 +1,114 @@
+
+
+
+
+ 小时,允许的通配符[, - * /]
+
+
+
+
+
+ 周期从
+ -
+ 小时
+
+
+
+
+
+ 从
+ 小时开始,每
+ 小时执行一次
+
+
+
+
+
+ 指定
+
+ {{item-1}}
+
+
+
+
+
+
+
diff --git a/ZR.Vue/src/components/Crontab/index.vue b/ZR.Vue/src/components/Crontab/index.vue
new file mode 100644
index 0000000..8e39046
--- /dev/null
+++ b/ZR.Vue/src/components/Crontab/index.vue
@@ -0,0 +1,389 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 确定
+ 重置
+ 取消
+
+
+
+
+
+
+
diff --git a/ZR.Vue/src/components/Crontab/min.vue b/ZR.Vue/src/components/Crontab/min.vue
new file mode 100644
index 0000000..43cab90
--- /dev/null
+++ b/ZR.Vue/src/components/Crontab/min.vue
@@ -0,0 +1,116 @@
+
+
+
+
+ 分钟,允许的通配符[, - * /]
+
+
+
+
+
+ 周期从
+ -
+ 分钟
+
+
+
+
+
+ 从
+ 分钟开始,每
+ 分钟执行一次
+
+
+
+
+
+ 指定
+
+ {{item-1}}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ZR.Vue/src/components/Crontab/month.vue b/ZR.Vue/src/components/Crontab/month.vue
new file mode 100644
index 0000000..fd0ac38
--- /dev/null
+++ b/ZR.Vue/src/components/Crontab/month.vue
@@ -0,0 +1,114 @@
+
+
+
+
+ 月,允许的通配符[, - * /]
+
+
+
+
+
+ 周期从
+ -
+ 月
+
+
+
+
+
+ 从
+ 月开始,每
+ 月月执行一次
+
+
+
+
+
+ 指定
+
+ {{item}}
+
+
+
+
+
+
+
diff --git a/ZR.Vue/src/components/Crontab/result.vue b/ZR.Vue/src/components/Crontab/result.vue
new file mode 100644
index 0000000..2ce2041
--- /dev/null
+++ b/ZR.Vue/src/components/Crontab/result.vue
@@ -0,0 +1,569 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ZR.Vue/src/components/Crontab/second.vue b/ZR.Vue/src/components/Crontab/second.vue
new file mode 100644
index 0000000..e7b7761
--- /dev/null
+++ b/ZR.Vue/src/components/Crontab/second.vue
@@ -0,0 +1,117 @@
+
+
+
+
+ 秒,允许的通配符[, - * /]
+
+
+
+
+
+ 周期从
+ -
+ 秒
+
+
+
+
+
+ 从
+ 秒开始,每
+ 秒执行一次
+
+
+
+
+
+ 指定
+
+ {{item-1}}
+
+
+
+
+
+
+
diff --git a/ZR.Vue/src/components/Crontab/week.vue b/ZR.Vue/src/components/Crontab/week.vue
new file mode 100644
index 0000000..1cec700
--- /dev/null
+++ b/ZR.Vue/src/components/Crontab/week.vue
@@ -0,0 +1,202 @@
+
+
+
+
+ 周,允许的通配符[, - * ? / L #]
+
+
+
+
+
+ 不指定
+
+
+
+
+
+ 周期从星期
+
+ {{item.value}}
+
+ -
+
+ {{item.value}}
+
+
+
+
+
+
+ 第
+ 周的星期
+
+ {{item.value}}
+
+
+
+
+
+
+ 本月最后一个星期
+
+ {{item.value}}
+
+
+
+
+
+
+ 指定
+
+ {{item.value}}
+
+
+
+
+
+
+
+
diff --git a/ZR.Vue/src/components/Crontab/year.vue b/ZR.Vue/src/components/Crontab/year.vue
new file mode 100644
index 0000000..5487a6c
--- /dev/null
+++ b/ZR.Vue/src/components/Crontab/year.vue
@@ -0,0 +1,131 @@
+
+
+
+
+ 不填,允许的通配符[, - * /]
+
+
+
+
+
+ 每年
+
+
+
+
+
+ 周期从
+ -
+
+
+
+
+
+
+ 从
+ 年开始,每
+ 年执行一次
+
+
+
+
+
+
+ 指定
+
+
+
+
+
+
+
+
+
diff --git a/ZR.Vue/src/views/login.vue b/ZR.Vue/src/views/login.vue
index 8d5cdea..5e3b75b 100644
--- a/ZR.Vue/src/views/login.vue
+++ b/ZR.Vue/src/views/login.vue
@@ -145,7 +145,7 @@ export default {
};
-