Search in sources :

Example 16 with Wrappers

use of com.baomidou.mybatisplus.core.toolkit.Wrappers in project shopzz by whoiszxl.

the class FileServiceImpl method delete.

@Override
public void delete(Long[] ids) {
    if (ArrayUtils.isEmpty(ids)) {
        ExceptionCatcher.catchValidateEx(ResponseResult.buildError("传参无效"));
    }
    List<FmsFile> fileList = list(Wrappers.<FmsFile>lambdaQuery().in(FmsFile::getId, ids));
    if (fileList.isEmpty()) {
        ExceptionCatcher.catchValidateEx(ResponseResult.buildError("传参无效"));
    }
    removeByIds(Arrays.asList(ids));
    List<FileDeleteCommand> fileDeleteCommandList = fileList.stream().map(file -> {
        FileDeleteCommand deleteCommand = new FileDeleteCommand();
        deleteCommand.setRelativePath(file.getRelativePath());
        deleteCommand.setFinalFileName(file.getFinalFileName());
        deleteCommand.setId(file.getId());
        return deleteCommand;
    }).collect(Collectors.toList());
    fileStrategy.delete(fileDeleteCommandList);
}
Also used : ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) ResponseResult(com.whoiszxl.bean.ResponseResult) Arrays(java.util.Arrays) Autowired(org.springframework.beans.factory.annotation.Autowired) FileStrategy(com.whoiszxl.strategy.FileStrategy) ArrayUtils(org.apache.commons.lang3.ArrayUtils) FileDeleteCommand(com.whoiszxl.cqrs.command.FileDeleteCommand) Collectors(java.util.stream.Collectors) FileMapper(com.whoiszxl.mapper.FileMapper) List(java.util.List) FileService(com.whoiszxl.service.FileService) Service(org.springframework.stereotype.Service) ExceptionCatcher(com.whoiszxl.exception.ExceptionCatcher) MultipartFile(org.springframework.web.multipart.MultipartFile) FmsFile(com.whoiszxl.entity.FmsFile) FmsFile(com.whoiszxl.entity.FmsFile) FileDeleteCommand(com.whoiszxl.cqrs.command.FileDeleteCommand)

Aggregations

Wrappers (com.baomidou.mybatisplus.core.toolkit.Wrappers)16 Collectors (java.util.stream.Collectors)15 Service (org.springframework.stereotype.Service)14 List (java.util.List)13 Transactional (org.springframework.transaction.annotation.Transactional)11 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)8 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 ArrayList (java.util.ArrayList)4 RequiredArgsConstructor (lombok.RequiredArgsConstructor)4 StrUtil (cn.hutool.core.util.StrUtil)3 Arrays (java.util.Arrays)3 Slf4j (lombok.extern.slf4j.Slf4j)3 SecurityContextUtils (cn.surveyking.server.core.uitls.SecurityContextUtils)2 BaseService (cn.surveyking.server.service.BaseService)2 UserService (cn.surveyking.server.service.UserService)2 RoleMenuDo (com.albedo.java.modules.sys.domain.RoleMenuDo)2 RoleMenuService (com.albedo.java.modules.sys.service.RoleMenuService)2 SysCacheUtil (com.albedo.java.modules.sys.util.SysCacheUtil)2 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)2