mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
!774 简化 system 和 infra 大模块模块的 VO
Merge pull request !774 from 芋道源码/feature/vo-optimize
This commit is contained in:
commit
47b77d7360
@ -21,7 +21,7 @@ public class OperateLogFrameworkServiceImpl implements OperateLogFrameworkServic
|
||||
@Override
|
||||
@Async
|
||||
public void createOperateLog(OperateLog operateLog) {
|
||||
OperateLogCreateReqDTO reqDTO = BeanUtil.copyProperties(operateLog, OperateLogCreateReqDTO.class);
|
||||
OperateLogCreateReqDTO reqDTO = BeanUtil.toBean(operateLog, OperateLogCreateReqDTO.class);
|
||||
operateLogApi.createOperateLog(reqDTO);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> {
|
||||
|
||||
default PageResult<T> selectPage(PageParam pageParam, @Param("ew") Wrapper<T> queryWrapper) {
|
||||
// 特殊:不分页,直接查询全部
|
||||
if (PageParam.PAGE_SIZE_NONE.equals(pageParam.getPageNo())) {
|
||||
if (PageParam.PAGE_SIZE_NONE.equals(pageParam.getPageSize())) {
|
||||
List<T> list = selectList(queryWrapper);
|
||||
return new PageResult<>(list, (long) list.size());
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
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;
|
||||
@ -38,15 +39,15 @@ public class ConfigController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建参数配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:create')")
|
||||
public CommonResult<Long> createConfig(@Valid @RequestBody ConfigCreateReqVO reqVO) {
|
||||
return success(configService.createConfig(reqVO));
|
||||
public CommonResult<Long> createConfig(@Valid @RequestBody ConfigSaveReqVO createReqVO) {
|
||||
return success(configService.createConfig(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "修改参数配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:update')")
|
||||
public CommonResult<Boolean> updateConfig(@Valid @RequestBody ConfigUpdateReqVO reqVO) {
|
||||
configService.updateConfig(reqVO);
|
||||
public CommonResult<Boolean> updateConfig(@Valid @RequestBody ConfigSaveReqVO updateReqVO) {
|
||||
configService.updateConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -84,8 +85,8 @@ public class ConfigController {
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获取参数配置分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:query')")
|
||||
public CommonResult<PageResult<ConfigRespVO>> getConfigPage(@Valid ConfigPageReqVO reqVO) {
|
||||
PageResult<ConfigDO> page = configService.getConfigPage(reqVO);
|
||||
public CommonResult<PageResult<ConfigRespVO>> getConfigPage(@Valid ConfigPageReqVO pageReqVO) {
|
||||
PageResult<ConfigDO> page = configService.getConfigPage(pageReqVO);
|
||||
return success(ConfigConvert.INSTANCE.convertPage(page));
|
||||
}
|
||||
|
||||
@ -93,13 +94,13 @@ public class ConfigController {
|
||||
@Operation(summary = "导出参数配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportConfig(@Valid ConfigExportReqVO reqVO,
|
||||
public void exportConfig(@Valid ConfigPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<ConfigDO> list = configService.getConfigList(reqVO);
|
||||
// 拼接数据
|
||||
List<ConfigExcelVO> datas = ConfigConvert.INSTANCE.convertList(list);
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ConfigDO> list = configService.getConfigPage(exportReqVO).getList();
|
||||
// 输出
|
||||
ExcelUtils.write(response, "参数配置.xls", "数据", ConfigExcelVO.class, datas);
|
||||
ExcelUtils.write(response, "参数配置.xls", "数据", ConfigRespVO.class,
|
||||
ConfigConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Schema(description = "管理后台 - 参数配置创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ConfigCreateReqVO extends ConfigBaseVO {
|
||||
|
||||
@Schema(description = "参数键名", requiredMode = Schema.RequiredMode.REQUIRED, example = "yunai.db.username")
|
||||
@NotBlank(message = "参数键名长度不能为空")
|
||||
@Size(max = 100, message = "参数键名长度不能超过100个字符")
|
||||
private String key;
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
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.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 参数配置 Excel 导出响应 VO
|
||||
*/
|
||||
@Data
|
||||
public class ConfigExcelVO {
|
||||
|
||||
@ExcelProperty("参数配置序号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("参数键名")
|
||||
private String configKey;
|
||||
|
||||
@ExcelProperty("参数分类")
|
||||
private String category;
|
||||
|
||||
@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 visible;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 参数配置导出 Request VO")
|
||||
@Data
|
||||
public class ConfigExportReqVO {
|
||||
|
||||
@Schema(description = "参数名称", example = "模糊匹配")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "参数键名,模糊匹配", example = "yunai.db.username")
|
||||
private String key;
|
||||
|
||||
@Schema(description = "参数类型,参见 SysConfigTypeEnum 枚举", example = "1")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -1,30 +1,56 @@
|
||||
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.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 参数配置信息 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ConfigRespVO extends ConfigBaseVO {
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ConfigRespVO {
|
||||
|
||||
@Schema(description = "参数配置序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("参数配置序号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "参数分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "biz")
|
||||
@ExcelProperty("参数分类")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "参数名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "数据库名")
|
||||
@ExcelProperty("参数名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "参数键名", requiredMode = Schema.RequiredMode.REQUIRED, example = "yunai.db.username")
|
||||
@NotBlank(message = "参数键名长度不能为空")
|
||||
@Size(max = 100, message = "参数键名长度不能超过100个字符")
|
||||
@ExcelProperty("参数键名")
|
||||
private String key;
|
||||
|
||||
@Schema(description = "参数键值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("参数键值")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "参数类型,参见 SysConfigTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "参数类型", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.CONFIG_TYPE)
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@ExcelProperty(value = "是否可见", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean visible;
|
||||
|
||||
@Schema(description = "备注", example = "备注一下很帅气!")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
@ -8,26 +8,31 @@ import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 参数配置 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - 参数配置创建/修改 Request VO")
|
||||
@Data
|
||||
public class ConfigBaseVO {
|
||||
public class ConfigSaveReqVO {
|
||||
|
||||
@Schema(description = "参数配置序号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "参数分组", requiredMode = Schema.RequiredMode.REQUIRED, example = "biz")
|
||||
@NotEmpty(message = "参数分组不能为空")
|
||||
@Size(max = 50, message = "参数名称不能超过50个字符")
|
||||
@Size(max = 50, message = "参数名称不能超过 50 个字符")
|
||||
private String category;
|
||||
|
||||
@Schema(description = "参数名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "数据库名")
|
||||
@NotBlank(message = "参数名称不能为空")
|
||||
@Size(max = 100, message = "参数名称不能超过100个字符")
|
||||
@Size(max = 100, message = "参数名称不能超过 100 个字符")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "参数键名", requiredMode = Schema.RequiredMode.REQUIRED, example = "yunai.db.username")
|
||||
@NotBlank(message = "参数键名长度不能为空")
|
||||
@Size(max = 100, message = "参数键名长度不能超过 100 个字符")
|
||||
private String key;
|
||||
|
||||
@Schema(description = "参数键值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotBlank(message = "参数键值不能为空")
|
||||
@Size(max = 500, message = "参数键值长度不能超过500个字符")
|
||||
@Size(max = 500, message = "参数键值长度不能超过 500 个字符")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.config.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 参数配置创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ConfigUpdateReqVO extends ConfigBaseVO {
|
||||
|
||||
@Schema(description = "参数配置序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "参数配置编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -1,15 +1,14 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.db;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.db.DataSourceConfigConvert;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.service.db.DataSourceConfigService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -32,14 +31,14 @@ public class DataSourceConfigController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建数据源配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:create')")
|
||||
public CommonResult<Long> createDataSourceConfig(@Valid @RequestBody DataSourceConfigCreateReqVO createReqVO) {
|
||||
public CommonResult<Long> createDataSourceConfig(@Valid @RequestBody DataSourceConfigSaveReqVO createReqVO) {
|
||||
return success(dataSourceConfigService.createDataSourceConfig(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新数据源配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:update')")
|
||||
public CommonResult<Boolean> updateDataSourceConfig(@Valid @RequestBody DataSourceConfigUpdateReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateDataSourceConfig(@Valid @RequestBody DataSourceConfigSaveReqVO updateReqVO) {
|
||||
dataSourceConfigService.updateDataSourceConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
@ -58,8 +57,8 @@ public class DataSourceConfigController {
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:query')")
|
||||
public CommonResult<DataSourceConfigRespVO> getDataSourceConfig(@RequestParam("id") Long id) {
|
||||
DataSourceConfigDO dataSourceConfig = dataSourceConfigService.getDataSourceConfig(id);
|
||||
return success(DataSourceConfigConvert.INSTANCE.convert(dataSourceConfig));
|
||||
DataSourceConfigDO config = dataSourceConfigService.getDataSourceConfig(id);
|
||||
return success(BeanUtils.toBean(config, DataSourceConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ -67,7 +66,7 @@ public class DataSourceConfigController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:data-source-config:query')")
|
||||
public CommonResult<List<DataSourceConfigRespVO>> getDataSourceConfigList() {
|
||||
List<DataSourceConfigDO> list = dataSourceConfigService.getDataSourceConfigList();
|
||||
return success(DataSourceConfigConvert.INSTANCE.convertList(list));
|
||||
return success(BeanUtils.toBean(list, DataSourceConfigRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.db.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 数据源配置创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DataSourceConfigCreateReqVO extends DataSourceConfigBaseVO {
|
||||
|
||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
@NotNull(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
}
|
@ -1,19 +1,26 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.db.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 数据源配置 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DataSourceConfigRespVO extends DataSourceConfigBaseVO {
|
||||
public class DataSourceConfigRespVO {
|
||||
|
||||
@Schema(description = "主键编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "数据源名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "test")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "数据源连接", requiredMode = Schema.RequiredMode.REQUIRED, example = "jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "root")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
@ -1,14 +1,15 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.db.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 数据源配置 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - 数据源配置创建/修改 Request VO")
|
||||
@Data
|
||||
public class DataSourceConfigBaseVO {
|
||||
public class DataSourceConfigSaveReqVO {
|
||||
|
||||
@Schema(description = "主键编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "数据源名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "test")
|
||||
@NotNull(message = "数据源名称不能为空")
|
||||
@ -22,4 +23,8 @@ public class DataSourceConfigBaseVO {
|
||||
@NotNull(message = "用户名不能为空")
|
||||
private String username;
|
||||
|
||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
@NotNull(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.db.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 数据源配置更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DataSourceConfigUpdateReqVO extends DataSourceConfigBaseVO {
|
||||
|
||||
@Schema(description = "主键编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "主键编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||
@NotNull(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
}
|
@ -2,16 +2,15 @@ package cn.iocoder.yudao.module.infra.controller.admin.file;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.file.FileConfigConvert;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.service.file.FileConfigService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -33,14 +32,14 @@ public class FileConfigController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建文件配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:create')")
|
||||
public CommonResult<Long> createFileConfig(@Valid @RequestBody FileConfigCreateReqVO createReqVO) {
|
||||
public CommonResult<Long> createFileConfig(@Valid @RequestBody FileConfigSaveReqVO createReqVO) {
|
||||
return success(fileConfigService.createFileConfig(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新文件配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:update')")
|
||||
public CommonResult<Boolean> updateFileConfig(@Valid @RequestBody FileConfigUpdateReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateFileConfig(@Valid @RequestBody FileConfigSaveReqVO updateReqVO) {
|
||||
fileConfigService.updateFileConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
@ -67,8 +66,8 @@ public class FileConfigController {
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:query')")
|
||||
public CommonResult<FileConfigRespVO> getFileConfig(@RequestParam("id") Long id) {
|
||||
FileConfigDO fileConfig = fileConfigService.getFileConfig(id);
|
||||
return success(FileConfigConvert.INSTANCE.convert(fileConfig));
|
||||
FileConfigDO config = fileConfigService.getFileConfig(id);
|
||||
return success(BeanUtils.toBean(config, FileConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ -76,7 +75,7 @@ public class FileConfigController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:file-config:query')")
|
||||
public CommonResult<PageResult<FileConfigRespVO>> getFileConfigPage(@Valid FileConfigPageReqVO pageVO) {
|
||||
PageResult<FileConfigDO> pageResult = fileConfigService.getFileConfigPage(pageVO);
|
||||
return success(FileConfigConvert.INSTANCE.convertPage(pageResult));
|
||||
return success(BeanUtils.toBean(pageResult, FileConfigRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/test")
|
||||
|
@ -4,17 +4,17 @@ import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileUploadReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.file.FileConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
|
||||
import cn.iocoder.yudao.module.infra.service.file.FileService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@ -86,7 +86,7 @@ public class FileController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:file:query')")
|
||||
public CommonResult<PageResult<FileRespVO>> getFilePage(@Valid FilePageReqVO pageVO) {
|
||||
PageResult<FileDO> pageResult = fileService.getFilePage(pageVO);
|
||||
return success(FileConvert.INSTANCE.convertPage(pageResult));
|
||||
return success(BeanUtils.toBean(pageResult, FileRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.file.vo.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 文件配置 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class FileConfigBaseVO {
|
||||
|
||||
@Schema(description = "配置名", requiredMode = Schema.RequiredMode.REQUIRED, example = "S3 - 阿里云")
|
||||
@NotNull(message = "配置名不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "备注", example = "我是备注")
|
||||
private String remark;
|
||||
|
||||
}
|
@ -27,4 +27,4 @@ public class FileConfigPageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
}
|
@ -3,32 +3,31 @@ package cn.iocoder.yudao.module.infra.controller.admin.file.vo.config;
|
||||
import cn.iocoder.yudao.framework.file.core.client.FileClientConfig;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 文件配置 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class FileConfigRespVO extends FileConfigBaseVO {
|
||||
public class FileConfigRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "配置名", requiredMode = Schema.RequiredMode.REQUIRED, example = "S3 - 阿里云")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "存储器,参见 FileStorageEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "存储器不能为空")
|
||||
private Integer storage;
|
||||
|
||||
@Schema(description = "是否为主配置", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否为主配置不能为空")
|
||||
private Boolean master;
|
||||
|
||||
@Schema(description = "存储配置", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private FileClientConfig config;
|
||||
|
||||
@Schema(description = "备注", example = "我是备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
18
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/config/FileConfigCreateReqVO.java → yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/config/FileConfigSaveReqVO.java
Executable file → Normal file
18
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/config/FileConfigCreateReqVO.java → yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/vo/config/FileConfigSaveReqVO.java
Executable file → Normal file
@ -2,17 +2,20 @@ package cn.iocoder.yudao.module.infra.controller.admin.file.vo.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
@Schema(description = "管理后台 - 文件配置创建 Request VO")
|
||||
@Schema(description = "管理后台 - 文件配置创建/修改 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class FileConfigCreateReqVO extends FileConfigBaseVO {
|
||||
public class FileConfigSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "配置名", requiredMode = Schema.RequiredMode.REQUIRED, example = "S3 - 阿里云")
|
||||
@NotNull(message = "配置名不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "存储器,参见 FileStorageEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "存储器不能为空")
|
||||
@ -22,4 +25,7 @@ public class FileConfigCreateReqVO extends FileConfigBaseVO {
|
||||
@NotNull(message = "存储配置不能为空")
|
||||
private Map<String, Object> config;
|
||||
|
||||
@Schema(description = "备注", example = "我是备注")
|
||||
private String remark;
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.file.vo.config;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
@Schema(description = "管理后台 - 文件配置更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class FileConfigUpdateReqVO extends FileConfigBaseVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "存储配置,配置是动态参数,所以使用 Map 接收", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "存储配置不能为空")
|
||||
private Map<String, Object> config;
|
||||
|
||||
}
|
@ -1,18 +1,21 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
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.module.infra.controller.admin.job.vo.job.*;
|
||||
import cn.iocoder.yudao.module.infra.convert.job.JobConvert;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO;
|
||||
import cn.iocoder.yudao.module.infra.service.job.JobService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -23,7 +26,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -42,7 +44,7 @@ public class JobController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建定时任务")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:create')")
|
||||
public CommonResult<Long> createJob(@Valid @RequestBody JobCreateReqVO createReqVO)
|
||||
public CommonResult<Long> createJob(@Valid @RequestBody JobSaveReqVO createReqVO)
|
||||
throws SchedulerException {
|
||||
return success(jobService.createJob(createReqVO));
|
||||
}
|
||||
@ -50,7 +52,7 @@ public class JobController {
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新定时任务")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:update')")
|
||||
public CommonResult<Boolean> updateJob(@Valid @RequestBody JobUpdateReqVO updateReqVO)
|
||||
public CommonResult<Boolean> updateJob(@Valid @RequestBody JobSaveReqVO updateReqVO)
|
||||
throws SchedulerException {
|
||||
jobService.updateJob(updateReqVO);
|
||||
return success(true);
|
||||
@ -94,16 +96,7 @@ public class JobController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<JobRespVO> getJob(@RequestParam("id") Long id) {
|
||||
JobDO job = jobService.getJob(id);
|
||||
return success(JobConvert.INSTANCE.convert(job));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得定时任务列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<List<JobRespVO>> getJobList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<JobDO> list = jobService.getJobList(ids);
|
||||
return success(JobConvert.INSTANCE.convertList(list));
|
||||
return success(BeanUtils.toBean(job, JobRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ -111,19 +104,20 @@ public class JobController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<PageResult<JobRespVO>> getJobPage(@Valid JobPageReqVO pageVO) {
|
||||
PageResult<JobDO> pageResult = jobService.getJobPage(pageVO);
|
||||
return success(JobConvert.INSTANCE.convertPage(pageResult));
|
||||
return success(BeanUtils.toBean(pageResult, JobRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出定时任务 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportJobExcel(@Valid JobExportReqVO exportReqVO,
|
||||
public void exportJobExcel(@Valid JobPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<JobDO> list = jobService.getJobList(exportReqVO);
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<JobDO> list = jobService.getJobPage(exportReqVO).getList();
|
||||
// 导出 Excel
|
||||
List<JobExcelVO> datas = JobConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "定时任务.xls", "数据", JobExcelVO.class, datas);
|
||||
ExcelUtils.write(response, "定时任务.xls", "数据", JobRespVO.class,
|
||||
BeanUtils.toBean(list, JobRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get_next_times")
|
||||
@ -133,8 +127,9 @@ public class JobController {
|
||||
@Parameter(name = "count", description = "数量", example = "5")
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<List<LocalDateTime>> getJobNextTimes(@RequestParam("id") Long id,
|
||||
@RequestParam(value = "count", required = false, defaultValue = "5") Integer count) {
|
||||
public CommonResult<List<LocalDateTime>> getJobNextTimes(
|
||||
@RequestParam("id") Long id,
|
||||
@RequestParam(value = "count", required = false, defaultValue = "5") Integer count) {
|
||||
JobDO job = jobService.getJob(id);
|
||||
if (job == null) {
|
||||
return success(Collections.emptyList());
|
||||
|
@ -1,20 +1,18 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.util.OperateLogUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogRespVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.job.JobLogConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO;
|
||||
import cn.iocoder.yudao.module.infra.service.job.JobLogService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -26,7 +24,6 @@ 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;
|
||||
@ -47,16 +44,7 @@ public class JobLogController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<JobLogRespVO> getJobLog(@RequestParam("id") Long id) {
|
||||
JobLogDO jobLog = jobLogService.getJobLog(id);
|
||||
return success(JobLogConvert.INSTANCE.convert(jobLog));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得定时任务日志列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<List<JobLogRespVO>> getJobLogList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<JobLogDO> list = jobLogService.getJobLogList(ids);
|
||||
return success(JobLogConvert.INSTANCE.convertList(list));
|
||||
return success(BeanUtils.toBean(jobLog, JobLogRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ -64,19 +52,20 @@ public class JobLogController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:query')")
|
||||
public CommonResult<PageResult<JobLogRespVO>> getJobLogPage(@Valid JobLogPageReqVO pageVO) {
|
||||
PageResult<JobLogDO> pageResult = jobLogService.getJobLogPage(pageVO);
|
||||
return success(JobLogConvert.INSTANCE.convertPage(pageResult));
|
||||
return success(BeanUtils.toBean(pageResult, JobLogRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出定时任务日志 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportJobLogExcel(@Valid JobLogExportReqVO exportReqVO,
|
||||
public void exportJobLogExcel(@Valid JobLogPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<JobLogDO> list = jobLogService.getJobLogList(exportReqVO);
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<JobLogDO> list = jobLogService.getJobLogPage(exportReqVO).getList();
|
||||
// 导出 Excel
|
||||
List<JobLogExcelVO> datas = JobLogConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "任务日志.xls", "数据", JobLogExcelVO.class, datas);
|
||||
ExcelUtils.write(response, "任务日志.xls", "数据", JobLogRespVO.class,
|
||||
BeanUtils.toBean(list, JobLogRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 定时任务创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class JobCreateReqVO extends JobBaseVO {
|
||||
|
||||
@Schema(description = "处理器的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "sysUserSessionTimeoutJob")
|
||||
@NotNull(message = "处理器的名字不能为空")
|
||||
private String handlerName;
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
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.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 定时任务 Excel VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class JobExcelVO {
|
||||
|
||||
@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 LocalDateTime executeBeginTime;
|
||||
|
||||
@ExcelProperty("最后一次执行的结束时间")
|
||||
private LocalDateTime executeEndTime;
|
||||
|
||||
@ExcelProperty("上一次触发时间")
|
||||
private LocalDateTime firePrevTime;
|
||||
|
||||
@ExcelProperty("下一次触发时间")
|
||||
private LocalDateTime fireNextTime;
|
||||
|
||||
@ExcelProperty("监控超时时间")
|
||||
private Integer monitorTimeout;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 定时任务 Excel 导出 Request VO-参数和 JobPageReqVO 是一致的")
|
||||
@Data
|
||||
public class JobExportReqVO {
|
||||
|
||||
@Schema(description = "任务名称-模糊匹配", example = "测试任务")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "任务状态-参见 JobStatusEnum 枚举", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "处理器的名字-模糊匹配", example = "UserSessionTimeoutJob")
|
||||
private String handlerName;
|
||||
|
||||
}
|
@ -1,30 +1,59 @@
|
||||
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.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 定时任务 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class JobRespVO extends JobBaseVO {
|
||||
@ExcelIgnoreUnannotated
|
||||
public class JobRespVO {
|
||||
|
||||
@Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("任务编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试任务")
|
||||
@ExcelProperty("任务名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "任务状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "任务状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.JOB_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "处理器的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "sysUserSessionTimeoutJob")
|
||||
@NotNull(message = "处理器的名字不能为空")
|
||||
@ExcelProperty("处理器的名字")
|
||||
private String handlerName;
|
||||
|
||||
@Schema(description = "处理器的参数", example = "yudao")
|
||||
@ExcelProperty("处理器的参数")
|
||||
private String handlerParam;
|
||||
|
||||
@Schema(description = "CRON 表达式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0/10 * * * * ? *")
|
||||
@ExcelProperty("CRON 表达式")
|
||||
private String cronExpression;
|
||||
|
||||
@Schema(description = "重试次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "3")
|
||||
@NotNull(message = "重试次数不能为空")
|
||||
private Integer retryCount;
|
||||
|
||||
@Schema(description = "重试间隔", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
||||
private Integer retryInterval;
|
||||
|
||||
@Schema(description = "监控超时时间", example = "1000")
|
||||
@ExcelProperty("监控超时时间")
|
||||
private Integer monitorTimeout;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
@ -3,24 +3,29 @@ package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 定时任务 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - 定时任务创建/修改 Request VO")
|
||||
@Data
|
||||
public class JobBaseVO {
|
||||
public class JobSaveReqVO {
|
||||
|
||||
@Schema(description = "任务编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试任务")
|
||||
@NotNull(message = "任务名称不能为空")
|
||||
@NotEmpty(message = "任务名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "处理器的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "sysUserSessionTimeoutJob")
|
||||
@NotEmpty(message = "处理器的名字不能为空")
|
||||
private String handlerName;
|
||||
|
||||
@Schema(description = "处理器的参数", example = "yudao")
|
||||
private String handlerParam;
|
||||
|
||||
@Schema(description = "CRON 表达式", requiredMode = Schema.RequiredMode.REQUIRED, example = "0/10 * * * * ? *")
|
||||
@NotNull(message = "CRON 表达式不能为空")
|
||||
@NotEmpty(message = "CRON 表达式不能为空")
|
||||
private String cronExpression;
|
||||
|
||||
@Schema(description = "重试次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "3")
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.job;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 定时任务更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class JobUpdateReqVO extends JobBaseVO {
|
||||
|
||||
@Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "任务编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
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 JobLogBaseVO {
|
||||
|
||||
@Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "任务编号不能为空")
|
||||
private Long jobId;
|
||||
|
||||
@Schema(description = "处理器的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "sysUserSessionTimeoutJob")
|
||||
@NotNull(message = "处理器的名字不能为空")
|
||||
private String handlerName;
|
||||
|
||||
@Schema(description = "处理器的参数", example = "yudao")
|
||||
private String handlerParam;
|
||||
|
||||
@Schema(description = "第几次执行", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "第几次执行不能为空")
|
||||
private Integer executeIndex;
|
||||
|
||||
@Schema(description = "开始执行时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "开始执行时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime beginTime;
|
||||
|
||||
@Schema(description = "结束执行时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "执行时长", example = "123")
|
||||
private Integer duration;
|
||||
|
||||
@Schema(description = "任务状态,参见 JobLogStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "任务状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "结果数据", example = "执行成功")
|
||||
private String result;
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
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.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 定时任务 Excel VO
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Data
|
||||
public class JobLogExcelVO {
|
||||
|
||||
@ExcelProperty("日志编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("任务编号")
|
||||
private Long jobId;
|
||||
|
||||
@ExcelProperty("处理器的名字")
|
||||
private String handlerName;
|
||||
|
||||
@ExcelProperty("处理器的参数")
|
||||
private String handlerParam;
|
||||
|
||||
@ExcelProperty("第几次执行")
|
||||
private Integer executeIndex;
|
||||
|
||||
@ExcelProperty("开始执行时间")
|
||||
private LocalDateTime beginTime;
|
||||
|
||||
@ExcelProperty("结束执行时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@ExcelProperty("执行时长")
|
||||
private Integer duration;
|
||||
|
||||
@ExcelProperty(value = "任务状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.JOB_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("结果数据")
|
||||
private String result;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.job.vo.log;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 定时任务 Excel 导出 Request VO,参数和 JobLogPageReqVO 是一致的")
|
||||
@Data
|
||||
public class JobLogExportReqVO {
|
||||
|
||||
@Schema(description = "任务编号", example = "10")
|
||||
private Long jobId;
|
||||
|
||||
@Schema(description = "处理器的名字,模糊匹配")
|
||||
private String handlerName;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@Schema(description = "开始执行时间")
|
||||
private LocalDateTime beginTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@Schema(description = "结束执行时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "任务状态,参见 JobLogStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -1,22 +1,63 @@
|
||||
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.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 定时任务日志 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class JobLogRespVO extends JobLogBaseVO {
|
||||
@ExcelIgnoreUnannotated
|
||||
public class JobLogRespVO {
|
||||
|
||||
@Schema(description = "日志编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("日志编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("任务编号")
|
||||
private Long jobId;
|
||||
|
||||
@Schema(description = "处理器的名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "sysUserSessionTimeoutJob")
|
||||
@ExcelProperty("处理器的名字")
|
||||
private String handlerName;
|
||||
|
||||
@Schema(description = "处理器的参数", example = "yudao")
|
||||
@ExcelProperty("处理器的参数")
|
||||
private String handlerParam;
|
||||
|
||||
@Schema(description = "第几次执行", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("第几次执行")
|
||||
private Integer executeIndex;
|
||||
|
||||
@Schema(description = "开始执行时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("开始执行时间")
|
||||
private LocalDateTime beginTime;
|
||||
|
||||
@Schema(description = "结束执行时间")
|
||||
@ExcelProperty("结束执行时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "执行时长", example = "123")
|
||||
@ExcelProperty("执行时长")
|
||||
private Integer duration;
|
||||
|
||||
@Schema(description = "任务状态,参见 JobLogStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "任务状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.JOB_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "结果数据", example = "执行成功")
|
||||
@ExcelProperty("结果数据")
|
||||
private String result;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,17 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
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.ApiAccessLogExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.logger.ApiAccessLogConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
|
||||
import cn.iocoder.yudao.module.infra.service.logger.ApiAccessLogService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -40,21 +39,22 @@ public class ApiAccessLogController {
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得API 访问日志分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-access-log:query')")
|
||||
public CommonResult<PageResult<ApiAccessLogRespVO>> getApiAccessLogPage(@Valid ApiAccessLogPageReqVO pageVO) {
|
||||
PageResult<ApiAccessLogDO> pageResult = apiAccessLogService.getApiAccessLogPage(pageVO);
|
||||
return success(ApiAccessLogConvert.INSTANCE.convertPage(pageResult));
|
||||
public CommonResult<PageResult<ApiAccessLogRespVO>> getApiAccessLogPage(@Valid ApiAccessLogPageReqVO pageReqVO) {
|
||||
PageResult<ApiAccessLogDO> pageResult = apiAccessLogService.getApiAccessLogPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ApiAccessLogRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出API 访问日志 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-access-log:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportApiAccessLogExcel(@Valid ApiAccessLogExportReqVO exportReqVO,
|
||||
public void exportApiAccessLogExcel(@Valid ApiAccessLogPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<ApiAccessLogDO> list = apiAccessLogService.getApiAccessLogList(exportReqVO);
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ApiAccessLogDO> list = apiAccessLogService.getApiAccessLogPage(exportReqVO).getList();
|
||||
// 导出 Excel
|
||||
List<ApiAccessLogExcelVO> datas = ApiAccessLogConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "API 访问日志.xls", "数据", ApiAccessLogExcelVO.class, datas);
|
||||
ExcelUtils.write(response, "API 访问日志.xls", "数据", ApiAccessLogRespVO.class,
|
||||
BeanUtils.toBean(list, ApiAccessLogRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,19 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
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.ApiErrorLogExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogRespVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.logger.ApiErrorLogConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
|
||||
import cn.iocoder.yudao.module.infra.service.logger.ApiErrorLogService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -54,21 +53,22 @@ public class ApiErrorLogController {
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得 API 错误日志分页")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-error-log:query')")
|
||||
public CommonResult<PageResult<ApiErrorLogRespVO>> getApiErrorLogPage(@Valid ApiErrorLogPageReqVO pageVO) {
|
||||
PageResult<ApiErrorLogDO> pageResult = apiErrorLogService.getApiErrorLogPage(pageVO);
|
||||
return success(ApiErrorLogConvert.INSTANCE.convertPage(pageResult));
|
||||
public CommonResult<PageResult<ApiErrorLogRespVO>> getApiErrorLogPage(@Valid ApiErrorLogPageReqVO pageReqVO) {
|
||||
PageResult<ApiErrorLogDO> pageResult = apiErrorLogService.getApiErrorLogPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ApiErrorLogRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出 API 错误日志 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('infra:api-error-log:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportApiErrorLogExcel(@Valid ApiErrorLogExportReqVO exportReqVO,
|
||||
public void exportApiErrorLogExcel(@Valid ApiErrorLogPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<ApiErrorLogDO> list = apiErrorLogService.getApiErrorLogList(exportReqVO);
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ApiErrorLogDO> list = apiErrorLogService.getApiErrorLogPage(exportReqVO).getList();
|
||||
// 导出 Excel
|
||||
List<ApiErrorLogExcelVO> datas = ApiErrorLogConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "API 错误日志.xls", "数据", ApiErrorLogExcelVO.class, datas);
|
||||
ExcelUtils.write(response, "API 错误日志.xls", "数据", ApiErrorLogRespVO.class,
|
||||
BeanUtils.toBean(list, ApiErrorLogRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,75 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
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 ApiAccessLogBaseVO {
|
||||
|
||||
@Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "66600cb6-7852-11eb-9439-0242ac130002")
|
||||
@NotNull(message = "链路追踪编号不能为空")
|
||||
private String traceId;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户类型,参见 UserTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "用户类型不能为空")
|
||||
private Integer userType;
|
||||
|
||||
@Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String applicationName;
|
||||
|
||||
@Schema(description = "请求方法名", requiredMode = Schema.RequiredMode.REQUIRED, example = "GET")
|
||||
@NotNull(message = "请求方法名不能为空")
|
||||
private String requestMethod;
|
||||
|
||||
@Schema(description = "请求地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "/xxx/yyy")
|
||||
@NotNull(message = "请求地址不能为空")
|
||||
private String requestUrl;
|
||||
|
||||
@Schema(description = "请求参数")
|
||||
private String requestParams;
|
||||
|
||||
@Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
|
||||
@NotNull(message = "用户 IP不能为空")
|
||||
private String userIp;
|
||||
|
||||
@Schema(description = "浏览器 UA", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
|
||||
@NotNull(message = "浏览器 UA不能为空")
|
||||
private String userAgent;
|
||||
|
||||
@Schema(description = "开始请求时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "开始请求时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime beginTime;
|
||||
|
||||
@Schema(description = "结束请求时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "结束请求时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "执行时长", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@NotNull(message = "执行时长不能为空")
|
||||
private Integer duration;
|
||||
|
||||
@Schema(description = "结果码", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@NotNull(message = "结果码不能为空")
|
||||
private Integer resultCode;
|
||||
|
||||
@Schema(description = "结果提示", example = "芋道源码,牛逼!")
|
||||
private String resultMsg;
|
||||
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
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.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* API 访问日志 Excel VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class ApiAccessLogExcelVO {
|
||||
|
||||
@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 LocalDateTime beginTime;
|
||||
|
||||
@ExcelProperty("结束请求时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@ExcelProperty("执行时长")
|
||||
private Integer duration;
|
||||
|
||||
@ExcelProperty("结果码")
|
||||
private Integer resultCode;
|
||||
|
||||
@ExcelProperty("结果提示")
|
||||
private String resultMsg;
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - API 访问日志 Excel 导出 Request VO,参数和 ApiAccessLogPageReqVO 是一致的")
|
||||
@Data
|
||||
public class ApiAccessLogExportReqVO {
|
||||
|
||||
@Schema(description = "用户编号", example = "666")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户类型", example = "2")
|
||||
private Integer userType;
|
||||
|
||||
@Schema(description = "应用名", example = "dashboard")
|
||||
private String applicationName;
|
||||
|
||||
@Schema(description = "请求地址,模糊匹配", example = "/xxx/yyy")
|
||||
private String requestUrl;
|
||||
|
||||
@Schema(description = "开始时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] beginTime;
|
||||
|
||||
@Schema(description = "执行时长,大于等于,单位:毫秒", example = "100")
|
||||
private Integer duration;
|
||||
|
||||
@Schema(description = "结果码", example = "0")
|
||||
private Integer resultCode;
|
||||
|
||||
}
|
@ -1,21 +1,81 @@
|
||||
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.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - API 访问日志 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ApiAccessLogRespVO extends ApiAccessLogBaseVO {
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ApiAccessLogRespVO {
|
||||
|
||||
@Schema(description = "日志主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("日志主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "66600cb6-7852-11eb-9439-0242ac130002")
|
||||
@ExcelProperty("链路追踪编号")
|
||||
private String traceId;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||
@ExcelProperty("用户编号")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户类型,参见 UserTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.USER_TYPE)
|
||||
private Integer userType;
|
||||
|
||||
@Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
|
||||
@ExcelProperty("应用名")
|
||||
private String applicationName;
|
||||
|
||||
@Schema(description = "请求方法名", requiredMode = Schema.RequiredMode.REQUIRED, example = "GET")
|
||||
@ExcelProperty("请求方法名")
|
||||
private String requestMethod;
|
||||
|
||||
@Schema(description = "请求地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "/xxx/yyy")
|
||||
@ExcelProperty("请求地址")
|
||||
private String requestUrl;
|
||||
|
||||
@Schema(description = "请求参数")
|
||||
@ExcelProperty("请求参数")
|
||||
private String requestParams;
|
||||
|
||||
@Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
|
||||
@ExcelProperty("用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@Schema(description = "浏览器 UA", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
|
||||
@ExcelProperty("浏览器 UA")
|
||||
private String userAgent;
|
||||
|
||||
@Schema(description = "开始请求时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("开始请求时间")
|
||||
private LocalDateTime beginTime;
|
||||
|
||||
@Schema(description = "结束请求时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("结束请求时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "执行时长", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@ExcelProperty("执行时长")
|
||||
private Integer duration;
|
||||
|
||||
@Schema(description = "结果码", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@ExcelProperty("结果码")
|
||||
private Integer resultCode;
|
||||
|
||||
@Schema(description = "结果提示", example = "芋道源码,牛逼!")
|
||||
@ExcelProperty("结果提示")
|
||||
private String resultMsg;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
@ -1,95 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
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 ApiErrorLogBaseVO {
|
||||
|
||||
@Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "66600cb6-7852-11eb-9439-0242ac130002")
|
||||
@NotNull(message = "链路追踪编号不能为空")
|
||||
private String traceId;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "用户类型不能为空")
|
||||
private Integer userType;
|
||||
|
||||
@Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String applicationName;
|
||||
|
||||
@Schema(description = "请求方法名", requiredMode = Schema.RequiredMode.REQUIRED, example = "GET")
|
||||
@NotNull(message = "请求方法名不能为空")
|
||||
private String requestMethod;
|
||||
|
||||
@Schema(description = "请求地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "/xx/yy")
|
||||
@NotNull(message = "请求地址不能为空")
|
||||
private String requestUrl;
|
||||
|
||||
@Schema(description = "请求参数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "请求参数不能为空")
|
||||
private String requestParams;
|
||||
|
||||
@Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
|
||||
@NotNull(message = "用户 IP不能为空")
|
||||
private String userIp;
|
||||
|
||||
@Schema(description = "浏览器 UA", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
|
||||
@NotNull(message = "浏览器 UA不能为空")
|
||||
private String userAgent;
|
||||
|
||||
@Schema(description = "异常发生时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常发生时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime exceptionTime;
|
||||
|
||||
@Schema(description = "异常名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常名不能为空")
|
||||
private String exceptionName;
|
||||
|
||||
@Schema(description = "异常导致的消息", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常导致的消息不能为空")
|
||||
private String exceptionMessage;
|
||||
|
||||
@Schema(description = "异常导致的根消息", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常导致的根消息不能为空")
|
||||
private String exceptionRootCauseMessage;
|
||||
|
||||
@Schema(description = "异常的栈轨迹", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常的栈轨迹不能为空")
|
||||
private String exceptionStackTrace;
|
||||
|
||||
@Schema(description = "异常发生的类全名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常发生的类全名不能为空")
|
||||
private String exceptionClassName;
|
||||
|
||||
@Schema(description = "异常发生的类文件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常发生的类文件不能为空")
|
||||
private String exceptionFileName;
|
||||
|
||||
@Schema(description = "异常发生的方法名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常发生的方法名不能为空")
|
||||
private String exceptionMethodName;
|
||||
|
||||
@Schema(description = "异常发生的方法所在行", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常发生的方法所在行不能为空")
|
||||
private Integer exceptionLineNumber;
|
||||
|
||||
@Schema(description = "处理状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@NotNull(message = "处理状态不能为空")
|
||||
private Integer processStatus;
|
||||
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
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 com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* API 错误日志 Excel VO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class ApiErrorLogExcelVO {
|
||||
|
||||
@ExcelProperty("编号")
|
||||
private Integer id;
|
||||
|
||||
@ExcelProperty("链路追踪编号")
|
||||
private String traceId;
|
||||
|
||||
@ExcelProperty("用户编号")
|
||||
private Integer userId;
|
||||
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(cn.iocoder.yudao.module.system.enums.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 LocalDateTime 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 LocalDateTime createTime;
|
||||
|
||||
@ExcelProperty(value = "处理状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.API_ERROR_LOG_PROCESS_STATUS)
|
||||
private Integer processStatus;
|
||||
|
||||
@ExcelProperty("处理时间")
|
||||
private LocalDateTime processTime;
|
||||
|
||||
@ExcelProperty("处理用户编号")
|
||||
private Integer processUserId;
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - API 错误日志 Excel 导出 Request VO,参数和 ApiErrorLogPageReqVO 是一致的")
|
||||
@Data
|
||||
public class ApiErrorLogExportReqVO {
|
||||
|
||||
@Schema(description = "用户编号", example = "666")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户类型", example = "1")
|
||||
private Integer userType;
|
||||
|
||||
@Schema(description = "应用名", example = "dashboard")
|
||||
private String applicationName;
|
||||
|
||||
@Schema(description = "请求地址", example = "/xx/yy")
|
||||
private String requestUrl;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@Schema(description = "异常发生时间")
|
||||
private LocalDateTime[] exceptionTime;
|
||||
|
||||
@Schema(description = "处理状态", example = "0")
|
||||
private Integer processStatus;
|
||||
|
||||
}
|
@ -1,28 +1,112 @@
|
||||
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 com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - API 错误日志 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ApiErrorLogRespVO extends ApiErrorLogBaseVO {
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ApiErrorLogRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("编号")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
@Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "66600cb6-7852-11eb-9439-0242ac130002")
|
||||
@ExcelProperty("链路追踪编号")
|
||||
private String traceId;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||
@ExcelProperty("用户编号")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "用户类型", converter = DictConvert.class)
|
||||
@DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_TYPE)
|
||||
private Integer userType;
|
||||
|
||||
@Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
|
||||
@ExcelProperty("应用名")
|
||||
private String applicationName;
|
||||
|
||||
@Schema(description = "请求方法名", requiredMode = Schema.RequiredMode.REQUIRED, example = "GET")
|
||||
@ExcelProperty("请求方法名")
|
||||
private String requestMethod;
|
||||
|
||||
@Schema(description = "请求地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "/xx/yy")
|
||||
@ExcelProperty("请求地址")
|
||||
private String requestUrl;
|
||||
|
||||
@Schema(description = "请求参数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("请求参数")
|
||||
private String requestParams;
|
||||
|
||||
@Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
|
||||
@ExcelProperty("用户 IP")
|
||||
private String userIp;
|
||||
|
||||
@Schema(description = "浏览器 UA", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
|
||||
@ExcelProperty("浏览器 UA")
|
||||
private String userAgent;
|
||||
|
||||
@Schema(description = "异常发生时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常发生时间")
|
||||
private LocalDateTime exceptionTime;
|
||||
|
||||
@Schema(description = "异常名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常名")
|
||||
private String exceptionName;
|
||||
|
||||
@Schema(description = "异常导致的消息", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常导致的消息")
|
||||
private String exceptionMessage;
|
||||
|
||||
@Schema(description = "异常导致的根消息", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常导致的根消息")
|
||||
private String exceptionRootCauseMessage;
|
||||
|
||||
@Schema(description = "异常的栈轨迹", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常的栈轨迹")
|
||||
private String exceptionStackTrace;
|
||||
|
||||
@Schema(description = "异常发生的类全名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常发生的类全名")
|
||||
private String exceptionClassName;
|
||||
|
||||
@Schema(description = "异常发生的类文件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常发生的类文件")
|
||||
private String exceptionFileName;
|
||||
|
||||
@Schema(description = "异常发生的方法名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常发生的方法名")
|
||||
private String exceptionMethodName;
|
||||
|
||||
@Schema(description = "异常发生的方法所在行", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("异常发生的方法所在行")
|
||||
private Integer exceptionLineNumber;
|
||||
|
||||
@Schema(description = "处理状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@ExcelProperty(value = "处理状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.API_ERROR_LOG_PROCESS_STATUS)
|
||||
private Integer processStatus;
|
||||
|
||||
@Schema(description = "处理时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("处理时间")
|
||||
private LocalDateTime processTime;
|
||||
|
||||
@Schema(description = "处理用户编号", example = "233")
|
||||
@ExcelProperty("处理用户编号")
|
||||
private Integer processUserId;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.config;
|
||||
|
||||
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 cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
@ -19,15 +17,12 @@ public interface ConfigConvert {
|
||||
|
||||
PageResult<ConfigRespVO> convertPage(PageResult<ConfigDO> page);
|
||||
|
||||
List<ConfigRespVO> convertList(List<ConfigDO> list);
|
||||
|
||||
@Mapping(source = "configKey", target = "key")
|
||||
ConfigRespVO convert(ConfigDO bean);
|
||||
|
||||
@Mapping(source = "key", target = "configKey")
|
||||
ConfigDO convert(ConfigCreateReqVO bean);
|
||||
|
||||
ConfigDO convert(ConfigUpdateReqVO bean);
|
||||
|
||||
@Mapping(source = "configKey", target = "key")
|
||||
List<ConfigExcelVO> convertList(List<ConfigDO> list);
|
||||
ConfigDO convert(ConfigSaveReqVO bean);
|
||||
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.db;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.*;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
|
||||
|
||||
/**
|
||||
* 数据源配置 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataSourceConfigConvert {
|
||||
|
||||
DataSourceConfigConvert INSTANCE = Mappers.getMapper(DataSourceConfigConvert.class);
|
||||
|
||||
DataSourceConfigDO convert(DataSourceConfigCreateReqVO bean);
|
||||
|
||||
DataSourceConfigDO convert(DataSourceConfigUpdateReqVO bean);
|
||||
|
||||
DataSourceConfigRespVO convert(DataSourceConfigDO bean);
|
||||
|
||||
List<DataSourceConfigRespVO> convertList(List<DataSourceConfigDO> list);
|
||||
|
||||
}
|
@ -1,16 +1,11 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.file;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileConfigDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件配置 Convert
|
||||
*
|
||||
@ -22,15 +17,6 @@ public interface FileConfigConvert {
|
||||
FileConfigConvert INSTANCE = Mappers.getMapper(FileConfigConvert.class);
|
||||
|
||||
@Mapping(target = "config", ignore = true)
|
||||
FileConfigDO convert(FileConfigCreateReqVO bean);
|
||||
|
||||
@Mapping(target = "config", ignore = true)
|
||||
FileConfigDO convert(FileConfigUpdateReqVO bean);
|
||||
|
||||
FileConfigRespVO convert(FileConfigDO bean);
|
||||
|
||||
List<FileConfigRespVO> convertList(List<FileConfigDO> list);
|
||||
|
||||
PageResult<FileConfigRespVO> convertPage(PageResult<FileConfigDO> page);
|
||||
FileConfigDO convert(FileConfigSaveReqVO bean);
|
||||
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.file;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileRespVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface FileConvert {
|
||||
|
||||
FileConvert INSTANCE = Mappers.getMapper(FileConvert.class);
|
||||
|
||||
FileRespVO convert(FileDO bean);
|
||||
|
||||
PageResult<FileRespVO> convertPage(PageResult<FileDO> page);
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
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.JobCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定时任务 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface JobConvert {
|
||||
|
||||
JobConvert INSTANCE = Mappers.getMapper(JobConvert.class);
|
||||
|
||||
JobDO convert(JobCreateReqVO bean);
|
||||
|
||||
JobDO convert(JobUpdateReqVO bean);
|
||||
|
||||
JobRespVO convert(JobDO bean);
|
||||
|
||||
List<JobRespVO> convertList(List<JobDO> list);
|
||||
|
||||
PageResult<JobRespVO> convertPage(PageResult<JobDO> page);
|
||||
|
||||
List<JobExcelVO> convertList02(List<JobDO> list);
|
||||
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
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.JobLogExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogRespVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定时任务日志 Convert
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface JobLogConvert {
|
||||
|
||||
JobLogConvert INSTANCE = Mappers.getMapper(JobLogConvert.class);
|
||||
|
||||
JobLogRespVO convert(JobLogDO bean);
|
||||
|
||||
List<JobLogRespVO> convertList(List<JobLogDO> list);
|
||||
|
||||
PageResult<JobLogRespVO> convertPage(PageResult<JobLogDO> page);
|
||||
|
||||
List<JobLogExcelVO> convertList02(List<JobLogDO> list);
|
||||
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 访问日志 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ApiAccessLogConvert {
|
||||
|
||||
ApiAccessLogConvert INSTANCE = Mappers.getMapper(ApiAccessLogConvert.class);
|
||||
|
||||
ApiAccessLogRespVO convert(ApiAccessLogDO bean);
|
||||
|
||||
List<ApiAccessLogRespVO> convertList(List<ApiAccessLogDO> list);
|
||||
|
||||
PageResult<ApiAccessLogRespVO> convertPage(PageResult<ApiAccessLogDO> page);
|
||||
|
||||
List<ApiAccessLogExcelVO> convertList02(List<ApiAccessLogDO> list);
|
||||
|
||||
ApiAccessLogDO convert(ApiAccessLogCreateReqDTO bean);
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package cn.iocoder.yudao.module.infra.convert.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExcelVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogRespVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 错误日志 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface ApiErrorLogConvert {
|
||||
|
||||
ApiErrorLogConvert INSTANCE = Mappers.getMapper(ApiErrorLogConvert.class);
|
||||
|
||||
ApiErrorLogRespVO convert(ApiErrorLogDO bean);
|
||||
|
||||
PageResult<ApiErrorLogRespVO> convertPage(PageResult<ApiErrorLogDO> page);
|
||||
|
||||
List<ApiErrorLogExcelVO> convertList02(List<ApiErrorLogDO> list);
|
||||
|
||||
ApiErrorLogDO convert(ApiErrorLogCreateReqDTO bean);
|
||||
|
||||
}
|
@ -3,13 +3,10 @@ package cn.iocoder.yudao.module.infra.dal.mysql.config;
|
||||
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 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.dal.dataobject.config.ConfigDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ConfigMapper extends BaseMapperX<ConfigDO> {
|
||||
|
||||
@ -25,12 +22,4 @@ public interface ConfigMapper extends BaseMapperX<ConfigDO> {
|
||||
.betweenIfPresent(ConfigDO::getCreateTime, reqVO.getCreateTime()));
|
||||
}
|
||||
|
||||
default List<ConfigDO> selectList(ConfigExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<ConfigDO>()
|
||||
.likeIfPresent(ConfigDO::getName, reqVO.getName())
|
||||
.likeIfPresent(ConfigDO::getConfigKey, reqVO.getKey())
|
||||
.eqIfPresent(ConfigDO::getType, reqVO.getType())
|
||||
.betweenIfPresent(ConfigDO::getCreateTime, reqVO.getCreateTime()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ 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.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
@ -11,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 任务日志 Mapper
|
||||
@ -32,17 +30,6 @@ public interface JobLogMapper extends BaseMapperX<JobLogDO> {
|
||||
);
|
||||
}
|
||||
|
||||
default List<JobLogDO> selectList(JobLogExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<JobLogDO>()
|
||||
.eqIfPresent(JobLogDO::getJobId, reqVO.getJobId())
|
||||
.likeIfPresent(JobLogDO::getHandlerName, reqVO.getHandlerName())
|
||||
.geIfPresent(JobLogDO::getBeginTime, reqVO.getBeginTime())
|
||||
.leIfPresent(JobLogDO::getEndTime, reqVO.getEndTime())
|
||||
.eqIfPresent(JobLogDO::getStatus, reqVO.getStatus())
|
||||
.orderByDesc(JobLogDO::getId) // ID 倒序
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 物理删除指定时间之前的日志
|
||||
*
|
||||
|
@ -1,15 +1,12 @@
|
||||
package cn.iocoder.yudao.module.infra.dal.mysql.job;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO;
|
||||
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 cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定时任务 Mapper
|
||||
*
|
||||
@ -30,12 +27,4 @@ public interface JobMapper extends BaseMapperX<JobDO> {
|
||||
);
|
||||
}
|
||||
|
||||
default List<JobDO> selectList(JobExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<JobDO>()
|
||||
.likeIfPresent(JobDO::getName, reqVO.getName())
|
||||
.eqIfPresent(JobDO::getStatus, reqVO.getStatus())
|
||||
.likeIfPresent(JobDO::getHandlerName, reqVO.getHandlerName())
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.infra.dal.mysql.logger;
|
||||
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 cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
@ -11,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 访问日志 Mapper
|
||||
@ -34,19 +32,6 @@ public interface ApiAccessLogMapper extends BaseMapperX<ApiAccessLogDO> {
|
||||
);
|
||||
}
|
||||
|
||||
default List<ApiAccessLogDO> selectList(ApiAccessLogExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<ApiAccessLogDO>()
|
||||
.eqIfPresent(ApiAccessLogDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(ApiAccessLogDO::getUserType, reqVO.getUserType())
|
||||
.eqIfPresent(ApiAccessLogDO::getApplicationName, reqVO.getApplicationName())
|
||||
.likeIfPresent(ApiAccessLogDO::getRequestUrl, reqVO.getRequestUrl())
|
||||
.betweenIfPresent(ApiAccessLogDO::getBeginTime, reqVO.getBeginTime())
|
||||
.geIfPresent(ApiAccessLogDO::getDuration, reqVO.getDuration())
|
||||
.eqIfPresent(ApiAccessLogDO::getResultCode, reqVO.getResultCode())
|
||||
.orderByDesc(ApiAccessLogDO::getId)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 物理删除指定时间之前的日志
|
||||
*
|
||||
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.infra.dal.mysql.logger;
|
||||
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 cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
@ -11,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 错误日志 Mapper
|
||||
@ -33,18 +31,6 @@ public interface ApiErrorLogMapper extends BaseMapperX<ApiErrorLogDO> {
|
||||
);
|
||||
}
|
||||
|
||||
default List<ApiErrorLogDO> selectList(ApiErrorLogExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<ApiErrorLogDO>()
|
||||
.eqIfPresent(ApiErrorLogDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(ApiErrorLogDO::getUserType, reqVO.getUserType())
|
||||
.eqIfPresent(ApiErrorLogDO::getApplicationName, reqVO.getApplicationName())
|
||||
.likeIfPresent(ApiErrorLogDO::getRequestUrl, reqVO.getRequestUrl())
|
||||
.betweenIfPresent(ApiErrorLogDO::getExceptionTime, reqVO.getExceptionTime())
|
||||
.eqIfPresent(ApiErrorLogDO::getProcessStatus, reqVO.getProcessStatus())
|
||||
.orderByDesc(ApiErrorLogDO::getId)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 物理删除指定时间之前的日志
|
||||
*
|
||||
|
@ -1,14 +1,11 @@
|
||||
package cn.iocoder.yudao.module.infra.service.config;
|
||||
|
||||
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.controller.admin.config.vo.ConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 参数配置 Service 接口
|
||||
@ -20,17 +17,17 @@ public interface ConfigService {
|
||||
/**
|
||||
* 创建参数配置
|
||||
*
|
||||
* @param reqVO 创建信息
|
||||
* @param createReqVO 创建信息
|
||||
* @return 配置编号
|
||||
*/
|
||||
Long createConfig(@Valid ConfigCreateReqVO reqVO);
|
||||
Long createConfig(@Valid ConfigSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新参数配置
|
||||
*
|
||||
* @param reqVO 更新信息
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateConfig(@Valid ConfigUpdateReqVO reqVO);
|
||||
void updateConfig(@Valid ConfigSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除参数配置
|
||||
@ -63,13 +60,4 @@ public interface ConfigService {
|
||||
*/
|
||||
PageResult<ConfigDO> getConfigPage(@Valid ConfigPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获得参数配置列表
|
||||
*
|
||||
* @param reqVO 列表
|
||||
* @return 列表
|
||||
*/
|
||||
List<ConfigDO> getConfigList(@Valid ConfigExportReqVO reqVO);
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
package cn.iocoder.yudao.module.infra.service.config;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.controller.admin.config.vo.ConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.config.ConfigConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigMapper;
|
||||
@ -16,7 +13,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
|
||||
@ -33,22 +29,26 @@ public class ConfigServiceImpl implements ConfigService {
|
||||
private ConfigMapper configMapper;
|
||||
|
||||
@Override
|
||||
public Long createConfig(ConfigCreateReqVO reqVO) {
|
||||
// 校验正确性
|
||||
validateConfigForCreateOrUpdate(null, reqVO.getKey());
|
||||
public Long createConfig(ConfigSaveReqVO createReqVO) {
|
||||
// 校验参数配置 key 的唯一性
|
||||
validateConfigKeyUnique(null, createReqVO.getKey());
|
||||
|
||||
// 插入参数配置
|
||||
ConfigDO config = ConfigConvert.INSTANCE.convert(reqVO);
|
||||
ConfigDO config = ConfigConvert.INSTANCE.convert(createReqVO);
|
||||
config.setType(ConfigTypeEnum.CUSTOM.getType());
|
||||
configMapper.insert(config);
|
||||
return config.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateConfig(ConfigUpdateReqVO reqVO) {
|
||||
// 校验正确性
|
||||
validateConfigForCreateOrUpdate(reqVO.getId(), null); // 不允许更新 key
|
||||
public void updateConfig(ConfigSaveReqVO updateReqVO) {
|
||||
// 校验自己存在
|
||||
validateConfigExists(updateReqVO.getId());
|
||||
// 校验参数配置 key 的唯一性
|
||||
validateConfigKeyUnique(updateReqVO.getId(), updateReqVO.getKey());
|
||||
|
||||
// 更新参数配置
|
||||
ConfigDO updateObj = ConfigConvert.INSTANCE.convert(reqVO);
|
||||
ConfigDO updateObj = ConfigConvert.INSTANCE.convert(updateReqVO);
|
||||
configMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@ -75,22 +75,8 @@ public class ConfigServiceImpl implements ConfigService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ConfigDO> getConfigPage(ConfigPageReqVO reqVO) {
|
||||
return configMapper.selectPage(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigDO> getConfigList(ConfigExportReqVO reqVO) {
|
||||
return configMapper.selectList(reqVO);
|
||||
}
|
||||
|
||||
private void validateConfigForCreateOrUpdate(Long id, String key) {
|
||||
// 校验自己存在
|
||||
validateConfigExists(id);
|
||||
// 校验参数配置 key 的唯一性
|
||||
if (StrUtil.isNotEmpty(key)) {
|
||||
validateConfigKeyUnique(id, key);
|
||||
}
|
||||
public PageResult<ConfigDO> getConfigPage(ConfigPageReqVO pageReqVO) {
|
||||
return configMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
@ -1,7 +1,6 @@
|
||||
package cn.iocoder.yudao.module.infra.service.db;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@ -20,14 +19,14 @@ public interface DataSourceConfigService {
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDataSourceConfig(@Valid DataSourceConfigCreateReqVO createReqVO);
|
||||
Long createDataSourceConfig(@Valid DataSourceConfigSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新数据源配置
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDataSourceConfig(@Valid DataSourceConfigUpdateReqVO updateReqVO);
|
||||
void updateDataSourceConfig(@Valid DataSourceConfigSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除数据源配置
|
||||
|
@ -1,9 +1,8 @@
|
||||
package cn.iocoder.yudao.module.infra.service.db;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.JdbcUtils;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.db.DataSourceConfigConvert;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.db.DataSourceConfigMapper;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
||||
@ -35,21 +34,21 @@ public class DataSourceConfigServiceImpl implements DataSourceConfigService {
|
||||
private DynamicDataSourceProperties dynamicDataSourceProperties;
|
||||
|
||||
@Override
|
||||
public Long createDataSourceConfig(DataSourceConfigCreateReqVO createReqVO) {
|
||||
DataSourceConfigDO dataSourceConfig = DataSourceConfigConvert.INSTANCE.convert(createReqVO);
|
||||
validateConnectionOK(dataSourceConfig);
|
||||
public Long createDataSourceConfig(DataSourceConfigSaveReqVO createReqVO) {
|
||||
DataSourceConfigDO config = BeanUtils.toBean(createReqVO, DataSourceConfigDO.class);
|
||||
validateConnectionOK(config);
|
||||
|
||||
// 插入
|
||||
dataSourceConfigMapper.insert(dataSourceConfig);
|
||||
dataSourceConfigMapper.insert(config);
|
||||
// 返回
|
||||
return dataSourceConfig.getId();
|
||||
return config.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDataSourceConfig(DataSourceConfigUpdateReqVO updateReqVO) {
|
||||
public void updateDataSourceConfig(DataSourceConfigSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDataSourceConfigExists(updateReqVO.getId());
|
||||
DataSourceConfigDO updateObj = DataSourceConfigConvert.INSTANCE.convert(updateReqVO);
|
||||
DataSourceConfigDO updateObj = BeanUtils.toBean(updateReqVO, DataSourceConfigDO.class);
|
||||
validateConnectionOK(updateObj);
|
||||
|
||||
// 更新
|
||||
|
@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.infra.service.file;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.file.core.client.FileClient;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileConfigDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@ -22,14 +21,14 @@ public interface FileConfigService {
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createFileConfig(@Valid FileConfigCreateReqVO createReqVO);
|
||||
Long createFileConfig(@Valid FileConfigSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新文件配置
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateFileConfig(@Valid FileConfigUpdateReqVO updateReqVO);
|
||||
void updateFileConfig(@Valid FileConfigSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 更新文件配置为 Master
|
||||
|
@ -4,14 +4,14 @@ import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||
import cn.iocoder.yudao.framework.file.core.client.FileClient;
|
||||
import cn.iocoder.yudao.framework.file.core.client.FileClientConfig;
|
||||
import cn.iocoder.yudao.framework.file.core.client.FileClientFactory;
|
||||
import cn.iocoder.yudao.framework.file.core.enums.FileStorageEnum;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.file.FileConfigConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.file.FileConfigMapper;
|
||||
@ -63,7 +63,7 @@ public class FileConfigServiceImpl implements FileConfigService {
|
||||
return fileClientFactory.getFileClient(null == config ? id : config.getId());
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@Resource
|
||||
private FileClientFactory fileClientFactory;
|
||||
@ -75,7 +75,7 @@ public class FileConfigServiceImpl implements FileConfigService {
|
||||
private Validator validator;
|
||||
|
||||
@Override
|
||||
public Long createFileConfig(FileConfigCreateReqVO createReqVO) {
|
||||
public Long createFileConfig(FileConfigSaveReqVO createReqVO) {
|
||||
FileConfigDO fileConfig = FileConfigConvert.INSTANCE.convert(createReqVO)
|
||||
.setConfig(parseClientConfig(createReqVO.getStorage(), createReqVO.getConfig()))
|
||||
.setMaster(false); // 默认非 master
|
||||
@ -84,7 +84,7 @@ public class FileConfigServiceImpl implements FileConfigService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFileConfig(FileConfigUpdateReqVO updateReqVO) {
|
||||
public void updateFileConfig(FileConfigSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
FileConfigDO config = validateFileConfigExists(updateReqVO.getId());
|
||||
// 更新
|
||||
@ -126,7 +126,7 @@ public class FileConfigServiceImpl implements FileConfigService {
|
||||
// 校验存在
|
||||
FileConfigDO config = validateFileConfigExists(id);
|
||||
if (Boolean.TRUE.equals(config.getMaster())) {
|
||||
throw exception(FILE_CONFIG_DELETE_FAIL_MASTER);
|
||||
throw exception(FILE_CONFIG_DELETE_FAIL_MASTER);
|
||||
}
|
||||
// 删除
|
||||
fileConfigMapper.deleteById(id);
|
||||
|
@ -2,13 +2,9 @@ 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.JobLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Job 日志 Service 接口
|
||||
*
|
||||
@ -24,14 +20,6 @@ public interface JobLogService extends JobLogFrameworkService {
|
||||
*/
|
||||
JobLogDO getJobLog(Long id);
|
||||
|
||||
/**
|
||||
* 获得定时任务列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 定时任务列表
|
||||
*/
|
||||
List<JobLogDO> getJobLogList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得定时任务分页
|
||||
*
|
||||
@ -40,14 +28,6 @@ public interface JobLogService extends JobLogFrameworkService {
|
||||
*/
|
||||
PageResult<JobLogDO> getJobLogPage(JobLogPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得定时任务列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 定时任务分页
|
||||
*/
|
||||
List<JobLogDO> getJobLogList(JobLogExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 清理 exceedDay 天前的任务日志
|
||||
*
|
||||
|
@ -1,7 +1,6 @@
|
||||
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.log.JobLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper;
|
||||
@ -13,8 +12,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Job 日志 Service 实现类
|
||||
@ -30,8 +27,10 @@ public class JobLogServiceImpl implements JobLogService {
|
||||
private JobLogMapper jobLogMapper;
|
||||
|
||||
@Override
|
||||
public Long createJobLog(Long jobId, LocalDateTime beginTime, String jobHandlerName, String jobHandlerParam, Integer executeIndex) {
|
||||
JobLogDO log = JobLogDO.builder().jobId(jobId).handlerName(jobHandlerName).handlerParam(jobHandlerParam).executeIndex(executeIndex)
|
||||
public Long createJobLog(Long jobId, LocalDateTime beginTime,
|
||||
String jobHandlerName, String jobHandlerParam, Integer executeIndex) {
|
||||
JobLogDO log = JobLogDO.builder().jobId(jobId).handlerName(jobHandlerName)
|
||||
.handlerParam(jobHandlerParam).executeIndex(executeIndex)
|
||||
.beginTime(beginTime).status(JobLogStatusEnum.RUNNING.getStatus()).build();
|
||||
jobLogMapper.insert(log);
|
||||
return log.getId();
|
||||
@ -42,7 +41,8 @@ public class JobLogServiceImpl implements JobLogService {
|
||||
public void updateJobLogResultAsync(Long logId, LocalDateTime endTime, Integer duration, boolean success, String result) {
|
||||
try {
|
||||
JobLogDO updateObj = JobLogDO.builder().id(logId).endTime(endTime).duration(duration)
|
||||
.status(success ? JobLogStatusEnum.SUCCESS.getStatus() : JobLogStatusEnum.FAILURE.getStatus()).result(result).build();
|
||||
.status(success ? JobLogStatusEnum.SUCCESS.getStatus() : JobLogStatusEnum.FAILURE.getStatus())
|
||||
.result(result).build();
|
||||
jobLogMapper.updateById(updateObj);
|
||||
} catch (Exception ex) {
|
||||
log.error("[updateJobLogResultAsync][logId({}) endTime({}) duration({}) success({}) result({})]",
|
||||
@ -72,19 +72,9 @@ public class JobLogServiceImpl implements JobLogService {
|
||||
return jobLogMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JobLogDO> getJobLogList(Collection<Long> ids) {
|
||||
return jobLogMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<JobLogDO> getJobLogPage(JobLogPageReqVO pageReqVO) {
|
||||
return jobLogMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JobLogDO> getJobLogList(JobLogExportReqVO exportReqVO) {
|
||||
return jobLogMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
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.JobCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO;
|
||||
import org.quartz.SchedulerException;
|
||||
|
||||
@ -25,14 +23,14 @@ public interface JobService {
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createJob(@Valid JobCreateReqVO createReqVO) throws SchedulerException;
|
||||
Long createJob(@Valid JobSaveReqVO createReqVO) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 更新定时任务
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateJob(@Valid JobUpdateReqVO updateReqVO) throws SchedulerException;
|
||||
void updateJob(@Valid JobSaveReqVO updateReqVO) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 更新定时任务的状态
|
||||
@ -80,12 +78,4 @@ public interface JobService {
|
||||
*/
|
||||
PageResult<JobDO> getJobPage(JobPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得定时任务列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 定时任务分页
|
||||
*/
|
||||
List<JobDO> getJobList(JobExportReqVO exportReqVO);
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package cn.iocoder.yudao.module.infra.service.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
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.JobCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.job.JobConvert;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.job.JobMapper;
|
||||
import cn.iocoder.yudao.module.infra.enums.job.JobStatusEnum;
|
||||
@ -21,8 +19,8 @@ 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.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.containsAny;
|
||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 定时任务 Service 实现类
|
||||
@ -41,14 +39,14 @@ public class JobServiceImpl implements JobService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createJob(JobCreateReqVO createReqVO) throws SchedulerException {
|
||||
public Long createJob(JobSaveReqVO createReqVO) throws SchedulerException {
|
||||
validateCronExpression(createReqVO.getCronExpression());
|
||||
// 校验唯一性
|
||||
if (jobMapper.selectByHandlerName(createReqVO.getHandlerName()) != null) {
|
||||
throw exception(JOB_HANDLER_EXISTS);
|
||||
}
|
||||
// 插入
|
||||
JobDO job = JobConvert.INSTANCE.convert(createReqVO);
|
||||
JobDO job = BeanUtils.toBean(createReqVO, JobDO.class);
|
||||
job.setStatus(JobStatusEnum.INIT.getStatus());
|
||||
fillJobMonitorTimeoutEmpty(job);
|
||||
jobMapper.insert(job);
|
||||
@ -66,7 +64,7 @@ public class JobServiceImpl implements JobService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateJob(JobUpdateReqVO updateReqVO) throws SchedulerException {
|
||||
public void updateJob(JobSaveReqVO updateReqVO) throws SchedulerException {
|
||||
validateCronExpression(updateReqVO.getCronExpression());
|
||||
// 校验存在
|
||||
JobDO job = validateJobExists(updateReqVO.getId());
|
||||
@ -75,7 +73,7 @@ public class JobServiceImpl implements JobService {
|
||||
throw exception(JOB_UPDATE_ONLY_NORMAL_STATUS);
|
||||
}
|
||||
// 更新
|
||||
JobDO updateObj = JobConvert.INSTANCE.convert(updateReqVO);
|
||||
JobDO updateObj = BeanUtils.toBean(updateReqVO, JobDO.class);
|
||||
fillJobMonitorTimeoutEmpty(updateObj);
|
||||
jobMapper.updateById(updateObj);
|
||||
|
||||
@ -159,11 +157,6 @@ public class JobServiceImpl implements JobService {
|
||||
return jobMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JobDO> getJobList(JobExportReqVO exportReqVO) {
|
||||
return jobMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
private static void fillJobMonitorTimeoutEmpty(JobDO job) {
|
||||
if (job.getMonitorTimeout() == null) {
|
||||
job.setMonitorTimeout(0);
|
||||
|
@ -2,12 +2,9 @@ package cn.iocoder.yudao.module.infra.service.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 访问日志 Service 接口
|
||||
*
|
||||
@ -30,14 +27,6 @@ public interface ApiAccessLogService {
|
||||
*/
|
||||
PageResult<ApiAccessLogDO> getApiAccessLogPage(ApiAccessLogPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得 API 访问日志列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return API 访问日志分页
|
||||
*/
|
||||
List<ApiAccessLogDO> getApiAccessLogList(ApiAccessLogExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 清理 exceedDay 天前的访问日志
|
||||
*
|
||||
|
@ -1,10 +1,9 @@
|
||||
package cn.iocoder.yudao.module.infra.service.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.logger.ApiAccessLogConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiAccessLogMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -13,7 +12,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 访问日志 Service 实现类
|
||||
@ -30,7 +28,7 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService {
|
||||
|
||||
@Override
|
||||
public void createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) {
|
||||
ApiAccessLogDO apiAccessLog = ApiAccessLogConvert.INSTANCE.convert(createDTO);
|
||||
ApiAccessLogDO apiAccessLog = BeanUtils.toBean(createDTO, ApiAccessLogDO.class);
|
||||
apiAccessLogMapper.insert(apiAccessLog);
|
||||
}
|
||||
|
||||
@ -39,11 +37,6 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService {
|
||||
return apiAccessLogMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApiAccessLogDO> getApiAccessLogList(ApiAccessLogExportReqVO exportReqVO) {
|
||||
return apiAccessLogMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public Integer cleanAccessLog(Integer exceedDay, Integer deleteLimit) {
|
||||
|
@ -2,12 +2,9 @@ package cn.iocoder.yudao.module.infra.service.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* API 错误日志 Service 接口
|
||||
*
|
||||
@ -30,14 +27,6 @@ public interface ApiErrorLogService {
|
||||
*/
|
||||
PageResult<ApiErrorLogDO> getApiErrorLogPage(ApiErrorLogPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得 API 错误日志列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return API 错误日志分页
|
||||
*/
|
||||
List<ApiErrorLogDO> getApiErrorLogList(ApiErrorLogExportReqVO exportReqVO);
|
||||
|
||||
/**
|
||||
* 更新 API 错误日志已处理
|
||||
*
|
||||
|
@ -1,10 +1,9 @@
|
||||
package cn.iocoder.yudao.module.infra.service.logger;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.convert.logger.ApiErrorLogConvert;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper;
|
||||
import cn.iocoder.yudao.module.infra.enums.logger.ApiErrorLogProcessStatusEnum;
|
||||
@ -14,11 +13,9 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_NOT_FOUND;
|
||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_PROCESSED;
|
||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* API 错误日志 Service 实现类
|
||||
@ -35,7 +32,7 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService {
|
||||
|
||||
@Override
|
||||
public void createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) {
|
||||
ApiErrorLogDO apiErrorLog = ApiErrorLogConvert.INSTANCE.convert(createDTO)
|
||||
ApiErrorLogDO apiErrorLog = BeanUtils.toBean(createDTO, ApiErrorLogDO.class)
|
||||
.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
|
||||
apiErrorLogMapper.insert(apiErrorLog);
|
||||
}
|
||||
@ -45,11 +42,6 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService {
|
||||
return apiErrorLogMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApiErrorLogDO> getApiErrorLogList(ApiErrorLogExportReqVO exportReqVO) {
|
||||
return apiErrorLogMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateApiErrorLogProcess(Long id, Integer processStatus, Long processUserId) {
|
||||
ApiErrorLogDO errorLog = apiErrorLogMapper.selectById(id);
|
||||
|
@ -4,10 +4,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
|
||||
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.controller.admin.config.vo.ConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigMapper;
|
||||
import cn.iocoder.yudao.module.infra.enums.config.ConfigTypeEnum;
|
||||
@ -15,7 +13,6 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||
@ -40,7 +37,8 @@ public class ConfigServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testCreateConfig_success() {
|
||||
// 准备参数
|
||||
ConfigCreateReqVO reqVO = randomPojo(ConfigCreateReqVO.class);
|
||||
ConfigSaveReqVO reqVO = randomPojo(ConfigSaveReqVO.class)
|
||||
.setId(null); // 防止 id 被赋值,导致唯一性校验失败
|
||||
|
||||
// 调用
|
||||
Long configId = configService.createConfig(reqVO);
|
||||
@ -48,7 +46,7 @@ public class ConfigServiceImplTest extends BaseDbUnitTest {
|
||||
assertNotNull(configId);
|
||||
// 校验记录的属性是否正确
|
||||
ConfigDO config = configMapper.selectById(configId);
|
||||
assertPojoEquals(reqVO, config);
|
||||
assertPojoEquals(reqVO, config, "id");
|
||||
assertEquals(ConfigTypeEnum.CUSTOM.getType(), config.getType());
|
||||
}
|
||||
|
||||
@ -58,7 +56,7 @@ public class ConfigServiceImplTest extends BaseDbUnitTest {
|
||||
ConfigDO dbConfig = randomConfigDO();
|
||||
configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
ConfigUpdateReqVO reqVO = randomPojo(ConfigUpdateReqVO.class, o -> {
|
||||
ConfigSaveReqVO reqVO = randomPojo(ConfigSaveReqVO.class, o -> {
|
||||
o.setId(dbConfig.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
@ -178,38 +176,6 @@ public class ConfigServiceImplTest extends BaseDbUnitTest {
|
||||
assertPojoEquals(dbConfig, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConfigList() {
|
||||
// mock 数据
|
||||
ConfigDO dbConfig = randomConfigDO(o -> { // 等会查询到
|
||||
o.setName("芋艿");
|
||||
o.setConfigKey("yunai");
|
||||
o.setType(ConfigTypeEnum.SYSTEM.getType());
|
||||
o.setCreateTime(buildTime(2021, 2, 1));
|
||||
});
|
||||
configMapper.insert(dbConfig);
|
||||
// 测试 name 不匹配
|
||||
configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setName("土豆")));
|
||||
// 测试 key 不匹配
|
||||
configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setConfigKey("tudou")));
|
||||
// 测试 type 不匹配
|
||||
configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setType(ConfigTypeEnum.CUSTOM.getType())));
|
||||
// 测试 createTime 不匹配
|
||||
configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setCreateTime(buildTime(2021, 1, 1))));
|
||||
// 准备参数
|
||||
ConfigExportReqVO reqVO = new ConfigExportReqVO();
|
||||
reqVO.setName("艿");
|
||||
reqVO.setKey("nai");
|
||||
reqVO.setType(ConfigTypeEnum.SYSTEM.getType());
|
||||
reqVO.setCreateTime(buildBetweenTime(2021, 1, 15, 2021, 2, 15));
|
||||
|
||||
// 调用
|
||||
List<ConfigDO> list = configService.getConfigList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbConfig, list.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConfig() {
|
||||
// mock 数据
|
||||
|
@ -6,8 +6,7 @@ import cn.hutool.crypto.symmetric.AES;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.type.EncryptTypeHandler;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.JdbcUtils;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.db.DataSourceConfigMapper;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
||||
@ -70,7 +69,8 @@ public class DataSourceConfigServiceImplTest extends BaseDbUnitTest {
|
||||
public void testCreateDataSourceConfig_success() {
|
||||
try (MockedStatic<JdbcUtils> databaseUtilsMock = mockStatic(JdbcUtils.class)) {
|
||||
// 准备参数
|
||||
DataSourceConfigCreateReqVO reqVO = randomPojo(DataSourceConfigCreateReqVO.class);
|
||||
DataSourceConfigSaveReqVO reqVO = randomPojo(DataSourceConfigSaveReqVO.class)
|
||||
.setId(null); // 避免 id 被设置
|
||||
// mock 方法
|
||||
databaseUtilsMock.when(() -> JdbcUtils.isConnectionOK(eq(reqVO.getUrl()),
|
||||
eq(reqVO.getUsername()), eq(reqVO.getPassword()))).thenReturn(true);
|
||||
@ -81,7 +81,7 @@ public class DataSourceConfigServiceImplTest extends BaseDbUnitTest {
|
||||
assertNotNull(dataSourceConfigId);
|
||||
// 校验记录的属性是否正确
|
||||
DataSourceConfigDO dataSourceConfig = dataSourceConfigMapper.selectById(dataSourceConfigId);
|
||||
assertPojoEquals(reqVO, dataSourceConfig);
|
||||
assertPojoEquals(reqVO, dataSourceConfig, "id");
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class DataSourceConfigServiceImplTest extends BaseDbUnitTest {
|
||||
DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class);
|
||||
dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
DataSourceConfigUpdateReqVO reqVO = randomPojo(DataSourceConfigUpdateReqVO.class, o -> {
|
||||
DataSourceConfigSaveReqVO reqVO = randomPojo(DataSourceConfigSaveReqVO.class, o -> {
|
||||
o.setId(dbDataSourceConfig.getId()); // 设置更新的 ID
|
||||
});
|
||||
// mock 方法
|
||||
@ -110,7 +110,7 @@ public class DataSourceConfigServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testUpdateDataSourceConfig_notExists() {
|
||||
// 准备参数
|
||||
DataSourceConfigUpdateReqVO reqVO = randomPojo(DataSourceConfigUpdateReqVO.class);
|
||||
DataSourceConfigSaveReqVO reqVO = randomPojo(DataSourceConfigSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> dataSourceConfigService.updateDataSourceConfig(reqVO), DATA_SOURCE_CONFIG_NOT_EXISTS);
|
||||
|
@ -11,9 +11,8 @@ import cn.iocoder.yudao.framework.file.core.client.local.LocalFileClient;
|
||||
import cn.iocoder.yudao.framework.file.core.client.local.LocalFileClientConfig;
|
||||
import cn.iocoder.yudao.framework.file.core.enums.FileStorageEnum;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.file.FileConfigMapper;
|
||||
import lombok.Data;
|
||||
@ -41,10 +40,10 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link FileConfigServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
* {@link FileConfigServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Import(FileConfigServiceImpl.class)
|
||||
public class FileConfigServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@ -64,8 +63,9 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest {
|
||||
// 准备参数
|
||||
Map<String, Object> config = MapUtil.<String, Object>builder().put("basePath", "/yunai")
|
||||
.put("domain", "https://www.iocoder.cn").build();
|
||||
FileConfigCreateReqVO reqVO = randomPojo(FileConfigCreateReqVO.class,
|
||||
o -> o.setStorage(FileStorageEnum.LOCAL.getStorage()).setConfig(config));
|
||||
FileConfigSaveReqVO reqVO = randomPojo(FileConfigSaveReqVO.class,
|
||||
o -> o.setStorage(FileStorageEnum.LOCAL.getStorage()).setConfig(config))
|
||||
.setId(null); // 避免 id 被赋值
|
||||
|
||||
// 调用
|
||||
Long fileConfigId = fileConfigService.createFileConfig(reqVO);
|
||||
@ -73,7 +73,7 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest {
|
||||
assertNotNull(fileConfigId);
|
||||
// 校验记录的属性是否正确
|
||||
FileConfigDO fileConfig = fileConfigMapper.selectById(fileConfigId);
|
||||
assertPojoEquals(reqVO, fileConfig, "config");
|
||||
assertPojoEquals(reqVO, fileConfig, "id", "config");
|
||||
assertFalse(fileConfig.getMaster());
|
||||
assertEquals("/yunai", ((LocalFileClientConfig) fileConfig.getConfig()).getBasePath());
|
||||
assertEquals("https://www.iocoder.cn", ((LocalFileClientConfig) fileConfig.getConfig()).getDomain());
|
||||
@ -88,8 +88,9 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest {
|
||||
.setConfig(new LocalFileClientConfig().setBasePath("/yunai").setDomain("https://www.iocoder.cn")));
|
||||
fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
FileConfigUpdateReqVO reqVO = randomPojo(FileConfigUpdateReqVO.class, o -> {
|
||||
FileConfigSaveReqVO reqVO = randomPojo(FileConfigSaveReqVO.class, o -> {
|
||||
o.setId(dbFileConfig.getId()); // 设置更新的 ID
|
||||
o.setStorage(FileStorageEnum.LOCAL.getStorage());
|
||||
Map<String, Object> config = MapUtil.<String, Object>builder().put("basePath", "/yunai2")
|
||||
.put("domain", "https://doc.iocoder.cn").build();
|
||||
o.setConfig(config);
|
||||
@ -109,7 +110,7 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testUpdateFileConfig_notExists() {
|
||||
// 准备参数
|
||||
FileConfigUpdateReqVO reqVO = randomPojo(FileConfigUpdateReqVO.class);
|
||||
FileConfigSaveReqVO reqVO = randomPojo(FileConfigSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> fileConfigService.updateFileConfig(reqVO), FILE_CONFIG_NOT_EXISTS);
|
||||
@ -148,8 +149,8 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
// 调用
|
||||
fileConfigService.deleteFileConfig(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(fileConfigMapper.selectById(id));
|
||||
// 校验数据不存在了
|
||||
assertNull(fileConfigMapper.selectById(id));
|
||||
// 验证 cache
|
||||
assertNull(fileConfigService.getClientCache().getIfPresent(id));
|
||||
}
|
||||
@ -177,30 +178,30 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Test
|
||||
public void testGetFileConfigPage() {
|
||||
// mock 数据
|
||||
FileConfigDO dbFileConfig = randomFileConfigDO().setName("芋道源码")
|
||||
.setStorage(FileStorageEnum.LOCAL.getStorage());
|
||||
dbFileConfig.setCreateTime(LocalDateTimeUtil.parse("2020-01-23", DatePattern.NORM_DATE_PATTERN));// 等会查询到
|
||||
fileConfigMapper.insert(dbFileConfig);
|
||||
// 测试 name 不匹配
|
||||
fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setName("源码")));
|
||||
// 测试 storage 不匹配
|
||||
fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setStorage(FileStorageEnum.DB.getStorage())));
|
||||
// 测试 createTime 不匹配
|
||||
fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setCreateTime(LocalDateTimeUtil.parse("2020-11-23", DatePattern.NORM_DATE_PATTERN))));
|
||||
// 准备参数
|
||||
FileConfigPageReqVO reqVO = new FileConfigPageReqVO();
|
||||
reqVO.setName("芋道");
|
||||
reqVO.setStorage(FileStorageEnum.LOCAL.getStorage());
|
||||
reqVO.setCreateTime((new LocalDateTime[]{buildTime(2020, 1, 1),
|
||||
buildTime(2020, 1, 24)}));
|
||||
// mock 数据
|
||||
FileConfigDO dbFileConfig = randomFileConfigDO().setName("芋道源码")
|
||||
.setStorage(FileStorageEnum.LOCAL.getStorage());
|
||||
dbFileConfig.setCreateTime(LocalDateTimeUtil.parse("2020-01-23", DatePattern.NORM_DATE_PATTERN));// 等会查询到
|
||||
fileConfigMapper.insert(dbFileConfig);
|
||||
// 测试 name 不匹配
|
||||
fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setName("源码")));
|
||||
// 测试 storage 不匹配
|
||||
fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setStorage(FileStorageEnum.DB.getStorage())));
|
||||
// 测试 createTime 不匹配
|
||||
fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setCreateTime(LocalDateTimeUtil.parse("2020-11-23", DatePattern.NORM_DATE_PATTERN))));
|
||||
// 准备参数
|
||||
FileConfigPageReqVO reqVO = new FileConfigPageReqVO();
|
||||
reqVO.setName("芋道");
|
||||
reqVO.setStorage(FileStorageEnum.LOCAL.getStorage());
|
||||
reqVO.setCreateTime((new LocalDateTime[]{buildTime(2020, 1, 1),
|
||||
buildTime(2020, 1, 24)}));
|
||||
|
||||
// 调用
|
||||
PageResult<FileConfigDO> pageResult = fileConfigService.getFileConfigPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbFileConfig, pageResult.getList().get(0));
|
||||
// 调用
|
||||
PageResult<FileConfigDO> pageResult = fileConfigService.getFileConfigPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbFileConfig, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.infra.service.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper;
|
||||
@ -12,14 +11,11 @@ import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static java.util.Collections.singleton;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
@ -110,23 +106,6 @@ public class JobLogServiceImplTest extends BaseDbUnitTest {
|
||||
assertPojoEquals(dbJobLog, jobLog);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJobLogList() {
|
||||
// mock 数据
|
||||
JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> o.setExecuteIndex(1));
|
||||
jobLogMapper.insert(dbJobLog);
|
||||
// 测试 handlerName 不匹配
|
||||
jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> {}));
|
||||
// 准备参数
|
||||
Collection<Long> ids = singleton(dbJobLog.getId());
|
||||
|
||||
// 调用
|
||||
List<JobLogDO> list = jobLogService.getJobLogList(ids);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbJobLog, list.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJobPage() {
|
||||
// mock 数据
|
||||
@ -164,40 +143,4 @@ public class JobLogServiceImplTest extends BaseDbUnitTest {
|
||||
assertPojoEquals(dbJobLog, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJobList_export() {
|
||||
// mock 数据
|
||||
JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> {
|
||||
o.setExecuteIndex(1);
|
||||
o.setHandlerName("handlerName 单元测试");
|
||||
o.setStatus(JobLogStatusEnum.SUCCESS.getStatus());
|
||||
o.setBeginTime(buildTime(2021, 1, 8));
|
||||
o.setEndTime(buildTime(2021, 1, 8));
|
||||
});
|
||||
jobLogMapper.insert(dbJobLog);
|
||||
// 测试 jobId 不匹配
|
||||
jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setJobId(randomLongId())));
|
||||
// 测试 handlerName 不匹配
|
||||
jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setHandlerName(randomString())));
|
||||
// 测试 beginTime 不匹配
|
||||
jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setBeginTime(buildTime(2021, 1, 7))));
|
||||
// 测试 endTime 不匹配
|
||||
jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setEndTime(buildTime(2021, 1, 9))));
|
||||
// 测试 status 不匹配
|
||||
jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setStatus(JobLogStatusEnum.FAILURE.getStatus())));
|
||||
// 准备参数
|
||||
JobLogExportReqVO reqVo = new JobLogExportReqVO();
|
||||
reqVo.setJobId(dbJobLog.getJobId());
|
||||
reqVo.setHandlerName("单元");
|
||||
reqVo.setBeginTime(dbJobLog.getBeginTime());
|
||||
reqVo.setEndTime(dbJobLog.getEndTime());
|
||||
reqVo.setStatus(JobLogStatusEnum.SUCCESS.getStatus());
|
||||
|
||||
// 调用
|
||||
List<JobLogDO> list = jobLogService.getJobLogList(reqVo);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbJobLog, list.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,10 +3,8 @@ package cn.iocoder.yudao.module.infra.service.job;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobSaveReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.job.JobMapper;
|
||||
import cn.iocoder.yudao.module.infra.enums.job.JobStatusEnum;
|
||||
@ -16,17 +14,13 @@ import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString;
|
||||
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@ -44,7 +38,7 @@ public class JobServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testCreateJob_cronExpressionValid() {
|
||||
// 准备参数。Cron 表达式为 String 类型,默认随机字符串。
|
||||
JobCreateReqVO reqVO = randomPojo(JobCreateReqVO.class);
|
||||
JobSaveReqVO reqVO = randomPojo(JobSaveReqVO.class);
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> jobService.createJob(reqVO), JOB_CRON_EXPRESSION_VALID);
|
||||
@ -53,7 +47,7 @@ public class JobServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testCreateJob_jobHandlerExists() throws SchedulerException {
|
||||
// 准备参数 指定 Cron 表达式
|
||||
JobCreateReqVO reqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
|
||||
JobSaveReqVO reqVO = randomPojo(JobSaveReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
|
||||
|
||||
// 调用
|
||||
jobService.createJob(reqVO);
|
||||
@ -64,7 +58,8 @@ public class JobServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testCreateJob_success() throws SchedulerException {
|
||||
// 准备参数 指定 Cron 表达式
|
||||
JobCreateReqVO reqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
|
||||
JobSaveReqVO reqVO = randomPojo(JobSaveReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"))
|
||||
.setId(null);
|
||||
|
||||
// 调用
|
||||
Long jobId = jobService.createJob(reqVO);
|
||||
@ -72,7 +67,7 @@ public class JobServiceImplTest extends BaseDbUnitTest {
|
||||
assertNotNull(jobId);
|
||||
// 校验记录的属性是否正确
|
||||
JobDO job = jobMapper.selectById(jobId);
|
||||
assertPojoEquals(reqVO, job);
|
||||
assertPojoEquals(reqVO, job, "id");
|
||||
assertEquals(JobStatusEnum.NORMAL.getStatus(), job.getStatus());
|
||||
// 校验调用
|
||||
verify(schedulerManager).addJob(eq(job.getId()), eq(job.getHandlerName()), eq(job.getHandlerParam()),
|
||||
@ -82,7 +77,7 @@ public class JobServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testUpdateJob_jobNotExists(){
|
||||
// 准备参数
|
||||
JobUpdateReqVO reqVO = randomPojo(JobUpdateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
|
||||
JobSaveReqVO reqVO = randomPojo(JobSaveReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
|
||||
|
||||
// 调用,并断言异常
|
||||
assertServiceException(() -> jobService.updateJob(reqVO), JOB_NOT_EXISTS);
|
||||
@ -94,7 +89,7 @@ public class JobServiceImplTest extends BaseDbUnitTest {
|
||||
JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.INIT.getStatus()));
|
||||
jobMapper.insert(job);
|
||||
// 准备参数
|
||||
JobUpdateReqVO updateReqVO = randomPojo(JobUpdateReqVO.class, o -> {
|
||||
JobSaveReqVO updateReqVO = randomPojo(JobSaveReqVO.class, o -> {
|
||||
o.setId(job.getId());
|
||||
o.setCronExpression("0 0/1 * * * ? *");
|
||||
});
|
||||
@ -110,7 +105,7 @@ public class JobServiceImplTest extends BaseDbUnitTest {
|
||||
JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus()));
|
||||
jobMapper.insert(job);
|
||||
// 准备参数
|
||||
JobUpdateReqVO updateReqVO = randomPojo(JobUpdateReqVO.class, o -> {
|
||||
JobSaveReqVO updateReqVO = randomPojo(JobSaveReqVO.class, o -> {
|
||||
o.setId(job.getId());
|
||||
o.setCronExpression("0 0/1 * * * ? *");
|
||||
});
|
||||
@ -200,25 +195,6 @@ public class JobServiceImplTest extends BaseDbUnitTest {
|
||||
verify(schedulerManager).deleteJob(eq(job.getHandlerName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJobList() {
|
||||
// mock 数据
|
||||
JobDO dbJob = randomPojo(JobDO.class, o -> {
|
||||
o.setStatus(randomEle(JobStatusEnum.values()).getStatus()); // 保证 status 的范围
|
||||
});
|
||||
jobMapper.insert(dbJob);
|
||||
// 测试 id 不匹配
|
||||
jobMapper.insert(cloneIgnoreId(dbJob, o -> {}));
|
||||
|
||||
// 准备参数
|
||||
Collection<Long> ids = singletonList(dbJob.getId());
|
||||
// 调用
|
||||
List<JobDO> list = jobService.getJobList(ids);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbJob, list.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJobPage() {
|
||||
// mock 数据
|
||||
@ -248,34 +224,6 @@ public class JobServiceImplTest extends BaseDbUnitTest {
|
||||
assertPojoEquals(dbJob, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJobList_export() {
|
||||
// mock 数据
|
||||
JobDO dbJob = randomPojo(JobDO.class, o -> {
|
||||
o.setName("定时任务测试");
|
||||
o.setHandlerName("handlerName 单元测试");
|
||||
o.setStatus(JobStatusEnum.INIT.getStatus());
|
||||
});
|
||||
jobMapper.insert(dbJob);
|
||||
// 测试 name 不匹配
|
||||
jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setName("土豆")));
|
||||
// 测试 status 不匹配
|
||||
jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus())));
|
||||
// 测试 handlerName 不匹配
|
||||
jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setHandlerName(randomString())));
|
||||
// 准备参数
|
||||
JobExportReqVO reqVo = new JobExportReqVO();
|
||||
reqVo.setName("定时");
|
||||
reqVo.setStatus(JobStatusEnum.INIT.getStatus());
|
||||
reqVo.setHandlerName("单元");
|
||||
|
||||
// 调用
|
||||
List<JobDO> list = jobService.getJobList(reqVo);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbJob, list.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetJob() {
|
||||
// mock 数据
|
||||
|
@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstant
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiAccessLogMapper;
|
||||
@ -13,7 +12,6 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
|
||||
@ -75,49 +73,6 @@ public class ApiAccessLogServiceImplTest extends BaseDbUnitTest {
|
||||
assertPojoEquals(apiAccessLogDO, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetApiAccessLogList() {
|
||||
ApiAccessLogDO apiAccessLogDO = randomPojo(ApiAccessLogDO.class, o -> {
|
||||
o.setUserId(2233L);
|
||||
o.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
o.setApplicationName("yudao-test");
|
||||
o.setRequestUrl("foo");
|
||||
o.setBeginTime(buildTime(2021, 3, 13));
|
||||
o.setDuration(1000);
|
||||
o.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode());
|
||||
});
|
||||
apiAccessLogMapper.insert(apiAccessLogDO);
|
||||
// 测试 userId 不匹配
|
||||
apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserId(3344L)));
|
||||
// 测试 userType 不匹配
|
||||
apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
|
||||
// 测试 applicationName 不匹配
|
||||
apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setApplicationName("test")));
|
||||
// 测试 requestUrl 不匹配
|
||||
apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setRequestUrl("bar")));
|
||||
// 测试 beginTime 不匹配:构造一个早期时间 2021-02-06 00:00:00
|
||||
apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setBeginTime(buildTime(2021, 2, 6))));
|
||||
// 测试 duration 不匹配
|
||||
apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setDuration(100)));
|
||||
// 测试 resultCode 不匹配
|
||||
apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setResultCode(2)));
|
||||
// 准备参数
|
||||
ApiAccessLogExportReqVO reqVO = new ApiAccessLogExportReqVO();
|
||||
reqVO.setUserId(2233L);
|
||||
reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
reqVO.setApplicationName("yudao-test");
|
||||
reqVO.setRequestUrl("foo");
|
||||
reqVO.setBeginTime(buildBetweenTime(2021, 3, 13, 2021, 3, 13));
|
||||
reqVO.setDuration(1000);
|
||||
reqVO.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode());
|
||||
|
||||
// 调用
|
||||
List<ApiAccessLogDO> list = apiAccessLogService.getApiAccessLogList(reqVO);
|
||||
// 断言,只查到了一条符合条件的
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(apiAccessLogDO, list.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateApiAccessLog() {
|
||||
// 准备参数
|
||||
|
@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
|
||||
import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper;
|
||||
@ -13,7 +12,6 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.randomEle;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
|
||||
@ -78,46 +76,6 @@ public class ApiErrorLogServiceImplTest extends BaseDbUnitTest {
|
||||
assertPojoEquals(apiErrorLogDO, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetApiErrorLogList() {
|
||||
// mock 数据
|
||||
ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, o -> {
|
||||
o.setUserId(2233L);
|
||||
o.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
o.setApplicationName("yudao-test");
|
||||
o.setRequestUrl("foo");
|
||||
o.setExceptionTime(buildTime(2021, 3, 13));
|
||||
o.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
|
||||
});
|
||||
apiErrorLogMapper.insert(apiErrorLogDO);
|
||||
// 测试 userId 不匹配
|
||||
apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setUserId(3344L)));
|
||||
// 测试 userType 不匹配
|
||||
apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setUserType(UserTypeEnum.MEMBER.getValue())));
|
||||
// 测试 applicationName 不匹配
|
||||
apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setApplicationName("test")));
|
||||
// 测试 requestUrl 不匹配
|
||||
apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setRequestUrl("bar")));
|
||||
// 测试 exceptionTime 不匹配:构造一个早期时间 2021-02-06 00:00:00
|
||||
apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setExceptionTime(buildTime(2021, 2, 6))));
|
||||
// 测试 progressStatus 不匹配
|
||||
apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus())));
|
||||
// 准备参数
|
||||
ApiErrorLogExportReqVO reqVO = new ApiErrorLogExportReqVO();
|
||||
reqVO.setUserId(2233L);
|
||||
reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
reqVO.setApplicationName("yudao-test");
|
||||
reqVO.setRequestUrl("foo");
|
||||
reqVO.setExceptionTime(buildBetweenTime(2021, 3, 1, 2021, 3, 31));
|
||||
reqVO.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
|
||||
|
||||
// 调用
|
||||
List<ApiErrorLogDO> list = apiErrorLogService.getApiErrorLogList(reqVO);
|
||||
// 断言,只查到了一条符合条件的
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(apiErrorLogDO, list.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateApiErrorLog() {
|
||||
// 准备参数
|
||||
|
@ -1,8 +1,11 @@
|
||||
package cn.iocoder.yudao.module.system.enums.permission;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 数据范围枚举类
|
||||
*
|
||||
@ -12,7 +15,7 @@ import lombok.Getter;
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DataScopeEnum {
|
||||
public enum DataScopeEnum implements IntArrayValuable {
|
||||
|
||||
ALL(1), // 全部数据权限
|
||||
|
||||
@ -27,4 +30,11 @@ public enum DataScopeEnum {
|
||||
*/
|
||||
private final Integer scope;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DataScopeEnum::getScope).toArray();
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.api.dept;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.convert.dept.DeptConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -24,13 +24,13 @@ public class DeptApiImpl implements DeptApi {
|
||||
@Override
|
||||
public DeptRespDTO getDept(Long id) {
|
||||
DeptDO dept = deptService.getDept(id);
|
||||
return DeptConvert.INSTANCE.convert03(dept);
|
||||
return BeanUtils.toBean(dept, DeptRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptRespDTO> getDeptList(Collection<Long> ids) {
|
||||
List<DeptDO> depts = deptService.getDeptList(ids);
|
||||
return DeptConvert.INSTANCE.convertList03(depts);
|
||||
return BeanUtils.toBean(depts, DeptRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.api.dict;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
||||
import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
||||
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -28,13 +28,13 @@ public class DictDataApiImpl implements DictDataApi {
|
||||
@Override
|
||||
public DictDataRespDTO getDictData(String dictType, String value) {
|
||||
DictDataDO dictData = dictDataService.getDictData(dictType, value);
|
||||
return DictDataConvert.INSTANCE.convert02(dictData);
|
||||
return BeanUtils.toBean(dictData, DictDataRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictDataRespDTO parseDictData(String dictType, String label) {
|
||||
DictDataDO dictData = dictDataService.parseDictData(dictType, label);
|
||||
return DictDataConvert.INSTANCE.convert02(dictData);
|
||||
return BeanUtils.toBean(dictData, DictDataRespDTO.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cn.iocoder.yudao.module.system.api.oauth2;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO;
|
||||
import cn.iocoder.yudao.module.system.convert.auth.OAuth2TokenConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
|
||||
import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -25,24 +25,25 @@ public class OAuth2TokenApiImpl implements OAuth2TokenApi {
|
||||
public OAuth2AccessTokenRespDTO createAccessToken(OAuth2AccessTokenCreateReqDTO reqDTO) {
|
||||
OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.createAccessToken(
|
||||
reqDTO.getUserId(), reqDTO.getUserType(), reqDTO.getClientId(), reqDTO.getScopes());
|
||||
return OAuth2TokenConvert.INSTANCE.convert2(accessTokenDO);
|
||||
return BeanUtils.toBean(accessTokenDO, OAuth2AccessTokenRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OAuth2AccessTokenCheckRespDTO checkAccessToken(String accessToken) {
|
||||
return OAuth2TokenConvert.INSTANCE.convert(oauth2TokenService.checkAccessToken(accessToken));
|
||||
OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.checkAccessToken(accessToken);
|
||||
return BeanUtils.toBean(accessTokenDO, OAuth2AccessTokenCheckRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OAuth2AccessTokenRespDTO removeAccessToken(String accessToken) {
|
||||
OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.removeAccessToken(accessToken);
|
||||
return OAuth2TokenConvert.INSTANCE.convert2(accessTokenDO);
|
||||
return BeanUtils.toBean(accessTokenDO, OAuth2AccessTokenRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OAuth2AccessTokenRespDTO refreshAccessToken(String refreshToken, String clientId) {
|
||||
OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.refreshAccessToken(refreshToken, clientId);
|
||||
return OAuth2TokenConvert.INSTANCE.convert2(accessTokenDO);
|
||||
return BeanUtils.toBean(accessTokenDO, OAuth2AccessTokenRespDTO.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cn.iocoder.yudao.module.system.api.social;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxJsapiSignatureRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO;
|
||||
import cn.iocoder.yudao.module.system.convert.social.SocialClientConvert;
|
||||
import cn.iocoder.yudao.module.system.service.social.SocialClientService;
|
||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -31,13 +31,13 @@ public class SocialClientApiImpl implements SocialClientApi {
|
||||
@Override
|
||||
public SocialWxJsapiSignatureRespDTO createWxMpJsapiSignature(Integer userType, String url) {
|
||||
WxJsapiSignature signature = socialClientService.createWxMpJsapiSignature(userType, url);
|
||||
return SocialClientConvert.INSTANCE.convert(signature);
|
||||
return BeanUtils.toBean(signature, SocialWxJsapiSignatureRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocialWxPhoneNumberInfoRespDTO getWxMaPhoneNumberInfo(Integer userType, String phoneCode) {
|
||||
WxMaPhoneNumberInfo info = socialClientService.getWxMaPhoneNumberInfo(userType, phoneCode);
|
||||
return SocialClientConvert.INSTANCE.convert(info);
|
||||
return BeanUtils.toBean(info, SocialWxPhoneNumberInfoRespDTO.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.api.user;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import cn.iocoder.yudao.module.system.convert.user.UserConvert;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -24,25 +24,25 @@ public class AdminUserApiImpl implements AdminUserApi {
|
||||
@Override
|
||||
public AdminUserRespDTO getUser(Long id) {
|
||||
AdminUserDO user = userService.getUser(id);
|
||||
return UserConvert.INSTANCE.convert4(user);
|
||||
return BeanUtils.toBean(user, AdminUserRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdminUserRespDTO> getUserList(Collection<Long> ids) {
|
||||
List<AdminUserDO> users = userService.getUserList(ids);
|
||||
return UserConvert.INSTANCE.convertList4(users);
|
||||
return BeanUtils.toBean(users, AdminUserRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdminUserRespDTO> getUserListByDeptIds(Collection<Long> deptIds) {
|
||||
List<AdminUserDO> users = userService.getUserListByDeptIds(deptIds);
|
||||
return UserConvert.INSTANCE.convertList4(users);
|
||||
return BeanUtils.toBean(users, AdminUserRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdminUserRespDTO> getUserListByPostIds(Collection<Long> postIds) {
|
||||
List<AdminUserDO> users = userService.getUserListByPostIds(postIds);
|
||||
return UserConvert.INSTANCE.convertList4(users);
|
||||
return BeanUtils.toBean(users, AdminUserRespDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,11 +17,6 @@ import javax.annotation.Resource;
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Tag(name = "管理后台 - 验证码")
|
||||
@RestController("adminCaptchaController")
|
||||
@RequestMapping("/system/captcha")
|
||||
|
@ -2,20 +2,22 @@ package cn.iocoder.yudao.module.system.controller.admin.dept;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.*;
|
||||
import cn.iocoder.yudao.module.system.convert.dept.DeptConvert;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSimpleRespVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
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.validation.Valid;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@ -32,16 +34,16 @@ public class DeptController {
|
||||
@PostMapping("create")
|
||||
@Operation(summary = "创建部门")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:create')")
|
||||
public CommonResult<Long> createDept(@Valid @RequestBody DeptCreateReqVO reqVO) {
|
||||
Long deptId = deptService.createDept(reqVO);
|
||||
public CommonResult<Long> createDept(@Valid @RequestBody DeptSaveReqVO createReqVO) {
|
||||
Long deptId = deptService.createDept(createReqVO);
|
||||
return success(deptId);
|
||||
}
|
||||
|
||||
@PutMapping("update")
|
||||
@Operation(summary = "更新部门")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:update')")
|
||||
public CommonResult<Boolean> updateDept(@Valid @RequestBody DeptUpdateReqVO reqVO) {
|
||||
deptService.updateDept(reqVO);
|
||||
public CommonResult<Boolean> updateDept(@Valid @RequestBody DeptSaveReqVO updateReqVO) {
|
||||
deptService.updateDept(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -59,20 +61,15 @@ public class DeptController {
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:query')")
|
||||
public CommonResult<List<DeptRespVO>> getDeptList(DeptListReqVO reqVO) {
|
||||
List<DeptDO> list = deptService.getDeptList(reqVO);
|
||||
list.sort(Comparator.comparing(DeptDO::getSort));
|
||||
return success(DeptConvert.INSTANCE.convertList(list));
|
||||
return success(BeanUtils.toBean(list, DeptRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list-all-simple")
|
||||
@GetMapping(value = {"/list-all-simple", "/simple-list"})
|
||||
@Operation(summary = "获取部门精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
|
||||
public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptList() {
|
||||
// 获得部门列表,只要开启状态的
|
||||
DeptListReqVO reqVO = new DeptListReqVO();
|
||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
List<DeptDO> list = deptService.getDeptList(reqVO);
|
||||
// 排序后,返回给前端
|
||||
list.sort(Comparator.comparing(DeptDO::getSort));
|
||||
return success(DeptConvert.INSTANCE.convertList02(list));
|
||||
List<DeptDO> list = deptService.getDeptList(
|
||||
new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ -80,7 +77,8 @@ public class DeptController {
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:query')")
|
||||
public CommonResult<DeptRespVO> getDept(@RequestParam("id") Long id) {
|
||||
return success(DeptConvert.INSTANCE.convert(deptService.getDept(id)));
|
||||
DeptDO dept = deptService.getDept(id);
|
||||
return success(BeanUtils.toBean(dept, DeptRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class PostController {
|
||||
return success(BeanUtils.toBean(post, PostRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list-all-simple")
|
||||
@GetMapping(value = {"/list-all-simple", "simple-list"})
|
||||
@Operation(summary = "获取岗位全列表", description = "只包含被开启的岗位,主要用于前端的下拉选项")
|
||||
public CommonResult<List<PostSimpleRespVO>> getSimplePostList() {
|
||||
// 获得岗位列表,只要开启状态的
|
||||
|
@ -1,12 +0,0 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 部门创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DeptCreateReqVO extends DeptBaseVO {
|
||||
}
|
@ -2,19 +2,35 @@ package cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 部门信息 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DeptRespVO extends DeptBaseVO {
|
||||
public class DeptRespVO {
|
||||
|
||||
@Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@Schema(description = "部门编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "父部门 ID", example = "1024")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "2048")
|
||||
private Long leaderUserId;
|
||||
|
||||
@Schema(description = "联系电话", example = "15601691000")
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "邮箱", example = "yudao@iocoder.cn")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@ -8,19 +10,19 @@ import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 部门 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - 部门创建/修改 Request VO")
|
||||
@Data
|
||||
public class DeptBaseVO {
|
||||
public class DeptSaveReqVO {
|
||||
|
||||
@Schema(description = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
@Schema(description = "部门编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
@Size(max = 30, message = "部门名称长度不能超过30个字符")
|
||||
@Size(max = 30, message = "部门名称长度不能超过 30 个字符")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "父菜单 ID", example = "1024")
|
||||
@Schema(description = "父部门 ID", example = "1024")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ -36,12 +38,12 @@ public class DeptBaseVO {
|
||||
|
||||
@Schema(description = "邮箱", example = "yudao@iocoder.cn")
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(max = 50, message = "邮箱长度不能超过50个字符")
|
||||
@Size(max = 50, message = "邮箱长度不能超过 50 个字符")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
// @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 部门更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DeptUpdateReqVO extends DeptBaseVO {
|
||||
|
||||
@Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "部门编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post;
|
||||
|
||||
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.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@ -10,6 +12,7 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 岗位信息 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PostRespVO {
|
||||
|
||||
@Schema(description = "岗位序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ -29,6 +32,7 @@ public class PostRespVO {
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
|
@ -1,16 +1,20 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dict;
|
||||
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.*;
|
||||
import cn.iocoder.yudao.module.system.convert.dict.DictDataConvert;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
||||
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -36,16 +40,16 @@ public class DictDataController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "新增字典数据")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:create')")
|
||||
public CommonResult<Long> createDictData(@Valid @RequestBody DictDataCreateReqVO reqVO) {
|
||||
Long dictDataId = dictDataService.createDictData(reqVO);
|
||||
public CommonResult<Long> createDictData(@Valid @RequestBody DictDataSaveReqVO createReqVO) {
|
||||
Long dictDataId = dictDataService.createDictData(createReqVO);
|
||||
return success(dictDataId);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "修改字典数据")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:update')")
|
||||
public CommonResult<Boolean> updateDictData(@Valid @RequestBody DictDataUpdateReqVO reqVO) {
|
||||
dictDataService.updateDictData(reqVO);
|
||||
public CommonResult<Boolean> updateDictData(@Valid @RequestBody DictDataSaveReqVO updateReqVO) {
|
||||
dictDataService.updateDictData(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -58,19 +62,20 @@ public class DictDataController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/list-all-simple")
|
||||
@GetMapping(value = {"/list-all-simple", "simple-list"})
|
||||
@Operation(summary = "获得全部字典数据列表", description = "一般用于管理后台缓存字典数据在本地")
|
||||
// 无需添加权限认证,因为前端全局都需要
|
||||
public CommonResult<List<DictDataSimpleRespVO>> getSimpleDictDataList() {
|
||||
List<DictDataDO> list = dictDataService.getDictDataList();
|
||||
return success(DictDataConvert.INSTANCE.convertList(list));
|
||||
return success(BeanUtils.toBean(list, DictDataSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "/获得字典类型的分页列表")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||
public CommonResult<PageResult<DictDataRespVO>> getDictTypePage(@Valid DictDataPageReqVO reqVO) {
|
||||
return success(DictDataConvert.INSTANCE.convertPage(dictDataService.getDictDataPage(reqVO)));
|
||||
public CommonResult<PageResult<DictDataRespVO>> getDictTypePage(@Valid DictDataPageReqVO pageReqVO) {
|
||||
PageResult<DictDataDO> pageResult = dictDataService.getDictDataPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DictDataRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get")
|
||||
@ -78,18 +83,20 @@ public class DictDataController {
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||
public CommonResult<DictDataRespVO> getDictData(@RequestParam("id") Long id) {
|
||||
return success(DictDataConvert.INSTANCE.convert(dictDataService.getDictData(id)));
|
||||
DictDataDO dictData = dictDataService.getDictData(id);
|
||||
return success(BeanUtils.toBean(dictData, DictDataRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export")
|
||||
@Operation(summary = "导出字典数据")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void export(HttpServletResponse response, @Valid DictDataExportReqVO reqVO) throws IOException {
|
||||
List<DictDataDO> list = dictDataService.getDictDataList(reqVO);
|
||||
List<DictDataExcelVO> data = DictDataConvert.INSTANCE.convertList02(list);
|
||||
public void export(HttpServletResponse response, @Valid DictDataPageReqVO exportReqVO) throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DictDataDO> list = dictDataService.getDictDataPage(exportReqVO).getList();
|
||||
// 输出
|
||||
ExcelUtils.write(response, "字典数据.xls", "数据列表", DictDataExcelVO.class, data);
|
||||
ExcelUtils.write(response, "字典数据.xls", "数据", DictDataRespVO.class,
|
||||
BeanUtils.toBean(list, DictDataRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,16 +1,20 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dict;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.*;
|
||||
import cn.iocoder.yudao.module.system.convert.dict.DictTypeConvert;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypePageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeSimpleRespVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictTypeDO;
|
||||
import cn.iocoder.yudao.module.system.service.dict.DictTypeService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -36,16 +40,16 @@ public class DictTypeController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建字典类型")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:create')")
|
||||
public CommonResult<Long> createDictType(@Valid @RequestBody DictTypeCreateReqVO reqVO) {
|
||||
Long dictTypeId = dictTypeService.createDictType(reqVO);
|
||||
public CommonResult<Long> createDictType(@Valid @RequestBody DictTypeSaveReqVO createReqVO) {
|
||||
Long dictTypeId = dictTypeService.createDictType(createReqVO);
|
||||
return success(dictTypeId);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "修改字典类型")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:update')")
|
||||
public CommonResult<Boolean> updateDictType(@Valid @RequestBody DictTypeUpdateReqVO reqVO) {
|
||||
dictTypeService.updateDictType(reqVO);
|
||||
public CommonResult<Boolean> updateDictType(@Valid @RequestBody DictTypeSaveReqVO updateReqVO) {
|
||||
dictTypeService.updateDictType(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -58,11 +62,12 @@ public class DictTypeController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Operation(summary = "/获得字典类型的分页列表")
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得字典类型的分页列表")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||
public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(@Valid DictTypePageReqVO reqVO) {
|
||||
return success(DictTypeConvert.INSTANCE.convertPage(dictTypeService.getDictTypePage(reqVO)));
|
||||
public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(@Valid DictTypePageReqVO pageReqVO) {
|
||||
PageResult<DictTypeDO> pageResult = dictTypeService.getDictTypePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DictTypeRespVO.class));
|
||||
}
|
||||
|
||||
@Operation(summary = "/查询字典类型详细")
|
||||
@ -70,26 +75,28 @@ public class DictTypeController {
|
||||
@GetMapping(value = "/get")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||
public CommonResult<DictTypeRespVO> getDictType(@RequestParam("id") Long id) {
|
||||
return success(DictTypeConvert.INSTANCE.convert(dictTypeService.getDictType(id)));
|
||||
DictTypeDO dictType = dictTypeService.getDictType(id);
|
||||
return success(BeanUtils.toBean(dictType, DictTypeRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list-all-simple")
|
||||
@GetMapping(value = {"/list-all-simple", "simple-list"})
|
||||
@Operation(summary = "获得全部字典类型列表", description = "包括开启 + 禁用的字典类型,主要用于前端的下拉选项")
|
||||
// 无需添加权限认证,因为前端全局都需要
|
||||
public CommonResult<List<DictTypeSimpleRespVO>> getSimpleDictTypeList() {
|
||||
List<DictTypeDO> list = dictTypeService.getDictTypeList();
|
||||
return success(DictTypeConvert.INSTANCE.convertList(list));
|
||||
return success(BeanUtils.toBean(list, DictTypeSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@Operation(summary = "导出数据类型")
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@ss.hasPermission('system:dict:query')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void export(HttpServletResponse response, @Valid DictTypeExportReqVO reqVO) throws IOException {
|
||||
List<DictTypeDO> list = dictTypeService.getDictTypeList(reqVO);
|
||||
List<DictTypeExcelVO> data = DictTypeConvert.INSTANCE.convertList02(list);
|
||||
// 输出
|
||||
ExcelUtils.write(response, "字典类型.xls", "类型列表", DictTypeExcelVO.class, data);
|
||||
public void export(HttpServletResponse response, @Valid DictTypePageReqVO exportReqVO) throws IOException {
|
||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DictTypeDO> list = dictTypeService.getDictTypePage(exportReqVO).getList();
|
||||
// 导出
|
||||
ExcelUtils.write(response, "字典类型.xls", "数据", DictTypeRespVO.class,
|
||||
BeanUtils.toBean(list, DictTypeRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dict.vo.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Schema(description = "管理后台 - 字典数据创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DictDataCreateReqVO extends DictDataBaseVO {
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dict.vo.data;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 字典数据 Excel 导出响应 VO
|
||||
*/
|
||||
@Data
|
||||
public class DictDataExcelVO {
|
||||
|
||||
@ExcelProperty("字典编码")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("字典排序")
|
||||
private Integer sort;
|
||||
|
||||
@ExcelProperty("字典标签")
|
||||
private String label;
|
||||
|
||||
@ExcelProperty("字典键值")
|
||||
private String value;
|
||||
|
||||
@ExcelProperty("字典类型")
|
||||
private String dictType;
|
||||
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dict.vo.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Schema(description = "管理后台 - 字典类型导出 Request VO")
|
||||
@Data
|
||||
public class DictDataExportReqVO {
|
||||
|
||||
@Schema(description = "字典标签", example = "芋道")
|
||||
@Size(max = 100, message = "字典标签长度不能超过100个字符")
|
||||
private String label;
|
||||
|
||||
@Schema(description = "字典类型,模糊匹配", example = "sys_common_sex")
|
||||
@Size(max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||
private String dictType;
|
||||
|
||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dict.vo.data;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -21,6 +23,7 @@ public class DictDataPageReqVO extends PageParam {
|
||||
private String dictType;
|
||||
|
||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
@ -1,23 +1,54 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dict.vo.data;
|
||||
|
||||
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.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 字典数据信息 Response VO")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DictDataRespVO extends DictDataBaseVO {
|
||||
@ExcelIgnoreUnannotated
|
||||
public class DictDataRespVO {
|
||||
|
||||
@Schema(description = "字典数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("字典编码")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@ExcelProperty("字典排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "字典标签", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
||||
@ExcelProperty("字典标签")
|
||||
private String label;
|
||||
|
||||
@Schema(description = "字典值", requiredMode = Schema.RequiredMode.REQUIRED, example = "iocoder")
|
||||
@ExcelProperty("字典键值")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "字典类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "sys_common_sex")
|
||||
@ExcelProperty("字典类型")
|
||||
private String dictType;
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.COMMON_STATUS)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "颜色类型,default、primary、success、info、warning、danger", example = "default")
|
||||
private String colorType;
|
||||
|
||||
@Schema(description = "css 样式", example = "btn-visible")
|
||||
private String cssClass;
|
||||
|
||||
@Schema(description = "备注", example = "我是一个角色")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dict.vo.data;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@ -7,12 +9,12 @@ import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 字典数据 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - 字典数据创建/修改 Request VO")
|
||||
@Data
|
||||
public class DictDataBaseVO {
|
||||
public class DictDataSaveReqVO {
|
||||
|
||||
@Schema(description = "字典数据编号", example = "1024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
@ -35,11 +37,12 @@ public class DictDataBaseVO {
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
// @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "颜色类型,default、primary、success、info、warning、danger", example = "default")
|
||||
private String colorType;
|
||||
|
||||
@Schema(description = "css 样式", example = "btn-visible")
|
||||
private String cssClass;
|
||||
|
@ -1,18 +0,0 @@
|
||||
package cn.iocoder.yudao.module.system.controller.admin.dict.vo.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 字典数据更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DictDataUpdateReqVO extends DictDataBaseVO {
|
||||
|
||||
@Schema(description = "字典数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "字典数据编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user