diff --git a/ZR.Admin.WebApi/Controllers/Business/GendemoController.cs b/ZR.Admin.WebApi/Controllers/Business/GendemoController.cs new file mode 100644 index 0000000..eafcbb5 --- /dev/null +++ b/ZR.Admin.WebApi/Controllers/Business/GendemoController.cs @@ -0,0 +1,167 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Infrastructure; +using Infrastructure.Attribute; +using Infrastructure.Enums; +using Infrastructure.Model; +using Mapster; +using ZR.Model.Dto; +using ZR.Model.Models; +using ZR.Service.Business.IBusinessService; +using ZR.Admin.WebApi.Extensions; +using ZR.Admin.WebApi.Filters; +using ZR.Common; +using Infrastructure.Extensions; +using System.Linq; + +namespace ZR.Admin.WebApi.Controllers +{ + /// + /// 演示Controller + /// + /// @author zz + /// @date 2022-03-31 + /// + [Verify] + [Route("business/GenDemo")] + public class GenDemoController : BaseController + { + /// + /// 演示接口 + /// + private readonly IGenDemoService _GenDemoService; + + public GenDemoController(IGenDemoService GenDemoService) + { + _GenDemoService = GenDemoService; + } + + /// + /// 查询演示列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "business:gendemo:list")] + public IActionResult QueryGenDemo([FromQuery] GenDemoQueryDto parm) + { + var response = _GenDemoService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询演示详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "business:gendemo:query")] + public IActionResult GetGenDemo(int Id) + { + var response = _GenDemoService.GetFirst(x => x.Id == Id); + + return SUCCESS(response); + } + + /// + /// 添加演示 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "business:gendemo:add")] + [Log(Title = "演示", BusinessType = BusinessType.INSERT)] + public IActionResult AddGenDemo([FromBody] GenDemoDto parm) + { + if (parm == null) + { + throw new CustomException("请求参数错误"); + } + //从 Dto 映射到 实体 + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _GenDemoService.Insert(modal, it => new + { + it.Name, + it.Icon, + it.ShowStatus, + it.Sex, + it.Sort, + it.Remark, + it.BeginTime, + it.EndTime, + it.Feature, + }); + return ToResponse(response); + } + + /// + /// 更新演示 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "business:gendemo:edit")] + [Log(Title = "演示", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateGenDemo([FromBody] GenDemoDto parm) + { + if (parm == null) + { + throw new CustomException("请求实体不能为空"); + } + //从 Dto 映射到 实体 + var modal = parm.Adapt().ToUpdate(HttpContext); + + var response = _GenDemoService.Update(w => w.Id == modal.Id, it => new GenDemo() + { + //Update 字段映射 + Name = modal.Name, + Icon = modal.Icon, + ShowStatus = modal.ShowStatus, + Sex = modal.Sex, + Sort = modal.Sort, + Remark = modal.Remark, + BeginTime = modal.BeginTime, + EndTime = modal.EndTime, + Feature = modal.Feature, + }); + + return ToResponse(response); + } + + /// + /// 删除演示 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:gendemo:delete")] + [Log(Title = "演示", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteGenDemo(string ids) + { + int[] idsArr = Tools.SpitIntArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _GenDemoService.Delete(idsArr); + + return ToResponse(response); + } + + /// + /// 导出演示 + /// + /// + [Log(Title = "演示", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)] + [HttpGet("export")] + [ActionPermissionFilter(Permission = "business:gendemo:export")] + public IActionResult Export([FromQuery] GenDemoQueryDto parm) + { + parm.PageSize = 10000; + var list = _GenDemoService.GetList(parm).Result; + + string sFileName = ExportExcel(list, "GenDemo", "演示"); + return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName }); + } + + } +} \ No newline at end of file diff --git a/ZR.Admin.WebApi/Controllers/CommonController.cs b/ZR.Admin.WebApi/Controllers/CommonController.cs index 18e2433..c9e44a6 100644 --- a/ZR.Admin.WebApi/Controllers/CommonController.cs +++ b/ZR.Admin.WebApi/Controllers/CommonController.cs @@ -139,7 +139,7 @@ namespace ZR.Admin.WebApi.Controllers return SUCCESS(new { url = file.AccessUrl, - fileName, + fileName = file.FileName, fileId = file.Id.ToString() }); } diff --git a/ZR.Admin.WebApi/Controllers/System/SysPostController.cs b/ZR.Admin.WebApi/Controllers/System/SysPostController.cs index 5deb34a..9143d49 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysPostController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysPostController.cs @@ -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))); } /// diff --git a/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs b/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs index 4ec55bf..25f2b6b 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysProfileController.cs @@ -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 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 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 }); } } } diff --git a/ZR.Admin.WebApi/Controllers/System/TasksController.cs b/ZR.Admin.WebApi/Controllers/System/TasksController.cs index 651ca6e..754eef6 100644 --- a/ZR.Admin.WebApi/Controllers/System/TasksController.cs +++ b/ZR.Admin.WebApi/Controllers/System/TasksController.cs @@ -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 /// /// 编码 /// - [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); } /// @@ -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().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) { diff --git a/ZR.Admin.WebApi/Dockerfile b/ZR.Admin.WebApi/Dockerfile new file mode 100644 index 0000000..0f0f4be --- /dev/null +++ b/ZR.Admin.WebApi/Dockerfile @@ -0,0 +1,21 @@ +FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base +# /appļ +WORKDIR /app +#Ŀ¼,ڽڷ +#VOLUME /app +#dockerⱩ¶˿ +EXPOSE 8888 +VOLUME /app/logs +#COPY bin/Release/net5.0/publish/ app/ +COPY . app/ + +#ڵʱãĬʱDZ׼ʱȱʱ8Сʱ +RUN echo "Asia/shanghai" > /etc/timezone +RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime + +# ƷļĿ¼ +#COPY . app/ +WORKDIR /app + +#ȼ dotnet ZR.Admin.WebApi.dllָ˿Ĭdocker˿80˿ +ENTRYPOINT ["dotnet", "ZR.Admin.WebApi.dll", "--server.urls","http://*:8888"] \ No newline at end of file diff --git a/ZR.Admin.WebApi/Properties/PublishProfiles/FolderProfile1.pubxml b/ZR.Admin.WebApi/Properties/PublishProfiles/FolderProfile1.pubxml new file mode 100644 index 0000000..d0d2ce9 --- /dev/null +++ b/ZR.Admin.WebApi/Properties/PublishProfiles/FolderProfile1.pubxml @@ -0,0 +1,16 @@ + + + + + False + False + True + Release + Any CPU + FileSystem + bin\Release\net6.0\publish\ + FileSystem + + \ No newline at end of file diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/README.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/README.txt new file mode 100644 index 0000000..e69de29 diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt new file mode 100644 index 0000000..d1f186f --- /dev/null +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt @@ -0,0 +1,552 @@ + + + + \ No newline at end of file diff --git a/ZR.CodeGenerator/CodeGenerateTemplate.cs b/ZR.CodeGenerator/CodeGenerateTemplate.cs index 4e526c2..b3820d9 100644 --- a/ZR.CodeGenerator/CodeGenerateTemplate.cs +++ b/ZR.CodeGenerator/CodeGenerateTemplate.cs @@ -34,26 +34,23 @@ namespace ZR.CodeGenerator sb.AppendLine(" "); sb.AppendLine($" {{{{form.{columnName}}}}}"); sb.AppendLine(" "); - return sb.ToString(); } - - //树 - if (genTable.TplCategory.Equals("tree", StringComparison.OrdinalIgnoreCase) && genTable.TreeParentCode != null && dbFieldInfo.CsharpField.Equals(genTable.TreeParentCode)) + else if (genTable.TplCategory.Equals("tree", StringComparison.OrdinalIgnoreCase) && genTable.TreeParentCode != null && dbFieldInfo.CsharpField.Equals(genTable.TreeParentCode)) { + //树 sb.AppendLine(@" "); sb.AppendLine($@" "); sb.AppendLine($@" "); sb.AppendLine(@" "); sb.AppendLine(@" "); - return sb.ToString(); } //主键、非自增要插入,不能编辑 - if (dbFieldInfo.IsPk || dbFieldInfo.IsIncrement) + else if (dbFieldInfo.IsPk || dbFieldInfo.IsIncrement) { sb.AppendLine(" "); sb.AppendLine($" "); //主键非自增 显示input - if (dbFieldInfo.IsPk && !dbFieldInfo.IsIncrement) + if (!dbFieldInfo.IsIncrement) { sb.AppendLine($" "); } @@ -64,105 +61,106 @@ namespace ZR.CodeGenerator sb.AppendLine(" "); sb.AppendLine(" "); - return sb.ToString(); - } - if (dbFieldInfo.HtmlType == GenConstants.HTML_INPUT_NUMBER) - { - //数字框 - sb.AppendLine(" "); - sb.AppendLine($" "); - sb.AppendLine($" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - } - else if (dbFieldInfo.HtmlType == GenConstants.HTML_DATETIME) - { - //时间 - sb.AppendLine(" "); - sb.AppendLine($" "); - sb.AppendLine($" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - } - else if (dbFieldInfo.HtmlType == GenConstants.HTML_IMAGE_UPLOAD) - { - //图片 - sb.AppendLine(" "); - sb.AppendLine($" "); - sb.AppendLine($@" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - } - else if (dbFieldInfo.HtmlType == GenConstants.HTML_FILE_UPLOAD) - { - //文件 - sb.AppendLine(" "); - sb.AppendLine($" "); - sb.AppendLine($@" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - } - else if (dbFieldInfo.HtmlType == GenConstants.HTML_RADIO) - { - //单选按钮 - sb.AppendLine(" "); - sb.AppendLine($" "); - sb.AppendLine($" "); - sb.AppendLine($" {{{{item.dictLabel}}}}"); - sb.AppendLine(" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - } - else if (dbFieldInfo.HtmlType == GenConstants.HTML_TEXTAREA) - { - //文本域 - sb.AppendLine(" "); - sb.AppendLine($" "); - sb.AppendLine($" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - } - else if (dbFieldInfo.HtmlType == GenConstants.HTML_EDITOR) - { - //编辑器 - sb.AppendLine(" "); - sb.AppendLine($" "); - sb.AppendLine($" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - } - else if (dbFieldInfo.HtmlType == GenConstants.HTML_SELECT) - { - //下拉框 - sb.AppendLine(" "); - sb.AppendLine($" "); - sb.AppendLine($" "); - sb.AppendLine($" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - sb.AppendLine(" "); - } - else if (dbFieldInfo.HtmlType == GenConstants.HTML_CHECKBOX) - { - //多选框 - sb.AppendLine(" "); - sb.AppendLine($" "); - sb.AppendLine($" "); - sb.AppendLine($" {{{{item.dictLabel}}}}"); - sb.AppendLine(" "); - sb.AppendLine(" "); - sb.AppendLine(" "); } else { - string inputNumTxt = CodeGeneratorTool.IsNumber(dbFieldInfo.CsharpType) ? ".number" : ""; - sb.AppendLine(" "); - sb.AppendLine($" "); - sb.AppendLine($" "); - sb.AppendLine(" "); - sb.AppendLine(" "); + if (dbFieldInfo.HtmlType == GenConstants.HTML_INPUT_NUMBER) + { + //数字框 + sb.AppendLine(" "); + sb.AppendLine($" "); + sb.AppendLine($" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + } + else if (dbFieldInfo.HtmlType == GenConstants.HTML_DATETIME) + { + //时间 + sb.AppendLine(" "); + sb.AppendLine($" "); + sb.AppendLine($" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + } + else if (dbFieldInfo.HtmlType == GenConstants.HTML_IMAGE_UPLOAD) + { + //图片 + sb.AppendLine(" "); + sb.AppendLine($" "); + sb.AppendLine($@" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + } + else if (dbFieldInfo.HtmlType == GenConstants.HTML_FILE_UPLOAD) + { + //文件 + sb.AppendLine(" "); + sb.AppendLine($" "); + sb.AppendLine($@" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + } + else if (dbFieldInfo.HtmlType == GenConstants.HTML_RADIO) + { + //单选按钮 + sb.AppendLine(" "); + sb.AppendLine($" "); + sb.AppendLine($" "); + sb.AppendLine($" {{{{item.dictLabel}}}}"); + sb.AppendLine(" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + } + else if (dbFieldInfo.HtmlType == GenConstants.HTML_TEXTAREA) + { + //文本域 + sb.AppendLine(" "); + sb.AppendLine($" "); + sb.AppendLine($" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + } + else if (dbFieldInfo.HtmlType == GenConstants.HTML_EDITOR) + { + //编辑器 + sb.AppendLine(" "); + sb.AppendLine($" "); + sb.AppendLine($" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + } + else if (dbFieldInfo.HtmlType == GenConstants.HTML_SELECT) + { + //下拉框 + sb.AppendLine(" "); + sb.AppendLine($" "); + sb.AppendLine($" "); + sb.AppendLine($" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + } + else if (dbFieldInfo.HtmlType == GenConstants.HTML_CHECKBOX) + { + //多选框 + sb.AppendLine(" "); + sb.AppendLine($" "); + sb.AppendLine($" "); + sb.AppendLine($" {{{{item.dictLabel}}}}"); + sb.AppendLine(" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + } + else + { + string inputNumTxt = CodeGeneratorTool.IsNumber(dbFieldInfo.CsharpType) ? ".number" : ""; + sb.AppendLine(" "); + sb.AppendLine($" "); + sb.AppendLine($" "); + sb.AppendLine(" "); + sb.AppendLine(" "); + } } - return sb.ToString(); } diff --git a/ZR.CodeGenerator/CodeGeneratorTool.cs b/ZR.CodeGenerator/CodeGeneratorTool.cs index 29805e2..1f8e228 100644 --- a/ZR.CodeGenerator/CodeGeneratorTool.cs +++ b/ZR.CodeGenerator/CodeGeneratorTool.cs @@ -85,6 +85,7 @@ namespace ZR.CodeGenerator GenerateService(replaceDto, dto); GenerateControllers(replaceDto, dto); GenerateVueViews(replaceDto, dto); + GenerateVue3Views(replaceDto, dto); GenerateVueJs(replaceDto, dto); GenerateSql(replaceDto, dto); @@ -201,7 +202,41 @@ namespace ZR.CodeGenerator generateDto.GenCodes.Add(new GenCode(6, "index.vue", fullPath, result)); } + /// + /// vue3 + /// + /// + /// + private static void GenerateVue3Views(ReplaceDto replaceDto, GenerateDto generateDto) + { + string fileName = string.Empty; + switch (generateDto.GenTable.TplCategory) + { + //case "tree": + // fileName = "TplTreeVue.txt"; + // break; + case "crud": + fileName = "Vue.txt"; + break; + //case "select": + // fileName = "TplVueSelect.txt"; + // break; + default: + fileName = "Vue.txt"; + break; + } + fileName = Path.Combine("v3", fileName); + var tpl = FileHelper.ReadJtTemplate(fileName); + //tpl.Set("vueQueryFormHtml", replaceDto.VueQueryFormHtml); + //tpl.Set("VueViewEditFormRuleContent", replaceDto.VueViewEditFormRuleContent);//添加、修改表单验证规则 + //tpl.Set("VueViewFormContent", replaceDto.VueViewFormHtml);//添加、修改表单 + //tpl.Set("VueViewListContent", replaceDto.VueViewListHtml);//查询 table列 + var result = tpl.Render(); + var fullPath = generateDto.IsPreview ? string.Empty : Path.Combine(generateDto.GenCodePath, "ZR.Vue3", "src", "views", generateDto.GenTable.ModuleName.FirstLowerCase(), $"{generateDto.GenTable.BusinessName.FirstUpperCase()}.vue"); + //Console.WriteLine(result); + generateDto.GenCodes.Add(new GenCode(16, "index.vue", fullPath, result)); + } /// /// 生成vue页面api /// @@ -478,6 +513,7 @@ namespace ZR.CodeGenerator options.OutMode = OutMode.Auto; //options.DisableeLogogram = true;//禁用简写 options.Data.Set("refs", "$");//特殊标签替换 + options.Data.Set("modal", "$");//特殊标签替换 options.Data.Set("index", "$");//特殊标签替换 options.Data.Set("confirm", "$");//特殊标签替换 options.Data.Set("nextTick", "$"); diff --git a/ZR.Model/Dto/Business/GendemoDto.cs b/ZR.Model/Dto/Business/GendemoDto.cs new file mode 100644 index 0000000..0276c45 --- /dev/null +++ b/ZR.Model/Dto/Business/GendemoDto.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using ZR.Model.Dto; +using ZR.Model.Models; + +namespace ZR.Model.Dto +{ + /// + /// 演示输入对象 + /// + public class GenDemoDto + { + [Required(ErrorMessage = "id不能为空")] + public int Id { get; set; } + [Required(ErrorMessage = "名称不能为空")] + public string Name { get; set; } + public string Icon { get; set; } + [Required(ErrorMessage = "显示状态不能为空")] + public int ShowStatus { get; set; } + public int? Sex { get; set; } + public int? Sort { get; set; } + public string Remark { get; set; } + public DateTime? BeginTime { get; set; } + public DateTime? EndTime { get; set; } + public string Feature { get; set; } + } + + /// + /// 演示查询对象 + /// + public class GenDemoQueryDto : PagerInfo + { + public int? Id { get; set; } + public string Name { get; set; } + public int? ShowStatus { get; set; } + public DateTime? BeginAddTime { get; set; } + public DateTime? EndAddTime { get; set; } + } +} diff --git a/ZR.Model/Models/Business/Gendemo.cs b/ZR.Model/Models/Business/Gendemo.cs new file mode 100644 index 0000000..ae8a913 --- /dev/null +++ b/ZR.Model/Models/Business/Gendemo.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using SqlSugar; +using OfficeOpenXml.Attributes; + +namespace ZR.Model.Models +{ + /// + /// 演示,数据实体对象 + /// + /// @author zz + /// @date 2022-03-31 + /// + [SugarTable("gen_demo")] + public class GenDemo + { + /// + /// 描述 : id + /// 空值 : false + /// + [EpplusTableColumn(Header = "id")] + [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 描述 : 名称 + /// 空值 : false + /// + [EpplusTableColumn(Header = "名称")] + public string Name { get; set; } + + /// + /// 描述 : 图片 + /// 空值 : true + /// + [EpplusTableColumn(Header = "图片")] + public string Icon { get; set; } + + /// + /// 描述 : 显示状态 + /// 空值 : false + /// + [EpplusTableColumn(Header = "显示状态")] + public int ShowStatus { get; set; } + + /// + /// 描述 : 添加时间 + /// 空值 : true + /// + [EpplusTableColumn(Header = "添加时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")] + public DateTime? AddTime { get; set; } + + /// + /// 描述 : 用户性别 + /// 空值 : true + /// + [EpplusTableColumn(Header = "用户性别")] + public int? Sex { get; set; } + + /// + /// 描述 : 排序 + /// 空值 : true + /// + [EpplusTableColumn(Header = "排序")] + public int? Sort { get; set; } + + /// + /// 描述 : 备注 + /// 空值 : true + /// + [EpplusTableColumn(Header = "备注")] + public string Remark { get; set; } + + /// + /// 描述 : 开始时间 + /// 空值 : true + /// + [EpplusTableColumn(Header = "开始时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")] + public DateTime? BeginTime { get; set; } + + /// + /// 描述 : 结束时间 + /// 空值 : true + /// + [EpplusTableColumn(Header = "结束时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")] + public DateTime? EndTime { get; set; } + + /// + /// 描述 : 特征 + /// 空值 : true + /// + [EpplusTableColumn(Header = "特征")] + public string Feature { get; set; } + + /// + /// 描述 : 父级id + /// 空值 : true + /// + [EpplusTableColumn(Header = "父级id")] + public int? ParentId { get; set; } + + } +} \ No newline at end of file diff --git a/ZR.Model/System/Dto/TasksDto.cs b/ZR.Model/System/Dto/TasksDto.cs index 3fa3cdf..9b0d9a9 100644 --- a/ZR.Model/System/Dto/TasksDto.cs +++ b/ZR.Model/System/Dto/TasksDto.cs @@ -112,6 +112,11 @@ namespace ZR.Model.System.Dto /// [Display(Name = "传入参数")] public string JobParams { get; set; } + public string ApiUrl { get; set; } + /// + /// 1、程序集任务 2、apiUrl任务 + /// + public int TaskType { get; set; } } /// @@ -219,6 +224,10 @@ namespace ZR.Model.System.Dto /// [Display(Name = "传入参数")] public string JobParams { get; set; } + public string ApiUrl { get; set; } + /// + /// 1、程序集任务 2、apiUrl任务 + /// + public int TaskType { get; set; } } - } diff --git a/ZR.Model/System/SysTasksQz.cs b/ZR.Model/System/SysTasksQz.cs index 58deb98..2827394 100644 --- a/ZR.Model/System/SysTasksQz.cs +++ b/ZR.Model/System/SysTasksQz.cs @@ -157,5 +157,13 @@ namespace ZR.Model.System /// 最后运行时间 /// public DateTime? LastRunTime { get; set; } + /// + /// api执行地址 + /// + public string ApiUrl { get; set; } + /// + /// 任务类型 1程序集2网络请求 + /// + public int TaskType { get; set; } } } diff --git a/ZR.Repository/Business/GendemoRepository.cs b/ZR.Repository/Business/GendemoRepository.cs new file mode 100644 index 0000000..6d9548c --- /dev/null +++ b/ZR.Repository/Business/GendemoRepository.cs @@ -0,0 +1,20 @@ +using System; +using Infrastructure.Attribute; +using ZR.Repository.System; +using ZR.Model.Models; + +namespace ZR.Repository +{ + /// + /// 演示仓储 + /// + /// @author zz + /// @date 2022-03-31 + /// + [AppService(ServiceLifetime = LifeTime.Transient)] + public class GenDemoRepository : BaseRepository + { + #region 业务逻辑代码 + #endregion + } +} \ No newline at end of file diff --git a/ZR.Service/Business/GendemoService.cs b/ZR.Service/Business/GendemoService.cs new file mode 100644 index 0000000..91dd21d --- /dev/null +++ b/ZR.Service/Business/GendemoService.cs @@ -0,0 +1,56 @@ +using Infrastructure; +using Infrastructure.Attribute; +using ZR.Model; +using ZR.Model.Dto; +using ZR.Model.Models; +using ZR.Repository; +using ZR.Service.Business.IBusinessService; +using System; +using SqlSugar; +using System.Collections.Generic; + +namespace ZR.Service.Business +{ + /// + /// 演示Service业务层处理 + /// + /// @author zz + /// @date 2022-03-31 + /// + [AppService(ServiceType = typeof(IGenDemoService), ServiceLifetime = LifeTime.Transient)] + public class GenDemoService : BaseService, IGenDemoService + { + private readonly GenDemoRepository _GenDemorepository; + public GenDemoService(GenDemoRepository repository) + { + _GenDemorepository = repository; + } + + #region 业务逻辑代码 + + /// + /// 查询演示列表 + /// + /// + /// + public PagedInfo GetList(GenDemoQueryDto parm) + { + //开始拼装查询条件 + var predicate = Expressionable.Create(); + + //搜索条件查询语法参考Sqlsugar + predicate = predicate.AndIF(parm.Id != null, it => it.Id == parm.Id); + predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name == parm.Name); + predicate = predicate.AndIF(parm.ShowStatus != null, it => it.ShowStatus == parm.ShowStatus); + predicate = predicate.AndIF(parm.BeginAddTime == null, it => it.AddTime >= DateTime.Now.AddDays(-1)); + predicate = predicate.AndIF(parm.BeginAddTime != null, it => it.AddTime >= parm.BeginAddTime && it.AddTime <= parm.EndAddTime); + var response = _GenDemorepository + .Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + return response; + } + + #endregion + } +} \ No newline at end of file diff --git a/ZR.Service/Business/IBusinessService/IGendemoService.cs b/ZR.Service/Business/IBusinessService/IGendemoService.cs new file mode 100644 index 0000000..ea2bd18 --- /dev/null +++ b/ZR.Service/Business/IBusinessService/IGendemoService.cs @@ -0,0 +1,20 @@ +using System; +using ZR.Model; +using ZR.Model.Dto; +using ZR.Model.Models; +using System.Collections.Generic; + +namespace ZR.Service.Business.IBusinessService +{ + /// + /// 演示service接口 + /// + /// @author zz + /// @date 2022-03-31 + /// + public interface IGenDemoService : IBaseService + { + PagedInfo GetList(GenDemoQueryDto parm); + + } +} diff --git a/ZR.Tasks/JobFactory.cs b/ZR.Tasks/JobFactory.cs index 13e3d50..1317ee3 100644 --- a/ZR.Tasks/JobFactory.cs +++ b/ZR.Tasks/JobFactory.cs @@ -7,7 +7,7 @@ namespace ZR.Tasks { public class JobFactory : IJobFactory { - private NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + private readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); /// /// 注入反射获取依赖对象 @@ -42,12 +42,10 @@ namespace ZR.Tasks public void ReturnJob(IJob job) { - var disposable = job as IDisposable; - if (disposable != null) + if (job is IDisposable disposable) { disposable.Dispose(); } - } } } diff --git a/ZR.Tasks/TaskScheduler/Job_HttpRequest.cs b/ZR.Tasks/TaskScheduler/Job_HttpRequest.cs new file mode 100644 index 0000000..b65a9ad --- /dev/null +++ b/ZR.Tasks/TaskScheduler/Job_HttpRequest.cs @@ -0,0 +1,33 @@ +using Infrastructure; +using Infrastructure.Attribute; +using Quartz; +using Quartz.Impl; +using Quartz.Impl.Triggers; +using System.Threading.Tasks; +using ZR.Service.System.IService; + +namespace ZR.Tasks.TaskScheduler +{ + [AppService(ServiceType = typeof(Job_HttpRequest), ServiceLifetime = LifeTime.Scoped)] + internal class Job_HttpRequest : JobBase, IJob + { + private readonly ISysTasksQzService tasksQzService; + + public Job_HttpRequest(ISysTasksQzService tasksQzService) + { + this.tasksQzService = tasksQzService; + } + public async Task Execute(IJobExecutionContext context) + { + await ExecuteJob(context, async () => await Run(context)); + } + public async Task Run(IJobExecutionContext context) + { + AbstractTrigger trigger = (context as JobExecutionContextImpl).Trigger as AbstractTrigger; + var info = await tasksQzService.GetByIdAsync(trigger.Name); + + var result = await HttpHelper.HttpPostAsync("http://" + info.ApiUrl, info.JobParams); + //Console.WriteLine(result); + } + } +} diff --git a/ZR.Vue/src/api/business/demo.js b/ZR.Vue/src/api/business/demo.js new file mode 100644 index 0000000..d26d22b --- /dev/null +++ b/ZR.Vue/src/api/business/demo.js @@ -0,0 +1,78 @@ +import request from '@/utils/request' + +/** +* 演示分页查询 +* @param {查询条件} data +*/ +export function listDemo(query) { + return request({ + url: 'business/Demo/list', + method: 'get', + params: query, + }) +} + + +/** +* 新增演示 +* @param data +*/ +export function addDemo(data) { + return request({ + url: 'business/Demo', + method: 'post', + data: data, + }) +} + +/** +* 修改演示 +* @param data +*/ +export function updateDemo(data) { + return request({ + url: 'business/Demo', + method: 'PUT', + data: data, + }) +} + +/** +* 获取演示详情 +* @param {Id} +*/ +export function getDemo(id) { + return request({ + url: 'business/Demo/' + id, + method: 'get' + }) +} + +/** +* 删除演示 +* @param {主键} pid +*/ +export function delDemo(pid) { + return request({ + url: 'business/Demo/' + pid, + method: 'delete' + }) +} + +// 导出演示 +export function exportDemo(query) { + return request({ + url: 'business/Demo/export', + method: 'get', + params: query + }) +} + +//排序 +export function changeSort(data) { + return request({ + url: 'business/Demo/ChangeSort', + method: 'get', + params: data + }) +} diff --git a/ZR.Vue/src/api/business/genDemo.js b/ZR.Vue/src/api/business/genDemo.js new file mode 100644 index 0000000..1cbb869 --- /dev/null +++ b/ZR.Vue/src/api/business/genDemo.js @@ -0,0 +1,70 @@ +import request from '@/utils/request' + +/** +* 演示分页查询 +* @param {查询条件} data +*/ +export function listGenDemo(query) { + return request({ + url: 'business/GenDemo/list', + method: 'get', + params: query, + }) +} + + +/** +* 新增演示 +* @param data +*/ +export function addGenDemo(data) { + return request({ + url: 'business/GenDemo', + method: 'post', + data: data, + }) +} + +/** +* 修改演示 +* @param data +*/ +export function updateGenDemo(data) { + return request({ + url: 'business/GenDemo', + method: 'PUT', + data: data, + }) +} + +/** +* 获取演示详情 +* @param {Id} +*/ +export function getGenDemo(id) { + return request({ + url: 'business/GenDemo/' + id, + method: 'get' + }) +} + +/** +* 删除演示 +* @param {主键} pid +*/ +export function delGenDemo(pid) { + return request({ + url: 'business/GenDemo/' + pid, + method: 'delete' + }) +} + +// 导出演示 +export function exportGenDemo(query) { + return request({ + url: 'business/GenDemo/export', + method: 'get', + params: query + }) +} + diff --git a/ZR.Vue/src/components/TopNav/index.vue b/ZR.Vue/src/components/TopNav/index.vue index e92d381..16632e0 100644 --- a/ZR.Vue/src/components/TopNav/index.vue +++ b/ZR.Vue/src/components/TopNav/index.vue @@ -97,7 +97,7 @@ export default { if (routes.length === 0) { activePath = this.currentIndex || this.defaultRouter(); - console.log("activePath", activePath); + console.log("activePath", activePath); this.activeRoutes(activePath); } return activePath; diff --git a/ZR.Vue/src/layout/components/Sidebar/index.vue b/ZR.Vue/src/layout/components/Sidebar/index.vue index 06dc015..0b1e16e 100644 --- a/ZR.Vue/src/layout/components/Sidebar/index.vue +++ b/ZR.Vue/src/layout/components/Sidebar/index.vue @@ -1,11 +1,12 @@ diff --git a/ZR.Vue/src/views/login.vue b/ZR.Vue/src/views/login.vue index 5e3b75b..890e416 100644 --- a/ZR.Vue/src/views/login.vue +++ b/ZR.Vue/src/views/login.vue @@ -126,8 +126,7 @@ export default { this.$store .dispatch("Login", this.loginForm) .then(() => { - this.msgSuccess("登陆成功"); - this.loading = true; + this.msgSuccess("登录成功"); this.$router.push({ path: this.redirect || "/" }); }) .catch((error) => { diff --git a/ZR.Vue/src/views/monitor/job/index.vue b/ZR.Vue/src/views/monitor/job/index.vue index d24036b..f08e1b8 100644 --- a/ZR.Vue/src/views/monitor/job/index.vue +++ b/ZR.Vue/src/views/monitor/job/index.vue @@ -77,46 +77,71 @@ - +
{{form.id}}
- + - + - + - - - + + + + 执行程序集 + 执行url + - - - + + + + + + - + + + + + + + + 传入参数 + - + 导入 @@ -59,7 +55,6 @@
- diff --git a/document/admin-mysql.sql b/document/admin-mysql.sql index 411f907..98f1fc7 100644 --- a/document/admin-mysql.sql +++ b/document/admin-mysql.sql @@ -26,6 +26,8 @@ CREATE TABLE `Sys_TasksQz` ( `create_by` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人编码', `update_by` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人编码', `lastRunTime` datetime(0) NULL DEFAULT NULL COMMENT '最后执行时间', + `apiUrl` varchar(200) NULL DEFAULT NULL COMMENT '网络请求地址', + `taskType` int(11) NULL DEFAULT NULL COMMENT '任务类型1程序集 2网络请求' PRIMARY KEY (`ID`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '计划任务' ROW_FORMAT = Dynamic; diff --git a/document/admin-sqlserver.sql b/document/admin-sqlserver.sql index 253a39c..eeef41b 100644 --- a/document/admin-sqlserver.sql +++ b/document/admin-sqlserver.sql @@ -25,6 +25,8 @@ CREATE TABLE sys_tasksQz create_by varchar(50) NULL DEFAULT NULL , --'创建人编码', update_by varchar(50) NULL DEFAULT NULL , --'更新人编码', lastRunTime datetime , --最后执行时间 + taskType int null , --任务类型 1程序集 2网络请求 + apiUrl varchar(200) --网络请求地址 ) GO INSERT INTO sys_tasksQz VALUES ('1410905433996136448', '测试任务', 'SYSTEM', '0 0/10 * * * ? ', 'ZR.Tasks', 'TaskScheduler.Job_SyncTest', NULL, 0, '2021-07-02 18:17:31', '9999-12-31 00:00:00', 1, 1, 1, NULL, '2021-07-02 18:17:23', '2021-07-02 18:17:31', 'admin', NULL, NULL);