| | |
| | | package org.dromara.system.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.common.core.constant.CacheNames; |
| | | import org.dromara.common.core.domain.dto.OssDTO; |
| | | import org.dromara.common.core.exception.ServiceException; |
| | | import org.dromara.common.core.service.OssService; |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | |
| | | @Override |
| | | public List<SysOssVo> listByIds(Collection<Long> ossIds) { |
| | | List<SysOssVo> list = new ArrayList<>(); |
| | | SysOssServiceImpl ossService = SpringUtils.getAopProxy(this); |
| | | for (Long id : ossIds) { |
| | | SysOssVo vo = SpringUtils.getAopProxy(this).getById(id); |
| | | SysOssVo vo = ossService.getById(id); |
| | | if (ObjectUtil.isNotNull(vo)) { |
| | | try { |
| | | list.add(this.matchingUrl(vo)); |
| | |
| | | @Override |
| | | public String selectUrlByIds(String ossIds) { |
| | | List<String> list = new ArrayList<>(); |
| | | SysOssServiceImpl ossService = SpringUtils.getAopProxy(this); |
| | | for (Long id : StringUtils.splitTo(ossIds, Convert::toLong)) { |
| | | SysOssVo vo = SpringUtils.getAopProxy(this).getById(id); |
| | | SysOssVo vo = ossService.getById(id); |
| | | if (ObjectUtil.isNotNull(vo)) { |
| | | try { |
| | | list.add(this.matchingUrl(vo).getUrl()); |
| | |
| | | } |
| | | } |
| | | return String.join(StringUtils.SEPARATOR, list); |
| | | } |
| | | |
| | | @Override |
| | | public List<OssDTO> selectByIds(String ossIds) { |
| | | List<OssDTO> list = new ArrayList<>(); |
| | | for (Long id : StringUtils.splitTo(ossIds, Convert::toLong)) { |
| | | SysOssVo vo = SpringUtils.getAopProxy(this).getById(id); |
| | | if (ObjectUtil.isNotNull(vo)) { |
| | | try { |
| | | vo.setUrl(this.matchingUrl(vo).getUrl()); |
| | | list.add(BeanUtil.toBean(vo, OssDTO.class)); |
| | | } catch (Exception ignored) { |
| | | // 如果oss异常无法连接则将数据直接返回 |
| | | list.add(BeanUtil.toBean(vo, OssDTO.class)); |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) { |
| | |
| | | OssClient storage = OssFactory.instance(sysOss.getService()); |
| | | storage.delete(sysOss.getUrl()); |
| | | } |
| | | return baseMapper.deleteBatchIds(ids) > 0; |
| | | return baseMapper.deleteByIds(ids) > 0; |
| | | } |
| | | |
| | | /** |