2
0

feat: i18n support for export and log

This commit is contained in:
zhangsz
2025-02-11 18:21:13 +08:00
parent 0fdf23fa16
commit 1a5bf3461f
27 changed files with 340 additions and 118 deletions

View File

@@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.constant.Constants;
import org.wfc.common.core.domain.R;
import org.wfc.common.core.exception.job.TaskException;
import org.wfc.common.core.utils.MessageUtils;
import org.wfc.common.core.utils.StringUtils;
import org.wfc.common.core.utils.poi.ExcelUtil;
import org.wfc.common.core.web.controller.BaseController;
@@ -61,13 +62,13 @@ public class SysJobController extends BaseController
* 导出定时任务列表
*/
// @RequiresPermissions("monitor:job:export")
@Log(title = "定时任务", businessType = BusinessType.EXPORT)
@Log(title = "menu.system.job.management", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysJob sysJob)
{
List<SysJob> list = jobService.selectJobList(sysJob);
ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class);
util.exportExcel(response, list, "定时任务");
util.exportExcel(response, list, MessageUtils.message("excel.scheduled.task.list"));
}
/**
@@ -84,7 +85,7 @@ public class SysJobController extends BaseController
* 新增定时任务
*/
// @RequiresPermissions("monitor:job:add")
@Log(title = "定时任务", businessType = BusinessType.INSERT)
@Log(title = "menu.system.job.management", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysJob job) throws SchedulerException, TaskException
{
@@ -120,7 +121,7 @@ public class SysJobController extends BaseController
* 修改定时任务
*/
// @RequiresPermissions("monitor:job:edit")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@Log(title = "menu.system.job.management", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException
{
@@ -156,7 +157,7 @@ public class SysJobController extends BaseController
* 定时任务状态修改
*/
// @RequiresPermissions("monitor:job:changeStatus")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@Log(title = "menu.system.job.management", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException
{
@@ -169,7 +170,7 @@ public class SysJobController extends BaseController
* 定时任务立即执行一次
*/
// @RequiresPermissions("monitor:job:changeStatus")
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
@Log(title = "menu.system.job.management", businessType = BusinessType.UPDATE)
@PutMapping("/run")
public AjaxResult run(@RequestBody SysJob job) throws SchedulerException
{
@@ -189,7 +190,7 @@ public class SysJobController extends BaseController
* 删除定时任务
*/
// @RequiresPermissions("monitor:job:remove")
@Log(title = "定时任务", businessType = BusinessType.DELETE)
@Log(title = "menu.system.job.management", businessType = BusinessType.DELETE)
@DeleteMapping("/{jobIds}")
public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException
{

View File

@@ -1,5 +1,6 @@
package org.wfc.job.controller;
import org.aspectj.bridge.MessageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@@ -7,6 +8,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.utils.MessageUtils;
import org.wfc.common.core.utils.poi.ExcelUtil;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.domain.AjaxResult;
@@ -47,13 +49,13 @@ public class SysJobLogController extends BaseController
* 导出定时任务调度日志列表
*/
// @RequiresPermissions("monitor:job:export")
@Log(title = "任务调度日志", businessType = BusinessType.EXPORT)
@Log(title = "menu.system.job.log", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysJobLog sysJobLog)
{
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
util.exportExcel(response, list, "调度日志");
util.exportExcel(response, list, MessageUtils.message("menu.system.job.log"));
}
/**
@@ -70,7 +72,7 @@ public class SysJobLogController extends BaseController
* 删除定时任务调度日志
*/
// @RequiresPermissions("monitor:job:remove")
@Log(title = "定时任务调度日志", businessType = BusinessType.DELETE)
@Log(title = "menu.system.job.log", businessType = BusinessType.DELETE)
@DeleteMapping("/{jobLogIds}")
public AjaxResult remove(@PathVariable Long[] jobLogIds)
{
@@ -81,7 +83,7 @@ public class SysJobLogController extends BaseController
* 清空定时任务调度日志
*/
// @RequiresPermissions("monitor:job:remove")
@Log(title = "调度日志", businessType = BusinessType.CLEAN)
@Log(title = "menu.system.job.log", businessType = BusinessType.CLEAN)
@DeleteMapping("/clean")
public AjaxResult clean()
{

View File

@@ -25,35 +25,35 @@ public class SysJob extends BaseEntity
private static final long serialVersionUID = 1L;
/** 任务ID */
@Excel(name = "任务序号", cellType = ColumnType.NUMERIC)
@Excel(name = "excel.scheduled.task.id", cellType = ColumnType.NUMERIC)
private Long jobId;
/** 任务名称 */
@Excel(name = "任务名称")
@Excel(name = "excel.scheduled.task.name")
private String jobName;
/** 任务组名 */
@Excel(name = "任务组名")
@Excel(name = "excel.scheduled.task.job.group")
private String jobGroup;
/** 调用目标字符串 */
@Excel(name = "调用目标字符串")
@Excel(name = "excel.scheduled.task.invoke.target")
private String invokeTarget;
/** cron执行表达式 */
@Excel(name = "执行表达式 ")
@Excel(name = "excel.scheduled.task.cron.expression")
private String cronExpression;
/** cron计划策略 */
@Excel(name = "计划策略 ", readConverterExp = "0=默认,1=立即触发执行,2=触发一次执行,3=不触发立即执行")
@Excel(name = "excel.scheduled.task.schedule.strategy", readConverterExp = "0=Default,1=Trigger immediate execution,2=Trigger an execution,3=Do not trigger immediate execution")
private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT;
/** 是否并发执行0允许 1禁止 */
@Excel(name = "并发执行", readConverterExp = "0=允许,1=禁止")
@Excel(name = "excel.scheduled.task.concurrent", readConverterExp = "0=Enabled,1=Diasbled")
private String concurrent;
/** 任务状态0正常 1暂停 */
@Excel(name = "任务状态", readConverterExp = "0=正常,1=暂停")
@Excel(name = "excel.scheduled.task.status", readConverterExp = "0=Normal,1=Supend")
private String status;
public Long getJobId()

View File

@@ -16,31 +16,31 @@ public class SysJobLog extends BaseEntity
private static final long serialVersionUID = 1L;
/** ID */
@Excel(name = "日志序号")
@Excel(name = "excel.scheduled.task.log.id")
private Long jobLogId;
/** 任务名称 */
@Excel(name = "任务名称")
@Excel(name = "excel.scheduled.task.name")
private String jobName;
/** 任务组名 */
@Excel(name = "任务组名")
@Excel(name = "excel.scheduled.task.job.group")
private String jobGroup;
/** 调用目标字符串 */
@Excel(name = "调用目标字符串")
@Excel(name = "excel.scheduled.task.invoke.target")
private String invokeTarget;
/** 日志信息 */
@Excel(name = "日志信息")
@Excel(name = "excel.scheduled.task.log.info")
private String jobMessage;
/** 执行状态0正常 1失败 */
@Excel(name = "执行状态", readConverterExp = "0=正常,1=失败")
@Excel(name = "excel.scheduled.task.log.status", readConverterExp = "0=Success,1=Failure")
private String status;
/** 异常信息 */
@Excel(name = "异常信息")
@Excel(name = "excel.scheduled.task.log.error.msg")
private String exceptionInfo;
/** 开始时间 */