|
@ -29,6 +29,7 @@ import com.epmet.entity.OssEntity; |
|
|
import com.epmet.exception.ModuleErrorCode; |
|
|
import com.epmet.exception.ModuleErrorCode; |
|
|
import com.epmet.service.OssService; |
|
|
import com.epmet.service.OssService; |
|
|
import org.apache.commons.io.FilenameUtils; |
|
|
import org.apache.commons.io.FilenameUtils; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
@ -191,17 +192,23 @@ public class OssServiceImpl extends BaseServiceImpl<OssDao, OssEntity> implement |
|
|
@Override |
|
|
@Override |
|
|
public boolean articleRemoveFile(RemoveFileFormDTO formDTO) { |
|
|
public boolean articleRemoveFile(RemoveFileFormDTO formDTO) { |
|
|
logger.info("articleRemoveFile param:{}", JSON.toJSONString(formDTO)); |
|
|
logger.info("articleRemoveFile param:{}", JSON.toJSONString(formDTO)); |
|
|
|
|
|
if (StringUtils.isBlank(formDTO.getUrl())){ |
|
|
|
|
|
logger.warn("articleRemoveFile param is empty"); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
String key = RedisKeys.getOssFileKey(formDTO.getUrl().substring(formDTO.getUrl().lastIndexOf(StrConstant.SEPARATOR))); |
|
|
|
|
|
Object o = redisUtils.get(key); |
|
|
|
|
|
if (o == null){ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
redisUtils.delete(key); |
|
|
AbstractCloudStorageService build = OssFactory.build(); |
|
|
AbstractCloudStorageService build = OssFactory.build(); |
|
|
String ossDomain = build.getOssDomain(null); |
|
|
String ossDomain = build.getOssDomain(null); |
|
|
String fileName = formDTO.getUrl().replace(ossDomain, StrConstant.EPMETY_STR); |
|
|
String fileName = formDTO.getUrl().replace(ossDomain, StrConstant.EPMETY_STR); |
|
|
if (fileName.startsWith(StrConstant.SEPARATOR)){ |
|
|
if (fileName.startsWith(StrConstant.SEPARATOR)){ |
|
|
fileName = fileName.replaceFirst(StrConstant.SEPARATOR,StrConstant.EPMETY_STR); |
|
|
fileName = fileName.replaceFirst(StrConstant.SEPARATOR,StrConstant.EPMETY_STR); |
|
|
} |
|
|
} |
|
|
String key = RedisKeys.getOssFileKey(fileName); |
|
|
|
|
|
Object o = redisUtils.get(key); |
|
|
|
|
|
if (o == null){ |
|
|
|
|
|
//return false;
|
|
|
|
|
|
} |
|
|
|
|
|
logger.info("articleRemoveFile oss delete fileName:{}", fileName); |
|
|
logger.info("articleRemoveFile oss delete fileName:{}", fileName); |
|
|
OssFactory.build().delete(fileName,null); |
|
|
OssFactory.build().delete(fileName,null); |
|
|
OssEntity entity = baseDao.selectByUrl(formDTO.getUrl()); |
|
|
OssEntity entity = baseDao.selectByUrl(formDTO.getUrl()); |
|
|