Merge branch 'master' into net6.0

This commit is contained in:
不做码农
2022-04-04 08:27:47 +08:00
29 changed files with 1468 additions and 208 deletions

View File

@@ -9,6 +9,7 @@ using Infrastructure.Attribute;
using Infrastructure.Enums;
using Infrastructure;
using ZR.Service.System.IService;
using ZR.Common;
namespace ZR.Admin.WebApi.Controllers.System
{
@@ -106,9 +107,10 @@ namespace ZR.Admin.WebApi.Controllers.System
[HttpDelete("{id}")]
[ActionPermissionFilter(Permission = "system:post:remove")]
[Log(Title = "岗位删除", BusinessType = BusinessType.DELETE)]
public IActionResult Delete(int id = 0)
public IActionResult Delete(string id)
{
return ToResponse(ToJson(PostService.Delete(id)));
int[] ids = Tools.SpitIntArrary(id);
return ToResponse(ToJson(PostService.Delete(ids)));
}
/// <summary>

View File

@@ -15,6 +15,8 @@ using ZR.Common;
using ZR.Model.System.Dto;
using ZR.Model.System;
using ZR.Service.System.IService;
using Infrastructure.Extensions;
using System.Threading.Tasks;
namespace ZR.Admin.WebApi.Controllers.System
{
@@ -27,6 +29,7 @@ namespace ZR.Admin.WebApi.Controllers.System
private readonly ISysRoleService RoleService;
private readonly ISysUserPostService UserPostService;
private readonly ISysDeptService DeptService;
private readonly ISysFileService FileService;
private OptionsSetting OptionsSetting;
private IWebHostEnvironment hostEnvironment;
@@ -35,6 +38,7 @@ namespace ZR.Admin.WebApi.Controllers.System
ISysRoleService roleService,
ISysUserPostService postService,
ISysDeptService deptService,
ISysFileService sysFileService,
IOptions<OptionsSetting> options,
IWebHostEnvironment hostEnvironment)
{
@@ -42,6 +46,7 @@ namespace ZR.Admin.WebApi.Controllers.System
RoleService = roleService;
UserPostService = postService;
DeptService = deptService;
FileService = sysFileService;
OptionsSetting = options.Value;
this.hostEnvironment = hostEnvironment;
}
@@ -124,28 +129,17 @@ namespace ZR.Admin.WebApi.Controllers.System
[HttpPost("Avatar")]
[ActionPermissionFilter(Permission = "common")]
[Log(Title = "修改头像", BusinessType = BusinessType.UPDATE, IsSaveRequestData = false)]
public IActionResult Avatar([FromForm(Name = "picture")] IFormFile formFile)
public async Task<IActionResult> Avatar([FromForm(Name = "picture")] IFormFile formFile)
{
LoginUser loginUser = Framework.JwtUtil.GetLoginUser(HttpContext);
if (formFile == null) throw new CustomException("请选择文件");
string fileExt = Path.GetExtension(formFile.FileName);
string savePath = Path.Combine(hostEnvironment.WebRootPath, FileUtil.GetdirPath("uploads"));
string fileName = FileUtil.HashFileName() + (fileExt.IsEmpty() ? ".png" : fileExt);
SysFile file = await FileService.SaveFileToLocal(hostEnvironment.WebRootPath, fileName, "", HttpContext.GetName(), formFile);
if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); }
string fileName = FileUtil.HashFileName() + fileExt;
string finalFilePath = savePath + fileName;
using (var stream = new FileStream(finalFilePath, FileMode.Create))
{
formFile.CopyTo(stream);
}
string accessUrl = $"{OptionsSetting.Upload.UploadUrl}/{FileUtil.GetdirPath("uploads")}{fileName}";
UserService.UpdatePhoto(new SysUser() { Avatar = accessUrl, UserId = loginUser.UserId });
return SUCCESS(new { imgUrl = accessUrl });
UserService.UpdatePhoto(new SysUser() { Avatar = file.AccessUrl, UserId = loginUser.UserId });
return SUCCESS(new { imgUrl = file.AccessUrl });
}
}
}

View File

@@ -15,6 +15,7 @@ using ZR.Model.System;
using ZR.Service.System.IService;
using ZR.Tasks;
using Snowflake.Core;
using Infrastructure.Extensions;
namespace ZR.Admin.WebApi.Controllers
{
@@ -62,14 +63,14 @@ namespace ZR.Admin.WebApi.Controllers
/// </summary>
/// <param name="id">编码</param>
/// <returns></returns>
[HttpGet("{id}")]
[HttpGet("get")]
public IActionResult Get(string id)
{
if (!string.IsNullOrEmpty(id))
{
return SUCCESS(_tasksQzService.GetId(id));
}
return SUCCESS(_tasksQzService.GetAll());
return SUCCESS(null);
}
/// <summary>
@@ -90,7 +91,10 @@ namespace ZR.Admin.WebApi.Controllers
{
throw new CustomException($"cron表达式不正确");
}
if (string.IsNullOrEmpty(parm.ApiUrl) && parm.TaskType == 2)
{
throw new CustomException($"地址不能为空");
}
//从 Dto 映射到 实体
var tasksQz = parm.Adapt<SysTasksQz>().ToCreate();
var worker = new IdWorker(1, 1);
@@ -98,7 +102,13 @@ namespace ZR.Admin.WebApi.Controllers
tasksQz.ID = worker.NextId().ToString();
tasksQz.IsStart = false;
tasksQz.Create_by = HttpContext.GetName();
tasksQz.TaskType = parm.TaskType;
tasksQz.ApiUrl = parm.ApiUrl;
if (parm.ApiUrl.IfNotEmpty() && parm.TaskType == 2)
{
tasksQz.AssemblyName = "ZR.Tasks";
tasksQz.ClassName = "TaskScheduler.HttpResultfulJob";
}
return SUCCESS(_tasksQzService.Add(tasksQz));
}
@@ -125,7 +135,15 @@ namespace ZR.Admin.WebApi.Controllers
throw new CustomException($"cron表达式不正确");
}
var tasksQz = _tasksQzService.GetFirst(m => m.ID == parm.ID);
if (string.IsNullOrEmpty(parm.ApiUrl) && parm.TaskType == 2)
{
throw new CustomException($"api地址不能为空");
}
if (parm.ApiUrl.IfNotEmpty() && parm.TaskType == 2)
{
parm.AssemblyName = "ZR.Tasks";
parm.ClassName = "TaskScheduler.HttpResultfulJob";
}
if (tasksQz.IsStart)
{
throw new CustomException($"该任务正在运行中,请先停止在更新");
@@ -142,10 +160,12 @@ namespace ZR.Admin.WebApi.Controllers
TriggerType = parm.TriggerType,
IntervalSecond = parm.IntervalSecond,
JobParams = parm.JobParams,
Update_by = User.Identity.Name,
Update_by = HttpContextExtension.GetName(HttpContext),
Update_time = DateTime.Now,
BeginTime = parm.BeginTime,
EndTime = parm.EndTime
EndTime = parm.EndTime,
TaskType = parm.TaskType,
ApiUrl = parm.ApiUrl,
});
if (response > 0)
{