😎代码优化
This commit is contained in:
parent
683ebe16a5
commit
7aa49e7e30
@ -28,5 +28,5 @@ public enum CodeGenTypeEnum
|
|||||||
/// 种子数据
|
/// 种子数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("种子数据")]
|
[Description("种子数据")]
|
||||||
SeedData =3,
|
SeedData = 3,
|
||||||
}
|
}
|
||||||
@ -5,16 +5,14 @@
|
|||||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||||
|
|
||||||
using Furion.TimeCrontab;
|
using Furion.TimeCrontab;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Admin.NET.Core;
|
namespace Admin.NET.Core;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每天晚上2点进行数据库备份
|
||||||
|
/// </summary>
|
||||||
[JobDetail("job_DbBackupJob", Description = "备份数据库", GroupName = "default", Concurrent = false)]
|
[JobDetail("job_DbBackupJob", Description = "备份数据库", GroupName = "default", Concurrent = false)]
|
||||||
[Cron("0 1 * * *", CronStringFormat.Default, TriggerId = "trigger_DbBackupJob", Description = "备份数据库", RunOnStart = false)]
|
[Cron("0 0 2 * * ? *", CronStringFormat.Default, TriggerId = "trigger_DbBackupJob", Description = "备份数据库", RunOnStart = false)]
|
||||||
public class DbBackupJob : IJob
|
public class DbBackupJob : IJob
|
||||||
{
|
{
|
||||||
private readonly IServiceScopeFactory _scopeFactory;
|
private readonly IServiceScopeFactory _scopeFactory;
|
||||||
@ -26,18 +24,18 @@ public class DbBackupJob : IJob
|
|||||||
|
|
||||||
public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
|
public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
|
using var serviceScope = _scopeFactory.CreateScope();
|
||||||
|
var dbBackupService = serviceScope.ServiceProvider.GetRequiredService<SysDbBackupService>();
|
||||||
|
|
||||||
string msg = $"【{DateTime.Now}】开始备份数据库";
|
string msg = $"【{DateTime.Now}】开始备份数据库";
|
||||||
var originColor = Console.ForegroundColor;
|
var originColor = Console.ForegroundColor;
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
Console.WriteLine(msg);
|
Console.WriteLine(msg);
|
||||||
Console.ForegroundColor = originColor;
|
Console.ForegroundColor = originColor;
|
||||||
|
|
||||||
using var serviceScope = _scopeFactory.CreateScope();
|
// 清理7天前的备份文件
|
||||||
var dbBackupService = serviceScope.ServiceProvider.GetRequiredService<DbBackupService>();
|
|
||||||
|
|
||||||
//清理7天前的备份文件
|
|
||||||
dbBackupService.DeleteExpiredDbFile(7);
|
dbBackupService.DeleteExpiredDbFile(7);
|
||||||
//开始备份
|
// 开始备份
|
||||||
await dbBackupService.Backup();
|
await dbBackupService.Backup();
|
||||||
|
|
||||||
msg = $"【{DateTime.Now}】数据库备份完成";
|
msg = $"【{DateTime.Now}】数据库备份完成";
|
||||||
|
|||||||
@ -175,10 +175,10 @@ public class SysMenuSeedData : ISqlSugarEntitySeedData<SysMenu>
|
|||||||
new SysMenu{ Id=1310000000445, Pid=1310000000441, Title="获取支付订单详情(微信接口)", Permission="sysWechatPay/payInfoFromWechat", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
new SysMenu{ Id=1310000000445, Pid=1310000000441, Title="获取支付订单详情(微信接口)", Permission="sysWechatPay/payInfoFromWechat", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
||||||
new SysMenu{ Id=1310000000446, Pid=1310000000441, Title="退款申请", Permission="sysWechatPay/refundDomestic", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
new SysMenu{ Id=1310000000446, Pid=1310000000441, Title="退款申请", Permission="sysWechatPay/refundDomestic", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
||||||
|
|
||||||
new SysMenu{ Id=1310000000447, Pid=1310000000301, Title="数据库备份", Path="/platform/dbBackup", Name="dbBackup", Component="/system/dbBackup/index", Icon="ele-Coin", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=240 },
|
new SysMenu{ Id=1310000000451, Pid=1310000000301, Title="数据库备份", Path="/platform/dbBackup", Name="dbBackup", Component="/system/database/dbBackup", Icon="ele-Coin", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=240 },
|
||||||
new SysMenu{ Id=1310000000448, Pid=1310000000447, Title="查询", Permission="dbBackup/page", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
new SysMenu{ Id=1310000000452, Pid=1310000000451, Title="查询", Permission="dbBackup/page", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
||||||
new SysMenu{ Id=1310000000449, Pid=1310000000447, Title="删除", Permission="dbBackup/delete", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
new SysMenu{ Id=1310000000453, Pid=1310000000451, Title="删除", Permission="dbBackup/delete", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
||||||
new SysMenu{ Id=1310000000450, Pid=1310000000447, Title="增加", Permission="dbBackup/add", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
new SysMenu{ Id=1310000000454, Pid=1310000000451, Title="增加", Permission="dbBackup/add", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
||||||
|
|
||||||
new SysMenu{ Id=1310000000501, Pid=0, Title="日志管理", Path="/log", Name="log", Component="Layout", Icon="ele-DocumentCopy", Type=MenuTypeEnum.Dir, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=12000 },
|
new SysMenu{ Id=1310000000501, Pid=0, Title="日志管理", Path="/log", Name="log", Component="Layout", Icon="ele-DocumentCopy", Type=MenuTypeEnum.Dir, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=12000 },
|
||||||
new SysMenu{ Id=1310000000511, Pid=1310000000501, Title="访问日志", Path="/log/logvis", Name="sysLogVis", Component="/system/log/logvis/index", Icon="ele-Document", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
new SysMenu{ Id=1310000000511, Pid=1310000000501, Title="访问日志", Path="/log/logvis", Name="sysLogVis", Component="/system/log/logvis/index", Icon="ele-Document", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
|
||||||
|
|||||||
@ -4,17 +4,13 @@
|
|||||||
//
|
//
|
||||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Admin.NET.Core.Service;
|
namespace Admin.NET.Core.Service;
|
||||||
|
|
||||||
public class BackupDto
|
public class DbBackupOutput
|
||||||
{
|
{
|
||||||
public long Size { get; set; }
|
|
||||||
public string FileName { get; set; }
|
public string FileName { get; set; }
|
||||||
|
|
||||||
public DateTime CreateTime { get; set; }
|
public DateTime CreateTime { get; set; }
|
||||||
|
|
||||||
|
public long Size { get; set; }
|
||||||
}
|
}
|
||||||
@ -4,31 +4,58 @@
|
|||||||
//
|
//
|
||||||
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Admin.NET.Core.Service;
|
namespace Admin.NET.Core.Service;
|
||||||
|
|
||||||
public class DbBackupService : IDynamicApiController, ITransient
|
/// <summary>
|
||||||
|
/// 系统数据库备份服务 🧩
|
||||||
|
/// </summary>
|
||||||
|
[ApiDescriptionSettings(Order = 255)]
|
||||||
|
public class SysDbBackupService : IDynamicApiController, ITransient
|
||||||
{
|
{
|
||||||
private readonly SqlSugarRepository<SysUser> _sysUserRep;
|
private readonly SqlSugarRepository<SysUser> _sysUserRep;
|
||||||
private readonly string backupDir;
|
private readonly string backupDir;
|
||||||
|
|
||||||
public DbBackupService(SqlSugarRepository<SysUser> sysUserRep)
|
public SysDbBackupService(SqlSugarRepository<SysUser> sysUserRep)
|
||||||
{
|
{
|
||||||
_sysUserRep = sysUserRep;
|
_sysUserRep = sysUserRep;
|
||||||
backupDir = Path.Combine(App.WebHostEnvironment.WebRootPath, "DbBackup");
|
backupDir = Path.Combine(App.WebHostEnvironment.WebRootPath, "DbBackup");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 备份数据库
|
/// 获取备份列表 🔖
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[DisplayName("获取备份列表")]
|
||||||
[ApiDescriptionSettings(Name = "Add")]
|
public List<DbBackupOutput> GetList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var fileList = Directory.GetFiles(backupDir);
|
||||||
|
|
||||||
|
var dbBackupList = new List<DbBackupOutput>();
|
||||||
|
foreach (var item in fileList)
|
||||||
|
{
|
||||||
|
var info = new FileInfo(item);
|
||||||
|
dbBackupList.Add(new DbBackupOutput
|
||||||
|
{
|
||||||
|
FileName = info.Name,
|
||||||
|
Size = info.Length,
|
||||||
|
CreateTime = info.CreationTime
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return dbBackupList;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 备份数据库 🔖
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[ApiDescriptionSettings(Name = "Add"), HttpPost]
|
||||||
[DisplayName("备份数据库")]
|
[DisplayName("备份数据库")]
|
||||||
public async Task AddBackup()
|
public async Task AddBackup()
|
||||||
{
|
{
|
||||||
@ -36,10 +63,22 @@ public class DbBackupService : IDynamicApiController, ITransient
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 备份数据库 用于job调用
|
/// 删除备份 🔖
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName"></param>
|
||||||
|
[ApiDescriptionSettings(Name = "Delete"), HttpPost]
|
||||||
|
[DisplayName("删除备份")]
|
||||||
|
public void DeleteBackup([FromQuery] string fileName)
|
||||||
|
{
|
||||||
|
var path = Path.Combine(backupDir, fileName);
|
||||||
|
File.Delete(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 备份数据库
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[ApiDescriptionSettings(false)]
|
[NonAction]
|
||||||
public async Task Backup()
|
public async Task Backup()
|
||||||
{
|
{
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
@ -48,9 +87,10 @@ public class DbBackupService : IDynamicApiController, ITransient
|
|||||||
foreach (var option in options.ConnectionConfigs)
|
foreach (var option in options.ConnectionConfigs)
|
||||||
{
|
{
|
||||||
var configId = option.ConfigId == null || string.IsNullOrWhiteSpace(option.ConfigId.ToString())
|
var configId = option.ConfigId == null || string.IsNullOrWhiteSpace(option.ConfigId.ToString())
|
||||||
? SqlSugarConst.MainConfigId
|
? SqlSugarConst.MainConfigId : option.ConfigId.ToString();
|
||||||
: option.ConfigId.ToString();
|
|
||||||
if (option?.DbType == SqlSugar.DbType.MySql) //备份mysql 其他数据库自行扩展
|
// 备份mysql 其他数据库自行扩展
|
||||||
|
if (option?.DbType == SqlSugar.DbType.MySql)
|
||||||
{
|
{
|
||||||
var path = Path.Combine(backupDir, $"{configId}-{DateTime.Now:yyyyMMddHHmmss}.sql");
|
var path = Path.Combine(backupDir, $"{configId}-{DateTime.Now:yyyyMMddHHmmss}.sql");
|
||||||
_sysUserRep.Context.DbMaintenance.BackupDataBase(_sysUserRep.Context.Ado.Connection.Database, path);
|
_sysUserRep.Context.DbMaintenance.BackupDataBase(_sysUserRep.Context.Ado.Connection.Database, path);
|
||||||
@ -63,7 +103,7 @@ public class DbBackupService : IDynamicApiController, ITransient
|
|||||||
/// 删除过期备份文件
|
/// 删除过期备份文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="day">过期天数</param>
|
/// <param name="day">过期天数</param>
|
||||||
[ApiDescriptionSettings(false)]
|
[NonAction]
|
||||||
public void DeleteExpiredDbFile(int day = 7)
|
public void DeleteExpiredDbFile(int day = 7)
|
||||||
{
|
{
|
||||||
var list = Directory.GetFiles(backupDir);
|
var list = Directory.GetFiles(backupDir);
|
||||||
@ -83,41 +123,4 @@ public class DbBackupService : IDynamicApiController, ITransient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取备份列表
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost]
|
|
||||||
[ApiDescriptionSettings(Name = "Page")]
|
|
||||||
[DisplayName("获取备份列表")]
|
|
||||||
public List<BackupDto> GetBackupList()
|
|
||||||
{
|
|
||||||
var list = Directory.GetFiles(backupDir);
|
|
||||||
var result = new List<BackupDto>();
|
|
||||||
foreach (var item in list)
|
|
||||||
{
|
|
||||||
var info = new FileInfo(item);
|
|
||||||
result.Add(new BackupDto
|
|
||||||
{
|
|
||||||
FileName = info.Name,
|
|
||||||
Size = info.Length,
|
|
||||||
CreateTime = info.CreationTime
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除备份
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileName"></param>
|
|
||||||
[HttpPost]
|
|
||||||
[ApiDescriptionSettings(Name = "Delete")]
|
|
||||||
[DisplayName("删除备份")]
|
|
||||||
public void DeleteBackup([FromQuery] string fileName)
|
|
||||||
{
|
|
||||||
var path = Path.Combine(backupDir, fileName);
|
|
||||||
File.Delete(path);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -21,6 +21,7 @@ export * from './apis/sys-common-api';
|
|||||||
export * from './apis/sys-config-api';
|
export * from './apis/sys-config-api';
|
||||||
export * from './apis/sys-const-api';
|
export * from './apis/sys-const-api';
|
||||||
export * from './apis/sys-database-api';
|
export * from './apis/sys-database-api';
|
||||||
|
export * from './apis/sys-db-backup-api';
|
||||||
export * from './apis/sys-dict-data-api';
|
export * from './apis/sys-dict-data-api';
|
||||||
export * from './apis/sys-dict-type-api';
|
export * from './apis/sys-dict-type-api';
|
||||||
export * from './apis/sys-email-api';
|
export * from './apis/sys-email-api';
|
||||||
|
|||||||
288
Web/src/api-services/apis/sys-db-backup-api.ts
Normal file
288
Web/src/api-services/apis/sys-db-backup-api.ts
Normal file
@ -0,0 +1,288 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
/**
|
||||||
|
* Admin.NET 通用权限开发平台
|
||||||
|
* 让 .NET 开发更简单、更通用、更流行。整合最新技术,模块插件式开发,前后端分离,开箱即用。<br/><u><b><font color='FF0000'> 👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!</font></b></u>
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import globalAxios, { AxiosResponse, AxiosInstance, AxiosRequestConfig } from 'axios';
|
||||||
|
import { Configuration } from '../configuration';
|
||||||
|
// Some imports not used depending on template conditions
|
||||||
|
// @ts-ignore
|
||||||
|
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
|
||||||
|
import { AdminResultListDbBackupOutput } from '../models';
|
||||||
|
/**
|
||||||
|
* SysDbBackupApi - axios parameter creator
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const SysDbBackupApiAxiosParamCreator = function (configuration?: Configuration) {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 备份数据库 🔖
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
apiSysDbBackupAddPost: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
|
const localVarPath = `/api/sysDbBackup/add`;
|
||||||
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||||
|
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
const localVarRequestOptions :AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
// authentication Bearer required
|
||||||
|
// http bearer authentication required
|
||||||
|
if (configuration && configuration.accessToken) {
|
||||||
|
const accessToken = typeof configuration.accessToken === 'function'
|
||||||
|
? await configuration.accessToken()
|
||||||
|
: await configuration.accessToken;
|
||||||
|
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
const query = new URLSearchParams(localVarUrlObj.search);
|
||||||
|
for (const key in localVarQueryParameter) {
|
||||||
|
query.set(key, localVarQueryParameter[key]);
|
||||||
|
}
|
||||||
|
for (const key in options.params) {
|
||||||
|
query.set(key, options.params[key]);
|
||||||
|
}
|
||||||
|
localVarUrlObj.search = (new URLSearchParams(query)).toString();
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 删除备份 🔖
|
||||||
|
* @param {string} [fileName]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
apiSysDbBackupDeletePost: async (fileName?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
|
const localVarPath = `/api/sysDbBackup/delete`;
|
||||||
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||||
|
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
const localVarRequestOptions :AxiosRequestConfig = { method: 'POST', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
// authentication Bearer required
|
||||||
|
// http bearer authentication required
|
||||||
|
if (configuration && configuration.accessToken) {
|
||||||
|
const accessToken = typeof configuration.accessToken === 'function'
|
||||||
|
? await configuration.accessToken()
|
||||||
|
: await configuration.accessToken;
|
||||||
|
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileName !== undefined) {
|
||||||
|
localVarQueryParameter['fileName'] = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const query = new URLSearchParams(localVarUrlObj.search);
|
||||||
|
for (const key in localVarQueryParameter) {
|
||||||
|
query.set(key, localVarQueryParameter[key]);
|
||||||
|
}
|
||||||
|
for (const key in options.params) {
|
||||||
|
query.set(key, options.params[key]);
|
||||||
|
}
|
||||||
|
localVarUrlObj.search = (new URLSearchParams(query)).toString();
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 获取备份列表 🔖
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
apiSysDbBackupListGet: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||||
|
const localVarPath = `/api/sysDbBackup/list`;
|
||||||
|
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||||
|
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
|
||||||
|
let baseOptions;
|
||||||
|
if (configuration) {
|
||||||
|
baseOptions = configuration.baseOptions;
|
||||||
|
}
|
||||||
|
const localVarRequestOptions :AxiosRequestConfig = { method: 'GET', ...baseOptions, ...options};
|
||||||
|
const localVarHeaderParameter = {} as any;
|
||||||
|
const localVarQueryParameter = {} as any;
|
||||||
|
|
||||||
|
// authentication Bearer required
|
||||||
|
// http bearer authentication required
|
||||||
|
if (configuration && configuration.accessToken) {
|
||||||
|
const accessToken = typeof configuration.accessToken === 'function'
|
||||||
|
? await configuration.accessToken()
|
||||||
|
: await configuration.accessToken;
|
||||||
|
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
const query = new URLSearchParams(localVarUrlObj.search);
|
||||||
|
for (const key in localVarQueryParameter) {
|
||||||
|
query.set(key, localVarQueryParameter[key]);
|
||||||
|
}
|
||||||
|
for (const key in options.params) {
|
||||||
|
query.set(key, options.params[key]);
|
||||||
|
}
|
||||||
|
localVarUrlObj.search = (new URLSearchParams(query)).toString();
|
||||||
|
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||||
|
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
|
||||||
|
options: localVarRequestOptions,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SysDbBackupApi - functional programming interface
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const SysDbBackupApiFp = function(configuration?: Configuration) {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 备份数据库 🔖
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async apiSysDbBackupAddPost(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
|
||||||
|
const localVarAxiosArgs = await SysDbBackupApiAxiosParamCreator(configuration).apiSysDbBackupAddPost(options);
|
||||||
|
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||||
|
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||||
|
return axios.request(axiosRequestArgs);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 删除备份 🔖
|
||||||
|
* @param {string} [fileName]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async apiSysDbBackupDeletePost(fileName?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<void>>> {
|
||||||
|
const localVarAxiosArgs = await SysDbBackupApiAxiosParamCreator(configuration).apiSysDbBackupDeletePost(fileName, options);
|
||||||
|
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||||
|
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||||
|
return axios.request(axiosRequestArgs);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 获取备份列表 🔖
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async apiSysDbBackupListGet(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminResultListDbBackupOutput>>> {
|
||||||
|
const localVarAxiosArgs = await SysDbBackupApiAxiosParamCreator(configuration).apiSysDbBackupListGet(options);
|
||||||
|
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||||
|
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
|
||||||
|
return axios.request(axiosRequestArgs);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SysDbBackupApi - factory interface
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const SysDbBackupApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 备份数据库 🔖
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async apiSysDbBackupAddPost(options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
|
||||||
|
return SysDbBackupApiFp(configuration).apiSysDbBackupAddPost(options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 删除备份 🔖
|
||||||
|
* @param {string} [fileName]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async apiSysDbBackupDeletePost(fileName?: string, options?: AxiosRequestConfig): Promise<AxiosResponse<void>> {
|
||||||
|
return SysDbBackupApiFp(configuration).apiSysDbBackupDeletePost(fileName, options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 获取备份列表 🔖
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
*/
|
||||||
|
async apiSysDbBackupListGet(options?: AxiosRequestConfig): Promise<AxiosResponse<AdminResultListDbBackupOutput>> {
|
||||||
|
return SysDbBackupApiFp(configuration).apiSysDbBackupListGet(options).then((request) => request(axios, basePath));
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SysDbBackupApi - object-oriented interface
|
||||||
|
* @export
|
||||||
|
* @class SysDbBackupApi
|
||||||
|
* @extends {BaseAPI}
|
||||||
|
*/
|
||||||
|
export class SysDbBackupApi extends BaseAPI {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 备份数据库 🔖
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof SysDbBackupApi
|
||||||
|
*/
|
||||||
|
public async apiSysDbBackupAddPost(options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
|
||||||
|
return SysDbBackupApiFp(this.configuration).apiSysDbBackupAddPost(options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 删除备份 🔖
|
||||||
|
* @param {string} [fileName]
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof SysDbBackupApi
|
||||||
|
*/
|
||||||
|
public async apiSysDbBackupDeletePost(fileName?: string, options?: AxiosRequestConfig) : Promise<AxiosResponse<void>> {
|
||||||
|
return SysDbBackupApiFp(this.configuration).apiSysDbBackupDeletePost(fileName, options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @summary 获取备份列表 🔖
|
||||||
|
* @param {*} [options] Override http request option.
|
||||||
|
* @throws {RequiredError}
|
||||||
|
* @memberof SysDbBackupApi
|
||||||
|
*/
|
||||||
|
public async apiSysDbBackupListGet(options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminResultListDbBackupOutput>> {
|
||||||
|
return SysDbBackupApiFp(this.configuration).apiSysDbBackupListGet(options).then((request) => request(this.axios, this.basePath));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -399,6 +399,14 @@ export interface AddUserInput {
|
|||||||
*/
|
*/
|
||||||
signature?: string | null;
|
signature?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Token版本号
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof AddUserInput
|
||||||
|
*/
|
||||||
|
tokenVersion?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最新密码修改时间
|
* 最新密码修改时间
|
||||||
*
|
*
|
||||||
|
|||||||
@ -0,0 +1,71 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
/**
|
||||||
|
* Admin.NET 通用权限开发平台
|
||||||
|
* 让 .NET 开发更简单、更通用、更流行。整合最新技术,模块插件式开发,前后端分离,开箱即用。<br/><u><b><font color='FF0000'> 👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!</font></b></u>
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { DbBackupOutput } from './db-backup-output';
|
||||||
|
/**
|
||||||
|
* 全局返回结果
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @interface AdminResultListDbBackupOutput
|
||||||
|
*/
|
||||||
|
export interface AdminResultListDbBackupOutput {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态码
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof AdminResultListDbBackupOutput
|
||||||
|
*/
|
||||||
|
code?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型success、warning、error
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof AdminResultListDbBackupOutput
|
||||||
|
*/
|
||||||
|
type?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误信息
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof AdminResultListDbBackupOutput
|
||||||
|
*/
|
||||||
|
message?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据
|
||||||
|
*
|
||||||
|
* @type {Array<DbBackupOutput>}
|
||||||
|
* @memberof AdminResultListDbBackupOutput
|
||||||
|
*/
|
||||||
|
result?: Array<DbBackupOutput> | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附加数据
|
||||||
|
*
|
||||||
|
* @type {any}
|
||||||
|
* @memberof AdminResultListDbBackupOutput
|
||||||
|
*/
|
||||||
|
extras?: any | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*
|
||||||
|
* @type {Date}
|
||||||
|
* @memberof AdminResultListDbBackupOutput
|
||||||
|
*/
|
||||||
|
time?: Date;
|
||||||
|
}
|
||||||
@ -13,12 +13,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成类型枚举<br /> 前端 Frontend = 1<br /> 后端 Backend = 2<br />
|
* 代码生成类型枚举<br /> 前端 Frontend = 1<br /> 后端 Backend = 2<br /> 种子数据 SeedData = 3<br />
|
||||||
* @export
|
* @export
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
export enum CodeGenTypeEnum {
|
export enum CodeGenTypeEnum {
|
||||||
NUMBER_1 = 1,
|
NUMBER_1 = 1,
|
||||||
NUMBER_2 = 2
|
NUMBER_2 = 2,
|
||||||
|
NUMBER_3 = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
40
Web/src/api-services/models/db-backup-output.ts
Normal file
40
Web/src/api-services/models/db-backup-output.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
/**
|
||||||
|
* Admin.NET 通用权限开发平台
|
||||||
|
* 让 .NET 开发更简单、更通用、更流行。整合最新技术,模块插件式开发,前后端分离,开箱即用。<br/><u><b><font color='FF0000'> 👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!</font></b></u>
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by the swagger code generator program.
|
||||||
|
* https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @interface DbBackupOutput
|
||||||
|
*/
|
||||||
|
export interface DbBackupOutput {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
* @memberof DbBackupOutput
|
||||||
|
*/
|
||||||
|
fileName?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Date}
|
||||||
|
* @memberof DbBackupOutput
|
||||||
|
*/
|
||||||
|
createTime?: Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
* @memberof DbBackupOutput
|
||||||
|
*/
|
||||||
|
size?: number;
|
||||||
|
}
|
||||||
@ -36,6 +36,7 @@ export * from './admin-result-list-code-gen-config';
|
|||||||
export * from './admin-result-list-column-ouput';
|
export * from './admin-result-list-column-ouput';
|
||||||
export * from './admin-result-list-const-output';
|
export * from './admin-result-list-const-output';
|
||||||
export * from './admin-result-list-database-output';
|
export * from './admin-result-list-database-output';
|
||||||
|
export * from './admin-result-list-db-backup-output';
|
||||||
export * from './admin-result-list-db-column-output';
|
export * from './admin-result-list-db-column-output';
|
||||||
export * from './admin-result-list-db-table-info';
|
export * from './admin-result-list-db-table-info';
|
||||||
export * from './admin-result-list-enum-entity';
|
export * from './admin-result-list-enum-entity';
|
||||||
@ -149,6 +150,7 @@ export * from './data-table';
|
|||||||
export * from './database-output';
|
export * from './database-output';
|
||||||
export * from './date-time-format-info';
|
export * from './date-time-format-info';
|
||||||
export * from './day-of-week';
|
export * from './day-of-week';
|
||||||
|
export * from './db-backup-output';
|
||||||
export * from './db-column-input';
|
export * from './db-column-input';
|
||||||
export * from './db-column-output';
|
export * from './db-column-output';
|
||||||
export * from './db-object-type';
|
export * from './db-object-type';
|
||||||
|
|||||||
@ -414,6 +414,14 @@ export interface SysUser {
|
|||||||
*/
|
*/
|
||||||
signature?: string | null;
|
signature?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Token版本号
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof SysUser
|
||||||
|
*/
|
||||||
|
tokenVersion?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最新密码修改时间
|
* 最新密码修改时间
|
||||||
*
|
*
|
||||||
|
|||||||
@ -399,6 +399,14 @@ export interface UpdateUserInput {
|
|||||||
*/
|
*/
|
||||||
signature?: string | null;
|
signature?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Token版本号
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof UpdateUserInput
|
||||||
|
*/
|
||||||
|
tokenVersion?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最新密码修改时间
|
* 最新密码修改时间
|
||||||
*
|
*
|
||||||
|
|||||||
@ -414,6 +414,14 @@ export interface UserOutput {
|
|||||||
*/
|
*/
|
||||||
signature?: string | null;
|
signature?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Token版本号
|
||||||
|
*
|
||||||
|
* @type {number}
|
||||||
|
* @memberof UserOutput
|
||||||
|
*/
|
||||||
|
tokenVersion?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最新密码修改时间
|
* 最新密码修改时间
|
||||||
*
|
*
|
||||||
|
|||||||
@ -16,26 +16,4 @@ export const getAllDictList = () =>
|
|||||||
request({
|
request({
|
||||||
url: `${Api.AllDictList}`,
|
url: `${Api.AllDictList}`,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
});
|
});
|
||||||
|
|
||||||
// 获取所有备份文件
|
|
||||||
export const getBackupList = () =>
|
|
||||||
request({
|
|
||||||
url: `/api/dbBackup/page`,
|
|
||||||
method: 'post',
|
|
||||||
});
|
|
||||||
|
|
||||||
// 新增备份文件
|
|
||||||
export const addBackup = () =>
|
|
||||||
request({
|
|
||||||
url: `/api/dbBackup/add`,
|
|
||||||
method: 'post',
|
|
||||||
});
|
|
||||||
|
|
||||||
// 删除备份文件
|
|
||||||
export const deleteBackup = (fileName: String) =>
|
|
||||||
request({
|
|
||||||
url: `/api/dbBackup/delete`,
|
|
||||||
method: 'post',
|
|
||||||
params: { fileName },
|
|
||||||
});
|
|
||||||
85
Web/src/views/system/database/dbBackup.vue
Normal file
85
Web/src/views/system/database/dbBackup.vue
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
|
||||||
|
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options">
|
||||||
|
<template #toolbar_buttons>
|
||||||
|
<el-button type="primary" icon="ele-Plus" @click="handleAdd" v-auth="'dbBackup/add'" :loading="loading"> 新增 </el-button>
|
||||||
|
</template>
|
||||||
|
<template #toolbar_tools> </template>
|
||||||
|
|
||||||
|
<template #row_createTime="{ row }">
|
||||||
|
<el-tooltip :content="row.createTime" placement="top">
|
||||||
|
<span>{{ formatPast(row.createTime) }}</span>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
<template #row_size="{ row }">
|
||||||
|
<span>{{ (row.size / 1024 / 1024).toFixed(2) }} MB</span>
|
||||||
|
</template>
|
||||||
|
<template #row_buttons="{ row }">
|
||||||
|
<el-tooltip content="删除" placement="top">
|
||||||
|
<el-button icon="ele-Delete" text type="danger" v-auth="'dbBackup/delete'" @click="handleDelete(row)"> </el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
</vxe-grid>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { VxeGridInstance } from 'vxe-table';
|
||||||
|
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
|
||||||
|
import { formatPast } from '/@/utils/formatTime';
|
||||||
|
|
||||||
|
import { getAPI } from '/@/utils/axios-utils';
|
||||||
|
import { SysDbBackupApi } from '/@/api-services/api';
|
||||||
|
|
||||||
|
const xGrid = ref<VxeGridInstance>();
|
||||||
|
const loading = ref(false);
|
||||||
|
// 表格参数配置
|
||||||
|
const options = useVxeTable(
|
||||||
|
{
|
||||||
|
id: 'dbBackup',
|
||||||
|
name: '备份信息',
|
||||||
|
columns: [
|
||||||
|
// { type: 'checkbox', width: 40, fixed: 'left' },
|
||||||
|
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
|
||||||
|
{ field: 'fileName', title: '文件名称', minWidth: 200, showOverflow: 'tooltip' },
|
||||||
|
{ field: 'size', title: '文件大小', width: 150, showOverflow: 'tooltip', slots: { default: 'row_size' } },
|
||||||
|
{ field: 'createTime', title: '备份时间', width: 200, showOverflow: 'tooltip', slots: { default: 'row_createTime' } },
|
||||||
|
{ title: '操作', fixed: 'right', width: 150, showOverflow: true, slots: { default: 'row_buttons' } },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// 代理配置
|
||||||
|
proxyConfig: { autoLoad: true, ajax: { query: () => handleQueryApi() } },
|
||||||
|
// 分页配置
|
||||||
|
pagerConfig: { enabled: false },
|
||||||
|
// 工具栏配置
|
||||||
|
toolbarConfig: { enabled: false },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// 查询api
|
||||||
|
const handleQueryApi = async () => {
|
||||||
|
return await getAPI(SysDbBackupApi).apiSysDbBackupListGet();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 增加备份
|
||||||
|
const handleAdd = async () => {
|
||||||
|
loading.value = true;
|
||||||
|
await getAPI(SysDbBackupApi).apiSysDbBackupAddPost();
|
||||||
|
loading.value = false;
|
||||||
|
await xGrid.value?.commitProxy('reload');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除备份
|
||||||
|
const handleDelete = async (row: any) => {
|
||||||
|
loading.value = true;
|
||||||
|
await getAPI(SysDbBackupApi).apiSysDbBackupDeletePost(row.fileName);
|
||||||
|
loading.value = false;
|
||||||
|
await xGrid.value?.commitProxy('reload');
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
@ -1,129 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
|
|
||||||
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents">
|
|
||||||
<template #toolbar_buttons>
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
icon="ele-Plus"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-auth="'dbBackup/add'"
|
|
||||||
:loading="loading"
|
|
||||||
>
|
|
||||||
新增
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
<template #toolbar_tools> </template>
|
|
||||||
|
|
||||||
<template #row_createTime="{ row }">
|
|
||||||
<el-tooltip :content="row.createTime" placement="top">
|
|
||||||
<span>{{ formatPast(row.createTime) }}</span>
|
|
||||||
</el-tooltip>
|
|
||||||
</template>
|
|
||||||
<template #row_size="{ row }">
|
|
||||||
<span>{{ (row.size / 1024 / 1024).toFixed(2) }} MB</span>
|
|
||||||
</template>
|
|
||||||
<template #row_buttons="{ row }">
|
|
||||||
<el-tooltip content="删除" placement="top">
|
|
||||||
<el-button
|
|
||||||
icon="ele-Delete"
|
|
||||||
text
|
|
||||||
type="danger"
|
|
||||||
v-auth="'dbBackup/delete'"
|
|
||||||
@click="handleDelete(row)"
|
|
||||||
>
|
|
||||||
</el-button>
|
|
||||||
</el-tooltip>
|
|
||||||
</template>
|
|
||||||
</vxe-grid>
|
|
||||||
</el-card>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { ref } from "vue";
|
|
||||||
import { ElMessageBox, ElMessage } from "element-plus";
|
|
||||||
import { VxeGridInstance, VxeGridListeners } from "vxe-table";
|
|
||||||
import { useVxeTable } from "/@/hooks/useVxeTableOptionsHook";
|
|
||||||
import { formatPast } from "/@/utils/formatTime";
|
|
||||||
import { getBackupList, addBackup, deleteBackup } from "/@/api/system/admin";
|
|
||||||
|
|
||||||
const xGrid = ref<VxeGridInstance>();
|
|
||||||
const loading = ref(false);
|
|
||||||
// 表格参数配置
|
|
||||||
const options = useVxeTable(
|
|
||||||
{
|
|
||||||
id: "dbBackup",
|
|
||||||
name: "备份信息",
|
|
||||||
columns: [
|
|
||||||
// { type: 'checkbox', width: 40, fixed: 'left' },
|
|
||||||
{ type: "seq", title: "序号", width: 60, fixed: "left" },
|
|
||||||
{
|
|
||||||
field: "fileName",
|
|
||||||
title: "文件名称",
|
|
||||||
minWidth: 180,
|
|
||||||
showOverflow: "tooltip",
|
|
||||||
treeNode: true,
|
|
||||||
align: "left",
|
|
||||||
headerAlign: "center",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: "size",
|
|
||||||
title: "文件大小",
|
|
||||||
width: 100,
|
|
||||||
showOverflow: "tooltip",
|
|
||||||
slots: { default: "row_size" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: "createTime",
|
|
||||||
title: "备份时间",
|
|
||||||
width: 140,
|
|
||||||
showOverflow: "tooltip",
|
|
||||||
slots: { default: "row_createTime" },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "操作",
|
|
||||||
fixed: "right",
|
|
||||||
width: 100,
|
|
||||||
showOverflow: true,
|
|
||||||
slots: { default: "row_buttons" },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
// vxeGrid配置参数(此处可覆写任何参数),参考vxe-table官方文档
|
|
||||||
{
|
|
||||||
stripe: false,
|
|
||||||
// 多选配置
|
|
||||||
checkboxConfig: { range: false },
|
|
||||||
// 代理配置
|
|
||||||
proxyConfig: { autoLoad: true, ajax: { query: () => handleQueryApi() } },
|
|
||||||
// 分页配置
|
|
||||||
pagerConfig: { enabled: false },
|
|
||||||
// 工具栏配置
|
|
||||||
toolbarConfig: { export: false },
|
|
||||||
// 树形配置
|
|
||||||
treeConfig: { expandAll: false },
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// 查询api
|
|
||||||
const handleQueryApi = async () => {
|
|
||||||
return getBackupList();
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleAdd = async () => {
|
|
||||||
loading.value = true;
|
|
||||||
await addBackup();
|
|
||||||
loading.value = false;
|
|
||||||
await xGrid.value?.commitProxy("reload");
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDelete = async (row: any) => {
|
|
||||||
loading.value = true;
|
|
||||||
await deleteBackup(row.fileName);
|
|
||||||
loading.value = false;
|
|
||||||
await xGrid.value?.commitProxy("reload");
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
Loading…
Reference in New Issue
Block a user