Search in sources :

Example 1 with OptAttachment

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;
}
Also used : OptAttachment(com.paascloud.provider.model.domain.OptAttachment)

Example 2 with OptAttachment

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);
}
Also used : OptAttachment(com.paascloud.provider.model.domain.OptAttachment)

Example 3 with 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);
    }
}
Also used : OptAttachment(com.paascloud.provider.model.domain.OptAttachment) LoginAuthDto(com.paascloud.base.dto.LoginAuthDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with 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);
}
Also used : OptAttachment(com.paascloud.provider.model.domain.OptAttachment)

Example 5 with OptAttachment

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);
}
Also used : OptAttachment(com.paascloud.provider.model.domain.OptAttachment)

Aggregations

OptAttachment (com.paascloud.provider.model.domain.OptAttachment)6 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)1 OpcBizException (com.paascloud.provider.exceptions.OpcBizException)1 Transactional (org.springframework.transaction.annotation.Transactional)1