| | |
| | | package org.dromara.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.dev33.satoken.annotation.SaIgnore; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.dromara.common.core.domain.R; |
| | | import org.dromara.common.log.annotation.Log; |
| | | import org.dromara.common.log.enums.BusinessType; |
| | | import org.dromara.common.oss.entity.SynchronousRequest; |
| | | import org.dromara.common.redis.utils.QueueUtils; |
| | | import org.dromara.system.domain.vo.SysOssVo; |
| | | import org.dromara.system.service.ISysOssService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Slf4j |
| | | @SaIgnore |
| | |
| | | } |
| | | log.info("ossId:{},path:{}",request.getOssId(),request.getPath()); |
| | | SysOssVo oss = ossService.upload2(request); |
| | | |
| | | //添加队列数据 |
| | | QueueUtils.addDelayedQueueObject("OSS", oss.getOssId().toString(), 1, TimeUnit.HOURS); |
| | | log.info("通道: {} , 发送数据: {}", "OSS", oss.getOssId()); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除同步 |
| | | * |
| | | * @param ossIds OSS对象ID串 |
| | | */ |
| | | @SaCheckPermission("system:oss:remove") |
| | | @Log(title = "OSS对象存储", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ossIds}") |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable String ossIds) throws Exception { |
| | | return ossService.deleteWithValidByIds(List.of(convert(ossIds)), true,"000000") ? R.ok() : R.fail("提取码错误!"); |
| | | } |
| | | |
| | | public static Long[] convert(String input) { |
| | | String[] stringArray = input.split(","); |
| | | Long[] longArray = new Long[stringArray.length]; |
| | | |
| | | for (int i = 0; i < stringArray.length; i++) { |
| | | longArray[i] = Long.parseLong(stringArray[i].trim()); |
| | | } |
| | | |
| | | return longArray; |
| | | } |
| | | } |