Merge branch 'refs/heads/master-jdk17' into master-jdk17-excel

# Conflicts:
#	yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/handler/SelectSheetWriteHandler.java
This commit is contained in:
xingyu4j
2025-06-15 18:54:13 +08:00
88 changed files with 5752 additions and 2044 deletions

View File

@@ -122,6 +122,15 @@ public class CodegenController {
return success(true);
}
@Operation(summary = "批量删除数据库的表和字段定义")
@DeleteMapping("/delete-list")
@Parameter(name = "tableIds", description = "表编号列表", required = true)
@PreAuthorize("@ss.hasPermission('infra:codegen:delete')")
public CommonResult<Boolean> deleteCodegenList(@RequestParam("tableIds") List<Long> tableIds) {
codegenService.deleteCodegenList(tableIds);
return success(true);
}
@Operation(summary = "预览生成代码")
@GetMapping("/preview")
@Parameter(name = "tableId", description = "表编号", required = true, example = "1024")

View File

@@ -62,6 +62,15 @@ public class ConfigController {
return success(true);
}
@DeleteMapping("/delete-list")
@Operation(summary = "批量删除参数配置")
@Parameter(name = "ids", description = "编号列表", required = true)
@PreAuthorize("@ss.hasPermission('infra:config:delete')")
public CommonResult<Boolean> deleteConfigList(@RequestParam("ids") List<Long> ids) {
configService.deleteConfigList(ids);
return success(true);
}
@GetMapping(value = "/get")
@Operation(summary = "获得参数配置")
@Parameter(name = "id", description = "编号", required = true, example = "1024")

View File

@@ -52,6 +52,15 @@ public class DataSourceConfigController {
return success(true);
}
@DeleteMapping("/delete-list")
@Operation(summary = "批量删除数据源配置")
@Parameter(name = "ids", description = "编号列表", required = true)
@PreAuthorize("@ss.hasPermission('infra:data-source-config:delete')")
public CommonResult<Boolean> deleteDataSourceConfigList(@RequestParam("ids") List<Long> ids) {
dataSourceConfigService.deleteDataSourceConfigList(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得数据源配置")
@Parameter(name = "id", description = "编号", required = true, example = "1024")

View File

@@ -10,7 +10,7 @@ import java.time.LocalDateTime;
public class DataSourceConfigRespVO {
@Schema(description = "主键编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer id;
private Long id;
@Schema(description = "数据源名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "test")
private String name;

View File

@@ -17,6 +17,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 文件配置")
@@ -60,6 +62,15 @@ public class FileConfigController {
return success(true);
}
@DeleteMapping("/delete-list")
@Operation(summary = "批量删除文件配置")
@Parameter(name = "ids", description = "编号列表", required = true)
@PreAuthorize("@ss.hasPermission('infra:file-config:delete')")
public CommonResult<Boolean> deleteFileConfigList(@RequestParam("ids") List<Long> ids) {
fileConfigService.deleteFileConfigList(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得文件配置")
@Parameter(name = "id", description = "编号", required = true, example = "1024")

View File

@@ -26,6 +26,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils.writeAttachment;
@@ -75,6 +77,15 @@ public class FileController {
return success(true);
}
@DeleteMapping("/delete-list")
@Operation(summary = "批量删除文件")
@Parameter(name = "ids", description = "编号列表", required = true)
@PreAuthorize("@ss.hasPermission('infra:file:delete')")
public CommonResult<Boolean> deleteFileList(@RequestParam("ids") List<Long> ids) throws Exception {
fileService.deleteFileList(ids);
return success(true);
}
@GetMapping("/{configId}/get/**")
@PermitAll
@TenantIgnore

View File

@@ -81,6 +81,16 @@ public class JobController {
return success(true);
}
@DeleteMapping("/delete-list")
@Operation(summary = "批量删除定时任务")
@Parameter(name = "ids", description = "编号列表", required = true)
@PreAuthorize("@ss.hasPermission('infra:job:delete')")
public CommonResult<Boolean> deleteJobList(@RequestParam("ids") List<Long> ids)
throws SchedulerException {
jobService.deleteJobList(ids);
return success(true);
}
@PutMapping("/trigger")
@Operation(summary = "触发定时任务")
@Parameter(name = "id", description = "编号", required = true, example = "1024")

View File

@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
import java.util.List;
@Mapper
@@ -17,8 +18,12 @@ public interface CodegenColumnMapper extends BaseMapperX<CodegenColumnDO> {
}
default void deleteListByTableId(Long tableId) {
delete(CodegenColumnDO::getTableId, tableId);
}
default void deleteListByTableId(Collection<Long> tableIds) {
delete(new LambdaQueryWrapperX<CodegenColumnDO>()
.eq(CodegenColumnDO::getTableId, tableId));
.in(CodegenColumnDO::getTableId, tableIds));
}
}

View File

@@ -48,6 +48,13 @@ public interface CodegenService {
*/
void deleteCodegen(Long tableId);
/**
* 批量删除数据库的表和字段定义
*
* @param tableIds 数据编号列表
*/
void deleteCodegenList(List<Long> tableIds);
/**
* 获得表定义列表
*

View File

@@ -222,6 +222,15 @@ public class CodegenServiceImpl implements CodegenService {
codegenColumnMapper.deleteListByTableId(tableId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteCodegenList(List<Long> tableIds) {
// 批量删除 table 表定义
codegenTableMapper.deleteByIds(tableIds);
// 批量删除 column 字段定义
codegenColumnMapper.deleteListByTableId(tableIds);
}
@Override
public List<CodegenTableDO> getCodegenTableList(Long dataSourceConfigId) {
return codegenTableMapper.selectListByDataSourceConfigId(dataSourceConfigId);

View File

@@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigSaveReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
import jakarta.validation.Valid;
import java.util.List;
/**
* 参数配置 Service 接口
*
@@ -35,6 +37,13 @@ public interface ConfigService {
*/
void deleteConfig(Long id);
/**
* 批量删除参数配置
*
* @param ids 配置编号列表
*/
void deleteConfigList(List<Long> ids);
/**
* 获得参数配置
*

View File

@@ -13,6 +13,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
@@ -63,6 +65,20 @@ public class ConfigServiceImpl implements ConfigService {
configMapper.deleteById(id);
}
@Override
public void deleteConfigList(List<Long> ids) {
// 校验是否有内置配置
List<ConfigDO> configs = configMapper.selectByIds(ids);
configs.forEach(config -> {
if (ConfigTypeEnum.SYSTEM.getType().equals(config.getType())) {
throw exception(CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE);
}
});
// 批量删除
configMapper.deleteByIds(ids);
}
@Override
public ConfigDO getConfig(Long id) {
return configMapper.selectById(id);

View File

@@ -35,6 +35,13 @@ public interface DataSourceConfigService {
*/
void deleteDataSourceConfig(Long id);
/**
* 批量删除数据源配置
*
* @param ids 编号列表
*/
void deleteDataSourceConfigList(List<Long> ids);
/**
* 获得数据源配置
*

View File

@@ -63,6 +63,11 @@ public class DataSourceConfigServiceImpl implements DataSourceConfigService {
dataSourceConfigMapper.deleteById(id);
}
@Override
public void deleteDataSourceConfigList(List<Long> ids) {
dataSourceConfigMapper.deleteByIds(ids);
}
private void validateDataSourceConfigExists(Long id) {
if (dataSourceConfigMapper.selectById(id) == null) {
throw exception(DATA_SOURCE_CONFIG_NOT_EXISTS);

View File

@@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileConfigDO;
import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient;
import jakarta.validation.Valid;
import java.util.List;
/**
* 文件配置 Service 接口
*
@@ -43,6 +45,13 @@ public interface FileConfigService {
*/
void deleteFileConfig(Long id);
/**
* 批量删除文件配置
*
* @param ids 编号列表
*/
void deleteFileConfigList(List<Long> ids);
/**
* 获得文件配置
*

View File

@@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -134,6 +135,23 @@ public class FileConfigServiceImpl implements FileConfigService {
clearCache(id, null);
}
@Override
public void deleteFileConfigList(List<Long> ids) {
// 校验是否有主配置
List<FileConfigDO> configs = fileConfigMapper.selectByIds(ids);
for (FileConfigDO config : configs) {
if (Boolean.TRUE.equals(config.getMaster())) {
throw exception(FILE_CONFIG_DELETE_FAIL_MASTER);
}
}
// 批量删除
fileConfigMapper.deleteByIds(ids);
// 清空缓存
ids.forEach(id -> clearCache(id, null));
}
/**
* 清空指定文件配置
*

View File

@@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePresigned
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import jakarta.validation.constraints.NotEmpty;
import java.util.List;
/**
* 文件 Service 接口
*
@@ -59,6 +61,13 @@ public interface FileService {
*/
void deleteFile(Long id) throws Exception;
/**
* 批量删除文件
*
* @param ids 编号列表
*/
void deleteFileList(List<Long> ids) throws Exception;
/**
* 获得文件内容
*

View File

@@ -20,6 +20,8 @@ import jakarta.annotation.Resource;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;
import java.util.List;
import static cn.hutool.core.date.DatePattern.PURE_DATE_PATTERN;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_NOT_EXISTS;
@@ -156,6 +158,23 @@ public class FileServiceImpl implements FileService {
fileMapper.deleteById(id);
}
@Override
@SneakyThrows
public void deleteFileList(List<Long> ids) {
// 删除文件
List<FileDO> files = fileMapper.selectByIds(ids);
for (FileDO file : files) {
// 获取客户端
FileClient client = fileConfigService.getFileClient(file.getConfigId());
Assert.notNull(client, "客户端({}) 不能为空", file.getPath());
// 删除文件
client.delete(file.getPath());
}
// 删除记录
fileMapper.deleteByIds(ids);
}
private FileDO validateFileExists(Long id) {
FileDO fileDO = fileMapper.selectById(id);
if (fileDO == null) {

View File

@@ -7,6 +7,8 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO;
import jakarta.validation.Valid;
import org.quartz.SchedulerException;
import java.util.List;
/**
* 定时任务 Service 接口
*
@@ -58,6 +60,13 @@ public interface JobService {
*/
void deleteJob(Long id) throws SchedulerException;
/**
* 批量删除定时任务
*
* @param ids 编号列表
*/
void deleteJobList(List<Long> ids) throws SchedulerException;
/**
* 获得定时任务
*

View File

@@ -169,6 +169,19 @@ public class JobServiceImpl implements JobService {
schedulerManager.deleteJob(job.getHandlerName());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteJobList(List<Long> ids) throws SchedulerException {
// 批量删除
List<JobDO> jobs = jobMapper.selectByIds(ids);
jobMapper.deleteByIds(ids);
// 删除 Job 到 Quartz 中
for (JobDO job : jobs) {
schedulerManager.deleteJob(job.getHandlerName());
}
}
private JobDO validateJobExists(Long id) {
JobDO job = jobMapper.selectById(id);
if (job == null) {

View File

@@ -175,8 +175,6 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
@Transactional(rollbackFor = Exception.class)
#end
public void delete${simpleClassName}ListByIds(List<${primaryColumn.javaType}> ids) {
// 校验存在
validate${simpleClassName}Exists(ids);
// 删除
${classNameVar}Mapper.deleteByIds(ids);
## 特殊:主子表专属逻辑
@@ -193,12 +191,6 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
#end
}
private void validate${simpleClassName}Exists(List<${primaryColumn.javaType}> ids) {
List<${table.className}DO> list = ${classNameVar}Mapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS);
}
}
#end
private void validate${simpleClassName}Exists(${primaryColumn.javaType} id) {