Merge branch 'dev_372'
@ -19,6 +19,7 @@ namespace Infrastructure
|
||||
[Description("NO_DATA")]
|
||||
NODATA = 106,
|
||||
|
||||
[Description("操作失败")]
|
||||
FAIL = 1,
|
||||
|
||||
[Description("服务端出错啦")]
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
如果你只是将quartz.net发布到IIS,IIS应用池回收后就不能执行任务了,那么可以使用此windows服务器定时调用quartz.net站点
|
||||
如果你只是将本项目发布到IIS,IIS应用池回收后就不能执行任务了,那么可以使用此windows服务器定时调用本项目的站点
|
||||
|
||||
1、修改App.config中的url属性value值为你当前部署的quertz.net的站点+/Health/index(注意:如果是编译后的项目,一定要修改bin/Debug/Quartz.NET.WindowsService.exe.config的配置url)
|
||||
2、用记事本打开Install.bat文件修改E:\Quartz.NET\Quartz.NET.WindowsService\bin\Debug\Quartz.NET.WindowsService.exe
|
||||
改为:(这里填写你项目所在路径)\Quartz.NET\Quartz.NET.WindowsService\bin\Debug\Quartz.NET.WindowsService.exe
|
||||
1、修改App.config中的url属性value值为你当前部署的quertz.net的站点+/Common/Health
|
||||
2、用记事本打开Install.bat文件修改 项目发布后的目录\bin\Debug\Quartz.NET.WindowsService.exe
|
||||
改为:(这里填写你项目所在路径)\Quartz.NET.WindowsService\bin\Debug\Quartz.NET.WindowsService.exe
|
||||
3、编译项目
|
||||
4、点击Install.bat安装windows服务
|
||||
|
||||
|
||||
@ -103,6 +103,7 @@ Vue版前端技术栈 :基于vue、vuex、vue-router 、vue-cli 、axios 和 e
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img src="https://gitee.com/izory/ZrAdminNetCore/raw/master/document/images/17.png"/></td>
|
||||
<td><img src="https://gitee.com/izory/ZrAdminNetCore/raw/master/document/images/18.png"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -123,4 +124,5 @@ Vue版前端技术栈 :基于vue、vuex、vue-router 、vue-cli 、axios 和 e
|
||||
<img src="https://gitee.com/izory/ZrAdminNetCore/raw/master/document/images/pay.jpg"/>
|
||||
|
||||
源码地址
|
||||
https://gitee.com/izory/ZrAdminNetCore
|
||||
[Gitee](https://gitee.com/izory/ZrAdminNetCore/)https://gitee.com/izory/ZrAdminNetCore
|
||||
[Github](https://github.com/izhaorui/ZrAdmin.NET/)https://github.com/izhaorui/ZrAdmin.NET
|
||||
@ -1,7 +1,6 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
@ -9,8 +8,6 @@ using OfficeOpenXml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
@ -18,8 +15,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
[LogActionFilter]
|
||||
public class BaseController : ControllerBase
|
||||
{
|
||||
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static string TIME_FORMAT_FULL = "yyyy-MM-dd HH:mm:ss";
|
||||
public static string TIME_FORMAT_FULL_2 = "MM-dd HH:mm:ss";
|
||||
|
||||
@ -134,5 +129,37 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
|
||||
return sFileName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载导入模板
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="fileName">下载文件名</param>
|
||||
/// <returns></returns>
|
||||
protected string DownloadImportTemplate<T>(List<T> list, Stream stream, string fileName)
|
||||
{
|
||||
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
|
||||
string sFileName = $"{fileName}模板.xlsx";
|
||||
string newFileName = Path.Combine(webHostEnvironment.WebRootPath, "importTemplate", sFileName);
|
||||
//调试模式需要加上
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
if (!Directory.Exists(newFileName))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(newFileName));
|
||||
}
|
||||
using (ExcelPackage package = new(new FileInfo(newFileName)))
|
||||
{
|
||||
// 添加worksheet
|
||||
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(fileName);
|
||||
|
||||
//全部字段导出
|
||||
worksheet.Cells.LoadFromCollection(list, true, OfficeOpenXml.Table.TableStyles.Light13);
|
||||
package.SaveAs(stream);
|
||||
}
|
||||
|
||||
return sFileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +43,12 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
return SUCCESS(true);
|
||||
}
|
||||
|
||||
[Route("/")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
return Content("Hello看到这里页面说明你已经成功启动了本项目,加油吧 少年。");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送邮件
|
||||
/// </summary>
|
||||
@ -79,7 +85,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
[Verify]
|
||||
[ActionPermissionFilter(Permission = "system")]
|
||||
[ActionPermissionFilter(Permission = "common")]
|
||||
public IActionResult UploadFile([FromForm(Name = "file")] IFormFile formFile)
|
||||
{
|
||||
if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "上传文件不能为空");
|
||||
@ -114,7 +120,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Verify]
|
||||
[ActionPermissionFilter(Permission = "system")]
|
||||
[ActionPermissionFilter(Permission = "common")]
|
||||
public IActionResult UploadFileAliyun([FromForm(Name = "file")] IFormFile formFile, string fileDir = "")
|
||||
{
|
||||
if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "上传文件不能为空");
|
||||
|
||||
@ -4,7 +4,6 @@ using Infrastructure.Enums;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
@ -19,7 +18,6 @@ using ZR.Common;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.System.Generate;
|
||||
using ZR.Service;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers
|
||||
@ -31,20 +29,18 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
[Route("tool/gen")]
|
||||
public class CodeGeneratorController : BaseController
|
||||
{
|
||||
private CodeGeneraterService _CodeGeneraterService = new CodeGeneraterService();
|
||||
private IGenTableService GenTableService;
|
||||
private IGenTableColumnService GenTableColumnService;
|
||||
private readonly ISysDictDataService SysDictDataService;
|
||||
private IWebHostEnvironment WebHostEnvironment;
|
||||
private readonly CodeGeneraterService _CodeGeneraterService = new CodeGeneraterService();
|
||||
private readonly IGenTableService GenTableService;
|
||||
private readonly IGenTableColumnService GenTableColumnService;
|
||||
|
||||
private readonly IWebHostEnvironment WebHostEnvironment;
|
||||
public CodeGeneratorController(
|
||||
IGenTableService genTableService,
|
||||
IGenTableColumnService genTableColumnService,
|
||||
ISysDictDataService dictDataService,
|
||||
IWebHostEnvironment webHostEnvironment)
|
||||
{
|
||||
GenTableService = genTableService;
|
||||
GenTableColumnService = genTableColumnService;
|
||||
SysDictDataService = dictDataService;
|
||||
WebHostEnvironment = webHostEnvironment;
|
||||
}
|
||||
|
||||
@ -62,7 +58,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///获取所有表根据数据名
|
||||
///获取所有表根据数据库名
|
||||
/// </summary>
|
||||
/// <param name="dbName">数据库名</param>
|
||||
/// <param name="tableName">表名</param>
|
||||
@ -78,12 +74,13 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取代码生成表列表
|
||||
/// 查询生成表数据
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="pagerInfo">分页信息</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("listGenTable")]
|
||||
[HttpGet("list")]
|
||||
[ActionPermissionFilter(Permission = "tool:gen:list")]
|
||||
public IActionResult GetGenTable(string tableName, PagerInfo pagerInfo)
|
||||
{
|
||||
//查询原表数据,部分字段映射到代码生成表字段
|
||||
@ -93,18 +90,34 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询表字段列表
|
||||
/// 修改代码生成业务查询
|
||||
/// </summary>
|
||||
/// <param name="tableId">genTable表id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("column/{tableId}")]
|
||||
[HttpGet("{tableId}")]
|
||||
[ActionPermissionFilter(Permission = "tool:gen:query")]
|
||||
public IActionResult GetColumnList(long tableId)
|
||||
{
|
||||
var tableColumns = GenTableColumnService.GenTableColumns(tableId);
|
||||
var tableInfo = GenTableService.GetGenTableInfo(tableId);
|
||||
return SUCCESS(new { cloumns = tableColumns, info = tableInfo });
|
||||
var tables = GenTableService.GetGenTableAll();
|
||||
|
||||
return SUCCESS(new { columns = tableColumns, info = tableInfo, tables });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据表id查询表列
|
||||
/// </summary>
|
||||
/// <param name="tableId">genTable表id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("column/{tableId}")]
|
||||
[ActionPermissionFilter(Permission = "tool:gen:query")]
|
||||
public IActionResult GetTableColumnList(long tableId)
|
||||
{
|
||||
var tableColumns = GenTableColumnService.GenTableColumns(tableId);
|
||||
|
||||
return SUCCESS(new { columns = tableColumns });
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除代码生成
|
||||
/// </summary>
|
||||
@ -144,18 +157,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
var tabInfo = _CodeGeneraterService.GetTableInfo(dbName, tableName);
|
||||
if (tabInfo != null)
|
||||
{
|
||||
GenTable genTable = new()
|
||||
{
|
||||
BaseNameSpace = "ZR.",//导入默认命名空间前缀
|
||||
ModuleName = "business",//导入默认模块名
|
||||
ClassName = CodeGeneratorTool.GetClassName(tableName),
|
||||
BusinessName = CodeGeneratorTool.GetBusinessName(tableName),
|
||||
FunctionAuthor = ConfigUtils.Instance.GetConfig(GenConstants.Gen_author),
|
||||
TableName = tableName,
|
||||
TableComment = tabInfo?.Description,
|
||||
FunctionName = tabInfo?.Description,
|
||||
Create_by = userName,
|
||||
};
|
||||
GenTable genTable = CodeGeneratorTool.InitTable(dbName, userName, tableName, tabInfo?.Description);
|
||||
genTable.TableId = GenTableService.ImportGenTable(genTable);
|
||||
|
||||
if (genTable.TableId > 0)
|
||||
@ -242,7 +244,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
[HttpPost("genCode")]
|
||||
[Log(Title = "代码生成", BusinessType = BusinessType.GENCODE)]
|
||||
[ActionPermissionFilter(Permission = "tool:gen:code")]
|
||||
public IActionResult Generate([FromBody] GenerateDto dto)
|
||||
public IActionResult CodeGenerate([FromBody] GenerateDto dto)
|
||||
{
|
||||
if (dto.TableId <= 0)
|
||||
{
|
||||
@ -260,9 +262,29 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
//下载文件
|
||||
FileHelper.ZipGenCode(dto);
|
||||
|
||||
//HttpContext.Response.Headers.Add("Content-disposition", $"attachment; filename={zipFileName}");
|
||||
return SUCCESS(new { zipPath = "/Generatecode/" + dto.ZipFileName, fileName = dto.ZipFileName });
|
||||
return SUCCESS(new { path = "/Generatecode/" + dto.ZipFileName, fileName = dto.ZipFileName });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步数据库
|
||||
/// </summary>
|
||||
/// <param name="tableId"></param>
|
||||
/// <param name="tableName"></param>
|
||||
/// <returns></returns>
|
||||
[ActionPermissionFilter(Permission = "tool:gen:edit")]
|
||||
[Log(Title = "代码生成", BusinessType = BusinessType.UPDATE)]
|
||||
[HttpGet("synchDb/{tableId}")]
|
||||
public IActionResult SynchDb(string tableName, long tableId = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tableName) || tableId <= 0) throw new CustomException("参数错误");
|
||||
GenTable table = GenTableService.GetGenTableInfo(tableId);
|
||||
if (table == null) { throw new CustomException("原表不存在"); }
|
||||
|
||||
List<DbColumnInfo> dbColumnInfos = _CodeGeneraterService.GetColumnInfo(table.DbName, tableName);
|
||||
List<GenTableColumn> dbTableColumns = CodeGeneratorTool.InitGenTableColumn(table, dbColumnInfos);
|
||||
|
||||
GenTableService.SynchDb(tableId, table, dbTableColumns);
|
||||
return SUCCESS(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,9 +3,13 @@ using Infrastructure.Enums;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Common;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.Vo;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
@ -53,6 +57,30 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
{
|
||||
return SUCCESS(SysDictDataService.SelectDictDataByType(dictType));
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据字典类型查询字典数据信息
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpPost("types")]
|
||||
public IActionResult DictTypes([FromBody] List<SysdictDataDto> dto)
|
||||
{
|
||||
var list = SysDictDataService.SelectDictDataByTypes(dto.Select(f => f.DictType).ToArray());
|
||||
List<SysdictDataDto> dataVos = new();
|
||||
|
||||
foreach (var dic in dto)
|
||||
{
|
||||
SysdictDataDto vo = new()
|
||||
{
|
||||
DictType = dic.DictType,
|
||||
ColumnName = dic.ColumnName,
|
||||
List = list.FindAll(f => f.DictType == dic.DictType)
|
||||
};
|
||||
dataVos.Add(vo);
|
||||
}
|
||||
return SUCCESS(dataVos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询字典数据详细
|
||||
|
||||
@ -95,7 +95,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
throw new CustomException($"修改岗位{post.PostName}失败,岗位编码已存在");
|
||||
}
|
||||
post.Update_by = User.Identity.Name;
|
||||
return ToResponse(ToJson(PostService.Update(post) ? 1 : 0));
|
||||
return ToResponse(PostService.Update(post));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -129,15 +129,18 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
if (sysRoleDto == null || sysRoleDto.RoleId <= 0) return ToResponse(ApiResult.Error(101, "请求参数错误"));
|
||||
|
||||
sysRoleDto.Create_by = HttpContext.GetName();
|
||||
//删除角色菜单
|
||||
sysRoleService.DeleteRoleMenuByRoleId(sysRoleDto.RoleId);
|
||||
sysRoleService.InsertRoleMenu(sysRoleDto);
|
||||
bool result = sysRoleService.UseTran2(() =>
|
||||
{
|
||||
//删除角色菜单
|
||||
sysRoleService.DeleteRoleMenuByRoleId(sysRoleDto.RoleId);
|
||||
sysRoleService.InsertRoleMenu(sysRoleDto);
|
||||
});
|
||||
|
||||
return SUCCESS(true);
|
||||
return SUCCESS(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色删除 √
|
||||
/// 角色删除
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
@ -153,7 +156,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改角色状态 √
|
||||
/// 修改角色状态
|
||||
/// </summary>
|
||||
/// <param name="roleDto">角色对象</param>
|
||||
/// <returns></returns>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -8,7 +9,9 @@ using OfficeOpenXml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using ZR.Admin.WebApi.Filters;
|
||||
using ZR.Common;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service;
|
||||
@ -170,43 +173,37 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
return ToResponse(ToJson(result));
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 导入 ok
|
||||
///// </summary>
|
||||
///// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
||||
///// <returns></returns>
|
||||
//[HttpPost("importData")]
|
||||
//[Log(Title = "用户导入", BusinessType = BusinessType.IMPORT)]
|
||||
//[ActionPermissionFilter(Permission = "system:user:import")]
|
||||
//public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
|
||||
//{
|
||||
// var mapper = new Mapper(formFile.OpenReadStream());// 从流获取
|
||||
// //读取的sheet信息
|
||||
// var rows = mapper.Take<SysUser>(0);
|
||||
// foreach (var item in rows)
|
||||
// {
|
||||
// SysUser u = item.Value;
|
||||
// }
|
||||
// //TODO 业务逻辑
|
||||
// return SUCCESS(1);
|
||||
//}
|
||||
/// <summary>
|
||||
/// 导入
|
||||
/// </summary>
|
||||
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("importData")]
|
||||
[Log(Title = "用户导入", BusinessType = BusinessType.IMPORT)]
|
||||
[ActionPermissionFilter(Permission = "system:user:import")]
|
||||
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
|
||||
{
|
||||
IEnumerable<SysUser> users = ExcelHelper<SysUser>.ImportData(formFile.OpenReadStream());
|
||||
|
||||
///// <summary>
|
||||
///// 用户模板 ok
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//[HttpGet("importTemplate")]
|
||||
//[Log(Title = "用户模板", BusinessType = BusinessType.EXPORT)]
|
||||
//[ActionPermissionFilter(Permission = "system:user:export")]
|
||||
//public IActionResult ImportTemplateExcel()
|
||||
//{
|
||||
// List<SysUser> user = new List<SysUser>();
|
||||
// var mapper = new Mapper();
|
||||
// MemoryStream stream = new MemoryStream();
|
||||
// mapper.Save(stream, user, "sheel1", overwrite: true, xlsx: true);
|
||||
// //Response.Headers.Append("content-disposition", "attachment;filename=sysUser.xlsx");
|
||||
// return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "sysUser.xlsx");
|
||||
//}
|
||||
//TODO 业务逻辑,自行插入数据到db
|
||||
return SUCCESS(users);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户导入模板下载
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("importTemplate")]
|
||||
[Log(Title = "用户模板", BusinessType = BusinessType.EXPORT)]
|
||||
[AllowAnonymous]
|
||||
public IActionResult ImportTemplateExcel()
|
||||
{
|
||||
List<SysUser> user = new List<SysUser>();
|
||||
MemoryStream stream = new MemoryStream();
|
||||
|
||||
string sFileName = DownloadImportTemplate(user, stream, "用户列表");
|
||||
return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"{sFileName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户导出
|
||||
|
||||
@ -141,7 +141,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
Update_by = User.Identity.Name,
|
||||
Update_time = DateTime.Now
|
||||
});
|
||||
if (response)
|
||||
if (response > 0)
|
||||
{
|
||||
//先暂停原先的任务
|
||||
var respon = await _schedulerServer.UpdateTaskScheduleAsync(tasksQz, tasksQz.JobGroup);
|
||||
|
||||
@ -55,12 +55,12 @@ namespace ZR.Admin.WebApi.Filters
|
||||
bool isDemoMode = ConfigUtils.Instance.GetAppConfig("DemoMode", false);
|
||||
|
||||
//演示公开环境屏蔽权限
|
||||
string[] denyPerms = new string[] { "update", "add", "remove", "add", "edit", "delete", "import", "run", "start", "stop", "clear", "send" ,"export"};
|
||||
if (isDemoMode && (denyPerms.Any(f => Permission.ToLower().Contains(f.ToLower())) || Permission.Equals("system")))
|
||||
string[] denyPerms = new string[] { "update", "add", "remove", "add", "edit", "delete", "import", "run", "start", "stop", "clear", "send" ,"export", "upload", "common"};
|
||||
if (isDemoMode && denyPerms.Any(f => Permission.ToLower().Contains(f)))
|
||||
{
|
||||
context.Result = new JsonResult(new { code = ResultCode.FORBIDDEN, msg = "演示模式 , 不允许操作" });
|
||||
}
|
||||
if (!HasPermi && !Permission.Equals("system"))
|
||||
if (!HasPermi && !Permission.Equals("common"))
|
||||
{
|
||||
logger.Info($"用户{info.NickName}没有权限访问{context.HttpContext.Request.Path},当前权限[{Permission}]");
|
||||
context.Result = new JsonResult(new { code = ResultCode.FORBIDDEN, msg = "你没有权限访问" });
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
"commandName": "Project",
|
||||
"launchBrowser": false,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Production"
|
||||
"ASPNETCORE_ENVIRONMENT": "Stage"
|
||||
},
|
||||
"applicationUrl": "http://localhost:8888"
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
-- 菜单
|
||||
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by, create_time, remark)
|
||||
VALUES ('${genTable.functionName}', ${parentId}, 1, '${genTable.ModuleName}/${replaceDto.ModelTypeName}', '${genTable.ModuleName}/${genTable.BusinessName}/index', 0, 0, 'C', '0', '0', '${replaceDto.PermissionPrefix}:list', 'icon1', '', sysdate(), '${genTable.functionName}菜单');
|
||||
VALUES ('${genTable.functionName}', ${parentId}, 1, '${genTable.ModuleName}/${replaceDto.ModelTypeName}', '${genTable.ModuleName}/${genTable.BusinessName}', 0, 0, 'C', '0', '0', '${replaceDto.PermissionPrefix}:list', 'icon1', '', sysdate(), '${genTable.functionName}菜单');
|
||||
|
||||
-- 按钮父菜单id
|
||||
SELECT @menuId := LAST_INSERT_ID();
|
||||
|
||||
@ -101,14 +101,15 @@ $end
|
||||
//从 Dto 映射到 实体
|
||||
var model = parm.Adapt<${replaceDto.ModelTypeName}>().ToCreate(HttpContext);
|
||||
|
||||
return SUCCESS(_${replaceDto.ModelTypeName}Service.Insert(model, it => new
|
||||
var response = _${replaceDto.ModelTypeName}Service.Insert(model, it => new
|
||||
{
|
||||
$foreach(item in genTable.Columns)
|
||||
$if((item.IsInsert))
|
||||
it.$item.CsharpField,
|
||||
$end
|
||||
${end}
|
||||
}));
|
||||
});
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -137,7 +138,7 @@ $end
|
||||
${end}
|
||||
});
|
||||
|
||||
return SUCCESS(response);
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -154,7 +155,7 @@ ${end}
|
||||
|
||||
var response = _${replaceDto.ModelTypeName}Service.Delete(idsArr);
|
||||
|
||||
return SUCCESS(response);
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -33,7 +33,7 @@ $end
|
||||
</el-row>
|
||||
|
||||
<!-- 数据区域 -->
|
||||
<el-table :data="dataList" ref="table" border highlight-current-row @selection-change="handleSelectionChange">
|
||||
<el-table :data="dataList" v-loading="loading" ref="table" border highlight-current-row @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="50" align="center"/>
|
||||
${VueViewListContent}
|
||||
<el-table-column label="操作" align="center" width="200">
|
||||
@ -148,12 +148,21 @@ $end
|
||||
// 列表数据查询
|
||||
this.getList();
|
||||
|
||||
$set(index = 0)
|
||||
var dictParams = [
|
||||
$foreach(item in genTable.Columns)
|
||||
$if((item.HtmlType == "radio" || item.HtmlType == "select" || item.HtmlType == "checkbox") && item.DictType != "")
|
||||
this.getDicts("${item.DictType}").then((response) => {
|
||||
this.${item.ColumnName}Options = response.data;
|
||||
})
|
||||
{ dictType: "${item.DictType}", columnName: "${item.ColumnName}Options" },
|
||||
$set(index = index + 1)
|
||||
$end
|
||||
$end
|
||||
];
|
||||
$if(index > 0)
|
||||
this.getDicts(dictParams).then((response) => {
|
||||
response.data.forEach((element) => {
|
||||
this[element.columnName] = element.list;
|
||||
});
|
||||
});
|
||||
$end
|
||||
},
|
||||
methods: {
|
||||
@ -165,11 +174,12 @@ $if(item.HtmlType == "datetime" && item.IsQuery == true)
|
||||
this.queryParams["end${item.CsharpField}"] = this.addDateRange2(this.dateRange${item.CsharpField}, 1);
|
||||
$end
|
||||
$end
|
||||
console.log(JSON.stringify(this.queryParams));
|
||||
this.loading = true;
|
||||
list${genTable.BusinessName}(this.queryParams).then(res => {
|
||||
if (res.code == 200) {
|
||||
this.dataList = res.data.result;
|
||||
this.total = res.data.totalNum;
|
||||
this.loading = false;
|
||||
}
|
||||
})
|
||||
},
|
||||
@ -185,6 +195,9 @@ $foreach(item in genTable.Columns)
|
||||
$if((item.IsEdit || item.IsInsert))
|
||||
$item.ColumnName: undefined,
|
||||
$end
|
||||
$if((item.HtmlType == "checkbox"))
|
||||
${item.ColumnName}Checked: [],
|
||||
$end
|
||||
$end
|
||||
};
|
||||
this.resetForm("form");
|
||||
@ -237,10 +250,19 @@ $end
|
||||
this.reset();
|
||||
const id = row.${replaceDto.FistLowerPk} || this.ids;
|
||||
get${genTable.BusinessName}(id).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.form = res.data;
|
||||
this.open = true;
|
||||
this.title = "修改数据";
|
||||
const { code, data } = res;
|
||||
if (code == 200) {
|
||||
this.open = true;
|
||||
this.title = "修改数据";
|
||||
|
||||
this.form = {
|
||||
...data,
|
||||
$foreach(item in genTable.Columns)
|
||||
$if(item.HtmlType == "checkbox")
|
||||
${item.ColumnName}Checked: data.${item.columnName} ? data.${item.columnName}.split(',') : [],
|
||||
$end
|
||||
$end
|
||||
};
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -278,28 +300,33 @@ $end
|
||||
submitForm: function () {
|
||||
this.${refs}refs["form"].validate((valid) => {
|
||||
if (valid) {
|
||||
$foreach(item in genTable.Columns)
|
||||
$if(item.HtmlType == "checkbox")
|
||||
this.form.${item.ColumnName} = this.form.${item.columnName}Checked.toString();
|
||||
$end
|
||||
$end
|
||||
console.log(JSON.stringify(this.form));
|
||||
|
||||
if (this.form.${replaceDto.FistLowerPk} != undefined || this.title === "修改数据") {
|
||||
update${genTable.BusinessName}(this.form).then((res) => {
|
||||
if (!res.data) {
|
||||
this.msgError("修改失败");
|
||||
return;
|
||||
}
|
||||
if (this.form.${replaceDto.FistLowerPk} != undefined && this.title === "修改数据") {
|
||||
update${genTable.BusinessName}(this.form)
|
||||
.then((res) => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
//TODO 错误逻辑
|
||||
});
|
||||
} else {
|
||||
add${genTable.BusinessName}(this.form).then((res) => {
|
||||
if (!res.data) {
|
||||
this.msgError("新增失败");
|
||||
return;
|
||||
}
|
||||
add${genTable.BusinessName}(this.form)
|
||||
.then((res) => {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
//TODO 错误逻辑
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -118,6 +118,21 @@ namespace ZR.CodeGenerator
|
||||
sb.AppendLine(" </el-form-item>");
|
||||
sb.AppendLine(" </el-col>");
|
||||
}
|
||||
else if( dbFieldInfo.HtmlType == GenConstants.HTML_CHECKBOX)
|
||||
{
|
||||
//多选框
|
||||
sb.AppendLine(" <el-col :span=\"12\">");
|
||||
sb.AppendLine($" <el-form-item label=\"{labelName}\" prop=\"{columnName}\">");
|
||||
sb.AppendLine($" <el-checkbox-group v-model=\"form.{columnName}Checked\"> ");
|
||||
if (string.IsNullOrEmpty(dbFieldInfo.DictType))
|
||||
{
|
||||
sb.AppendLine($" <el-checkbox>请选择字典生成</el-checkbox>");
|
||||
}
|
||||
sb.AppendLine($" <el-checkbox v-for=\"item in {columnName}Options\" :key=\"item.dictValue\" :label=\"item.dictValue\">{{{{item.dictLabel}}}}</el-checkbox>");
|
||||
sb.AppendLine(" </el-checkbox-group>");
|
||||
sb.AppendLine(" </el-form-item>");
|
||||
sb.AppendLine(" </el-col>");
|
||||
}
|
||||
else
|
||||
{
|
||||
string inputNumTxt = CodeGeneratorTool.IsNumber(dbFieldInfo.CsharpType) ? ".number" : "";
|
||||
|
||||
@ -37,15 +37,7 @@ namespace ZR.CodeGenerator
|
||||
_option.ApiControllerNamespace = _option.BaseNamespace + "Admin.WebApi";
|
||||
|
||||
dto.GenOptions = _option;
|
||||
GenerateSingle(dto);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单表生成代码
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
public static void GenerateSingle(GenerateDto dto)
|
||||
{
|
||||
string PKName = "Id";
|
||||
string PKType = "int";
|
||||
ReplaceDto replaceDto = new();
|
||||
@ -98,7 +90,7 @@ namespace ZR.CodeGenerator
|
||||
}
|
||||
}
|
||||
|
||||
#region 生成Model
|
||||
#region 读取模板
|
||||
|
||||
/// <summary>
|
||||
/// 生成实体类Model
|
||||
@ -128,9 +120,6 @@ namespace ZR.CodeGenerator
|
||||
var result = tpl.Render();
|
||||
generateDto.GenCodes.Add(new GenCode(2, "Dto.cs", fullPath, result));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生成Repository
|
||||
|
||||
/// <summary>
|
||||
/// 生成Repository层代码文件
|
||||
@ -146,10 +135,6 @@ namespace ZR.CodeGenerator
|
||||
generateDto.GenCodes.Add(new GenCode(3, "Repository.cs", fullPath, result));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 生成Service
|
||||
|
||||
/// <summary>
|
||||
/// 生成Service文件
|
||||
/// </summary>
|
||||
@ -166,9 +151,6 @@ namespace ZR.CodeGenerator
|
||||
generateDto.GenCodes.Add(new GenCode(4, "IService.cs", fullPath2, result2));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 生成Controller
|
||||
/// <summary>
|
||||
/// 生成控制器ApiControllers文件
|
||||
/// </summary>
|
||||
@ -181,11 +163,9 @@ namespace ZR.CodeGenerator
|
||||
var result = tpl.Render();
|
||||
generateDto.GenCodes.Add(new GenCode(5, "Controller.cs", fullPath, result));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生成Vue页面 & api
|
||||
/// <summary>
|
||||
/// 6、生成Vue页面
|
||||
/// 生成Vue页面
|
||||
private static void GenerateVueViews(ReplaceDto replaceDto, GenerateDto generateDto)
|
||||
{
|
||||
var fullPath = Path.Combine(generateDto.GenCodePath, "ZR.Vue", "src", "views", generateDto.GenTable.ModuleName, $"{generateDto.GenTable.BusinessName}.vue");
|
||||
@ -200,8 +180,9 @@ namespace ZR.CodeGenerator
|
||||
var result = tpl.Render();
|
||||
generateDto.GenCodes.Add(new GenCode(6, "index.vue", fullPath, result));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 7、生成vue页面api
|
||||
/// 生成vue页面api
|
||||
/// </summary>
|
||||
/// <param name="replaceDto"></param>
|
||||
/// <param name="generateDto"></param>
|
||||
@ -215,10 +196,11 @@ namespace ZR.CodeGenerator
|
||||
generateDto.GenCodes.Add(new GenCode(7, "api.js", fullPath, result));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 生成SQL
|
||||
|
||||
/// <summary>
|
||||
/// 生成SQL
|
||||
/// </summary>
|
||||
/// <param name="replaceDto"></param>
|
||||
/// <param name="generateDto"></param>
|
||||
public static void GenerateSql(ReplaceDto replaceDto, GenerateDto generateDto)
|
||||
{
|
||||
string fullPath = Path.Combine(generateDto.GenCodePath, generateDto.GenTable.BusinessName + ".sql");
|
||||
@ -277,10 +259,6 @@ namespace ZR.CodeGenerator
|
||||
/// <returns>业务名</returns>
|
||||
public static string GetBusinessName(string tableName)
|
||||
{
|
||||
//int firstIndex = tableName.IndexOf("_");//_前缀长度
|
||||
//int nameLength = tableName.Length;
|
||||
//int subLength = (nameLength - lastIndex) - 1;
|
||||
//string businessName = tableName[(lastIndex + 1)..];
|
||||
return tableName.Substring(0, 1).ToUpper() + tableName[1..].Replace("_", "");
|
||||
}
|
||||
|
||||
@ -334,6 +312,34 @@ namespace ZR.CodeGenerator
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 初始化信息
|
||||
|
||||
/// <summary>
|
||||
/// 初始化表信息
|
||||
/// </summary>
|
||||
/// <param name="dbName"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="tableName"></param>
|
||||
/// <param name="desc"></param>
|
||||
/// <returns></returns>
|
||||
public static GenTable InitTable(string dbName, string userName, string tableName, string desc)
|
||||
{
|
||||
GenTable genTable = new()
|
||||
{
|
||||
DbName = dbName,
|
||||
BaseNameSpace = "ZR.",//导入默认命名空间前缀
|
||||
ModuleName = "business",//导入默认模块名
|
||||
ClassName = GetClassName(tableName),
|
||||
BusinessName = GetBusinessName(tableName),
|
||||
FunctionAuthor = ConfigUtils.Instance.GetConfig(GenConstants.Gen_author),
|
||||
TableName = tableName,
|
||||
TableComment = desc,
|
||||
FunctionName = desc,
|
||||
Create_by = userName,
|
||||
};
|
||||
return genTable;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化列属性字段数据
|
||||
/// </summary>
|
||||
@ -344,68 +350,76 @@ namespace ZR.CodeGenerator
|
||||
List<GenTableColumn> genTableColumns = new();
|
||||
foreach (var column in dbColumnInfos)
|
||||
{
|
||||
GenTableColumn genTableColumn = new()
|
||||
{
|
||||
ColumnName = FirstLowerCase(column.DbColumnName),
|
||||
ColumnComment = column.ColumnDescription,
|
||||
IsPk = column.IsPrimarykey,
|
||||
ColumnType = column.DataType,
|
||||
TableId = genTable.TableId,
|
||||
TableName = genTable.TableName,
|
||||
CsharpType = GetCSharpDatatype(column.DataType),
|
||||
CsharpField = column.DbColumnName.Substring(0, 1).ToUpper() + column.DbColumnName[1..],
|
||||
IsRequired = !column.IsNullable,
|
||||
IsIncrement = column.IsIdentity,
|
||||
Create_by = genTable.Create_by,
|
||||
Create_time = DateTime.Now,
|
||||
IsInsert = !column.IsIdentity,//非自增字段都需要插入
|
||||
IsEdit = true,
|
||||
IsQuery = false,
|
||||
HtmlType = GenConstants.HTML_INPUT
|
||||
};
|
||||
|
||||
if (GenConstants.imageFiled.Any(f => column.DbColumnName.ToLower().Contains(f.ToLower())))
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_IMAGE_UPLOAD;
|
||||
}
|
||||
else if (GenConstants.COLUMNTYPE_TIME.Any(f => genTableColumn.CsharpType.ToLower().Contains(f.ToLower())))
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_DATETIME;
|
||||
}
|
||||
else if (GenConstants.radioFiled.Any(f => column.DbColumnName.EndsWith(f, StringComparison.OrdinalIgnoreCase)) ||
|
||||
GenConstants.radioFiled.Any(f => column.DbColumnName.StartsWith(f, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_RADIO;
|
||||
}
|
||||
else if (GenConstants.selectFiled.Any(f => column.DbColumnName == f) ||
|
||||
GenConstants.selectFiled.Any(f => column.DbColumnName.EndsWith(f, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_SELECT;
|
||||
}
|
||||
else if (column.Length > 500)
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_TEXTAREA;
|
||||
}
|
||||
//编辑字段
|
||||
if (column.IsIdentity || column.IsPrimarykey || GenConstants.COLUMNNAME_NOT_EDIT.Any(f => column.DbColumnName.Contains(f)))
|
||||
{
|
||||
genTableColumn.IsEdit = false;
|
||||
}
|
||||
//列表字段
|
||||
if (!GenConstants.COLUMNNAME_NOT_LIST.Any(f => column.DbColumnName.Contains(f) && !column.IsPrimarykey))
|
||||
{
|
||||
genTableColumn.IsList = true;
|
||||
}
|
||||
//时间类型初始化between范围查询
|
||||
if (genTableColumn.CsharpType == GenConstants.TYPE_DATE)
|
||||
{
|
||||
genTableColumn.QueryType = "BETWEEN";
|
||||
}
|
||||
genTableColumns.Add(genTableColumn);
|
||||
genTableColumns.Add(InitColumnField(genTable, column));
|
||||
}
|
||||
return genTableColumns;
|
||||
}
|
||||
|
||||
private static GenTableColumn InitColumnField(GenTable genTable, DbColumnInfo column)
|
||||
{
|
||||
GenTableColumn genTableColumn = new()
|
||||
{
|
||||
ColumnName = FirstLowerCase(column.DbColumnName),
|
||||
ColumnComment = column.ColumnDescription,
|
||||
IsPk = column.IsPrimarykey,
|
||||
ColumnType = column.DataType,
|
||||
TableId = genTable.TableId,
|
||||
TableName = genTable.TableName,
|
||||
CsharpType = GetCSharpDatatype(column.DataType),
|
||||
CsharpField = column.DbColumnName.Substring(0, 1).ToUpper() + column.DbColumnName[1..],
|
||||
IsRequired = !column.IsNullable,
|
||||
IsIncrement = column.IsIdentity,
|
||||
Create_by = genTable.Create_by,
|
||||
Create_time = DateTime.Now,
|
||||
IsInsert = !column.IsIdentity,//非自增字段都需要插入
|
||||
IsEdit = true,
|
||||
IsQuery = false,
|
||||
HtmlType = GenConstants.HTML_INPUT
|
||||
};
|
||||
|
||||
if (GenConstants.imageFiled.Any(f => column.DbColumnName.ToLower().Contains(f.ToLower())))
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_IMAGE_UPLOAD;
|
||||
}
|
||||
else if (GenConstants.COLUMNTYPE_TIME.Any(f => genTableColumn.CsharpType.ToLower().Contains(f.ToLower())))
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_DATETIME;
|
||||
}
|
||||
else if (GenConstants.radioFiled.Any(f => column.DbColumnName.EndsWith(f, StringComparison.OrdinalIgnoreCase)) ||
|
||||
GenConstants.radioFiled.Any(f => column.DbColumnName.StartsWith(f, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_RADIO;
|
||||
}
|
||||
else if (GenConstants.selectFiled.Any(f => column.DbColumnName == f) ||
|
||||
GenConstants.selectFiled.Any(f => column.DbColumnName.EndsWith(f, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_SELECT;
|
||||
}
|
||||
else if (column.Length > 500)
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_TEXTAREA;
|
||||
}
|
||||
//编辑字段
|
||||
if (column.IsIdentity || column.IsPrimarykey || GenConstants.COLUMNNAME_NOT_EDIT.Any(f => column.DbColumnName.Contains(f)))
|
||||
{
|
||||
genTableColumn.IsEdit = false;
|
||||
}
|
||||
//列表字段
|
||||
if (!GenConstants.COLUMNNAME_NOT_LIST.Any(f => column.DbColumnName.Contains(f) && !column.IsPrimarykey))
|
||||
{
|
||||
genTableColumn.IsList = true;
|
||||
}
|
||||
//时间类型初始化between范围查询
|
||||
if (genTableColumn.CsharpType == GenConstants.TYPE_DATE)
|
||||
{
|
||||
genTableColumn.QueryType = "BETWEEN";
|
||||
}
|
||||
|
||||
return genTableColumn;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 初始化Jnt模板
|
||||
/// </summary>
|
||||
|
||||
@ -49,7 +49,7 @@ namespace ZR.CodeGenerator.Service
|
||||
var tableList = GetSugarDbContext(dbName).DbMaintenance.GetTableInfoList(true);
|
||||
if (!string.IsNullOrEmpty(tableName))
|
||||
{
|
||||
return tableList.Where(f => f.Name.ToLower() == (tableName.ToLower())).FirstOrDefault();
|
||||
return tableList.Where(f => f.Name.Equals(tableName, System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -64,6 +64,5 @@ namespace ZR.CodeGenerator.Service
|
||||
{
|
||||
return GetSugarDbContext(dbName).DbMaintenance.GetColumnInfosByTableName(tableName, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
156
ZR.Common/ExcelHelper.cs
Normal file
@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using OfficeOpenXml;
|
||||
namespace ZR.Common
|
||||
{
|
||||
public class ExcelHelper<T> where T : new()
|
||||
{
|
||||
/// <summary>
|
||||
/// 导入数据
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> ImportData(Stream stream)
|
||||
{
|
||||
using ExcelPackage package = new(stream);
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
ExcelWorksheet worksheet = package.Workbook.Worksheets[0];//读取第1个sheet
|
||||
//获取表格的列数和行数
|
||||
|
||||
int colStart = worksheet.Dimension.Start.Column;
|
||||
int colEnd = worksheet.Dimension.End.Column;
|
||||
int rowStart = worksheet.Dimension.Start.Row;
|
||||
int rowEnd = worksheet.Dimension.End.Row;
|
||||
//int rowCount = worksheet.Dimension.Rows;
|
||||
//int ColCount = worksheet.Dimension.Columns;
|
||||
|
||||
List<T> resultList = new();
|
||||
List<PropertyInfo> propertyInfos = new();// new(typeof(T).GetProperties());
|
||||
Dictionary<string, int> dictHeader = new();
|
||||
for (int i = colStart; i < colEnd; i++)
|
||||
{
|
||||
var name = worksheet.Cells[rowStart, i].Value.ToString();
|
||||
dictHeader[name] = i;
|
||||
|
||||
PropertyInfo propertyInfo = MapPropertyInfo(name);
|
||||
if (propertyInfo != null)
|
||||
{
|
||||
propertyInfos.Add(propertyInfo);
|
||||
}
|
||||
}
|
||||
for (int row = rowStart + 1; row <= rowEnd; row++)
|
||||
{
|
||||
T result = new();
|
||||
|
||||
foreach (PropertyInfo p in propertyInfos)
|
||||
{
|
||||
try
|
||||
{
|
||||
ExcelRange cell = worksheet.Cells[row, dictHeader[p.Name]];
|
||||
if (cell.Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
switch (p.PropertyType.Name.ToLower())
|
||||
{
|
||||
case "string":
|
||||
p.SetValue(result, cell.GetValue<string>());
|
||||
break;
|
||||
case "int16":
|
||||
p.SetValue(result, cell.GetValue<short>()); break;
|
||||
case "int32":
|
||||
p.SetValue(result, cell.GetValue<int>()); break;
|
||||
case "int64":
|
||||
p.SetValue(result, cell.GetValue<long>()); break;
|
||||
case "decimal":
|
||||
p.SetValue(result, cell.GetValue<decimal>());
|
||||
break;
|
||||
case "double":
|
||||
p.SetValue(result, cell.GetValue<double>()); break;
|
||||
case "datetime":
|
||||
p.SetValue(result, cell.GetValue<DateTime>()); break;
|
||||
case "boolean":
|
||||
p.SetValue(result, cell.GetValue<bool>()); break;
|
||||
case "char":
|
||||
p.SetValue(result, cell.GetValue<string>()); break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (KeyNotFoundException ex)
|
||||
{
|
||||
Console.WriteLine("未找到该列将继续循环," + ex.Message);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
resultList.Add(result);
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找Excel列名对应的实体属性
|
||||
/// </summary>
|
||||
/// <param name="columnName"></param>
|
||||
/// <returns></returns>
|
||||
public static PropertyInfo MapPropertyInfo(string columnName)
|
||||
{
|
||||
PropertyInfo[] propertyList = GetProperties(typeof(T));
|
||||
PropertyInfo propertyInfo = propertyList.Where(p => p.Name == columnName).FirstOrDefault();
|
||||
if (propertyInfo != null)
|
||||
{
|
||||
return propertyInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (PropertyInfo tempPropertyInfo in propertyList)
|
||||
{
|
||||
System.ComponentModel.DescriptionAttribute[] attributes = (System.ComponentModel.DescriptionAttribute[])tempPropertyInfo.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);
|
||||
if (attributes.Length > 0)
|
||||
{
|
||||
if (attributes[0].Description == columnName)
|
||||
{
|
||||
return tempPropertyInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到类里面的属性集合
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="columns"></param>
|
||||
/// <returns></returns>
|
||||
public static PropertyInfo[] GetProperties(Type type, string[] columns = null)
|
||||
{
|
||||
PropertyInfo[] properties = null;
|
||||
properties = type.GetProperties();
|
||||
|
||||
if (columns != null && columns.Length > 0)
|
||||
{
|
||||
// 按columns顺序返回属性
|
||||
var columnPropertyList = new List<PropertyInfo>();
|
||||
foreach (var column in columns)
|
||||
{
|
||||
var columnProperty = properties.Where(p => p.Name == column).FirstOrDefault();
|
||||
if (columnProperty != null)
|
||||
{
|
||||
columnPropertyList.Add(columnProperty);
|
||||
}
|
||||
}
|
||||
return columnPropertyList.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
|
||||
<PackageReference Include="EPPlus" Version="5.8.3" />
|
||||
<PackageReference Include="MailKit" Version="2.15.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
13
ZR.Model/System/Dto/SysdictDataDto.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class SysdictDataDto
|
||||
{
|
||||
public string DictType { get; set; }
|
||||
public string ColumnName { get; set; }
|
||||
public List<SysDictData> List { get; set; }
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,10 @@ namespace ZR.Model.System.Generate
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int TableId { get; set; }
|
||||
/// <summary>
|
||||
/// 数据库名
|
||||
/// </summary>
|
||||
public string DbName { get; set; }
|
||||
/// <summary>
|
||||
/// 表名
|
||||
/// </summary>
|
||||
public string TableName { get; set; }
|
||||
|
||||
@ -25,7 +25,7 @@ namespace ZR.Model.System.Generate
|
||||
/// <summary>
|
||||
/// 列说明
|
||||
/// </summary>
|
||||
public string ColumnComment { get; set; }
|
||||
public string ColumnComment { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 数据库列类型
|
||||
/// </summary>
|
||||
|
||||
@ -121,24 +121,24 @@ namespace ZR.Repository
|
||||
|
||||
#region update
|
||||
|
||||
public bool Update(T entity, bool ignoreNullColumns = false)
|
||||
public int Update(T entity, bool ignoreNullColumns = false)
|
||||
{
|
||||
return Context.Updateable(entity).IgnoreColumns(ignoreNullColumns).ExecuteCommand() > 0;
|
||||
return Context.Updateable(entity).IgnoreColumns(ignoreNullColumns).ExecuteCommand();
|
||||
}
|
||||
|
||||
public bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false)
|
||||
public int Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false)
|
||||
{
|
||||
return Context.Updateable(entity).UpdateColumns(expression).IgnoreColumns(ignoreAllNull).ExecuteCommand() > 0;
|
||||
return Context.Updateable(entity).UpdateColumns(expression).IgnoreColumns(ignoreAllNull).ExecuteCommand();
|
||||
}
|
||||
|
||||
public bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
public int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
{
|
||||
return Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0;
|
||||
return Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand();
|
||||
}
|
||||
|
||||
public bool Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
public int Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
{
|
||||
return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0;
|
||||
return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -148,7 +148,7 @@ namespace ZR.Repository
|
||||
/// <param name="list"></param>
|
||||
/// <param name="isNull">默认为true</param>
|
||||
/// <returns></returns>
|
||||
public bool Update(T entity, List<string> list = null, bool isNull = true)
|
||||
public int Update(T entity, List<string> list = null, bool isNull = true)
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
@ -158,7 +158,7 @@ namespace ZR.Repository
|
||||
"Create_time"
|
||||
};
|
||||
}
|
||||
return Context.Updateable(entity).IgnoreColumns(isNull).IgnoreColumns(list.ToArray()).ExecuteCommand() > 0;
|
||||
return Context.Updateable(entity).IgnoreColumns(isNull).IgnoreColumns(list.ToArray()).ExecuteCommand();
|
||||
}
|
||||
|
||||
//public bool Update(List<T> entity)
|
||||
@ -169,9 +169,9 @@ namespace ZR.Repository
|
||||
// });
|
||||
// return result.IsSuccess;
|
||||
//}
|
||||
public bool Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns)
|
||||
public int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns)
|
||||
{
|
||||
return Context.Updateable<T>().SetColumns(columns).Where(where).RemoveDataCache().ExecuteCommand() > 0;
|
||||
return Context.Updateable<T>().SetColumns(columns).Where(where).RemoveDataCache().ExecuteCommand();
|
||||
}
|
||||
#endregion update
|
||||
|
||||
@ -218,9 +218,9 @@ namespace ZR.Repository
|
||||
{
|
||||
return Context.Deleteable<T>(id).ExecuteCommand();
|
||||
}
|
||||
public bool DeleteTable()
|
||||
public int DeleteTable()
|
||||
{
|
||||
return Context.Deleteable<T>().ExecuteCommand() > 0;
|
||||
return Context.Deleteable<T>().ExecuteCommand();
|
||||
}
|
||||
|
||||
#endregion delete
|
||||
|
||||
@ -44,7 +44,7 @@ namespace ZR.Repository
|
||||
|
||||
#region update
|
||||
|
||||
bool Update(T entity, bool ignoreNullColumns = false);
|
||||
int Update(T entity, bool ignoreNullColumns = false);
|
||||
|
||||
/// <summary>
|
||||
/// 只更新表达式的值
|
||||
@ -52,13 +52,13 @@ namespace ZR.Repository
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false);
|
||||
int Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false);
|
||||
|
||||
bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
|
||||
bool Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
int Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
|
||||
bool Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
|
||||
int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
|
||||
|
||||
#endregion update
|
||||
|
||||
@ -73,7 +73,7 @@ namespace ZR.Repository
|
||||
int Delete(Expression<Func<T, bool>> expression);
|
||||
int Delete(object[] obj);
|
||||
int Delete(object id);
|
||||
bool DeleteTable();
|
||||
int DeleteTable();
|
||||
|
||||
#endregion delete
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ using Infrastructure.Model;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
|
||||
@ -41,6 +42,17 @@ namespace ZR.Repository.System
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据字典类型查询
|
||||
/// </summary>
|
||||
/// <param name="dictData"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysDictData> SelectDictDataByTypes(string[] dictTypes)
|
||||
{
|
||||
return Context.Queryable<SysDictData>().Where(f => f.Status == "0" && dictTypes.Contains(f.DictType))
|
||||
.OrderBy(it => it.DictSort)
|
||||
.ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 新增保存字典数据信息
|
||||
/// </summary>
|
||||
|
||||
@ -122,24 +122,24 @@ namespace ZR.Service
|
||||
|
||||
#region update
|
||||
|
||||
public bool Update(T entity, bool ignoreNullColumns = false)
|
||||
public int Update(T entity, bool ignoreNullColumns = false)
|
||||
{
|
||||
return baseRepository.Update(entity, ignoreNullColumns);
|
||||
}
|
||||
|
||||
public bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false)
|
||||
public int Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false)
|
||||
{
|
||||
return baseRepository.Update(entity, expression, ignoreAllNull);
|
||||
}
|
||||
|
||||
public bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
public int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
{
|
||||
return baseRepository.Update(entity, expression, where);
|
||||
}
|
||||
|
||||
public bool Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
public int Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
|
||||
{
|
||||
return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand() > 0;
|
||||
return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand();
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
@ -171,7 +171,7 @@ namespace ZR.Service
|
||||
// });
|
||||
// return result.IsSuccess;
|
||||
//}
|
||||
public bool Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns)
|
||||
public int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns)
|
||||
{
|
||||
return baseRepository.Update(where, columns);
|
||||
}
|
||||
@ -220,7 +220,7 @@ namespace ZR.Service
|
||||
{
|
||||
return baseRepository.Delete(id);
|
||||
}
|
||||
public bool DeleteTable()
|
||||
public int DeleteTable()
|
||||
{
|
||||
return baseRepository.DeleteTable();
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ namespace ZR.Service
|
||||
|
||||
#region update
|
||||
|
||||
bool Update(T entity, bool ignoreNullColumns = false);
|
||||
int Update(T entity, bool ignoreNullColumns = false);
|
||||
|
||||
/// <summary>
|
||||
/// 只更新表达式的值
|
||||
@ -54,11 +54,11 @@ namespace ZR.Service
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="expression"></param>
|
||||
/// <returns></returns>
|
||||
bool Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false);
|
||||
int Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false);
|
||||
|
||||
bool Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
|
||||
bool Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
int Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@ -70,7 +70,7 @@ namespace ZR.Service
|
||||
//bool Update(T entity, List<string> list = null, bool isNull = true);
|
||||
|
||||
//bool Update(List<T> entity);
|
||||
bool Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
|
||||
int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
|
||||
|
||||
#endregion update
|
||||
|
||||
@ -85,7 +85,7 @@ namespace ZR.Service
|
||||
int Delete(Expression<Func<T, bool>> expression);
|
||||
int Delete(object[] obj);
|
||||
int Delete(object id);
|
||||
bool DeleteTable();
|
||||
int DeleteTable();
|
||||
|
||||
#endregion delete
|
||||
|
||||
|
||||
@ -60,6 +60,15 @@ namespace ZR.Service.System
|
||||
return info;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有代码生成表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<GenTable> GetGenTableAll()
|
||||
{
|
||||
return GenTableRepository.GetAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置代码生成其他参数
|
||||
/// </summary>
|
||||
@ -121,6 +130,35 @@ namespace ZR.Service.System
|
||||
genTable.Update_time = db.GetDate();
|
||||
return db.Updateable(genTable).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步数据库
|
||||
/// </summary>
|
||||
/// <param name="tableId">表id</param>
|
||||
/// <param name="dbTableColumns"></param>
|
||||
/// <param name="genTable"></param>
|
||||
public void SynchDb(long tableId, GenTable genTable, List<GenTableColumn> dbTableColumns)
|
||||
{
|
||||
List<GenTableColumn> tableColumns = GenTableColumnService.GenTableColumns(tableId);
|
||||
List<string> tableColumnNames = tableColumns.Select(f => f.ColumnName).ToList();
|
||||
List<string> dbTableColumneNames = dbTableColumns.Select(f => f.ColumnName).ToList();
|
||||
|
||||
List<GenTableColumn> insertColumns = new();
|
||||
foreach (var column in dbTableColumns)
|
||||
{
|
||||
if (!tableColumnNames.Contains(column.ColumnName))
|
||||
{
|
||||
insertColumns.Add(column);
|
||||
}
|
||||
}
|
||||
GenTableColumnService.Insert(insertColumns);
|
||||
|
||||
List<GenTableColumn> delColumns = tableColumns.FindAll(column => !dbTableColumneNames.Contains(column.ColumnName));
|
||||
if (delColumns!= null && delColumns.Count > 0)
|
||||
{
|
||||
GenTableColumnService.Delete(delColumns.Select(f => f.ColumnId).ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -12,8 +12,10 @@ namespace ZR.Service.System.IService
|
||||
|
||||
int DeleteGenTableByIds(long[] tableIds);
|
||||
int DeleteGenTableByTbName(string tableName);
|
||||
PagedInfo<GenTable> GetGenTables(GenTable genTable, Model.PagerInfo pagerInfo);
|
||||
PagedInfo<GenTable> GetGenTables(GenTable genTable, PagerInfo pagerInfo);
|
||||
GenTable GetGenTableInfo(long tableId);
|
||||
void SynchDb(long tableId, GenTable genTable, List<GenTableColumn> dbTableColumns);
|
||||
List<GenTable> GetGenTableAll();
|
||||
int UpdateGenTable(GenTable genTable);
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ namespace ZR.Service.System.IService
|
||||
{
|
||||
public PagedInfo<SysDictData> SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo);
|
||||
public List<SysDictData> SelectDictDataByType(string dictType);
|
||||
public List<SysDictData> SelectDictDataByTypes(string[] dictTypes);
|
||||
public SysDictData SelectDictDataById(long dictCode);
|
||||
public long InsertDictData(SysDictData dict);
|
||||
public long UpdateDictData(SysDictData dict);
|
||||
|
||||
@ -4,7 +4,7 @@ using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysRoleService
|
||||
public interface ISysRoleService : IBaseService<SysRole>
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据条件分页查询角色数据
|
||||
@ -12,7 +12,7 @@ namespace ZR.Service.System.IService
|
||||
/// <param name="role">角色信息</param>
|
||||
/// <param name="pager"></param>
|
||||
/// <returns>角色数据集合信息</returns>
|
||||
public PagedInfo<SysRole> SelectRoleList(SysRole role, Model.PagerInfo pager);
|
||||
public PagedInfo<SysRole> SelectRoleList(SysRole role, PagerInfo pager);
|
||||
|
||||
/// <summary>
|
||||
/// 查询所有角色
|
||||
@ -113,7 +113,7 @@ namespace ZR.Service.System.IService
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<long> SelectUserRoles(long userId);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户权限字符串集合
|
||||
/// </summary>
|
||||
|
||||
@ -49,7 +49,16 @@ namespace ZR.Service.System
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<SysDictData> SelectDictDataByTypes(string[] dictTypes)
|
||||
{
|
||||
string CK = $"SelectDictDataByTypes_{dictTypes}";
|
||||
if (CacheHelper.GetCache(CK) is not List<SysDictData> list)
|
||||
{
|
||||
list = SysDictDataRepository.SelectDictDataByTypes(dictTypes);
|
||||
CacheHelper.SetCache(CK, list, 30);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据字典数据ID查询信息
|
||||
/// </summary>
|
||||
|
||||
@ -17,14 +17,14 @@ namespace ZR.Service
|
||||
/// 角色
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysRoleService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysRoleService: ISysRoleService
|
||||
public class SysRoleService : BaseService<SysRole>, ISysRoleService
|
||||
{
|
||||
private SysRoleRepository SysRoleRepository;
|
||||
private ISysUserRoleService SysUserRoleService;
|
||||
|
||||
public SysRoleService(
|
||||
SysRoleRepository sysRoleRepository,
|
||||
ISysUserRoleService sysUserRoleService)
|
||||
SysRoleRepository sysRoleRepository,
|
||||
ISysUserRoleService sysUserRoleService) : base(sysRoleRepository)
|
||||
{
|
||||
SysRoleRepository = sysRoleRepository;
|
||||
SysUserRoleService = sysUserRoleService;
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
"dependencies": {
|
||||
"@riophae/vue-treeselect": "0.4.0",
|
||||
"axios": "^0.21.4",
|
||||
"clipboard": "2.0.4",
|
||||
"clipboard": "2.0.8",
|
||||
"core-js": "3.6.5",
|
||||
"echarts": "^5.1.1",
|
||||
"element-ui": "2.15.6",
|
||||
|
||||
@ -19,10 +19,18 @@ export function getData(dictCode) {
|
||||
|
||||
// 根据字典类型查询字典数据信息
|
||||
export function getDicts(dictType) {
|
||||
return request({
|
||||
url: '/system/dict/data/type/' + dictType,
|
||||
method: 'get'
|
||||
})
|
||||
if (typeof (dictType) === "object") {
|
||||
return request({
|
||||
url: '/system/dict/data/types',
|
||||
data: dictType,
|
||||
method: 'post'
|
||||
})
|
||||
} else {
|
||||
return request({
|
||||
url: '/system/dict/data/type/' + dictType,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 新增字典数据
|
||||
@ -58,4 +66,4 @@ export function exportData(query) {
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -9,8 +9,8 @@ import request from '@/utils/request'
|
||||
// }
|
||||
|
||||
/**
|
||||
* 创建数据库连接
|
||||
*/
|
||||
* 创建数据库连接
|
||||
*/
|
||||
// export function createGetDBConn(data) {
|
||||
// return request({
|
||||
// url: 'tool/gen/CreateDBConn',
|
||||
@ -19,8 +19,8 @@ import request from '@/utils/request'
|
||||
// })
|
||||
// }
|
||||
/**
|
||||
* 获取数据库
|
||||
*/
|
||||
* 获取数据库
|
||||
*/
|
||||
export function codeGetDBList() {
|
||||
return request({
|
||||
url: 'tool/gen/getDbList',
|
||||
@ -28,8 +28,8 @@ export function codeGetDBList() {
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 获取数据库表
|
||||
*/
|
||||
* 获取数据库表
|
||||
*/
|
||||
export function listDbTable(data) {
|
||||
return request({
|
||||
url: 'tool/gen/getTableList',
|
||||
@ -38,8 +38,8 @@ export function listDbTable(data) {
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 生成代码
|
||||
*/
|
||||
* 生成代码
|
||||
*/
|
||||
export async function codeGenerator(data) {
|
||||
return await request({
|
||||
url: 'tool/gen/genCode',
|
||||
@ -60,15 +60,23 @@ export function queryColumnInfo(tableId) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 查询表详细信息
|
||||
export function getGenTable(params) {
|
||||
// 查询生成表数据
|
||||
export function listTable(params) {
|
||||
return request({
|
||||
url: 'tool/gen/listGenTable',
|
||||
url: 'tool/gen/list',
|
||||
method: 'get',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
// 查询表详细信息
|
||||
export function getGenTable(tableId) {
|
||||
return request({
|
||||
url: '/tool/gen/' + tableId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 导入表
|
||||
export function importTable(data) {
|
||||
return request({
|
||||
@ -99,28 +107,15 @@ export function previewTable(tableId, data) {
|
||||
return request({
|
||||
url: '/tool/gen/preview/' + tableId,
|
||||
method: 'post',
|
||||
data: data
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// /**
|
||||
// *
|
||||
// * 数据库解密
|
||||
// */
|
||||
// export function dbtoolsConnStrDecrypt(data) {
|
||||
// return request({
|
||||
// url: 'DbTools/ConnStrDecrypt',
|
||||
// method: 'post',
|
||||
// params: data,
|
||||
// })
|
||||
// }
|
||||
// /**
|
||||
// * 数据库加密
|
||||
// */
|
||||
// export function dbtoolsConnStrEncrypt(data) {
|
||||
// return request({
|
||||
// url: 'DbTools/ConnStrEncrypt',
|
||||
// method: 'post',
|
||||
// params: data,
|
||||
// })
|
||||
// }
|
||||
// 同步数据库
|
||||
export function synchDb(tableId, data) {
|
||||
return request({
|
||||
url: '/tool/gen/synchDb/' + tableId,
|
||||
method: 'get',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
Before Width: | Height: | Size: 509 KiB After Width: | Height: | Size: 5.4 KiB |
@ -1,45 +0,0 @@
|
||||
<script>
|
||||
import { DatePicker, DatePickerOptions } from 'element-ui'
|
||||
import { calendarShortcuts } from '@/utils/shortcuts'
|
||||
|
||||
export default {
|
||||
name: 'DateRangePicker',
|
||||
mixins: [DatePicker],
|
||||
props: {
|
||||
type: {
|
||||
type: String,
|
||||
default: 'daterange'
|
||||
},
|
||||
valueFormat: {
|
||||
type: String,
|
||||
default: 'yyyy-MM-dd HH:mm:ss'
|
||||
},
|
||||
defaultTime: {
|
||||
type: Array,
|
||||
default: _ => ['00:00:00', '23:59:59']
|
||||
},
|
||||
pickerOptions: {
|
||||
type: DatePickerOptions,
|
||||
default: _ => {
|
||||
return { shortcuts: calendarShortcuts }
|
||||
}
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
default: 'small'
|
||||
},
|
||||
rangeSeparator: {
|
||||
type: String,
|
||||
default: ':'
|
||||
},
|
||||
startPlaceholder: {
|
||||
type: String,
|
||||
default: '开始日期'
|
||||
},
|
||||
endPlaceholder: {
|
||||
type: String,
|
||||
default: '结束日期'
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -144,10 +144,12 @@ export default {
|
||||
},
|
||||
// 上传成功回调
|
||||
handleUploadSuccess(res, file) {
|
||||
if (res.code != 200) {
|
||||
this.msgError(`上传失败,原因:${res.msg}!`);
|
||||
return;
|
||||
}
|
||||
this.msgSuccess("上传成功");
|
||||
console.log(res.data.fileName, res.data.url);
|
||||
this.fileList.push({ name: res.data.fileName, url: res.data.url });
|
||||
|
||||
this.$emit("input", this.column, this.listToString(this.fileList));
|
||||
},
|
||||
// 删除文件
|
||||
|
||||
@ -111,9 +111,14 @@ export default {
|
||||
},
|
||||
//上传成功回调
|
||||
handleUploadSuccess(res) {
|
||||
console.log(res);
|
||||
this.loading.close();
|
||||
if (res.code != 200) {
|
||||
this.msgError(`上传失败,原因:${res.msg}!`);
|
||||
return;
|
||||
}
|
||||
this.fileList.push({ name: res.data.fileName, url: res.data.url });
|
||||
this.$emit(`input`, this.column, this.listToString(this.fileList));
|
||||
this.loading.close();
|
||||
},
|
||||
// 上传前loading加载
|
||||
handleBeforeUpload(file) {
|
||||
@ -167,7 +172,7 @@ export default {
|
||||
for (let i in list) {
|
||||
strs += list[i].url.replace(this.baseUrl, "") + separator;
|
||||
}
|
||||
return strs != '' ? strs.substr(0, strs.length - 1) : '';
|
||||
return strs != "" ? strs.substr(0, strs.length - 1) : "";
|
||||
},
|
||||
handleUploadError() {
|
||||
this.$message({
|
||||
|
||||
54
ZR.Vue/src/directive/module/clipboard.js
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* v-clipboard 文字复制剪贴
|
||||
* Copyright (c) 2021 ruoyi
|
||||
*/
|
||||
|
||||
import Clipboard from 'clipboard'
|
||||
export default {
|
||||
bind(el, binding, vnode) {
|
||||
switch (binding.arg) {
|
||||
case 'success':
|
||||
el._vClipBoard_success = binding.value;
|
||||
break;
|
||||
case 'error':
|
||||
el._vClipBoard_error = binding.value;
|
||||
break;
|
||||
default: {
|
||||
const clipboard = new Clipboard(el, {
|
||||
text: () => binding.value,
|
||||
action: () => binding.arg === 'cut' ? 'cut' : 'copy'
|
||||
});
|
||||
clipboard.on('success', e => {
|
||||
const callback = el._vClipBoard_success;
|
||||
callback && callback(e);
|
||||
});
|
||||
clipboard.on('error', e => {
|
||||
const callback = el._vClipBoard_error;
|
||||
callback && callback(e);
|
||||
});
|
||||
el._vClipBoard = clipboard;
|
||||
}
|
||||
}
|
||||
},
|
||||
update(el, binding) {
|
||||
if (binding.arg === 'success') {
|
||||
el._vClipBoard_success = binding.value;
|
||||
} else if (binding.arg === 'error') {
|
||||
el._vClipBoard_error = binding.value;
|
||||
} else {
|
||||
el._vClipBoard.text = function () { return binding.value; };
|
||||
el._vClipBoard.action = () => binding.arg === 'cut' ? 'cut' : 'copy';
|
||||
}
|
||||
},
|
||||
unbind(el, binding) {
|
||||
if (!el._vClipboard) return
|
||||
if (binding.arg === 'success') {
|
||||
delete el._vClipBoard_success;
|
||||
} else if (binding.arg === 'error') {
|
||||
delete el._vClipBoard_error;
|
||||
} else {
|
||||
el._vClipBoard.destroy();
|
||||
delete el._vClipBoard;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
import hasRole from './hasRole'
|
||||
import hasPermi from './hasPermi'
|
||||
import clipboard from '../module/clipboard'
|
||||
|
||||
const install = function(Vue) {
|
||||
Vue.directive('hasRole', hasRole)
|
||||
Vue.directive('hasPermi', hasPermi)
|
||||
Vue.directive('clipboard', clipboard)
|
||||
}
|
||||
|
||||
if (window.Vue) {
|
||||
|
||||
@ -14,7 +14,7 @@ import permission from './directive/permission'
|
||||
|
||||
import './assets/icons' // icon
|
||||
import './permission' // permission control
|
||||
import { getDicts } from "@/api/system/dict/data";
|
||||
import { getDicts} from "@/api/system/dict/data";
|
||||
import { getConfigKey } from "@/api/system/config";
|
||||
import { parseTime, resetForm, addDateRange, addDateRange2, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi";
|
||||
//分页组件
|
||||
@ -44,15 +44,15 @@ Vue.prototype.selectDictLabels = selectDictLabels
|
||||
Vue.prototype.download = download
|
||||
Vue.prototype.handleTree = handleTree
|
||||
|
||||
Vue.prototype.msgSuccess = function(msg) {
|
||||
Vue.prototype.msgSuccess = function (msg) {
|
||||
this.$message({ showClose: true, message: msg, type: "success" });
|
||||
}
|
||||
|
||||
Vue.prototype.msgError = function(msg) {
|
||||
Vue.prototype.msgError = function (msg) {
|
||||
this.$message({ showClose: true, message: msg, type: "error" });
|
||||
}
|
||||
|
||||
Vue.prototype.msgInfo = function(msg) {
|
||||
Vue.prototype.msgInfo = function (msg) {
|
||||
this.$message.info(msg);
|
||||
}
|
||||
|
||||
|
||||
@ -1,216 +0,0 @@
|
||||
/* eslint-disable */
|
||||
|
||||
/**
|
||||
* Date对象的补充函数,包括类似Python中的strftime()
|
||||
* 阿债 https://gitee.com/azhai/datetime.js
|
||||
*/
|
||||
|
||||
Date.prototype.toMidnight = function() {
|
||||
this.setHours(0)
|
||||
this.setMinutes(0)
|
||||
this.setSeconds(0)
|
||||
this.setMilliseconds(0)
|
||||
return this
|
||||
}
|
||||
|
||||
Date.prototype.daysAgo = function(days, midnight) {
|
||||
days = days ? days - 0 : 0
|
||||
const date = new Date(this.getTime() - days * 8.64E7)
|
||||
return midnight ? date.toMidnight() : date
|
||||
}
|
||||
|
||||
Date.prototype.monthBegin = function(offset) {
|
||||
offset = offset ? offset - 0 : 0
|
||||
const days = this.getDate() - 1 - offset
|
||||
return this.daysAgo(days, true)
|
||||
}
|
||||
|
||||
Date.prototype.quarterBegin = function() {
|
||||
const month = this.getMonth() - this.getMonth() % 3
|
||||
return new Date(this.getFullYear(), month, 1).toMidnight()
|
||||
}
|
||||
|
||||
Date.prototype.yearBegin = function() {
|
||||
return new Date(this.getFullYear(), 0, 1).toMidnight()
|
||||
}
|
||||
|
||||
Date.prototype.strftime = function(format, local) {
|
||||
if (!format) {
|
||||
const str = new Date(this.getTime() + 2.88E7).toISOString()
|
||||
return str.substr(0, 16).replace('T', ' ')
|
||||
}
|
||||
local = local && local.startsWith('zh') ? 'zh' : 'en'
|
||||
const padZero = function(str, len) {
|
||||
const pads = len - str.toString().length
|
||||
return (pads && pads > 0 ? '0'.repeat(pads) : '') + str
|
||||
}
|
||||
format = format.replace('%F', '%Y-%m-%d')
|
||||
format = format.replace(/%D|%x/, '%m/%d/%y')
|
||||
format = format.replace(/%T|%X/, '%H:%M:%S')
|
||||
format = format.replace('%R', '%H:%M')
|
||||
format = format.replace('%r', '%H:%M:%S %p')
|
||||
format = format.replace('%c', '%a %b %e %H:%M:%S %Y')
|
||||
const _this = this
|
||||
return format.replace(/%[A-Za-z%]/g, function(f) {
|
||||
let ans = f
|
||||
switch (f) {
|
||||
case '%%':
|
||||
ans = '%'
|
||||
break
|
||||
|
||||
case '%Y':
|
||||
case '%G':
|
||||
ans = _this.getFullYear()
|
||||
break
|
||||
|
||||
case '%y':
|
||||
ans = _this.getFullYear() % 100
|
||||
break
|
||||
|
||||
case '%C':
|
||||
ans = _this.getFullYear() / 100
|
||||
break
|
||||
|
||||
case '%m':
|
||||
case '%n':
|
||||
ans = _this.getMonth() + 1
|
||||
break
|
||||
|
||||
case '%B':
|
||||
local = local.startsWith('en') ? 'english' : local
|
||||
|
||||
case '%b':
|
||||
const m = _this.getMonth()
|
||||
ans = local_labels.monthes[local][m]
|
||||
break
|
||||
|
||||
case '%d':
|
||||
case '%e':
|
||||
ans = _this.getDate()
|
||||
break
|
||||
|
||||
case '%j':
|
||||
ans = _this.getDaysOfYear()
|
||||
break
|
||||
|
||||
case '%U':
|
||||
case '%W':
|
||||
const ws = _this.getWeeksOfYear(f === '%W')
|
||||
ans = padZero(ws, 2)
|
||||
break
|
||||
|
||||
case '%w':
|
||||
ans = _this.getDay()
|
||||
|
||||
case '%u':
|
||||
ans = ans === 0 ? 7 : ans
|
||||
break
|
||||
|
||||
case '%A':
|
||||
local = local.startsWith('en') ? 'english' : local
|
||||
|
||||
case '%a':
|
||||
const d = _this.getDay()
|
||||
ans = local_labels.weekdays[local][d]
|
||||
break
|
||||
|
||||
case '%H':
|
||||
case '%k':
|
||||
ans = _this.getHours()
|
||||
break
|
||||
|
||||
case '%I':
|
||||
case '%l':
|
||||
ans = _this.getHours()
|
||||
ans = ans % 12
|
||||
break
|
||||
|
||||
case '%M':
|
||||
ans = _this.getMinutes()
|
||||
break
|
||||
|
||||
case '%S':
|
||||
ans = _this.getSeconds()
|
||||
break
|
||||
|
||||
case '%s':
|
||||
ans = parseInt(_this.getTime() / 1E3)
|
||||
break
|
||||
|
||||
case '%f':
|
||||
const ms = _this.getMilliseconds()
|
||||
ans = padZero(ms * 1E3, 6)
|
||||
break
|
||||
|
||||
case '%P':
|
||||
local = local.startsWith('en') ? 'english' : local
|
||||
|
||||
case '%p':
|
||||
const h = _this.getHours()
|
||||
ans = local_labels.meridians[local][h < 12 ? 0 : 1]
|
||||
break
|
||||
|
||||
case '%z':
|
||||
let tzo = _this.getTimezoneOffset()
|
||||
const sign = tzo < 0 ? '-' : '+'
|
||||
tzo = Math.abs(tzo)
|
||||
const ho = padZero(tzo / 60, 2)
|
||||
const mo = padZero(tzo % 60, 2)
|
||||
ans = sign + ho + mo
|
||||
break
|
||||
|
||||
default:
|
||||
break
|
||||
}
|
||||
if (f === '%C' || f === '%y' || f === '%m' || f === '%d' || f === '%H' || f === '%M' || f === '%S') {
|
||||
ans = padZero(ans, 2)
|
||||
}
|
||||
return ans.toString()
|
||||
})
|
||||
}
|
||||
|
||||
Date.prototype.humanize = function(local) {
|
||||
local = local && local.startsWith('zh') ? 'zh' : 'en'
|
||||
const result = this.strftime('', local)
|
||||
const days = (Date.today() - this.toMidnight().getTime()) / 8.64E7
|
||||
if (days <= -10 || days >= 10) {
|
||||
return result
|
||||
}
|
||||
const labels = local_labels.dayagos[local]
|
||||
let lbl = ''
|
||||
if (days === 0 || days === 1) {
|
||||
lbl = labels[days]
|
||||
} else if (days === -1) {
|
||||
lbl = labels[2]
|
||||
} else if (days >= 2) {
|
||||
lbl = days + labels[3]
|
||||
} else {
|
||||
lbl = days + labels[4]
|
||||
}
|
||||
return lbl + result.substr(10, 6)
|
||||
}
|
||||
|
||||
const local_labels = {
|
||||
monthes: {
|
||||
english: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||
en: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
zh: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
|
||||
},
|
||||
weekdays: {
|
||||
english: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
||||
en: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
||||
zh: ['日', '一', '二', '三', '四', '五', '六']
|
||||
},
|
||||
meridians: {
|
||||
english: ['a.m.', 'p.m.'],
|
||||
en: ['AM', 'PM'],
|
||||
zh: ['上午', '下午']
|
||||
},
|
||||
dayagos: {
|
||||
english: ['Today', 'Yesterday', 'Tomorrow', ' days ago', ' days late'],
|
||||
en: ['Today', 'Yesterday', 'Tomorrow', ' days ago', ' days late'],
|
||||
zh: ['今天', '昨天', '明天', '天前', '天后']
|
||||
}
|
||||
}
|
||||
|
||||
export default Date
|
||||
@ -1,13 +1,10 @@
|
||||
import axios from 'axios'
|
||||
import {
|
||||
MessageBox,
|
||||
Message
|
||||
} from 'element-ui'
|
||||
import { MessageBox, Message } from 'element-ui'
|
||||
import store from '@/store'
|
||||
import {
|
||||
getToken
|
||||
} from '@/utils/auth'
|
||||
import { getToken } from '@/utils/auth'
|
||||
// import { blobValidate } from "@/utils/ruoyi";
|
||||
// import errorCode from '@/utils/errorCode'
|
||||
// import { saveAs } from 'file-saver'
|
||||
|
||||
// 解决后端跨域获取不到cookie问题
|
||||
axios.defaults.withCredentials = true
|
||||
@ -44,7 +41,10 @@ service.interceptors.response.use(res => {
|
||||
}
|
||||
// 未设置状态码则默认成功状态
|
||||
const { code, msg } = res.data;
|
||||
|
||||
// 二进制数据则直接返回
|
||||
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
|
||||
return res.data
|
||||
}
|
||||
if (code == 401) {
|
||||
MessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
|
||||
confirmButtonText: '重新登录',
|
||||
@ -57,7 +57,7 @@ service.interceptors.response.use(res => {
|
||||
})
|
||||
|
||||
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
|
||||
} else if (code == 0 || code == 110 || code == 101 || code == 403 || code == 500) {
|
||||
} else if (code == 0 || code == 1 || code == 110 || code == 101 || code == 403 || code == 500) {
|
||||
Message({
|
||||
message: msg,
|
||||
type: 'error'
|
||||
@ -138,4 +138,32 @@ export function postForm(url, data, config) {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 通用下载方法
|
||||
// export function download(url, params, filename) {
|
||||
// //downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
|
||||
// return service.post(url, params, {
|
||||
// //transformRequest: [(params) => { return tansParams(params) }],
|
||||
// headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
// responseType: 'blob'
|
||||
// }).then(async (data) => {
|
||||
// const isLogin = await blobValidate(data);
|
||||
// if (isLogin) {
|
||||
// const blob = new Blob([data])
|
||||
// saveAs(blob, filename)
|
||||
// } else {
|
||||
// const resText = await data.text();
|
||||
// const rspObj = JSON.parse(resText);
|
||||
// const errMsg = "出錯了";// errorCode[rspObj.code] || rspObj.msg || errorCode['default']
|
||||
// Message.error(errMsg);
|
||||
// }
|
||||
// // downloadLoadingInstance.close();
|
||||
// }).catch((r) => {
|
||||
// console.error(r)
|
||||
// Message.error('下载文件出现错误,请联系管理员!')
|
||||
// // downloadLoadingInstance.close();
|
||||
// })
|
||||
// }
|
||||
|
||||
export default service
|
||||
@ -69,8 +69,8 @@ export function addDateRange2(dateRange, index) {
|
||||
var time = undefined;
|
||||
if (null != dateRange && '' != dateRange) {
|
||||
if (dateRange.length <= 2) {
|
||||
time = dateRange[index];
|
||||
}
|
||||
time = dateRange[index];
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
@ -119,7 +119,9 @@ export function download(fileName) {
|
||||
|
||||
// 字符串格式化(%s )
|
||||
export function sprintf(str) {
|
||||
var args = arguments, flag = true, i = 1;
|
||||
var args = arguments,
|
||||
flag = true,
|
||||
i = 1;
|
||||
str = str.replace(/%s/g, function () {
|
||||
var arg = args[i++];
|
||||
if (typeof arg === 'undefined') {
|
||||
@ -172,3 +174,14 @@ export function handleTree(data, id, parentId, children, rootId) {
|
||||
});
|
||||
return treeData != '' ? treeData : data;
|
||||
}
|
||||
|
||||
// 验证是否为blob格式
|
||||
export async function blobValidate(data) {
|
||||
try {
|
||||
const text = await data.text();
|
||||
JSON.parse(text);
|
||||
return false;
|
||||
} catch (error) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,108 +0,0 @@
|
||||
import Date from './datetime.js'
|
||||
|
||||
export const calendarBaseShortcuts = [{
|
||||
text: '今天',
|
||||
onClick(picker) {
|
||||
const startTime = new Date(new Date().setHours(0, 0, 0))
|
||||
const endTime = new Date(new Date().setHours(23, 59, 59))
|
||||
picker.$emit('pick', [startTime, endTime])
|
||||
}
|
||||
}, {
|
||||
text: '昨天',
|
||||
onClick(picker) {
|
||||
const startTime = new Date(new Date().daysAgo(1).setHours(0, 0, 0))
|
||||
const endTime = new Date(new Date().daysAgo(1).setHours(23, 59, 59))
|
||||
picker.$emit('pick', [startTime, endTime])
|
||||
}
|
||||
}, {
|
||||
text: '最近一周',
|
||||
onClick(picker) {
|
||||
const startTime = new Date(new Date().daysAgo(7).setHours(0, 0, 0))
|
||||
const endTime = new Date(new Date().setHours(23, 59, 59))
|
||||
picker.$emit('pick', [startTime, endTime])
|
||||
}
|
||||
}, {
|
||||
text: '最近30天',
|
||||
onClick(picker) {
|
||||
const startTime = new Date(new Date().daysAgo(30).setHours(0, 0, 0))
|
||||
const endTime = new Date(new Date().setHours(23, 59, 59))
|
||||
picker.$emit('pick', [startTime, endTime])
|
||||
}
|
||||
}, {
|
||||
text: '这个月',
|
||||
onClick(picker) {
|
||||
const startTime = new Date(new Date().monthBegin().setHours(0, 0, 0))
|
||||
const endTime = new Date(new Date().setHours(23, 59, 59))
|
||||
picker.$emit('pick', [startTime, endTime])
|
||||
}
|
||||
}, {
|
||||
text: '本季度',
|
||||
onClick(picker) {
|
||||
const startTime = new Date(new Date().quarterBegin().setHours(0, 0, 0))
|
||||
const endTime = new Date(new Date().setHours(23, 59, 59))
|
||||
picker.$emit('pick', [startTime, endTime])
|
||||
}
|
||||
}]
|
||||
|
||||
export const calendarMoveShortcuts = [{
|
||||
text: '‹ 往前一天 ',
|
||||
onClick(picker) {
|
||||
let startTime = new Date(new Date().daysAgo(1).setHours(0, 0, 0))
|
||||
let endTime = new Date(new Date().daysAgo(1).setHours(23, 59, 59))
|
||||
if (!picker.value) {
|
||||
picker.value = [startTime, endTime]
|
||||
}
|
||||
startTime = picker.value[0].daysAgo(1)
|
||||
endTime = picker.value[1].daysAgo(1)
|
||||
picker.$emit('pick', [startTime, picker])
|
||||
}
|
||||
}, {
|
||||
text: ' 往后一天 ›',
|
||||
onClick(picker) {
|
||||
let startTime = new Date(new Date().setHours(0, 0, 0))
|
||||
let endTime = new Date(new Date().setHours(23, 59, 59))
|
||||
if (!picker.value) {
|
||||
picker.value = [startTime, endTime]
|
||||
}
|
||||
startTime = picker.value[0].daysAgo(-1)
|
||||
endTime = picker.value[1].daysAgo(-1)
|
||||
picker.$emit('pick', [startTime, endTime])
|
||||
}
|
||||
}, {
|
||||
text: '« 往前一周 ',
|
||||
onClick(picker) {
|
||||
let startTime = new Date(new Date().setHours(0, 0, 0))
|
||||
let endTime = new Date(new Date().setHours(23, 59, 59))
|
||||
if (!picker.value) {
|
||||
picker.value = [startTime.daysAgo(new Date().getDay()),
|
||||
endTime.daysAgo(new Date().getDay() + 1)]
|
||||
} else {
|
||||
picker.value = [picker.value[0].daysAgo(picker.value[0].getDay()),
|
||||
picker.value[1].daysAgo(picker.value[1].getDay() + 1)]
|
||||
}
|
||||
startTime = picker.value[0].daysAgo(7)
|
||||
endTime = picker.value[1]
|
||||
picker.$emit('pick', [startTime, endTime])
|
||||
}
|
||||
}, {
|
||||
text: ' 往后一周 »',
|
||||
onClick(picker) {
|
||||
let startTime = new Date(new Date().setHours(0, 0, 0))
|
||||
let endTime = new Date(new Date().setHours(23, 59, 59))
|
||||
if (!picker.value) {
|
||||
picker.value = [startTime.daysAgo(new Date().getDay() - 7),
|
||||
endTime.daysAgo(new Date().getDay() - 6)]
|
||||
} else {
|
||||
picker.value = [picker.value[0].daysAgo(picker.value[0].getDay() - 7),
|
||||
picker.value[1].daysAgo(picker.value[1].getDay() - 6)]
|
||||
}
|
||||
startTime = picker.value[0]
|
||||
endTime = picker.value[1].daysAgo(-7)
|
||||
picker.$emit('pick', [startTime, endTime])
|
||||
}
|
||||
}]
|
||||
|
||||
export const calendarShortcuts = [
|
||||
...calendarBaseShortcuts,
|
||||
...calendarMoveShortcuts
|
||||
]
|
||||
@ -151,9 +151,9 @@ export default {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
// background-image: url("../assets/image/login-background.jpg");
|
||||
background-image: url("../assets/image/login-background.jpg");
|
||||
background-size: cover;
|
||||
background-color: rgba(56, 157, 170, 0.82);
|
||||
// background-color: rgba(56, 157, 170, 0.82);
|
||||
}
|
||||
.title {
|
||||
margin: 0px auto 30px auto;
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
<el-input v-model="queryParams.title" placeholder="请输入系统模块" clearable style="width: 200px;" size="small" @keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="操作人员" prop="operName">
|
||||
<el-input v-model="queryParams.operName" placeholder="请输入操作人员" clearable style="width: 160px;" size="small" @keyup.enter.native="handleQuery" />
|
||||
<el-input v-model="queryParams.operName" placeholder="请输入操作人员" clearable style="width: 160px;" size="small"
|
||||
@keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" prop="businessType">
|
||||
<el-select v-model="queryParams.businessType" placeholder="操作类型" clearable size="small" style="width: 240px">
|
||||
@ -18,8 +19,8 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="操作时间">
|
||||
<!-- <el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker> -->
|
||||
<date-range-picker v-model="dateRange" class="date-item" />
|
||||
<el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-"
|
||||
start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
@ -29,13 +30,15 @@
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['monitor:operlog:remove']">删除</el-button>
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
|
||||
v-hasPermi="['monitor:operlog:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" @click="handleClean" v-hasPermi="['monitor:operlog:remove']">清空</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:operlog:export']">导出</el-button>
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:operlog:export']">导出
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
@ -52,7 +55,8 @@
|
||||
<el-table-column label="操作状态" align="center" prop="status" :formatter="statusFormat" />
|
||||
<el-table-column label="用时" align="center" prop="elapsed">
|
||||
<template slot-scope="scope">
|
||||
<span :style="scope.row.elapsed < 1000 ? 'color:green':scope.row.elapsed <3000 ?'color:orange':'color:red'">{{ scope.row.elapsed }} ms</span>
|
||||
<span :style="scope.row.elapsed < 1000 ? 'color:green':scope.row.elapsed <3000 ?'color:orange':'color:red'">{{ scope.row.elapsed }}
|
||||
ms</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="日志内容" align="center" prop="errorMsg" :show-overflow-tooltip="true" />
|
||||
@ -63,7 +67,8 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row,scope.index)" v-hasPermi="['monitor:operlog:query']">详细</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row,scope.index)" v-hasPermi="['monitor:operlog:query']">详细
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -124,11 +129,8 @@ import {
|
||||
cleanOperlog,
|
||||
exportOperlog,
|
||||
} from "@/api/monitor/operlog";
|
||||
import DateRangePicker from "@/components/DateRangePicker";
|
||||
import { downloadFile } from "@/utils/zipdownload.js";
|
||||
|
||||
export default {
|
||||
components: { DateRangePicker },
|
||||
name: "Operlog",
|
||||
data() {
|
||||
return {
|
||||
@ -267,10 +269,7 @@ export default {
|
||||
const { code, data } = response;
|
||||
if (code == 200) {
|
||||
this.msgSuccess("导出成功");
|
||||
downloadFile(
|
||||
process.env.VUE_APP_BASE_API + data.path,
|
||||
data.fileName
|
||||
);
|
||||
this.download(data.path);
|
||||
} else {
|
||||
this.msgError("导出失败");
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:post:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:post:export']">导出</el-button>
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:post:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
@ -98,7 +98,6 @@ import {
|
||||
updatePost,
|
||||
exportPost,
|
||||
} from "@/api/system/post";
|
||||
import { downloadFile } from "@/utils/zipdownload.js";
|
||||
|
||||
export default {
|
||||
name: "Post",
|
||||
@ -269,12 +268,7 @@ export default {
|
||||
return exportPost(queryParams);
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response)
|
||||
// this.download(response.msg);
|
||||
downloadFile(
|
||||
process.env.VUE_APP_BASE_API + response.data.path,
|
||||
response.data.fileName
|
||||
);
|
||||
this.download(response.data.path);
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@ -7,17 +7,20 @@
|
||||
<el-input v-model="deptName" placeholder="请输入部门名称" clearable size="small" prefix-icon="el-icon-search" style="margin-bottom: 20px" />
|
||||
</div>
|
||||
<div class="head-container">
|
||||
<el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode" ref="tree" default-expand-all @node-click="handleNodeClick" />
|
||||
<el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" :filter-node-method="filterNode" ref="tree"
|
||||
default-expand-all @node-click="handleNodeClick" />
|
||||
</div>
|
||||
</el-col>
|
||||
<!--用户数据-->
|
||||
<el-col :span="20">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||
<el-form-item label="用户名称" prop="userName">
|
||||
<el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery" />
|
||||
<el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable size="small" style="width: 240px"
|
||||
@keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码" prop="phonenumber">
|
||||
<el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable size="small" style="width: 240px" @keyup.enter.native="handleQuery" />
|
||||
<el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable size="small" style="width: 240px"
|
||||
@keyup.enter.native="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="用户状态" clearable size="small" style="width: 240px">
|
||||
@ -25,7 +28,8 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间">
|
||||
<el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
<el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" range-separator="-"
|
||||
start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
@ -38,16 +42,19 @@
|
||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:user:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['system:user:edit']">修改</el-button>
|
||||
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
|
||||
v-hasPermi="['system:user:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['system:user:remove']">删除</el-button>
|
||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
|
||||
v-hasPermi="['system:user:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport" v-hasPermi="['system:user:import']">导入</el-button>
|
||||
</el-col> -->
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:user:export']">导出</el-button>
|
||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system:user:export']">导出
|
||||
</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
||||
</el-row>
|
||||
@ -78,8 +85,10 @@
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="160">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']">修改</el-button>
|
||||
<el-button v-if="scope.row.userId !== 1 | scope.row.userName != 'admin'" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']">删除</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-key" @click="handleResetPwd(scope.row)" v-hasPermi="['system:user:resetPwd']">重置</el-button>
|
||||
<el-button v-if="scope.row.userId !== 1 | scope.row.userName != 'admin'" size="mini" type="text" icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']">删除</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-key" @click="handleResetPwd(scope.row)" v-hasPermi="['system:user:resetPwd']">重置
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -148,14 +157,16 @@
|
||||
<el-col :span="12">
|
||||
<el-form-item label="岗位">
|
||||
<el-select v-model="form.postIds" multiple placeholder="请选择">
|
||||
<el-option v-for="item in postOptions" :key="item.postId" :label="item.postName" :value="item.postId" :disabled="item.status == 1"></el-option>
|
||||
<el-option v-for="item in postOptions" :key="item.postId" :label="item.postName" :value="item.postId" :disabled="item.status == 1">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="角色">
|
||||
<el-select v-model="form.roleIds" multiple placeholder="请选择" @change="selectRole($event)">
|
||||
<el-option v-for="item in roleOptions" :key="item.roleId" :label="item.roleName" :value="item.roleId" :disabled="item.status == 1"></el-option>
|
||||
<el-option v-for="item in roleOptions" :key="item.roleId" :label="item.roleName" :value="item.roleId" :disabled="item.status == 1">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -176,19 +187,17 @@
|
||||
|
||||
<!-- 用户导入对话框 -->
|
||||
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
|
||||
<el-upload name="file" ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
|
||||
:on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
|
||||
<el-upload name="file" ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
|
||||
:action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress"
|
||||
:on-success="handleFileSuccess" :auto-upload="false" drag>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">
|
||||
将文件拖到此处,或
|
||||
<em>点击上传</em>
|
||||
</div>
|
||||
<div class="el-upload__tip" slot="tip">
|
||||
<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
|
||||
<el-link type="info" style="font-size: 12px" @click="importTemplate">下载模板</el-link>
|
||||
</div>
|
||||
<div class="el-upload__tip" style="color: red" slot="tip">
|
||||
提示:仅允许导入“xls”或“xlsx”格式文件!
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<div class="el-upload__tip text-center" slot="tip">
|
||||
<div class="el-upload__tip" slot="tip">
|
||||
<el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
|
||||
</div>
|
||||
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
|
||||
</div>
|
||||
</el-upload>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
@ -209,13 +218,11 @@ import {
|
||||
exportUser,
|
||||
resetUserPwd,
|
||||
changeUserStatus,
|
||||
// importTemplate,
|
||||
} from "@/api/system/user";
|
||||
import { getToken } from "@/utils/auth";
|
||||
import { treeselect } from "@/api/system/dept";
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
import { downloadFile } from "@/utils/zipdownload.js";
|
||||
|
||||
export default {
|
||||
name: "User",
|
||||
@ -273,7 +280,7 @@ export default {
|
||||
// 是否更新已经存在的用户数据
|
||||
updateSupport: 0,
|
||||
// 设置上传的请求头部
|
||||
headers: { Authorization: 'Bearer ' + getToken() },
|
||||
headers: { Authorization: "Bearer " + getToken() },
|
||||
// 上传的地址
|
||||
url: process.env.VUE_APP_BASE_API + "system/user/importData",
|
||||
},
|
||||
@ -548,14 +555,10 @@ export default {
|
||||
type: "warning",
|
||||
}).then(() => {
|
||||
exportUser(queryParams).then((response) => {
|
||||
console.log(JSON.stringify(response));
|
||||
const { code, data } = response;
|
||||
if (code == 200) {
|
||||
this.msgSuccess("导出成功");
|
||||
downloadFile(
|
||||
process.env.VUE_APP_BASE_API + data.path,
|
||||
data.fileName
|
||||
);
|
||||
this.download(data.path);
|
||||
} else {
|
||||
this.msgError("导出失败");
|
||||
}
|
||||
@ -569,9 +572,7 @@ export default {
|
||||
},
|
||||
/** 下载模板操作 */
|
||||
importTemplate() {
|
||||
// importTemplate().then((response) => {
|
||||
downLoadExcel("system/user/importTemplate", "用户数据导入模板");
|
||||
// });
|
||||
this.download("/system/user/importTemplate", "用户数据导入模板");
|
||||
},
|
||||
// 文件上传中处理
|
||||
handleFileUploadProgress(event, file, fileList) {
|
||||
|
||||
@ -157,7 +157,7 @@ export default {
|
||||
getGenTable(tableId).then((res) => {
|
||||
this.columns = res.data.columns;
|
||||
this.info = res.data.info;
|
||||
this.tables = res.data.tables; //子表
|
||||
this.tables = res.data.tables;//子表
|
||||
});
|
||||
/** 查询字典下拉列表 */
|
||||
listType({ pageSize: 100 }).then((response) => {
|
||||
|
||||
@ -7,7 +7,8 @@
|
||||
<el-select v-model="info.tplCategory" @change="tplSelectChange">
|
||||
<el-option label="单表(增删改查)" value="crud" />
|
||||
<!-- <el-option label="树表(增删改查)" value="tree" />
|
||||
<el-option label="主子表(增删改查)" value="sub" /> -->
|
||||
<el-option label="导航查询" value="subNav"></el-option> -->
|
||||
<!-- <el-option label="主子表(增删改查)" value="sub" /> -->
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -179,7 +180,7 @@
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
<el-select v-model="info.subTableName" placeholder="请选择" @change="subSelectChange">
|
||||
<el-select v-model="info.subTableName" placeholder="请选择" @change="subSelectChange(this)">
|
||||
<el-option v-for="(table, index) in tables" :key="index" :label="table.tableName + ':' + table.tableComment" :value="table.tableName">
|
||||
</el-option>
|
||||
</el-select>
|
||||
@ -203,6 +204,7 @@
|
||||
</el-form>
|
||||
</template>
|
||||
<script>
|
||||
import { queryColumnInfo } from "@/api/tool/gen";
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
|
||||
@ -214,7 +216,7 @@ export default {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
// 字表
|
||||
// 子表
|
||||
tables: {
|
||||
type: Array,
|
||||
default: null,
|
||||
@ -237,10 +239,20 @@ export default {
|
||||
{ required: true, message: "请选择生成模板", trigger: "blur" },
|
||||
],
|
||||
moduleName: [
|
||||
{ required: true, message: "请输入生成模块名", trigger: "blur", pattern:/^[A-Za-z]+$/ },
|
||||
{
|
||||
required: true,
|
||||
message: "请输入生成模块名",
|
||||
trigger: "blur",
|
||||
pattern: /^[A-Za-z]+$/,
|
||||
},
|
||||
],
|
||||
businessName: [
|
||||
{ required: true, message: "请输入生成业务名", trigger: "blur", pattern:/^[A-Za-z]+$/},
|
||||
{
|
||||
required: true,
|
||||
message: "请输入生成业务名",
|
||||
trigger: "blur",
|
||||
pattern: /^[A-Za-z]+$/,
|
||||
},
|
||||
],
|
||||
functionName: [
|
||||
{ required: true, message: "请输入生成功能名", trigger: "blur" },
|
||||
@ -281,10 +293,18 @@ export default {
|
||||
},
|
||||
/** 设置关联外键 */
|
||||
setSubTableColumns(value) {
|
||||
console.log(value);
|
||||
if (value == null || value == undefined || value == "") {
|
||||
return;
|
||||
}
|
||||
for (var item in this.tables) {
|
||||
const name = this.tables[item].tableName;
|
||||
if (value === name) {
|
||||
this.subColumns = this.tables[item].columns;
|
||||
const obj = this.tables[item];
|
||||
if (value === obj.tableName) {
|
||||
queryColumnInfo(obj.tableId).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.subColumns = res.data.columns;
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSearch()">查询</el-button>
|
||||
<el-button type="default" icon="el-icon-refresh" size="small" @click="loadTableData()">刷新</el-button>
|
||||
<!-- <el-button type="default" icon="el-icon-refresh" size="small" @click="loadTableData()">刷新</el-button> -->
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@ -28,9 +28,11 @@
|
||||
<span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="tableName" label="表名" sortable="custom" width="180" />
|
||||
<el-table-column prop="dbName" label="数据库名" width="100" />
|
||||
<el-table-column prop="tableId" label="表id" width="80" />
|
||||
<el-table-column prop="tableName" label="表名" sortable="custom" width="110" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="tableComment" label="表描述" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="className" label="实体" />
|
||||
<el-table-column prop="className" label="实体" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="createTime" label="创建时间" />
|
||||
<el-table-column prop="updateTime" label="更新时间" />
|
||||
<el-table-column label="操作" align="center" width="350">
|
||||
@ -38,7 +40,7 @@
|
||||
<el-button type="text" icon="el-icon-view" @click="handleShowDialog(scope.row, 'preview')" v-hasPermi="['tool:gen:preview']">预览</el-button>
|
||||
<el-button type="text" icon="el-icon-edit" @click="handleEditTable(scope.row)" v-hasPermi="['tool:gen:edit']">编辑</el-button>
|
||||
<el-button type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['tool:gen:remove']">删除</el-button>
|
||||
<!-- <el-button type="text" icon="el-icon-refresh" @click="handleRefresh(scope.row)" v-hasPermi="['tool:gen:refresh']">同步</el-button> -->
|
||||
<el-button type="text" icon="el-icon-refresh" @click="handleSynchDb(scope.row)" v-hasPermi="['tool:gen:edit']">同步</el-button>
|
||||
<el-button type="text" icon="el-icon-download" @click="handleShowDialog(scope.row, 'generate')" v-hasPermi="['tool:gen:code']">生成代码
|
||||
</el-button>
|
||||
</template>
|
||||
@ -50,8 +52,9 @@
|
||||
<el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh" append-to-body>
|
||||
<el-tabs v-model="preview.activeName">
|
||||
<el-tab-pane v-for="(item, key) in preview.data" :label="item.title" :name="key.toString()" :key="key">
|
||||
<pre v-html="highlightedCode(item.content)">
|
||||
</pre>
|
||||
<el-link :underline="false" icon="el-icon-document-copy" v-clipboard:copy="item.content" v-clipboard:success="clipboardSuccess"
|
||||
style="float:right">复制</el-link>
|
||||
<pre><code class="hljs" v-html="highlightedCode(item.content, item.title)"></code></pre>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-dialog>
|
||||
@ -91,11 +94,11 @@
|
||||
<script>
|
||||
import {
|
||||
codeGenerator,
|
||||
getGenTable,
|
||||
listTable,
|
||||
delTable,
|
||||
previewTable,
|
||||
synchDb
|
||||
} from "@/api/tool/gen";
|
||||
import { downloadFile } from "@/utils/zipdownload.js";
|
||||
import importTable from "./importTable";
|
||||
import { Loading } from "element-ui";
|
||||
import hljs from "highlight.js";
|
||||
@ -151,7 +154,7 @@ export default {
|
||||
handleSearch() {
|
||||
this.tableloading = true;
|
||||
|
||||
getGenTable(this.queryParams).then((res) => {
|
||||
listTable(this.queryParams).then((res) => {
|
||||
this.tableData = res.data.result;
|
||||
this.total = res.data.totalNum;
|
||||
this.tableloading = false;
|
||||
@ -230,10 +233,7 @@ export default {
|
||||
if (code == 200) {
|
||||
this.showGenerate = false;
|
||||
this.msgSuccess("恭喜你,代码生成完成!");
|
||||
downloadFile(
|
||||
process.env.VUE_APP_BASE_API + data.zipPath,
|
||||
data.fileName
|
||||
);
|
||||
this.download(data.path);
|
||||
} else {
|
||||
this.msgError(res.msg);
|
||||
}
|
||||
@ -278,6 +278,11 @@ export default {
|
||||
});
|
||||
});
|
||||
},
|
||||
/** 复制代码成功 */
|
||||
clipboardSuccess() {
|
||||
this.msgSuccess("复制成功");
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(section) {
|
||||
this.tableIds = section.map((item) => item.tableId);
|
||||
this.multiple = !section.length;
|
||||
@ -285,15 +290,21 @@ export default {
|
||||
},
|
||||
/** 高亮显示 */
|
||||
highlightedCode(code, key) {
|
||||
// var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
|
||||
// var language = key.substring(key.lastIndexOf(".") , key.length)
|
||||
const result = hljs.highlightAuto(code || "");
|
||||
return result.value || " ";
|
||||
},
|
||||
handleRefresh(row) {
|
||||
this.$message({
|
||||
type: "info",
|
||||
message: "敬请期待",
|
||||
});
|
||||
// 同步代码
|
||||
handleSynchDb(row) {
|
||||
const tableName = row.tableName;
|
||||
this.$confirm('确认要强制同步"' + tableName + '"表结构吗?')
|
||||
.then(function () {
|
||||
return synchDb(row.tableId, { tableName, dbName: row.dbName });
|
||||
})
|
||||
.then(() => {
|
||||
this.msgSuccess("同步成功");
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -23,8 +23,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZR.Tasks", "ZR.Tasks\ZR.Tas
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Quartz定时任务", "Quartz定时任务", "{8A1C9D96-9967-42DA-9A57-2C945E08E93E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quartz.NET.WindowsService", "Quartz.NET.WindowsService\Quartz.NET.WindowsService.csproj", "{3040DD22-663E-44CB-909B-3D0043867361}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UI", "UI", "{7BBADB30-A3CB-4A8D-91E2-FE8F13AD1536}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZR.CodeGenerator", "ZR.CodeGenerator\ZR.CodeGenerator.csproj", "{42F902A7-33C4-44D6-A7D8-5E0E72DAA03C}"
|
||||
@ -63,10 +61,6 @@ Global
|
||||
{328C152F-4DA3-4ABB-A9B7-628109902088}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{328C152F-4DA3-4ABB-A9B7-628109902088}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{328C152F-4DA3-4ABB-A9B7-628109902088}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3040DD22-663E-44CB-909B-3D0043867361}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3040DD22-663E-44CB-909B-3D0043867361}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3040DD22-663E-44CB-909B-3D0043867361}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3040DD22-663E-44CB-909B-3D0043867361}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{42F902A7-33C4-44D6-A7D8-5E0E72DAA03C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{42F902A7-33C4-44D6-A7D8-5E0E72DAA03C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{42F902A7-33C4-44D6-A7D8-5E0E72DAA03C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@ -83,7 +77,6 @@ Global
|
||||
{D7F7C898-8758-46E6-B26B-960FE79FF8CF} = {3DA5CBAB-687B-4022-B43B-AA7856121B9E}
|
||||
{DF8B3C35-6E0E-481B-B2CB-C2BED3AF8634} = {3DA5CBAB-687B-4022-B43B-AA7856121B9E}
|
||||
{328C152F-4DA3-4ABB-A9B7-628109902088} = {8A1C9D96-9967-42DA-9A57-2C945E08E93E}
|
||||
{3040DD22-663E-44CB-909B-3D0043867361} = {8A1C9D96-9967-42DA-9A57-2C945E08E93E}
|
||||
{42F902A7-33C4-44D6-A7D8-5E0E72DAA03C} = {3DA5CBAB-687B-4022-B43B-AA7856121B9E}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
|
||||
@ -663,7 +663,8 @@ create table gen_table (
|
||||
update_by varchar(64) default '' comment '更新者',
|
||||
update_time datetime comment '更新时间',
|
||||
remark varchar(500) default null comment '备注',
|
||||
primary key (tableId)
|
||||
dbName VARCHAR(100) comment '数据库名',
|
||||
PRIMARY key (tableId)
|
||||
) engine=innodb auto_increment=1 comment = '代码生成业务表';
|
||||
|
||||
|
||||
@ -717,6 +718,7 @@ CREATE TABLE `gen_demo` (
|
||||
`remark` VARCHAR(200) COMMENT '备注',
|
||||
`beginTime` datetime(0) NULL DEFAULT NULL COMMENT '开始时间',
|
||||
`endTime` datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
|
||||
`feature` varchar(100) NULL COMMENT '特征'
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 289 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 488 KiB After Width: | Height: | Size: 94 KiB |
BIN
document/images/18.png
Normal file
|
After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 92 KiB |