# Conflicts:
#	yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileConfigController.java
#	yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java
#	yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java
#	yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/MenuController.java
#	yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/dept/PostServiceImpl.java
#	yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/dict/DictTypeServiceImpl.java
#	yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleService.java
This commit is contained in:
YunaiV
2025-06-16 08:35:21 +08:00
44 changed files with 421 additions and 40 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")
@@ -92,7 +101,7 @@ public class ConfigController {
return success(ConfigConvert.INSTANCE.convertPage(page));
}
@GetMapping("/export")
@GetMapping("/export-excel")
@Operation(summary = "导出参数配置")
@PreAuthorize("@ss.hasPermission('infra:config:export')")
@ApiAccessLog(operateType = EXPORT)

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

@@ -11,12 +11,13 @@ import cn.iocoder.yudao.module.infra.service.file.FileConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
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.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -61,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

@@ -14,6 +14,11 @@ 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.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -21,11 +26,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
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;
@@ -76,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 javax.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 javax.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 javax.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

@@ -16,10 +16,11 @@ import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient;
import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.FilePresignedUrlRespDTO;
import cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils;
import com.google.common.annotations.VisibleForTesting;
import jakarta.annotation.Resource;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
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;
@@ -157,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 javax.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) {