mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-15 19:45:06 +08:00
多模块重构 5:infra 模块的初始化
This commit is contained in:
@ -0,0 +1,108 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO;
|
||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.*;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.*;
|
||||
import cn.iocoder.yudao.module.infra.convert.config.InfConfigConvert;
|
||||
import cn.iocoder.yudao.module.infra.service.config.InfConfigService;
|
||||
import cn.iocoder.yudao.module.infra.controller.config.vo.*;
|
||||
import cn.iocoder.yudao.module.infra.enums.InfErrorCodeConstants;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Api(tags = "参数配置")
|
||||
@RestController
|
||||
@RequestMapping("/infra/config")
|
||||
@Validated
|
||||
public class ConfigController {
|
||||
|
||||
@Resource
|
||||
private InfConfigService configService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建参数配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:create')")
|
||||
public CommonResult<Long> createConfig(@Valid @RequestBody ConfigCreateReqVO reqVO) {
|
||||
return success(configService.createConfig(reqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("修改参数配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:update')")
|
||||
public CommonResult<Boolean> updateConfig(@Valid @RequestBody ConfigUpdateReqVO reqVO) {
|
||||
configService.updateConfig(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除参数配置")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:delete')")
|
||||
public CommonResult<Boolean> deleteConfig(@RequestParam("id") Long id) {
|
||||
configService.deleteConfig(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get")
|
||||
@ApiOperation("获得参数配置")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:query')")
|
||||
public CommonResult<ConfigRespVO> getConfig(@RequestParam("id") Long id) {
|
||||
return success(InfConfigConvert.INSTANCE.convert(configService.getConfig(id)));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get-value-by-key")
|
||||
@ApiOperation(value = "根据参数键名查询参数值", notes = "敏感配置,不允许返回给前端")
|
||||
@ApiImplicitParam(name = "key", value = "参数键", required = true, example = "yunai.biz.username", dataTypeClass = String.class)
|
||||
public CommonResult<String> getConfigKey(@RequestParam("key") String key) {
|
||||
InfConfigDO config = configService.getConfigByKey(key);
|
||||
if (config == null) {
|
||||
return null;
|
||||
}
|
||||
if (config.getSensitive()) {
|
||||
throw ServiceExceptionUtil.exception(InfErrorCodeConstants.CONFIG_GET_VALUE_ERROR_IF_SENSITIVE);
|
||||
}
|
||||
return success(config.getValue());
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获取参数配置分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:query')")
|
||||
public CommonResult<PageResult<ConfigRespVO>> getConfigPage(@Valid ConfigPageReqVO reqVO) {
|
||||
PageResult<InfConfigDO> page = configService.getConfigPage(reqVO);
|
||||
return success(InfConfigConvert.INSTANCE.convertPage(page));
|
||||
}
|
||||
|
||||
@GetMapping("/export")
|
||||
@ApiOperation("导出参数配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportSysConfig(@Valid ConfigExportReqVO reqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<InfConfigDO> list = configService.getConfigList(reqVO);
|
||||
// 拼接数据
|
||||
List<ConfigExcelVO> datas = InfConfigConvert.INSTANCE.convertList(list);
|
||||
// 输出
|
||||
ExcelUtils.write(response, "参数配置.xls", "数据", ConfigExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 参数配置 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class ConfigBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "参数分组", required = true, example = "biz")
|
||||
@NotEmpty(message = "参数分组不能为空")
|
||||
@Size(max = 50, message = "参数名称不能超过50个字符")
|
||||
private String group;
|
||||
|
||||
@ApiModelProperty(value = "参数名称", required = true, example = "数据库名")
|
||||
@NotBlank(message = "参数名称不能为空")
|
||||
@Size(max = 100, message = "参数名称不能超过100个字符")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "参数键值", required = true, example = "1024")
|
||||
@NotBlank(message = "参数键值不能为空")
|
||||
@Size(max = 500, message = "参数键值长度不能超过500个字符")
|
||||
private String value;
|
||||
|
||||
@ApiModelProperty(value = "是否敏感", required = true, example = "true")
|
||||
@NotNull(message = "是否敏感不能为空")
|
||||
private Boolean sensitive;
|
||||
|
||||
@ApiModelProperty(value = "备注", example = "备注一下很帅气!")
|
||||
private String remark;
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@ApiModel("管理后台 - 参数配置创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ConfigCreateReqVO extends ConfigBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "参数键名", required = true, example = "yunai.db.username")
|
||||
@NotBlank(message = "参数键名长度不能为空")
|
||||
@Size(max = 100, message = "参数键名长度不能超过100个字符")
|
||||
private String key;
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 参数配置 Excel 导出响应 VO
|
||||
*/
|
||||
@Data
|
||||
public class ConfigExcelVO {
|
||||
|
||||
@ExcelProperty("参数配置序号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("参数键名")
|
||||
private String key;
|
||||
|
||||
@ExcelProperty("参数分组")
|
||||
private String group;
|
||||
|
||||
@ExcelProperty("参数名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("参数键值")
|
||||
private String value;
|
||||
|
||||
@ExcelProperty(value = "参数类型", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.CONFIG_TYPE)
|
||||
private Integer type;
|
||||
|
||||
@ExcelProperty(value = "是否敏感", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean sensitive;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("参数配置导出 Request VO")
|
||||
@Data
|
||||
public class ConfigExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "参数名称", example = "模糊匹配")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "参数键名", example = "yunai.db.username", notes = "模糊匹配")
|
||||
private String key;
|
||||
|
||||
@ApiModelProperty(value = "参数类型", example = "1", notes = "参见 SysConfigTypeEnum 枚举")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "开始时间", example = "2020-10-24 00:00:00")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date beginTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间", example = "2020-10-24 23:59:59")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date endTime;
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("参数配置分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ConfigPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "参数名称", example = "模糊匹配")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "参数键名", example = "yunai.db.username", notes = "模糊匹配")
|
||||
private String key;
|
||||
|
||||
@ApiModelProperty(value = "参数类型", example = "1", notes = "参见 SysConfigTypeEnum 枚举")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "开始时间", example = "2020-10-24 00:00:00")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date beginTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间", example = "2020-10-24 23:59:59")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date endTime;
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("参数配置信息 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ConfigRespVO extends ConfigBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "参数配置序号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "参数键名", required = true, example = "yunai.db.username")
|
||||
@NotBlank(message = "参数键名长度不能为空")
|
||||
@Size(max = 100, message = "参数键名长度不能超过100个字符")
|
||||
private String key;
|
||||
|
||||
@ApiModelProperty(value = "参数类型", required = true, example = "1", notes = "参见 SysConfigTypeEnum 枚举")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("参数配置创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ConfigUpdateReqVO extends ConfigBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "参数配置序号", required = true, example = "1024")
|
||||
@NotNull(message = "参数配置编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.doc;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
import cn.smallbun.screw.core.Configuration;
|
||||
import cn.smallbun.screw.core.engine.EngineConfig;
|
||||
import cn.smallbun.screw.core.engine.EngineFileType;
|
||||
import cn.smallbun.screw.core.engine.EngineTemplateType;
|
||||
import cn.smallbun.screw.core.execute.DocumentationExecute;
|
||||
import cn.smallbun.screw.core.process.ProcessConfig;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties;
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
@Api(tags = "数据库文档")
|
||||
@RestController
|
||||
@RequestMapping("/infra/db-doc")
|
||||
public class InfDbDocController {
|
||||
|
||||
@Resource
|
||||
private DynamicDataSourceProperties dynamicDataSourceProperties;
|
||||
|
||||
private static final String FILE_OUTPUT_DIR = System.getProperty("java.io.tmpdir") + File.separator
|
||||
+ "db-doc";
|
||||
private static final String DOC_FILE_NAME = "数据库文档";
|
||||
private static final String DOC_VERSION = "1.0.0";
|
||||
private static final String DOC_DESCRIPTION = "文档描述";
|
||||
|
||||
@GetMapping("/export-html")
|
||||
@ApiOperation("导出 html 格式的数据文档")
|
||||
@ApiImplicitParam(name = "deleteFile", value = "是否删除在服务器本地生成的数据库文档", example = "true", dataTypeClass = Boolean.class)
|
||||
public void exportHtml(@RequestParam(defaultValue = "true") Boolean deleteFile,
|
||||
HttpServletResponse response) throws IOException {
|
||||
doExportFile(EngineFileType.HTML, deleteFile, response);
|
||||
}
|
||||
|
||||
@GetMapping("/export-word")
|
||||
@ApiOperation("导出 word 格式的数据文档")
|
||||
@ApiImplicitParam(name = "deleteFile", value = "是否删除在服务器本地生成的数据库文档", example = "true", dataTypeClass = Boolean.class)
|
||||
public void exportWord(@RequestParam(defaultValue = "true") Boolean deleteFile,
|
||||
HttpServletResponse response) throws IOException {
|
||||
doExportFile(EngineFileType.WORD, deleteFile, response);
|
||||
}
|
||||
|
||||
@GetMapping("/export-markdown")
|
||||
@ApiOperation("导出 markdown 格式的数据文档")
|
||||
@ApiImplicitParam(name = "deleteFile", value = "是否删除在服务器本地生成的数据库文档", example = "true", dataTypeClass = Boolean.class)
|
||||
public void exportMarkdown(@RequestParam(defaultValue = "true") Boolean deleteFile,
|
||||
HttpServletResponse response) throws IOException {
|
||||
doExportFile(EngineFileType.MD, deleteFile, response);
|
||||
}
|
||||
|
||||
private void doExportFile(EngineFileType fileOutputType, Boolean deleteFile,
|
||||
HttpServletResponse response) throws IOException {
|
||||
String docFileName = DOC_FILE_NAME + "_" + IdUtil.fastSimpleUUID();
|
||||
String filePath = doExportFile(fileOutputType, docFileName);
|
||||
String downloadFileName = DOC_FILE_NAME + fileOutputType.getFileSuffix(); //下载后的文件名
|
||||
try {
|
||||
// 读取,返回
|
||||
ServletUtils.writeAttachment(response, downloadFileName, FileUtil.readBytes(filePath));
|
||||
} finally {
|
||||
handleDeleteFile(deleteFile, filePath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出文件,返回文件路径
|
||||
*
|
||||
* @param fileOutputType 文件类型
|
||||
* @param fileName 文件名, 无需 ".docx" 等文件后缀
|
||||
* @return 生成的文件所在路径
|
||||
*/
|
||||
private String doExportFile(EngineFileType fileOutputType, String fileName) {
|
||||
try (HikariDataSource dataSource = buildDataSource()) {
|
||||
// 创建 screw 的配置
|
||||
Configuration config = Configuration.builder()
|
||||
.version(DOC_VERSION) // 版本
|
||||
.description(DOC_DESCRIPTION) // 描述
|
||||
.dataSource(dataSource) // 数据源
|
||||
.engineConfig(buildEngineConfig(fileOutputType, fileName)) // 引擎配置
|
||||
.produceConfig(buildProcessConfig()) // 处理配置
|
||||
.build();
|
||||
|
||||
// 执行 screw,生成数据库文档
|
||||
new DocumentationExecute(config).execute();
|
||||
|
||||
return FILE_OUTPUT_DIR + File.separator + fileName + fileOutputType.getFileSuffix();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDeleteFile(Boolean deleteFile, String filePath) {
|
||||
if (!deleteFile) {
|
||||
return;
|
||||
}
|
||||
FileUtil.del(filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数据源
|
||||
*/
|
||||
// TODO 芋艿:screw 暂时不支持 druid,尴尬
|
||||
private HikariDataSource buildDataSource() {
|
||||
// 获得 DataSource 数据源,目前只支持首个
|
||||
String primary = dynamicDataSourceProperties.getPrimary();
|
||||
DataSourceProperty dataSourceProperty = dynamicDataSourceProperties.getDatasource().get(primary);
|
||||
// 创建 HikariConfig 配置类
|
||||
HikariConfig hikariConfig = new HikariConfig();
|
||||
hikariConfig.setJdbcUrl(dataSourceProperty.getUrl());
|
||||
hikariConfig.setUsername(dataSourceProperty.getUsername());
|
||||
hikariConfig.setPassword(dataSourceProperty.getPassword());
|
||||
hikariConfig.addDataSourceProperty("useInformationSchema", "true"); // 设置可以获取 tables remarks 信息
|
||||
// 创建数据源
|
||||
return new HikariDataSource(hikariConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 screw 的引擎配置
|
||||
*/
|
||||
private static EngineConfig buildEngineConfig(EngineFileType fileOutputType, String docFileName) {
|
||||
return EngineConfig.builder()
|
||||
.fileOutputDir(FILE_OUTPUT_DIR) // 生成文件路径
|
||||
.openOutputDir(false) // 打开目录
|
||||
.fileType(fileOutputType) // 文件类型
|
||||
.produceType(EngineTemplateType.freemarker) // 文件类型
|
||||
.fileName(docFileName) // 自定义文件名称
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 screw 的处理配置,一般可忽略
|
||||
* 指定生成逻辑、当存在指定表、指定表前缀、指定表后缀时,将生成指定表,其余表不生成、并跳过忽略表配置
|
||||
*/
|
||||
private static ProcessConfig buildProcessConfig() {
|
||||
return ProcessConfig.builder()
|
||||
.ignoreTablePrefix(Collections.singletonList("QRTZ_")) // 忽略表前缀
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.file;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.InfFilePageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.service.file.InfFileService;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.controller.file.vo.InfFileRespVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.service.file.InfFileCoreService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.convert.file.InfFileConvert;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Api(tags = "文件存储")
|
||||
@RestController
|
||||
@RequestMapping("/infra/file")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class InfFileController {
|
||||
|
||||
@Resource
|
||||
private InfFileService fileService;
|
||||
@Resource
|
||||
private InfFileCoreService fileCoreService;
|
||||
|
||||
@PostMapping("/upload")
|
||||
@ApiOperation("上传文件")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "文件附件", required = true, dataTypeClass = MultipartFile.class),
|
||||
@ApiImplicitParam(name = "path", value = "文件路径", example = "yudaoyuanma.png", dataTypeClass = String.class)
|
||||
})
|
||||
public CommonResult<String> uploadFile(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam("path") String path) throws IOException {
|
||||
return success(fileCoreService.createFile(path, IoUtil.readBytes(file.getInputStream())));
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除文件")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = String.class)
|
||||
@PreAuthorize("@ss.hasPermission('infra:file:delete')")
|
||||
public CommonResult<Boolean> deleteFile(@RequestParam("id") String id) {
|
||||
fileCoreService.deleteFile(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get/{path}")
|
||||
@ApiOperation("下载文件")
|
||||
@ApiImplicitParam(name = "path", value = "文件附件", required = true, dataTypeClass = MultipartFile.class)
|
||||
public void getFile(HttpServletResponse response, @PathVariable("path") String path) throws IOException {
|
||||
TenantContextHolder.setNullTenantId();
|
||||
InfFileDO file = fileCoreService.getFile(path);
|
||||
if (file == null) {
|
||||
log.warn("[getFile][path({}) 文件不存在]", path);
|
||||
response.setStatus(HttpStatus.NOT_FOUND.value());
|
||||
return;
|
||||
}
|
||||
ServletUtils.writeAttachment(response, path, file.getContent());
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得文件分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file:query')")
|
||||
public CommonResult<PageResult<InfFileRespVO>> getFilePage(@Valid InfFilePageReqVO pageVO) {
|
||||
PageResult<InfFileDO> pageResult = fileService.getFilePage(pageVO);
|
||||
return success(InfFileConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.file.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("文件分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfFilePageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "文件路径", example = "yudao", notes = "模糊匹配")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "文件类型", example = "jpg", notes = "模糊匹配")
|
||||
private String type;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始创建时间")
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束创建时间")
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.framework.quartz.core.util.CronUtils;
|
||||
import cn.iocoder.yudao.adminserver.modules.infra.controller.job.vo.job.*;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.*;
|
||||
import cn.iocoder.yudao.module.infra.convert.job.InfJobConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.InfJobDO;
|
||||
import cn.iocoder.yudao.module.infra.service.job.InfJobService;
|
||||
import cn.iocoder.yudao.module.infra.controller.job.vo.job.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Api(tags = "定时任务")
|
||||
@RestController
|
||||
@RequestMapping("/infra/job")
|
||||
@Validated
|
||||
public class InfJobController {
|
||||
|
||||
@Resource
|
||||
private InfJobService jobService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建定时任务")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:create')")
|
||||
public CommonResult<Long> createJob(@Valid @RequestBody InfJobCreateReqVO createReqVO)
|
||||
throws SchedulerException {
|
||||
return success(jobService.createJob(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新定时任务")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:update')")
|
||||
public CommonResult<Boolean> updateJob(@Valid @RequestBody InfJobUpdateReqVO updateReqVO)
|
||||
throws SchedulerException {
|
||||
jobService.updateJob(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/update-status")
|
||||
@ApiOperation("更新定时任务的状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class),
|
||||
@ApiImplicitParam(name = "status", value = "状态", required = true, example = "1", dataTypeClass = Integer.class),
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:update')")
|
||||
public CommonResult<Boolean> updateJobStatus(@RequestParam(value = "id") Long id, @RequestParam("status") Integer status)
|
||||
throws SchedulerException {
|
||||
jobService.updateJobStatus(id, status);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除定时任务")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:delete')")
|
||||
public CommonResult<Boolean> deleteJob(@RequestParam("id") Long id)
|
||||
throws SchedulerException {
|
||||
jobService.deleteJob(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/trigger")
|
||||
@ApiOperation("触发定时任务")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:trigger')")
|
||||
public CommonResult<Boolean> triggerJob(@RequestParam("id") Long id) throws SchedulerException {
|
||||
jobService.triggerJob(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得定时任务")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<InfJobRespVO> getJob(@RequestParam("id") Long id) {
|
||||
InfJobDO job = jobService.getJob(id);
|
||||
return success(InfJobConvert.INSTANCE.convert(job));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得定时任务列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<List<InfJobRespVO>> getJobList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<InfJobDO> list = jobService.getJobList(ids);
|
||||
return success(InfJobConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得定时任务分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<PageResult<InfJobRespVO>> getJobPage(@Valid InfJobPageReqVO pageVO) {
|
||||
PageResult<InfJobDO> pageResult = jobService.getJobPage(pageVO);
|
||||
return success(InfJobConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出定时任务 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportJobExcel(@Valid InfJobExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<InfJobDO> list = jobService.getJobList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<InfJobExcelVO> datas = InfJobConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "定时任务.xls", "数据", InfJobExcelVO.class, datas);
|
||||
}
|
||||
|
||||
@GetMapping("/get_next_times")
|
||||
@ApiOperation("获得定时任务的下 n 次执行时间")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class),
|
||||
@ApiImplicitParam(name = "count", value = "数量", example = "5", dataTypeClass = Long.class)
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<List<Date>> getJobNextTimes(@RequestParam("id") Long id,
|
||||
@RequestParam(value = "count", required = false, defaultValue = "5") Integer count) {
|
||||
InfJobDO job = jobService.getJob(id);
|
||||
if (job == null) {
|
||||
return success(Collections.emptyList());
|
||||
}
|
||||
return success(CronUtils.getNextTimes(job.getCronExpression(), count));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.InfJobLogExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.InfJobLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.InfJobLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.InfJobLogRespVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.job.InfJobLogConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.InfJobLogDO;
|
||||
import cn.iocoder.yudao.module.infra.service.job.InfJobLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Api(tags = "定时任务日志")
|
||||
@RestController
|
||||
@RequestMapping("/infra/job-log")
|
||||
@Validated
|
||||
public class InfJobLogController {
|
||||
|
||||
@Resource
|
||||
private InfJobLogService jobLogService;
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得定时任务日志")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<InfJobLogRespVO> getJobLog(@RequestParam("id") Long id) {
|
||||
InfJobLogDO jobLog = jobLogService.getJobLog(id);
|
||||
return success(InfJobLogConvert.INSTANCE.convert(jobLog));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得定时任务日志列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<List<InfJobLogRespVO>> getJobLogList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<InfJobLogDO> list = jobLogService.getJobLogList(ids);
|
||||
return success(InfJobLogConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得定时任务日志分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<PageResult<InfJobLogRespVO>> getJobLogPage(@Valid InfJobLogPageReqVO pageVO) {
|
||||
PageResult<InfJobLogDO> pageResult = jobLogService.getJobLogPage(pageVO);
|
||||
return success(InfJobLogConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出定时任务日志 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportJobLogExcel(@Valid InfJobLogExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<InfJobLogDO> list = jobLogService.getJobLogList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<InfJobLogExcelVO> datas = InfJobLogConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "任务日志.xls", "数据", InfJobLogExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 定时任务 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class InfJobBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "任务名称", required = true, example = "测试任务")
|
||||
@NotNull(message = "任务名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "处理器的参数", example = "yudao")
|
||||
private String handlerParam;
|
||||
|
||||
@ApiModelProperty(value = "CRON 表达式", required = true, example = "0/10 * * * * ? *")
|
||||
@NotNull(message = "CRON 表达式不能为空")
|
||||
private String cronExpression;
|
||||
|
||||
@ApiModelProperty(value = "重试次数", required = true, example = "3")
|
||||
@NotNull(message = "重试次数不能为空")
|
||||
private Integer retryCount;
|
||||
|
||||
@ApiModelProperty(value = "重试间隔", required = true, example = "1000")
|
||||
@NotNull(message = "重试间隔不能为空")
|
||||
private Integer retryInterval;
|
||||
|
||||
@ApiModelProperty(value = "监控超时时间", example = "1000")
|
||||
private Integer monitorTimeout;
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("定时任务创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfJobCreateReqVO extends InfJobBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "处理器的名字", required = true, example = "sysUserSessionTimeoutJob")
|
||||
@NotNull(message = "处理器的名字不能为空")
|
||||
private String handlerName;
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 定时任务 Excel VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class InfJobExcelVO {
|
||||
|
||||
@ExcelProperty("任务编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("任务名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty(value = "任务状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.JOB_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("处理器的名字")
|
||||
private String handlerName;
|
||||
|
||||
@ExcelProperty("处理器的参数")
|
||||
private String handlerParam;
|
||||
|
||||
@ExcelProperty("CRON 表达式")
|
||||
private String cronExpression;
|
||||
|
||||
@ExcelProperty("最后一次执行的开始时间")
|
||||
private Date executeBeginTime;
|
||||
|
||||
@ExcelProperty("最后一次执行的结束时间")
|
||||
private Date executeEndTime;
|
||||
|
||||
@ExcelProperty("上一次触发时间")
|
||||
private Date firePrevTime;
|
||||
|
||||
@ExcelProperty("下一次触发时间")
|
||||
private Date fireNextTime;
|
||||
|
||||
@ExcelProperty("监控超时时间")
|
||||
private Integer monitorTimeout;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel(value = "定时任务 Excel 导出 Request VO", description = "参数和 InfJobPageReqVO 是一致的")
|
||||
@Data
|
||||
public class InfJobExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "任务名称", example = "测试任务", notes = "模糊匹配")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "任务状态", example = "1", notes = "参见 InfJobStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "处理器的名字", example = "sysUserSessionTimeoutJob", notes = "模糊匹配")
|
||||
private String handlerName;
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ApiModel("定时任务分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfJobPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "任务名称", example = "测试任务", notes = "模糊匹配")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "任务状态", example = "1", notes = "参见 InfJobStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "处理器的名字", example = "sysUserSessionTimeoutJob", notes = "模糊匹配")
|
||||
private String handlerName;
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("定时任务 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfJobRespVO extends InfJobBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "任务编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "任务状态", required = true, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "处理器的名字", required = true, example = "sysUserSessionTimeoutJob")
|
||||
@NotNull(message = "处理器的名字不能为空")
|
||||
private String handlerName;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("定时任务更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfJobUpdateReqVO extends InfJobBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "任务编号", required = true, example = "1024")
|
||||
@NotNull(message = "任务编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 定时任务日志 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class InfJobLogBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "任务编号", required = true, example = "1024")
|
||||
@NotNull(message = "任务编号不能为空")
|
||||
private Long jobId;
|
||||
|
||||
@ApiModelProperty(value = "处理器的名字", required = true, example = "sysUserSessionTimeoutJob")
|
||||
@NotNull(message = "处理器的名字不能为空")
|
||||
private String handlerName;
|
||||
|
||||
@ApiModelProperty(value = "处理器的参数", example = "yudao")
|
||||
private String handlerParam;
|
||||
|
||||
@ApiModelProperty(value = "第几次执行", required = true, example = "1")
|
||||
@NotNull(message = "第几次执行不能为空")
|
||||
private Integer executeIndex;
|
||||
|
||||
@ApiModelProperty(value = "开始执行时间", required = true)
|
||||
@NotNull(message = "开始执行时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date beginTime;
|
||||
|
||||
@ApiModelProperty(value = "结束执行时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "执行时长", example = "123")
|
||||
private Integer duration;
|
||||
|
||||
@ApiModelProperty(value = "任务状态", required = true, example = "1", notes = "参见 InfJobLogStatusEnum 枚举")
|
||||
@NotNull(message = "任务状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "结果数据", example = "执行成功")
|
||||
private String result;
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 定时任务 Excel VO
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Data
|
||||
public class InfJobLogExcelVO {
|
||||
|
||||
@ExcelProperty("日志编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("任务编号")
|
||||
private Long jobId;
|
||||
|
||||
@ExcelProperty("处理器的名字")
|
||||
private String handlerName;
|
||||
|
||||
@ExcelProperty("处理器的参数")
|
||||
private String handlerParam;
|
||||
|
||||
@ExcelProperty("第几次执行")
|
||||
private Integer executeIndex;
|
||||
|
||||
@ExcelProperty("开始执行时间")
|
||||
private Date beginTime;
|
||||
|
||||
@ExcelProperty("结束执行时间")
|
||||
private Date endTime;
|
||||
|
||||
@ExcelProperty("执行时长")
|
||||
private Integer duration;
|
||||
|
||||
@ExcelProperty(value = "任务状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.JOB_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("结果数据")
|
||||
private String result;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel(value = "定时任务 Excel 导出 Request VO", description = "参数和 InfJobLogPageReqVO 是一致的")
|
||||
@Data
|
||||
public class InfJobLogExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "任务编号", example = "10")
|
||||
private Long jobId;
|
||||
|
||||
@ApiModelProperty(value = "处理器的名字", notes = "模糊匹配")
|
||||
private String handlerName;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始执行时间")
|
||||
private Date beginTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束执行时间")
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "任务状态", notes = "参见 InfJobLogStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("定时任务日志分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfJobLogPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "任务编号", example = "10")
|
||||
private Long jobId;
|
||||
|
||||
@ApiModelProperty(value = "处理器的名字", notes = "模糊匹配")
|
||||
private String handlerName;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始执行时间")
|
||||
private Date beginTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束执行时间")
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "任务状态", notes = "参见 InfJobLogStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("定时任务日志 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfJobLogRespVO extends InfJobLogBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "日志编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.InfApiAccessLogExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.InfApiAccessLogRespVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.logger.InfApiAccessLogConvert;
|
||||
import cn.iocoder.yudao.module.infra.service.logger.InfApiAccessLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Api(tags = "API 访问日志")
|
||||
@RestController
|
||||
@RequestMapping("/infra/api-access-log")
|
||||
@Validated
|
||||
public class InfApiAccessLogController {
|
||||
|
||||
@Resource
|
||||
private InfApiAccessLogService apiAccessLogService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得API 访问日志分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-access-log:query')")
|
||||
public CommonResult<PageResult<InfApiAccessLogRespVO>> getApiAccessLogPage(@Valid InfApiAccessLogPageReqVO pageVO) {
|
||||
PageResult<InfApiAccessLogDO> pageResult = apiAccessLogService.getApiAccessLogPage(pageVO);
|
||||
return success(InfApiAccessLogConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出API 访问日志 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-access-log:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportApiAccessLogExcel(@Valid InfApiAccessLogExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<InfApiAccessLogDO> list = apiAccessLogService.getApiAccessLogList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<InfApiAccessLogExcelVO> datas = InfApiAccessLogConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "API 访问日志.xls", "数据", InfApiAccessLogExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.InfApiErrorLogExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.InfApiErrorLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.InfApiErrorLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.InfApiErrorLogRespVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.logger.InfApiErrorLogConvert;
|
||||
import cn.iocoder.yudao.module.infra.service.logger.InfApiErrorLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Api(tags = "API 错误日志")
|
||||
@RestController
|
||||
@RequestMapping("/infra/api-error-log")
|
||||
@Validated
|
||||
public class InfApiErrorLogController {
|
||||
|
||||
@Resource
|
||||
private InfApiErrorLogService apiErrorLogService;
|
||||
|
||||
@PutMapping("/update-status")
|
||||
@ApiOperation("更新 API 错误日志的状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class),
|
||||
@ApiImplicitParam(name = "processStatus", value = "处理状态", required = true, example = "1", dataTypeClass = Integer.class)
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-error-log:update-status')")
|
||||
public CommonResult<Boolean> updateApiErrorLogProcess(@RequestParam("id") Long id,
|
||||
@RequestParam("processStatus") Integer processStatus) {
|
||||
apiErrorLogService.updateApiErrorLogProcess(id, processStatus, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得 API 错误日志分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-error-log:query')")
|
||||
public CommonResult<PageResult<InfApiErrorLogRespVO>> getApiErrorLogPage(@Valid InfApiErrorLogPageReqVO pageVO) {
|
||||
PageResult<InfApiErrorLogDO> pageResult = apiErrorLogService.getApiErrorLogPage(pageVO);
|
||||
return success(InfApiErrorLogConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出 API 错误日志 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-error-log:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportApiErrorLogExcel(@Valid InfApiErrorLogExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<InfApiErrorLogDO> list = apiErrorLogService.getApiErrorLogList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<InfApiErrorLogExcelVO> datas = InfApiErrorLogConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "API 错误日志.xls", "数据", InfApiErrorLogExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* API 访问日志 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class InfApiAccessLogBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "链路追踪编号", required = true, example = "66600cb6-7852-11eb-9439-0242ac130002")
|
||||
@NotNull(message = "链路追踪编号不能为空")
|
||||
private String traceId;
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "666")
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型", required = true, example = "2", notes = "参见 UserTypeEnum 枚举")
|
||||
@NotNull(message = "用户类型不能为空")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "应用名", required = true, example = "dashboard")
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String applicationName;
|
||||
|
||||
@ApiModelProperty(value = "请求方法名", required = true, example = "GET")
|
||||
@NotNull(message = "请求方法名不能为空")
|
||||
private String requestMethod;
|
||||
|
||||
@ApiModelProperty(value = "请求地址", required = true, example = "/xxx/yyy")
|
||||
@NotNull(message = "请求地址不能为空")
|
||||
private String requestUrl;
|
||||
|
||||
@ApiModelProperty(value = "请求参数")
|
||||
private String requestParams;
|
||||
|
||||
@ApiModelProperty(value = "用户 IP", required = true, example = "127.0.0.1")
|
||||
@NotNull(message = "用户 IP不能为空")
|
||||
private String userIp;
|
||||
|
||||
@ApiModelProperty(value = "浏览器 UA", required = true, example = "Mozilla/5.0")
|
||||
@NotNull(message = "浏览器 UA不能为空")
|
||||
private String userAgent;
|
||||
|
||||
@ApiModelProperty(value = "开始请求时间", required = true)
|
||||
@NotNull(message = "开始请求时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date beginTime;
|
||||
|
||||
@ApiModelProperty(value = "结束请求时间", required = true)
|
||||
@NotNull(message = "结束请求时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "执行时长", required = true, example = "100")
|
||||
@NotNull(message = "执行时长不能为空")
|
||||
private Integer duration;
|
||||
|
||||
@ApiModelProperty(value = "结果码", required = true, example = "0")
|
||||
@NotNull(message = "结果码不能为空")
|
||||
private Integer resultCode;
|
||||
|
||||
@ApiModelProperty(value = "结果提示", example = "芋道源码,牛逼!")
|
||||
private String resultMsg;
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* API 访问日志 Excel VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class InfApiAccessLogExcelVO {
|
||||
|
||||
@ExcelProperty("日志主键")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("链路追踪编号")
|
||||
private String traceId;
|
||||
|
||||
@ExcelProperty("用户编号")
|
||||
private Long userId;
|
||||
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.USER_TYPE)
|
||||
private Integer userType;
|
||||
|
||||
@ExcelProperty("应用名")
|
||||
private String applicationName;
|
||||
|
||||
@ExcelProperty("请求方法名")
|
||||
private String requestMethod;
|
||||
|
||||
@ExcelProperty("请求地址")
|
||||
private String requestUrl;
|
||||
|
||||
@ExcelProperty("请求参数")
|
||||
private String requestParams;
|
||||
|
||||
@ExcelProperty("用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@ExcelProperty("浏览器 UA")
|
||||
private String userAgent;
|
||||
|
||||
@ExcelProperty("开始请求时间")
|
||||
private Date beginTime;
|
||||
|
||||
@ExcelProperty("结束请求时间")
|
||||
private Date endTime;
|
||||
|
||||
@ExcelProperty("执行时长")
|
||||
private Integer duration;
|
||||
|
||||
@ExcelProperty("结果码")
|
||||
private Integer resultCode;
|
||||
|
||||
@ExcelProperty("结果提示")
|
||||
private String resultMsg;
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel(value = "API 访问日志 Excel 导出 Request VO", description = "参数和 InfApiAccessLogPageReqVO 是一致的")
|
||||
@Data
|
||||
public class InfApiAccessLogExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", example = "666")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型", example = "2")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "应用名", example = "dashboard")
|
||||
private String applicationName;
|
||||
|
||||
@ApiModelProperty(value = "请求地址", example = "/xxx/yyy", notes = "模糊匹配")
|
||||
private String requestUrl;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始开始请求时间")
|
||||
private Date beginBeginTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束开始请求时间")
|
||||
private Date endBeginTime;
|
||||
|
||||
@ApiModelProperty(value = "执行时长", example = "100", notes = "大于等于,单位:毫秒")
|
||||
private Integer duration;
|
||||
|
||||
@ApiModelProperty(value = "结果码", example = "0")
|
||||
private Integer resultCode;
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("API 访问日志分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfApiAccessLogPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", example = "666")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型", example = "2")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "应用名", example = "dashboard")
|
||||
private String applicationName;
|
||||
|
||||
@ApiModelProperty(value = "请求地址", example = "/xxx/yyy", notes = "模糊匹配")
|
||||
private String requestUrl;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始开始请求时间")
|
||||
private Date beginBeginTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束开始请求时间")
|
||||
private Date endBeginTime;
|
||||
|
||||
@ApiModelProperty(value = "执行时长", example = "100", notes = "大于等于,单位:毫秒")
|
||||
private Integer duration;
|
||||
|
||||
@ApiModelProperty(value = "结果码", example = "0")
|
||||
private Integer resultCode;
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("API 访问日志 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfApiAccessLogRespVO extends InfApiAccessLogBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "日志主键", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* API 错误日志 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class InfApiErrorLogBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "链路追踪编号", required = true, example = "66600cb6-7852-11eb-9439-0242ac130002")
|
||||
@NotNull(message = "链路追踪编号不能为空")
|
||||
private String traceId;
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "666")
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型", required = true, example = "1")
|
||||
@NotNull(message = "用户类型不能为空")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "应用名", required = true, example = "dashboard")
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String applicationName;
|
||||
|
||||
@ApiModelProperty(value = "请求方法名", required = true, example = "GET")
|
||||
@NotNull(message = "请求方法名不能为空")
|
||||
private String requestMethod;
|
||||
|
||||
@ApiModelProperty(value = "请求地址", required = true, example = "/xx/yy")
|
||||
@NotNull(message = "请求地址不能为空")
|
||||
private String requestUrl;
|
||||
|
||||
@ApiModelProperty(value = "请求参数", required = true)
|
||||
@NotNull(message = "请求参数不能为空")
|
||||
private String requestParams;
|
||||
|
||||
@ApiModelProperty(value = "用户 IP", required = true, example = "127.0.0.1")
|
||||
@NotNull(message = "用户 IP不能为空")
|
||||
private String userIp;
|
||||
|
||||
@ApiModelProperty(value = "浏览器 UA", required = true, example = "Mozilla/5.0")
|
||||
@NotNull(message = "浏览器 UA不能为空")
|
||||
private String userAgent;
|
||||
|
||||
@ApiModelProperty(value = "异常发生时间", required = true)
|
||||
@NotNull(message = "异常发生时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date exceptionTime;
|
||||
|
||||
@ApiModelProperty(value = "异常名", required = true)
|
||||
@NotNull(message = "异常名不能为空")
|
||||
private String exceptionName;
|
||||
|
||||
@ApiModelProperty(value = "异常导致的消息", required = true)
|
||||
@NotNull(message = "异常导致的消息不能为空")
|
||||
private String exceptionMessage;
|
||||
|
||||
@ApiModelProperty(value = "异常导致的根消息", required = true)
|
||||
@NotNull(message = "异常导致的根消息不能为空")
|
||||
private String exceptionRootCauseMessage;
|
||||
|
||||
@ApiModelProperty(value = "异常的栈轨迹", required = true)
|
||||
@NotNull(message = "异常的栈轨迹不能为空")
|
||||
private String exceptionStackTrace;
|
||||
|
||||
@ApiModelProperty(value = "异常发生的类全名", required = true)
|
||||
@NotNull(message = "异常发生的类全名不能为空")
|
||||
private String exceptionClassName;
|
||||
|
||||
@ApiModelProperty(value = "异常发生的类文件", required = true)
|
||||
@NotNull(message = "异常发生的类文件不能为空")
|
||||
private String exceptionFileName;
|
||||
|
||||
@ApiModelProperty(value = "异常发生的方法名", required = true)
|
||||
@NotNull(message = "异常发生的方法名不能为空")
|
||||
private String exceptionMethodName;
|
||||
|
||||
@ApiModelProperty(value = "异常发生的方法所在行", required = true)
|
||||
@NotNull(message = "异常发生的方法所在行不能为空")
|
||||
private Integer exceptionLineNumber;
|
||||
|
||||
@ApiModelProperty(value = "处理状态", required = true, example = "0")
|
||||
@NotNull(message = "处理状态不能为空")
|
||||
private Integer processStatus;
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* API 错误日志 Excel VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class InfApiErrorLogExcelVO {
|
||||
|
||||
@ExcelProperty("编号")
|
||||
private Integer id;
|
||||
|
||||
@ExcelProperty("链路追踪编号")
|
||||
private String traceId;
|
||||
|
||||
@ExcelProperty("用户编号")
|
||||
private Integer userId;
|
||||
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.USER_TYPE)
|
||||
private Integer userType;
|
||||
|
||||
@ExcelProperty("应用名")
|
||||
private String applicationName;
|
||||
|
||||
@ExcelProperty("请求方法名")
|
||||
private String requestMethod;
|
||||
|
||||
@ExcelProperty("请求地址")
|
||||
private String requestUrl;
|
||||
|
||||
@ExcelProperty("请求参数")
|
||||
private String requestParams;
|
||||
|
||||
@ExcelProperty("用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@ExcelProperty("浏览器 UA")
|
||||
private String userAgent;
|
||||
|
||||
@ExcelProperty("异常发生时间")
|
||||
private Date exceptionTime;
|
||||
|
||||
@ExcelProperty("异常名")
|
||||
private String exceptionName;
|
||||
|
||||
@ExcelProperty("异常导致的消息")
|
||||
private String exceptionMessage;
|
||||
|
||||
@ExcelProperty("异常导致的根消息")
|
||||
private String exceptionRootCauseMessage;
|
||||
|
||||
@ExcelProperty("异常的栈轨迹")
|
||||
private String exceptionStackTrace;
|
||||
|
||||
@ExcelProperty("异常发生的类全名")
|
||||
private String exceptionClassName;
|
||||
|
||||
@ExcelProperty("异常发生的类文件")
|
||||
private String exceptionFileName;
|
||||
|
||||
@ExcelProperty("异常发生的方法名")
|
||||
private String exceptionMethodName;
|
||||
|
||||
@ExcelProperty("异常发生的方法所在行")
|
||||
private Integer exceptionLineNumber;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ExcelProperty(value = "处理状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.API_ERROR_LOG_PROCESS_STATUS)
|
||||
private Integer processStatus;
|
||||
|
||||
@ExcelProperty("处理时间")
|
||||
private Date processTime;
|
||||
|
||||
@ExcelProperty("处理用户编号")
|
||||
private Integer processUserId;
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel(value = "API 错误日志 Excel 导出 Request VO", description = "参数和 InfApiErrorLogPageReqVO 是一致的")
|
||||
@Data
|
||||
public class InfApiErrorLogExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", example = "666")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型", example = "1")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "应用名", example = "dashboard")
|
||||
private String applicationName;
|
||||
|
||||
@ApiModelProperty(value = "请求地址", example = "/xx/yy")
|
||||
private String requestUrl;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始异常发生时间")
|
||||
private Date beginExceptionTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束异常发生时间")
|
||||
private Date endExceptionTime;
|
||||
|
||||
@ApiModelProperty(value = "处理状态", example = "0")
|
||||
private Integer processStatus;
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("API 错误日志分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfApiErrorLogPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", example = "666")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "用户类型", example = "1")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "应用名", example = "dashboard")
|
||||
private String applicationName;
|
||||
|
||||
@ApiModelProperty(value = "请求地址", example = "/xx/yy")
|
||||
private String requestUrl;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始异常发生时间")
|
||||
private Date beginExceptionTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束异常发生时间")
|
||||
private Date endExceptionTime;
|
||||
|
||||
@ApiModelProperty(value = "处理状态", example = "0")
|
||||
private Integer processStatus;
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("API 错误日志 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfApiErrorLogRespVO extends InfApiErrorLogBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "处理时间", required = true)
|
||||
private Date processTime;
|
||||
|
||||
@ApiModelProperty(value = "处理用户编号", example = "233")
|
||||
private Integer processUserId;
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
### 请求 /infra/redis/get-monitor-info 接口 => 成功
|
||||
GET {{baseUrl}}/infra/redis/get-monitor-info
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 请求 /infra/redis/get-key-list 接口 => 成功
|
||||
GET {{baseUrl}}/infra/redis/get-key-list
|
||||
Authorization: Bearer {{token}}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.redis;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.redis.core.RedisKeyDefine;
|
||||
import cn.iocoder.yudao.framework.redis.core.RedisKeyRegistry;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.redis.vo.InfRedisKeyRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.redis.vo.InfRedisMonitorRespVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.redis.RedisConvert;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.redis.connection.RedisServerCommands;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Api(tags = "Redis 监控")
|
||||
@RestController
|
||||
@RequestMapping("/infra/redis")
|
||||
public class RedisController {
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@GetMapping("/get-monitor-info")
|
||||
@ApiOperation("获得 Redis 监控信息")
|
||||
@PreAuthorize("@ss.hasPermission('infra:redis:get-monitor-info')")
|
||||
public CommonResult<InfRedisMonitorRespVO> getRedisMonitorInfo() {
|
||||
// 获得 Redis 统计信息
|
||||
Properties info = stringRedisTemplate.execute((RedisCallback<Properties>) RedisServerCommands::info);
|
||||
Long dbSize = stringRedisTemplate.execute(RedisServerCommands::dbSize);
|
||||
Properties commandStats = stringRedisTemplate.execute((
|
||||
RedisCallback<Properties>) connection -> connection.info("commandstats"));
|
||||
assert commandStats != null; // 断言,避免警告
|
||||
// 拼接结果返回
|
||||
return success(RedisConvert.INSTANCE.build(info, dbSize, commandStats));
|
||||
}
|
||||
|
||||
@GetMapping("/get-key-list")
|
||||
@ApiOperation("获得 Redis Key 列表")
|
||||
@PreAuthorize("@ss.hasPermission('infra:redis:get-key-list')")
|
||||
public CommonResult<List<InfRedisKeyRespVO>> getKeyList() {
|
||||
List<RedisKeyDefine> keyDefines = RedisKeyRegistry.list();
|
||||
return success(RedisConvert.INSTANCE.convertList(keyDefines));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.redis.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.redis.core.RedisKeyDefine;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@ApiModel("Redis Key 信息 Response VO")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public class InfRedisKeyRespVO {
|
||||
|
||||
@ApiModelProperty(value = "login_user:%s", required = true, example = "String")
|
||||
private String keyTemplate;
|
||||
|
||||
@ApiModelProperty(value = "Key 类型的枚举", required = true, example = "String")
|
||||
private RedisKeyDefine.KeyTypeEnum keyType;
|
||||
|
||||
@ApiModelProperty(value = "Value 类型", required = true, example = "java.lang.String")
|
||||
private Class valueType;
|
||||
|
||||
@ApiModelProperty(value = "超时类型", required = true, example = "1")
|
||||
private RedisKeyDefine.TimeoutTypeEnum timeoutType;
|
||||
|
||||
@ApiModelProperty(value = "过期时间,单位:毫秒", required = true, example = "1024")
|
||||
private Duration timeout;
|
||||
|
||||
@ApiModelProperty(value = "备注", required = true, example = "啦啦啦啦~")
|
||||
private String memo;
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.redis.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
@ApiModel("Redis 监控信息 Response VO")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public class InfRedisMonitorRespVO {
|
||||
|
||||
@ApiModelProperty(value = "Redis info 指令结果", required = true, notes = "具体字段,查看 Redis 文档")
|
||||
private Properties info;
|
||||
|
||||
@ApiModelProperty(value = "Redis key 数量", required = true, example = "1024")
|
||||
private Long dbSize;
|
||||
|
||||
@ApiModelProperty(value = "CommandStat 数组", required = true)
|
||||
private List<CommandStat> commandStats;
|
||||
|
||||
@ApiModel("Redis 命令统计结果")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public static class CommandStat {
|
||||
|
||||
@ApiModelProperty(value = "Redis 命令", required = true, example = "get")
|
||||
private String command;
|
||||
|
||||
@ApiModelProperty(value = "调用次数", required = true, example = "1024")
|
||||
private Integer calls;
|
||||
|
||||
@ApiModelProperty(value = "消耗 CPU 秒数", required = true, example = "666")
|
||||
private Long usec;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 占位
|
||||
*/
|
||||
package cn.iocoder.yudao.module.infra.controller.app;
|
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 提供 RESTful API 给前端:
|
||||
* 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目
|
||||
* 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分
|
||||
*/
|
||||
package cn.iocoder.yudao.module.infra.controller;
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.config;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigUpdateReqVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface InfConfigConvert {
|
||||
|
||||
InfConfigConvert INSTANCE = Mappers.getMapper(InfConfigConvert.class);
|
||||
|
||||
PageResult<ConfigRespVO> convertPage(PageResult<InfConfigDO> page);
|
||||
|
||||
ConfigRespVO convert(InfConfigDO bean);
|
||||
|
||||
InfConfigDO convert(ConfigCreateReqVO bean);
|
||||
|
||||
InfConfigDO convert(ConfigUpdateReqVO bean);
|
||||
|
||||
List<ConfigExcelVO> convertList(List<InfConfigDO> list);
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.file;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.controller.file.vo.InfFileRespVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface InfFileConvert {
|
||||
|
||||
InfFileConvert INSTANCE = Mappers.getMapper(InfFileConvert.class);
|
||||
|
||||
InfFileRespVO convert(InfFileDO bean);
|
||||
|
||||
PageResult<InfFileRespVO> convertPage(PageResult<InfFileDO> page);
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.InfJobDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定时任务 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface InfJobConvert {
|
||||
|
||||
InfJobConvert INSTANCE = Mappers.getMapper(InfJobConvert.class);
|
||||
|
||||
InfJobDO convert(InfJobCreateReqVO bean);
|
||||
|
||||
InfJobDO convert(InfJobUpdateReqVO bean);
|
||||
|
||||
InfJobRespVO convert(InfJobDO bean);
|
||||
|
||||
List<InfJobRespVO> convertList(List<InfJobDO> list);
|
||||
|
||||
PageResult<InfJobRespVO> convertPage(PageResult<InfJobDO> page);
|
||||
|
||||
List<InfJobExcelVO> convertList02(List<InfJobDO> list);
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.InfJobLogExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.InfJobLogRespVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.InfJobLogDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定时任务日志 Convert
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface InfJobLogConvert {
|
||||
|
||||
InfJobLogConvert INSTANCE = Mappers.getMapper(InfJobLogConvert.class);
|
||||
|
||||
InfJobLogRespVO convert(InfJobLogDO bean);
|
||||
|
||||
List<InfJobLogRespVO> convertList(List<InfJobLogDO> list);
|
||||
|
||||
PageResult<InfJobLogRespVO> convertPage(PageResult<InfJobLogDO> page);
|
||||
|
||||
List<InfJobLogExcelVO> convertList02(List<InfJobLogDO> list);
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.logger;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.InfApiAccessLogExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.InfApiAccessLogRespVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 访问日志 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface InfApiAccessLogConvert {
|
||||
|
||||
InfApiAccessLogConvert INSTANCE = Mappers.getMapper(InfApiAccessLogConvert.class);
|
||||
|
||||
InfApiAccessLogRespVO convert(InfApiAccessLogDO bean);
|
||||
|
||||
List<InfApiAccessLogRespVO> convertList(List<InfApiAccessLogDO> list);
|
||||
|
||||
PageResult<InfApiAccessLogRespVO> convertPage(PageResult<InfApiAccessLogDO> page);
|
||||
|
||||
List<InfApiAccessLogExcelVO> convertList02(List<InfApiAccessLogDO> list);
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface InfApiAccessLogCoreConvert {
|
||||
|
||||
InfApiAccessLogCoreConvert INSTANCE = Mappers.getMapper(InfApiAccessLogCoreConvert.class);
|
||||
|
||||
InfApiAccessLogDO convert(ApiAccessLogCreateReqDTO bean);
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.logger;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.InfApiErrorLogExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.InfApiErrorLogRespVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 错误日志 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface InfApiErrorLogConvert {
|
||||
|
||||
InfApiErrorLogConvert INSTANCE = Mappers.getMapper(InfApiErrorLogConvert.class);
|
||||
|
||||
InfApiErrorLogRespVO convert(InfApiErrorLogDO bean);
|
||||
|
||||
PageResult<InfApiErrorLogRespVO> convertPage(PageResult<InfApiErrorLogDO> page);
|
||||
|
||||
List<InfApiErrorLogExcelVO> convertList02(List<InfApiErrorLogDO> list);
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface InfApiErrorLogCoreConvert {
|
||||
|
||||
InfApiErrorLogCoreConvert INSTANCE = Mappers.getMapper(InfApiErrorLogCoreConvert.class);
|
||||
|
||||
InfApiErrorLogDO convert(ApiErrorLogCreateReqDTO bean);
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 提供 POJO 类的实体转换
|
||||
*
|
||||
* 目前使用 MapStruct 框架
|
||||
*/
|
||||
package cn.iocoder.yudao.module.infra.convert;
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.redis;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.redis.core.RedisKeyDefine;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.redis.vo.InfRedisKeyRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.redis.vo.InfRedisMonitorRespVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
@Mapper
|
||||
public interface RedisConvert {
|
||||
|
||||
RedisConvert INSTANCE = Mappers.getMapper(RedisConvert.class);
|
||||
|
||||
default InfRedisMonitorRespVO build(Properties info, Long dbSize, Properties commandStats) {
|
||||
InfRedisMonitorRespVO respVO = InfRedisMonitorRespVO.builder().info(info).dbSize(dbSize)
|
||||
.commandStats(new ArrayList<>(commandStats.size())).build();
|
||||
commandStats.forEach((key, value) -> {
|
||||
respVO.getCommandStats().add(InfRedisMonitorRespVO.CommandStat.builder()
|
||||
.command(StrUtil.subAfter((String) key, "cmdstat_", false))
|
||||
.calls(Integer.valueOf(StrUtil.subBetween((String) value, "calls=", ",")))
|
||||
.usec(Long.valueOf(StrUtil.subBetween((String) value, "usec=", ",")))
|
||||
.build());
|
||||
});
|
||||
return respVO;
|
||||
}
|
||||
|
||||
List<InfRedisKeyRespVO> convertList(List<RedisKeyDefine> list);
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
<http://www.iocoder.cn/Spring-Boot/MapStruct/?yudao>
|
@ -0,0 +1,64 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.dataobject.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 参数配置表
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("inf_config")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfConfigDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 参数主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 参数分组
|
||||
*/
|
||||
@TableField("`group`")
|
||||
private String group;
|
||||
/**
|
||||
* 参数名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 参数键名
|
||||
*/
|
||||
@TableField("`key`")
|
||||
private String key;
|
||||
/**
|
||||
* 参数键值
|
||||
*/
|
||||
private String value;
|
||||
/**
|
||||
* 参数类型
|
||||
*
|
||||
* 枚举 {@link InfConfigTypeEnum}
|
||||
*/
|
||||
@TableField("`type`")
|
||||
private Integer type;
|
||||
/**
|
||||
* 是否敏感
|
||||
*
|
||||
* 对于敏感配置,需要管理权限才能查看
|
||||
*/
|
||||
@TableField("`sensitive`")
|
||||
private Boolean sensitive;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.dataobject.file;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 文件表
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
@TableName("inf_file")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InfFileDO extends TenantBaseDO {
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String id;
|
||||
/**
|
||||
* 文件类型
|
||||
*
|
||||
* 通过 {@link cn.hutool.core.io.FileTypeUtil#getType(InputStream)} 获取
|
||||
*/
|
||||
@TableField(value = "`type`")
|
||||
private String type;
|
||||
/**
|
||||
* 文件内容
|
||||
*/
|
||||
private byte[] content;
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.dataobject.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.infra.enums.job.InfJobStatusEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 定时任务 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("inf_job")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InfJobDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 任务编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 任务状态
|
||||
*
|
||||
* 枚举 {@link InfJobStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 处理器的名字
|
||||
*/
|
||||
private String handlerName;
|
||||
/**
|
||||
* 处理器的参数
|
||||
*/
|
||||
private String handlerParam;
|
||||
/**
|
||||
* CRON 表达式
|
||||
*/
|
||||
private String cronExpression;
|
||||
|
||||
// ========== 重试相关字段 ==========
|
||||
/**
|
||||
* 重试次数
|
||||
* 如果不重试,则设置为 0
|
||||
*/
|
||||
private Integer retryCount;
|
||||
/**
|
||||
* 重试间隔,单位:毫秒
|
||||
* 如果没有间隔,则设置为 0
|
||||
*/
|
||||
private Integer retryInterval;
|
||||
|
||||
// ========== 监控相关字段 ==========
|
||||
/**
|
||||
* 监控超时时间,单位:毫秒
|
||||
* 为空时,表示不监控
|
||||
*
|
||||
* 注意,这里的超时的目的,不是进行任务的取消,而是告警任务的执行时间过长
|
||||
*/
|
||||
private Integer monitorTimeout;
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.dataobject.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||
import cn.iocoder.yudao.module.infra.enums.job.InfJobLogStatusEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 定时任务的执行日志
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("inf_job_log")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InfJobLogDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 日志编号
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 任务编号
|
||||
*
|
||||
* 关联 {@link InfJobDO#getId()}
|
||||
*/
|
||||
private Long jobId;
|
||||
/**
|
||||
* 处理器的名字
|
||||
*
|
||||
* 冗余字段 {@link InfJobDO#getHandlerName()}
|
||||
*/
|
||||
private String handlerName;
|
||||
/**
|
||||
* 处理器的参数
|
||||
*
|
||||
* 冗余字段 {@link InfJobDO#getHandlerParam()}
|
||||
*/
|
||||
private String handlerParam;
|
||||
/**
|
||||
* 第几次执行
|
||||
*
|
||||
* 用于区分是不是重试执行。如果是重试执行,则 index 大于 1
|
||||
*/
|
||||
private Integer executeIndex;
|
||||
|
||||
/**
|
||||
* 开始执行时间
|
||||
*/
|
||||
private Date beginTime;
|
||||
/**
|
||||
* 结束执行时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 执行时长,单位:毫秒
|
||||
*/
|
||||
private Integer duration;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
* 枚举 {@link InfJobLogStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 结果数据
|
||||
*
|
||||
* 成功时,使用 {@link JobHandler#execute(String)} 的结果
|
||||
* 失败时,使用 {@link JobHandler#execute(String)} 的异常堆栈
|
||||
*/
|
||||
private String result;
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.dataobject.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* API 访问日志
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("inf_api_access_log")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InfApiAccessLogDO extends TenantBaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 链路追踪编号
|
||||
*
|
||||
* 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。
|
||||
*/
|
||||
private String traceId;
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 用户类型
|
||||
*
|
||||
* 枚举 {@link UserTypeEnum}
|
||||
*/
|
||||
private Integer userType;
|
||||
/**
|
||||
* 应用名
|
||||
*
|
||||
* 目前读取 `spring.application.name` 配置项
|
||||
*/
|
||||
private String applicationName;
|
||||
|
||||
// ========== 请求相关字段 ==========
|
||||
|
||||
/**
|
||||
* 请求方法名
|
||||
*/
|
||||
private String requestMethod;
|
||||
/**
|
||||
* 访问地址
|
||||
*/
|
||||
private String requestUrl;
|
||||
/**
|
||||
* 请求参数
|
||||
*
|
||||
* query: Query String
|
||||
* body: Quest Body
|
||||
*/
|
||||
private String requestParams;
|
||||
/**
|
||||
* 用户 IP
|
||||
*/
|
||||
private String userIp;
|
||||
/**
|
||||
* 浏览器 UA
|
||||
*/
|
||||
private String userAgent;
|
||||
|
||||
// ========== 执行相关字段 ==========
|
||||
|
||||
/**
|
||||
* 开始请求时间
|
||||
*/
|
||||
private Date beginTime;
|
||||
/**
|
||||
* 结束请求时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 执行时长,单位:毫秒
|
||||
*/
|
||||
private Integer duration;
|
||||
/**
|
||||
* 结果码
|
||||
*
|
||||
* 目前使用的 {@link CommonResult#getCode()} 属性
|
||||
*/
|
||||
private Integer resultCode;
|
||||
/**
|
||||
* 结果提示
|
||||
*
|
||||
* 目前使用的 {@link CommonResult#getMsg()} 属性
|
||||
*/
|
||||
private String resultMsg;
|
||||
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.dataobject.logger;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* API 异常数据
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("inf_api_error_log")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class InfApiErrorLogDO extends TenantBaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 链路追踪编号
|
||||
*
|
||||
* 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。
|
||||
*/
|
||||
private String traceId;
|
||||
/**
|
||||
* 用户类型
|
||||
*
|
||||
* 枚举 {@link UserTypeEnum}
|
||||
*/
|
||||
private Integer userType;
|
||||
/**
|
||||
* 应用名
|
||||
*
|
||||
* 目前读取 spring.application.name
|
||||
*/
|
||||
private String applicationName;
|
||||
|
||||
// ========== 请求相关字段 ==========
|
||||
|
||||
/**
|
||||
* 请求方法名
|
||||
*/
|
||||
private String requestMethod;
|
||||
/**
|
||||
* 访问地址
|
||||
*/
|
||||
private String requestUrl;
|
||||
/**
|
||||
* 请求参数
|
||||
*
|
||||
* query: Query String
|
||||
* body: Quest Body
|
||||
*/
|
||||
private String requestParams;
|
||||
/**
|
||||
* 用户 IP
|
||||
*/
|
||||
private String userIp;
|
||||
/**
|
||||
* 浏览器 UA
|
||||
*/
|
||||
private String userAgent;
|
||||
|
||||
// ========== 异常相关字段 ==========
|
||||
|
||||
/**
|
||||
* 异常发生时间
|
||||
*/
|
||||
private Date exceptionTime;
|
||||
/**
|
||||
* 异常名
|
||||
*
|
||||
* {@link Throwable#getClass()} 的类全名
|
||||
*/
|
||||
private String exceptionName;
|
||||
/**
|
||||
* 异常导致的消息
|
||||
*
|
||||
* {@link cn.hutool.core.exceptions.ExceptionUtil#getMessage(Throwable)}
|
||||
*/
|
||||
private String exceptionMessage;
|
||||
/**
|
||||
* 异常导致的根消息
|
||||
*
|
||||
* {@link cn.hutool.core.exceptions.ExceptionUtil#getRootCauseMessage(Throwable)}
|
||||
*/
|
||||
private String exceptionRootCauseMessage;
|
||||
/**
|
||||
* 异常的栈轨迹
|
||||
*
|
||||
* {@link org.apache.commons.lang3.exception.ExceptionUtils#getStackTrace(Throwable)}
|
||||
*/
|
||||
private String exceptionStackTrace;
|
||||
/**
|
||||
* 异常发生的类全名
|
||||
*
|
||||
* {@link StackTraceElement#getClassName()}
|
||||
*/
|
||||
private String exceptionClassName;
|
||||
/**
|
||||
* 异常发生的类文件
|
||||
*
|
||||
* {@link StackTraceElement#getFileName()}
|
||||
*/
|
||||
private String exceptionFileName;
|
||||
/**
|
||||
* 异常发生的方法名
|
||||
*
|
||||
* {@link StackTraceElement#getMethodName()}
|
||||
*/
|
||||
private String exceptionMethodName;
|
||||
/**
|
||||
* 异常发生的方法所在行
|
||||
*
|
||||
* {@link StackTraceElement#getLineNumber()}
|
||||
*/
|
||||
private Integer exceptionLineNumber;
|
||||
|
||||
// ========== 处理相关字段 ==========
|
||||
|
||||
/**
|
||||
* 处理状态
|
||||
*
|
||||
* 枚举 {@link InfApiErrorLogProcessStatusEnum}
|
||||
*/
|
||||
private Integer processStatus;
|
||||
/**
|
||||
* 处理时间
|
||||
*/
|
||||
private Date processTime;
|
||||
/**
|
||||
* 处理用户编号
|
||||
*
|
||||
* 关联 cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO.SysUserDO#getId()
|
||||
*/
|
||||
private Long processUserId;
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.apollo.internals.ConfigFrameworkDAO;
|
||||
import cn.iocoder.yudao.framework.apollo.internals.dto.ConfigRespDTO;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ConfigFrameworkDAO Core 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public class InfConfigCoreDAOImpl implements ConfigFrameworkDAO {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
public InfConfigCoreDAOImpl(String jdbcUrl, String username, String password) {
|
||||
DataSource dataSource = new DriverManagerDataSource(jdbcUrl, username, password);
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) {
|
||||
return jdbcTemplate.query("SELECT id FROM inf_config WHERE update_time > ? LIMIT 1",
|
||||
ResultSet::next, maxUpdateTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigRespDTO> selectList() {
|
||||
return jdbcTemplate.query("SELECT `key`, `value`, update_time, deleted FROM inf_config", new BeanPropertyRowMapper<>(ConfigRespDTO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.config;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigPageReqVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface InfConfigMapper extends BaseMapperX<InfConfigDO> {
|
||||
|
||||
default InfConfigDO selectByKey(String key) {
|
||||
return selectOne(new QueryWrapper<InfConfigDO>().eq("`key`", key));
|
||||
}
|
||||
|
||||
default PageResult<InfConfigDO> selectPage(ConfigPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<InfConfigDO>()
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.likeIfPresent("`key`", reqVO.getKey())
|
||||
.eqIfPresent("`type`", reqVO.getType())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime()));
|
||||
}
|
||||
|
||||
default List<InfConfigDO> selectList(ConfigExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<InfConfigDO>()
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.likeIfPresent("`key`", reqVO.getKey())
|
||||
.eqIfPresent("`type`", reqVO.getType())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime()));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.file;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface InfFileCoreMapper extends BaseMapperX<InfFileDO> {
|
||||
|
||||
default Integer selectCountById(String id) {
|
||||
return selectCount(InfFileDO::getId, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于 Path 获取文件
|
||||
* 实际上,是基于 ID 查询
|
||||
* 由于前端使用 <img /> 的方式获取图片,所以需要忽略租户的查询
|
||||
*
|
||||
* @param path 路径
|
||||
* @return 文件
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
default InfFileDO selectByPath(String path) {
|
||||
return selectById(path);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.file;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.InfFilePageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* admin 文件操作 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface InfFileMapper extends BaseMapperX<InfFileDO> {
|
||||
default PageResult<InfFileDO> selectPage(InfFilePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<InfFileDO>()
|
||||
.likeIfPresent("id", reqVO.getId())
|
||||
.likeIfPresent("type", reqVO.getType())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("create_time"));
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.InfJobLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.InfJobLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.InfJobLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 任务日志 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface InfJobLogMapper extends BaseMapperX<InfJobLogDO> {
|
||||
|
||||
default PageResult<InfJobLogDO> selectPage(InfJobLogPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<InfJobLogDO>()
|
||||
.eqIfPresent("job_id", reqVO.getJobId())
|
||||
.likeIfPresent("handler_name", reqVO.getHandlerName())
|
||||
.geIfPresent("begin_time", reqVO.getBeginTime())
|
||||
.leIfPresent("end_time", reqVO.getEndTime())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.orderByDesc("id") // ID 倒序
|
||||
);
|
||||
}
|
||||
|
||||
default List<InfJobLogDO> selectList(InfJobLogExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<InfJobLogDO>()
|
||||
.eqIfPresent("job_id", reqVO.getJobId())
|
||||
.likeIfPresent("handler_name", reqVO.getHandlerName())
|
||||
.geIfPresent("begin_time", reqVO.getBeginTime())
|
||||
.leIfPresent("end_time", reqVO.getEndTime())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.orderByDesc("id") // ID 倒序
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.job;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.InfJobDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定时任务 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface InfJobMapper extends BaseMapperX<InfJobDO> {
|
||||
|
||||
default InfJobDO selectByHandlerName(String handlerName) {
|
||||
return selectOne(InfJobDO::getHandlerName, handlerName);
|
||||
}
|
||||
|
||||
default PageResult<InfJobDO> selectPage(InfJobPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<InfJobDO>()
|
||||
.likeIfPresent(InfJobDO::getName, reqVO.getName())
|
||||
.eqIfPresent(InfJobDO::getStatus, reqVO.getStatus())
|
||||
.likeIfPresent(InfJobDO::getHandlerName, reqVO.getHandlerName())
|
||||
);
|
||||
}
|
||||
|
||||
default List<InfJobDO> selectList(InfJobExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<InfJobDO>()
|
||||
.likeIfPresent(InfJobDO::getName, reqVO.getName())
|
||||
.eqIfPresent(InfJobDO::getStatus, reqVO.getStatus())
|
||||
.likeIfPresent(InfJobDO::getHandlerName, reqVO.getHandlerName())
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* API 访问日志 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface InfApiAccessLogCoreMapper extends BaseMapperX<InfApiAccessLogDO> {
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.logger;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 访问日志 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface InfApiAccessLogMapper extends BaseMapperX<InfApiAccessLogDO> {
|
||||
|
||||
default PageResult<InfApiAccessLogDO> selectPage(InfApiAccessLogPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<InfApiAccessLogDO>()
|
||||
.eqIfPresent("user_id", reqVO.getUserId())
|
||||
.eqIfPresent("user_type", reqVO.getUserType())
|
||||
.eqIfPresent("application_name", reqVO.getApplicationName())
|
||||
.likeIfPresent("request_url", reqVO.getRequestUrl())
|
||||
.betweenIfPresent("begin_time", reqVO.getBeginBeginTime(), reqVO.getEndBeginTime())
|
||||
.geIfPresent("duration", reqVO.getDuration())
|
||||
.eqIfPresent("result_code", reqVO.getResultCode())
|
||||
.orderByDesc("id")
|
||||
);
|
||||
}
|
||||
|
||||
default List<InfApiAccessLogDO> selectList(InfApiAccessLogExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<InfApiAccessLogDO>()
|
||||
.eqIfPresent("user_id", reqVO.getUserId())
|
||||
.eqIfPresent("user_type", reqVO.getUserType())
|
||||
.eqIfPresent("application_name", reqVO.getApplicationName())
|
||||
.likeIfPresent("request_url", reqVO.getRequestUrl())
|
||||
.betweenIfPresent("begin_time", reqVO.getBeginBeginTime(), reqVO.getEndBeginTime())
|
||||
.geIfPresent("duration", reqVO.getDuration())
|
||||
.eqIfPresent("result_code", reqVO.getResultCode())
|
||||
.orderByDesc("id")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface InfApiErrorLogCoreMapper extends BaseMapperX<InfApiErrorLogDO> {
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.logger;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.InfApiErrorLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.InfApiErrorLogPageReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 错误日志 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface InfApiErrorLogMapper extends BaseMapperX<InfApiErrorLogDO> {
|
||||
|
||||
default PageResult<InfApiErrorLogDO> selectPage(InfApiErrorLogPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<InfApiErrorLogDO>()
|
||||
.eqIfPresent("user_id", reqVO.getUserId())
|
||||
.eqIfPresent("user_type", reqVO.getUserType())
|
||||
.eqIfPresent("application_name", reqVO.getApplicationName())
|
||||
.likeIfPresent("request_url", reqVO.getRequestUrl())
|
||||
.betweenIfPresent("exception_time", reqVO.getBeginExceptionTime(), reqVO.getEndExceptionTime())
|
||||
.eqIfPresent("process_status", reqVO.getProcessStatus())
|
||||
.orderByDesc("id")
|
||||
);
|
||||
}
|
||||
|
||||
default List<InfApiErrorLogDO> selectList(InfApiErrorLogExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<InfApiErrorLogDO>()
|
||||
.eqIfPresent("user_id", reqVO.getUserId())
|
||||
.eqIfPresent("user_type", reqVO.getUserType())
|
||||
.eqIfPresent("application_name", reqVO.getApplicationName())
|
||||
.likeIfPresent("request_url", reqVO.getRequestUrl())
|
||||
.betweenIfPresent("exception_time", reqVO.getBeginExceptionTime(), reqVO.getEndExceptionTime())
|
||||
.eqIfPresent("process_status", reqVO.getProcessStatus())
|
||||
.orderByDesc("id")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.infra.enums;
|
||||
|
||||
/**
|
||||
* Infra 字典类型的枚举类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface DictTypeConstants {
|
||||
|
||||
String REDIS_TIMEOUT_TYPE = "inf_redis_timeout_type"; // Redis 超时类型
|
||||
|
||||
String JOB_STATUS = "inf_job_status"; // 定时任务状态的枚举
|
||||
String JOB_LOG_STATUS = "inf_job_log_status"; // 定时任务日志状态的枚举
|
||||
|
||||
String API_ERROR_LOG_PROCESS_STATUS = "inf_api_error_log_process_status"; // API 错误日志的处理状态的枚举
|
||||
|
||||
String ERROR_CODE_TYPE = "inf_error_code_type"; // 错误码的类型枚举
|
||||
|
||||
String CONFIG_TYPE = "sys_config_type"; // 参数配置类型
|
||||
String BOOLEAN_STRING = "sys_boolean_string"; // Boolean 是否类型
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.infra.enums;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
|
||||
/**
|
||||
* Infra 错误码枚举类
|
||||
*
|
||||
* infra 系统,使用 1-001-000-000 段
|
||||
*/
|
||||
public interface InfErrorCodeConstants {
|
||||
|
||||
// ========== 参数配置 1001000000 ==========
|
||||
ErrorCode CONFIG_NOT_EXISTS = new ErrorCode(1001000001, "参数配置不存在");
|
||||
ErrorCode CONFIG_KEY_DUPLICATE = new ErrorCode(1001000002, "参数配置 key 重复");
|
||||
ErrorCode CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE = new ErrorCode(1001000003, "不能删除类型为系统内置的参数配置");
|
||||
ErrorCode CONFIG_GET_VALUE_ERROR_IF_SENSITIVE = new ErrorCode(1001000004, "不允许获取敏感配置到前端");
|
||||
|
||||
// ========== 定时任务 1001001000 ==========
|
||||
ErrorCode JOB_NOT_EXISTS = new ErrorCode(1001001000, "定时任务不存在");
|
||||
ErrorCode JOB_HANDLER_EXISTS = new ErrorCode(1001001001, "定时任务的处理器已经存在");
|
||||
ErrorCode JOB_CHANGE_STATUS_INVALID = new ErrorCode(1001001002, "只允许修改为开启或者关闭状态");
|
||||
ErrorCode JOB_CHANGE_STATUS_EQUALS = new ErrorCode(1001001003, "定时任务已经处于该状态,无需修改");
|
||||
ErrorCode JOB_UPDATE_ONLY_NORMAL_STATUS = new ErrorCode(1001001004, "只有开启状态的任务,才可以修改");
|
||||
ErrorCode JOB_CRON_EXPRESSION_VALID = new ErrorCode(1001001005, "CRON 表达式不正确");
|
||||
|
||||
// ========== API 错误日志 1001002000 ==========
|
||||
ErrorCode API_ERROR_LOG_NOT_FOUND = new ErrorCode(1001002000, "API 错误日志不存在");
|
||||
ErrorCode API_ERROR_LOG_PROCESSED = new ErrorCode(1001002001, "API 错误日志已处理");
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.module.infra.enums;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||
|
||||
/**
|
||||
* System 错误码枚举类
|
||||
*
|
||||
* system 系统,使用 1-006-000-000 段
|
||||
*/
|
||||
public interface SysErrorCodeConstants {
|
||||
|
||||
// ========= 文件相关 1006001000=================
|
||||
ErrorCode FILE_PATH_EXISTS = new ErrorCode(1006001000, "文件路径已存在");
|
||||
ErrorCode FILE_NOT_EXISTS = new ErrorCode(1006001002, "文件不存在");
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.infra.enums.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum InfConfigTypeEnum {
|
||||
|
||||
/**
|
||||
* 系统配置
|
||||
*/
|
||||
SYSTEM(1),
|
||||
/**
|
||||
* 自定义配置
|
||||
*/
|
||||
CUSTOM(2);
|
||||
|
||||
private final Integer type;
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.infra.enums.job;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 任务日志的状态枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum InfJobLogStatusEnum {
|
||||
|
||||
RUNNING(0), // 运行中
|
||||
SUCCESS(1), // 成功
|
||||
FAILURE(2); // 失败
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.infra.enums.job;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.quartz.impl.jdbcjobstore.Constants.*;
|
||||
|
||||
/**
|
||||
* 任务状态的枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum InfJobStatusEnum {
|
||||
|
||||
/**
|
||||
* 初始化中
|
||||
*/
|
||||
INIT(0, Collections.emptySet()),
|
||||
/**
|
||||
* 开启
|
||||
*/
|
||||
NORMAL(1, Sets.newHashSet(Constants.STATE_WAITING, Constants.STATE_ACQUIRED, Constants.STATE_BLOCKED)),
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
STOP(2, Sets.newHashSet(Constants.STATE_PAUSED, Constants.STATE_PAUSED_BLOCKED));
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final Integer status;
|
||||
/**
|
||||
* 对应的 Quartz 触发器的状态集合
|
||||
*/
|
||||
private final Set<String> quartzStates;
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.infra.enums.logger;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* API 异常数据的处理状态
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum InfApiErrorLogProcessStatusEnum {
|
||||
|
||||
INIT(0, "未处理"),
|
||||
DONE(1, "已处理"),
|
||||
IGNORE(2, "已忽略");
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final Integer status;
|
||||
/**
|
||||
* 资源类型名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package cn.iocoder.yudao.module.infra.file.config;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 文件 配置类
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(FileProperties.class)
|
||||
public class FileConfiguration {
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.infra.file.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ConfigurationProperties(prefix = "yudao.file")
|
||||
@Validated
|
||||
@Data
|
||||
public class FileProperties {
|
||||
|
||||
/**
|
||||
* 对应 InfFileController 的 getFile 方法
|
||||
*/
|
||||
@NotNull(message = "基础文件路径不能为空")
|
||||
private String basePath;
|
||||
|
||||
// TODO 七牛、等等
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 文件的存储,推荐使用七牛、阿里云、华为云、腾讯云等文件服务
|
||||
*
|
||||
* 在不采用云服务的情况下,我们有几种技术选型:
|
||||
* 方案 1. 使用自建的文件服务,例如说 minIO、FastDFS 等等
|
||||
* 方案 2. 使用服务器的文件系统存储
|
||||
* 方案 3. 使用数据库进行存储
|
||||
*
|
||||
* 如果考虑额外在搭建服务,推荐方案 1。
|
||||
* 对于方案 2 来说,如果要实现文件存储的高可用,需要多台服务器之间做实时同步,可以基于 rsync + inotify 来做
|
||||
* 对于方案 3 的话,实现起来最简单,但是数据库本身不适合存储海量的文件
|
||||
*
|
||||
* 综合考虑,暂时使用方案 3 的方式,比较适合这样一个 all in one 的项目。
|
||||
* 随着文件的量级大了之后,还是推荐采用云服务。
|
||||
*/
|
||||
package cn.iocoder.yudao.coreservice.modules.infra.framework.file;
|
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 属于 infra 模块的 framework 封装
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
package cn.iocoder.yudao.module.infra.framework;
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.infra.mq.consumer.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.apollo.internals.DBConfigRepository;
|
||||
import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessageListener;
|
||||
import cn.iocoder.yudao.module.infra.mq.message.config.InfConfigRefreshMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 针对 {@link InfConfigRefreshMessage} 的消费者
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class InfConfigRefreshConsumer extends AbstractChannelMessageListener<InfConfigRefreshMessage> {
|
||||
|
||||
@Override
|
||||
public void onMessage(InfConfigRefreshMessage message) {
|
||||
log.info("[onMessage][收到 Config 刷新消息]");
|
||||
DBConfigRepository.noticeSync();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
package cn.iocoder.yudao.module.infra.mq.consumer;
|
@ -0,0 +1,17 @@
|
||||
package cn.iocoder.yudao.module.infra.mq.message.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessage;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 配置数据刷新 Message
|
||||
*/
|
||||
@Data
|
||||
public class InfConfigRefreshMessage extends AbstractChannelMessage {
|
||||
|
||||
@Override
|
||||
public String getChannel() {
|
||||
return "infra.config.refresh";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
package cn.iocoder.yudao.module.infra.mq.message;
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.infra.mq.producer.config;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.mq.message.config.InfConfigRefreshMessage;
|
||||
import cn.iocoder.yudao.framework.mq.core.RedisMQTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* Config 配置相关消息的 Producer
|
||||
*/
|
||||
@Component
|
||||
public class InfConfigProducer {
|
||||
|
||||
@Resource
|
||||
private RedisMQTemplate redisMQTemplate;
|
||||
|
||||
/**
|
||||
* 发送 {@link InfConfigRefreshMessage} 消息
|
||||
*/
|
||||
public void sendConfigRefreshMessage() {
|
||||
InfConfigRefreshMessage message = new InfConfigRefreshMessage();
|
||||
redisMQTemplate.send(message);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
package cn.iocoder.yudao.module.infra.mq.producer;
|
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* infra 包下,我们放基础设施的运维与管理,支撑上层的通用与核心业务。
|
||||
* 例如说:定时任务的管理、服务器的信息等等
|
||||
*
|
||||
* 1. Controller URL:以 /infra/ 开头,避免和其它 Module 冲突
|
||||
* 2. DataObject 表名:以 infra_ 开头,方便在数据库中区分
|
||||
*/
|
||||
package cn.iocoder.yudao.module.infra;
|
@ -0,0 +1,75 @@
|
||||
package cn.iocoder.yudao.module.infra.service.config;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigUpdateReqVO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 参数配置 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface InfConfigService {
|
||||
|
||||
/**
|
||||
* 创建参数配置
|
||||
*
|
||||
* @param reqVO 创建信息
|
||||
* @return 配置编号
|
||||
*/
|
||||
Long createConfig(@Valid ConfigCreateReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 更新参数配置
|
||||
*
|
||||
* @param reqVO 更新信息
|
||||
*/
|
||||
void updateConfig(@Valid ConfigUpdateReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 删除参数配置
|
||||
*
|
||||
* @param id 配置编号
|
||||
*/
|
||||
void deleteConfig(Long id);
|
||||
|
||||
/**
|
||||
* 获得参数配置
|
||||
*
|
||||
* @param id 配置编号
|
||||
* @return 参数配置
|
||||
*/
|
||||
InfConfigDO getConfig(Long id);
|
||||
|
||||
/**
|
||||
* 根据参数键,获得参数配置
|
||||
*
|
||||
* @param key 配置键
|
||||
* @return 参数配置
|
||||
*/
|
||||
InfConfigDO getConfigByKey(String key);
|
||||
|
||||
/**
|
||||
* 获得参数配置分页列表
|
||||
*
|
||||
* @param reqVO 分页条件
|
||||
* @return 分页列表
|
||||
*/
|
||||
PageResult<InfConfigDO> getConfigPage(@Valid ConfigPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获得参数配置列表
|
||||
*
|
||||
* @param reqVO 列表
|
||||
* @return 列表
|
||||
*/
|
||||
List<InfConfigDO> getConfigList(@Valid ConfigExportReqVO reqVO);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package cn.iocoder.yudao.module.infra.service.config.impl;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO;
|
||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.config.InfConfigConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.config.InfConfigMapper;
|
||||
import cn.iocoder.yudao.module.infra.enums.config.InfConfigTypeEnum;
|
||||
import cn.iocoder.yudao.module.infra.mq.producer.config.InfConfigProducer;
|
||||
import cn.iocoder.yudao.module.infra.service.config.InfConfigService;
|
||||
import cn.iocoder.yudao.module.infra.enums.InfErrorCodeConstants;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 参数配置 Service 实现类
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Validated
|
||||
public class InfConfigServiceImpl implements InfConfigService {
|
||||
|
||||
@Resource
|
||||
private InfConfigMapper configMapper;
|
||||
|
||||
@Resource
|
||||
private InfConfigProducer configProducer;
|
||||
|
||||
@Override
|
||||
public Long createConfig(ConfigCreateReqVO reqVO) {
|
||||
// 校验正确性
|
||||
checkCreateOrUpdate(null, reqVO.getKey());
|
||||
// 插入参数配置
|
||||
InfConfigDO config = InfConfigConvert.INSTANCE.convert(reqVO);
|
||||
config.setType(InfConfigTypeEnum.CUSTOM.getType());
|
||||
configMapper.insert(config);
|
||||
// 发送刷新消息
|
||||
configProducer.sendConfigRefreshMessage();
|
||||
return config.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateConfig(ConfigUpdateReqVO reqVO) {
|
||||
// 校验正确性
|
||||
checkCreateOrUpdate(reqVO.getId(), null); // 不允许更新 key
|
||||
// 更新参数配置
|
||||
InfConfigDO updateObj = InfConfigConvert.INSTANCE.convert(reqVO);
|
||||
configMapper.updateById(updateObj);
|
||||
// 发送刷新消息
|
||||
configProducer.sendConfigRefreshMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteConfig(Long id) {
|
||||
// 校验配置存在
|
||||
InfConfigDO config = checkConfigExists(id);
|
||||
// 内置配置,不允许删除
|
||||
if (InfConfigTypeEnum.SYSTEM.getType().equals(config.getType())) {
|
||||
throw ServiceExceptionUtil.exception(InfErrorCodeConstants.CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE);
|
||||
}
|
||||
// 删除
|
||||
configMapper.deleteById(id);
|
||||
// 发送刷新消息
|
||||
configProducer.sendConfigRefreshMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfConfigDO getConfig(Long id) {
|
||||
return configMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfConfigDO getConfigByKey(String key) {
|
||||
return configMapper.selectByKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<InfConfigDO> getConfigPage(ConfigPageReqVO reqVO) {
|
||||
return configMapper.selectPage(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InfConfigDO> getConfigList(ConfigExportReqVO reqVO) {
|
||||
return configMapper.selectList(reqVO);
|
||||
}
|
||||
|
||||
private void checkCreateOrUpdate(Long id, String key) {
|
||||
// 校验自己存在
|
||||
checkConfigExists(id);
|
||||
// 校验参数配置 key 的唯一性
|
||||
checkConfigKeyUnique(id, key);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public InfConfigDO checkConfigExists(Long id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
InfConfigDO config = configMapper.selectById(id);
|
||||
if (config == null) {
|
||||
throw ServiceExceptionUtil.exception(InfErrorCodeConstants.CONFIG_NOT_EXISTS);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void checkConfigKeyUnique(Long id, String key) {
|
||||
InfConfigDO config = configMapper.selectByKey(key);
|
||||
if (config == null) {
|
||||
return;
|
||||
}
|
||||
// 如果 id 为空,说明不用比较是否为相同 id 的参数配置
|
||||
if (id == null) {
|
||||
throw ServiceExceptionUtil.exception(InfErrorCodeConstants.CONFIG_KEY_DUPLICATE);
|
||||
}
|
||||
if (!config.getId().equals(id)) {
|
||||
throw ServiceExceptionUtil.exception(InfErrorCodeConstants.CONFIG_KEY_DUPLICATE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package cn.iocoder.yudao.module.infra.service.file;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
||||
|
||||
/**
|
||||
* core service 文件接口
|
||||
*
|
||||
* @author 宋天
|
||||
*/
|
||||
public interface InfFileCoreService {
|
||||
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param path 文件路径
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
String createFile(String path, byte[] content);
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteFile(String id);
|
||||
|
||||
/**
|
||||
* 获得文件
|
||||
*
|
||||
* @param path 文件路径
|
||||
* @return 文件
|
||||
*/
|
||||
InfFileDO getFile(String path);
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.infra.service.file;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.InfFilePageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 文件 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface InfFileService {
|
||||
|
||||
/**
|
||||
* 获得文件分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 文件分页
|
||||
*/
|
||||
PageResult<InfFileDO> getFilePage(InfFilePageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package cn.iocoder.yudao.module.infra.service.file.impl;
|
||||
|
||||
import cn.hutool.core.io.FileTypeUtil;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.file.InfFileCoreMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.framework.file.config.FileProperties;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.service.file.InfFileCoreService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
import static cn.iocoder.yudao.coreservice.modules.infra.enums.SysErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* core service 文件实现类
|
||||
*
|
||||
* @author 宋天
|
||||
*/
|
||||
@Service
|
||||
public class InfFileCoreServiceImpl implements InfFileCoreService {
|
||||
|
||||
@Resource
|
||||
private InfFileCoreMapper fileMapper;
|
||||
|
||||
@Resource
|
||||
private FileProperties fileProperties;
|
||||
|
||||
@Override
|
||||
public String createFile(String path, byte[] content) {
|
||||
if (fileMapper.selectCountById(path) > 0) {
|
||||
throw exception(FILE_PATH_EXISTS);
|
||||
}
|
||||
// 保存到数据库
|
||||
InfFileDO file = new InfFileDO();
|
||||
file.setId(path);
|
||||
file.setType(FileTypeUtil.getType(new ByteArrayInputStream(content)));
|
||||
file.setContent(content);
|
||||
fileMapper.insert(file);
|
||||
// 拼接路径返回
|
||||
return fileProperties.getBasePath() + path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFile(String id) {
|
||||
// 校验存在
|
||||
this.validateFileExists(id);
|
||||
// 更新
|
||||
fileMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateFileExists(String id) {
|
||||
if (fileMapper.selectById(id) == null) {
|
||||
throw exception(FILE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfFileDO getFile(String path) {
|
||||
return fileMapper.selectByPath(path);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.module.infra.service.file.impl;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.file.InfFileMapper;
|
||||
import cn.iocoder.yudao.module.infra.service.file.InfFileService;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.InfFilePageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.service.file.InfFileCoreService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 文件 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
public class InfFileServiceImpl implements InfFileService {
|
||||
|
||||
@Resource
|
||||
private InfFileMapper fileMapper;
|
||||
|
||||
@Override
|
||||
public PageResult<InfFileDO> getFilePage(InfFilePageReqVO pageReqVO) {
|
||||
return fileMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.infra.service.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.quartz.core.service.JobLogFrameworkService;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.InfJobLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.InfJobLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.InfJobLogDO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Job 日志 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface InfJobLogService extends JobLogFrameworkService {
|
||||
|
||||
/**
|
||||
* 获得定时任务
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 定时任务
|
||||
*/
|
||||
InfJobLogDO getJobLog(Long id);
|
||||
|
||||
/**
|
||||
* 获得定时任务列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 定时任务列表
|
||||
*/
|
||||
List<InfJobLogDO> getJobLogList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得定时任务分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 定时任务分页
|
||||
*/
|
||||
PageResult<InfJobLogDO> getJobLogPage(InfJobLogPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得定时任务列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 定时任务分页
|
||||
*/
|
||||
List<InfJobLogDO> getJobLogList(InfJobLogExportReqVO exportReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package cn.iocoder.yudao.module.infra.service.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.InfJobDO;
|
||||
import org.quartz.SchedulerException;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定时任务 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface InfJobService {
|
||||
|
||||
/**
|
||||
* 创建定时任务
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createJob(@Valid InfJobCreateReqVO createReqVO) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 更新定时任务
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateJob(@Valid InfJobUpdateReqVO updateReqVO) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 更新定时任务的状态
|
||||
*
|
||||
* @param id 任务编号
|
||||
* @param status 状态
|
||||
*/
|
||||
void updateJobStatus(Long id, Integer status) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 触发定时任务
|
||||
*
|
||||
* @param id 任务编号
|
||||
*/
|
||||
void triggerJob(Long id) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 删除定时任务
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteJob(Long id) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 获得定时任务
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 定时任务
|
||||
*/
|
||||
InfJobDO getJob(Long id);
|
||||
|
||||
/**
|
||||
* 获得定时任务列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 定时任务列表
|
||||
*/
|
||||
List<InfJobDO> getJobList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得定时任务分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 定时任务分页
|
||||
*/
|
||||
PageResult<InfJobDO> getJobPage(InfJobPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得定时任务列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 定时任务分页
|
||||
*/
|
||||
List<InfJobDO> getJobList(InfJobExportReqVO exportReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.infra.service.job.impl;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.InfJobLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.InfJobLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.InfJobLogDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.job.InfJobLogMapper;
|
||||
import cn.iocoder.yudao.module.infra.enums.job.InfJobLogStatusEnum;
|
||||
import cn.iocoder.yudao.module.infra.service.job.InfJobLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Job 日志 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class InfJobLogServiceImpl implements InfJobLogService {
|
||||
|
||||
@Resource
|
||||
private InfJobLogMapper jobLogMapper;
|
||||
|
||||
@Override
|
||||
public Long createJobLog(Long jobId, Date beginTime, String jobHandlerName, String jobHandlerParam, Integer executeIndex) {
|
||||
InfJobLogDO log = InfJobLogDO.builder().jobId(jobId).handlerName(jobHandlerName).handlerParam(jobHandlerParam).executeIndex(executeIndex)
|
||||
.beginTime(beginTime).status(InfJobLogStatusEnum.RUNNING.getStatus()).build();
|
||||
jobLogMapper.insert(log);
|
||||
return log.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public void updateJobLogResultAsync(Long logId, Date endTime, Integer duration, boolean success, String result) {
|
||||
try {
|
||||
InfJobLogDO updateObj = InfJobLogDO.builder().id(logId).endTime(endTime).duration(duration)
|
||||
.status(success ? InfJobLogStatusEnum.SUCCESS.getStatus() : InfJobLogStatusEnum.FAILURE.getStatus()).result(result).build();
|
||||
jobLogMapper.updateById(updateObj);
|
||||
} catch (Exception ex) {
|
||||
log.error("[updateJobLogResultAsync][logId({}) endTime({}) duration({}) success({}) result({})]",
|
||||
logId, endTime, duration, success, result);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfJobLogDO getJobLog(Long id) {
|
||||
return jobLogMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InfJobLogDO> getJobLogList(Collection<Long> ids) {
|
||||
return jobLogMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<InfJobLogDO> getJobLogPage(InfJobLogPageReqVO pageReqVO) {
|
||||
return jobLogMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InfJobLogDO> getJobLogList(InfJobLogExportReqVO exportReqVO) {
|
||||
return jobLogMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,174 @@
|
||||
package cn.iocoder.yudao.module.infra.service.job.impl;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager;
|
||||
import cn.iocoder.yudao.framework.quartz.core.util.CronUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.InfJobUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.job.InfJobConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.InfJobDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.job.InfJobMapper;
|
||||
import cn.iocoder.yudao.module.infra.enums.job.InfJobStatusEnum;
|
||||
import cn.iocoder.yudao.module.infra.service.job.InfJobService;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.infra.enums.InfErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.containsAny;
|
||||
|
||||
/**
|
||||
* 定时任务 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class InfJobServiceImpl implements InfJobService {
|
||||
|
||||
@Resource
|
||||
private InfJobMapper jobMapper;
|
||||
|
||||
@Resource
|
||||
private SchedulerManager schedulerManager;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createJob(InfJobCreateReqVO createReqVO) throws SchedulerException {
|
||||
validateCronExpression(createReqVO.getCronExpression());
|
||||
// 校验唯一性
|
||||
if (jobMapper.selectByHandlerName(createReqVO.getHandlerName()) != null) {
|
||||
throw exception(JOB_HANDLER_EXISTS);
|
||||
}
|
||||
// 插入
|
||||
InfJobDO job = InfJobConvert.INSTANCE.convert(createReqVO);
|
||||
job.setStatus(InfJobStatusEnum.INIT.getStatus());
|
||||
fillJobMonitorTimeoutEmpty(job);
|
||||
jobMapper.insert(job);
|
||||
|
||||
// 添加 Job 到 Quartz 中
|
||||
schedulerManager.addJob(job.getId(), job.getHandlerName(), job.getHandlerParam(), job.getCronExpression(),
|
||||
createReqVO.getRetryCount(), createReqVO.getRetryInterval());
|
||||
// 更新
|
||||
InfJobDO updateObj = InfJobDO.builder().id(job.getId()).status(InfJobStatusEnum.NORMAL.getStatus()).build();
|
||||
jobMapper.updateById(updateObj);
|
||||
|
||||
// 返回
|
||||
return job.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateJob(InfJobUpdateReqVO updateReqVO) throws SchedulerException {
|
||||
validateCronExpression(updateReqVO.getCronExpression());
|
||||
// 校验存在
|
||||
InfJobDO job = this.validateJobExists(updateReqVO.getId());
|
||||
// 只有开启状态,才可以修改.原因是,如果出暂停状态,修改 Quartz Job 时,会导致任务又开始执行
|
||||
if (!job.getStatus().equals(InfJobStatusEnum.NORMAL.getStatus())) {
|
||||
throw exception(JOB_UPDATE_ONLY_NORMAL_STATUS);
|
||||
}
|
||||
// 更新
|
||||
InfJobDO updateObj = InfJobConvert.INSTANCE.convert(updateReqVO);
|
||||
fillJobMonitorTimeoutEmpty(updateObj);
|
||||
jobMapper.updateById(updateObj);
|
||||
|
||||
// 更新 Job 到 Quartz 中
|
||||
schedulerManager.updateJob(job.getHandlerName(), updateReqVO.getHandlerParam(), updateReqVO.getCronExpression(),
|
||||
updateReqVO.getRetryCount(), updateReqVO.getRetryInterval());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateJobStatus(Long id, Integer status) throws SchedulerException {
|
||||
// 校验 status
|
||||
if (!containsAny(status, InfJobStatusEnum.NORMAL.getStatus(), InfJobStatusEnum.STOP.getStatus())) {
|
||||
throw exception(JOB_CHANGE_STATUS_INVALID);
|
||||
}
|
||||
// 校验存在
|
||||
InfJobDO job = this.validateJobExists(id);
|
||||
// 校验是否已经为当前状态
|
||||
if (job.getStatus().equals(status)) {
|
||||
throw exception(JOB_CHANGE_STATUS_EQUALS);
|
||||
}
|
||||
// 更新 Job 状态
|
||||
InfJobDO updateObj = InfJobDO.builder().id(id).status(status).build();
|
||||
jobMapper.updateById(updateObj);
|
||||
|
||||
// 更新状态 Job 到 Quartz 中
|
||||
if (InfJobStatusEnum.NORMAL.getStatus().equals(status)) { // 开启
|
||||
schedulerManager.resumeJob(job.getHandlerName());
|
||||
} else { // 暂停
|
||||
schedulerManager.pauseJob(job.getHandlerName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void triggerJob(Long id) throws SchedulerException {
|
||||
// 校验存在
|
||||
InfJobDO job = this.validateJobExists(id);
|
||||
|
||||
// 触发 Quartz 中的 Job
|
||||
schedulerManager.triggerJob(job.getId(), job.getHandlerName(), job.getHandlerParam());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteJob(Long id) throws SchedulerException {
|
||||
// 校验存在
|
||||
InfJobDO job = this.validateJobExists(id);
|
||||
// 更新
|
||||
jobMapper.deleteById(id);
|
||||
|
||||
// 删除 Job 到 Quartz 中
|
||||
schedulerManager.deleteJob(job.getHandlerName());
|
||||
}
|
||||
|
||||
private InfJobDO validateJobExists(Long id) {
|
||||
InfJobDO job = jobMapper.selectById(id);
|
||||
if (job == null) {
|
||||
throw exception(JOB_NOT_EXISTS);
|
||||
}
|
||||
return job;
|
||||
}
|
||||
|
||||
private void validateCronExpression(String cronExpression) {
|
||||
if (!CronUtils.isValid(cronExpression)) {
|
||||
throw exception(JOB_CRON_EXPRESSION_VALID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfJobDO getJob(Long id) {
|
||||
return jobMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InfJobDO> getJobList(Collection<Long> ids) {
|
||||
return jobMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<InfJobDO> getJobPage(InfJobPageReqVO pageReqVO) {
|
||||
return jobMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InfJobDO> getJobList(InfJobExportReqVO exportReqVO) {
|
||||
return jobMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
private static void fillJobMonitorTimeoutEmpty(InfJobDO job) {
|
||||
if (job.getMonitorTimeout() == null) {
|
||||
job.setMonitorTimeout(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package cn.iocoder.yudao.module.infra.service.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService;
|
||||
|
||||
/**
|
||||
* API 访问日志 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface InfApiAccessLogCoreService extends ApiAccessLogFrameworkService {
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.module.infra.service.logger;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 访问日志 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface InfApiAccessLogService {
|
||||
|
||||
/**
|
||||
* 获得 API 访问日志分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return API 访问日志分页
|
||||
*/
|
||||
PageResult<InfApiAccessLogDO> getApiAccessLogPage(InfApiAccessLogPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得 API 访问日志列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return API 访问日志分页
|
||||
*/
|
||||
List<InfApiAccessLogDO> getApiAccessLogList(InfApiAccessLogExportReqVO exportReqVO);
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user