use of com.paascloud.provider.model.domain.OptAttachment in project paascloud-master by paascloud.
the class OptAttachmentServiceImpl method listFileUrl.
@Override
public List<ElementImgUrlDto> listFileUrl(final OptBatchGetUrlRequest urlRequest) {
List<ElementImgUrlDto> result = Lists.newArrayList();
String refNo = urlRequest.getRefNo();
Long expires = urlRequest.getExpires();
boolean encrypt = urlRequest.isEncrypt();
Preconditions.checkArgument(StringUtils.isNotEmpty(refNo), "业务单号不能为空");
List<OptAttachment> list = this.listByRefNo(refNo);
for (final OptAttachment optAttachment : list) {
String fileName = optAttachment.getPath() + optAttachment.getName();
String url = getUrl(expires, encrypt, fileName);
if (StringUtils.isNotEmpty(url)) {
ElementImgUrlDto dto = new ElementImgUrlDto(url, optAttachment.getName(), optAttachment.getId());
result.add(dto);
}
}
return result;
}
use of com.paascloud.provider.model.domain.OptAttachment in project paascloud-master by paascloud.
the class OptAttachmentServiceImpl method listByRefNo.
@Override
public List<OptAttachment> listByRefNo(final String refNo) {
OptAttachment optAttachment = new OptAttachment();
optAttachment.setRefNo(refNo);
return optAttachmentMapper.select(optAttachment);
}
use of com.paascloud.provider.model.domain.OptAttachment in project paascloud-master by paascloud.
the class OptAttachmentServiceImpl method updateAttachment.
@Override
@Transactional(rollbackFor = Exception.class)
public void updateAttachment(final UpdateAttachmentDto attachmentDto) throws QiniuException {
List<Long> attachmentIdList = attachmentDto.getAttachmentIdList();
LoginAuthDto loginAuthDto = attachmentDto.getLoginAuthDto();
String refNo = attachmentDto.getRefNo();
List<Long> idList = optAttachmentMapper.queryAttachmentByRefNo(refNo);
if (PublicUtil.isNotEmpty(idList)) {
idList.removeAll(attachmentIdList);
for (final Long id : idList) {
this.deleteFile(id);
}
}
for (final Long id : attachmentIdList) {
OptAttachment optAttachment = new OptAttachment();
optAttachment.setId(id);
optAttachment.setRefNo(refNo);
optAttachment.setUpdateInfo(loginAuthDto);
optAttachmentMapper.updateByPrimaryKeySelective(optAttachment);
}
}
use of com.paascloud.provider.model.domain.OptAttachment in project paascloud-master by paascloud.
the class OptAttachmentServiceImpl method rpcGetFileUrl.
/**
* Rpc get file url string.
*
* @param optGetUrlRequest the opt get url request
*
* @return the string
*/
@Override
public String rpcGetFileUrl(OptGetUrlRequest optGetUrlRequest) {
Long attachmentId = optGetUrlRequest.getAttachmentId();
Long expires = optGetUrlRequest.getExpires();
boolean encrypt = optGetUrlRequest.isEncrypt();
if (null == attachmentId) {
throw new IllegalArgumentException("参数异常, 请检查参数");
}
OptAttachment optAttachment = this.getById(attachmentId);
String fileName = optAttachment.getPath() + optAttachment.getName();
return getUrl(expires, encrypt, fileName);
}
use of com.paascloud.provider.model.domain.OptAttachment in project paascloud-master by paascloud.
the class OptAttachmentServiceImpl method insertAttachment.
private void insertAttachment(String fileType, String bucketName, LoginAuthDto loginAuthDto, OptUploadFileRespDto fileInfo) {
String attachmentName = fileInfo.getAttachmentName();
long id = generateId();
OptAttachment optAttachment = new OptAttachment();
optAttachment.setBucketName(bucketName);
optAttachment.setFormat(fileInfo.getFileType());
optAttachment.setName(attachmentName);
optAttachment.setType(fileType);
optAttachment.setFormat(StringUtils.substringAfterLast(attachmentName, "."));
optAttachment.setPath(fileInfo.getAttachmentPath());
optAttachment.setId(id);
optAttachment.setCenterName(bucketName);
fileInfo.setAttachmentId(id);
optAttachment.setUpdateInfo(loginAuthDto);
optAttachmentMapper.insertSelective(optAttachment);
}
Aggregations