Commit 2580bdfa authored by liqin's avatar liqin 💬

bug fixed

parent a7f88b77
package cn.wisenergy.chnmuseum.party.mapper;
import cn.wisenergy.chnmuseum.party.model.Asset;
import cn.wisenergy.chnmuseum.party.model.TBoxOperation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* <p>
* 视频 Mapper 接口
......@@ -31,4 +34,11 @@ public interface AssetMapper extends BaseMapper<Asset> {
"</script>")
Page<Asset> selectPageByConditions(Page<Object> page, String videoContentCatId, String videoContentCopyrightOwnerId);
@Select("<script>" +
"SELECT b.*, o.code as organ_code, o.`name` as organ_name " +
"FROM t_box_operation b, t_organ o " +
"where b.organ_id = o.id and b.private_key <> NULL" +
"</script>")
List<TBoxOperation> selectBoxListByOrgan();
}
package cn.wisenergy.chnmuseum.party.service;
import cn.wisenergy.chnmuseum.party.model.Asset;
import cn.wisenergy.chnmuseum.party.model.TBoxOperation;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 视频 服务类
......@@ -16,4 +19,6 @@ public interface AssetService extends IService<Asset> {
Page<Asset> pageByConditions(Page<Object> page, String videoContentCatId, String videoContentCopyrightOwnerId);
List<TBoxOperation> listBoxByOrgan();
}
......@@ -2,12 +2,14 @@ package cn.wisenergy.chnmuseum.party.service.impl;
import cn.wisenergy.chnmuseum.party.mapper.AssetMapper;
import cn.wisenergy.chnmuseum.party.model.Asset;
import cn.wisenergy.chnmuseum.party.model.TBoxOperation;
import cn.wisenergy.chnmuseum.party.service.AssetService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* <p>
......@@ -28,4 +30,9 @@ public class AssetServiceImpl extends ServiceImpl<AssetMapper, Asset> implements
return assetMapper.selectPageByConditions(page, videoContentCatId, videoContentCopyrightOwnerId);
}
@Override
public List<TBoxOperation> listBoxByOrgan() {
return assetMapper.selectBoxListByOrgan();
}
}
package cn.wisenergy.chnmuseum.party.web.controller;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ZipUtil;
import cn.wisenergy.chnmuseum.party.common.dfs.FastDFSUtils;
import cn.wisenergy.chnmuseum.party.common.log.MethodLog;
import cn.wisenergy.chnmuseum.party.common.log.OperModule;
import cn.wisenergy.chnmuseum.party.common.log.OperType;
import cn.wisenergy.chnmuseum.party.common.util.RSAUtils;
import cn.wisenergy.chnmuseum.party.common.video.VideoEncryptUtil;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.model.Asset;
import cn.wisenergy.chnmuseum.party.model.TBoxOperation;
import cn.wisenergy.chnmuseum.party.service.AssetService;
import cn.wisenergy.chnmuseum.party.service.TBoxOperationService;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.tobato.fastdfs.domain.fdfs.MetaData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -33,10 +35,10 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* <pre>
......@@ -110,18 +112,14 @@ public class AssetController extends BaseController {
final Map<String, InputStream> map = new LinkedHashMap<>(idList.size());
final List<Asset> assetList = assetService.listByIds(idList);
for (final Asset asset : assetList) {
final String fileUrlCrypto = asset.getFileUrlCrypto();
for (Asset asset : assetList) {
ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
FastDFSUtils.downloadFile(fileUrlCrypto, byteOutputStream);
final Set<MetaData> fileMetaData = FastDFSUtils.getFileMetaData(fileUrlCrypto);
String fileName = fileMetaData.stream().filter(x -> "MD5".equals(x.getName())).map(MetaData::getValue).findFirst().get() + ".chnmuseum";
map.put(fileName, VideoEncryptUtil.encrypt(new ByteArrayInputStream(byteOutputStream.toByteArray()), VideoEncryptUtil.cipher));
FastDFSUtils.downloadFile(asset.getFileUrlCrypto(), byteOutputStream);
map.put(asset.getMd5() + ".chnmuseum", VideoEncryptUtil.encrypt(new ByteArrayInputStream(byteOutputStream.toByteArray()), VideoEncryptUtil.cipher));
}
ServletOutputStream outputStream = response.getOutputStream();
String[] paths = map.keySet().toArray(new String[0]);
InputStream[] ins = map.values().toArray(new InputStream[0]);
ZipUtil.zip(outputStream, paths, ins);
ZipUtil.zip(response.getOutputStream(), paths, ins);
}
@ApiOperation(value = "视频文件汇出GET", notes = "视频文件汇出GET")
......@@ -133,39 +131,33 @@ public class AssetController extends BaseController {
@MethodLog(operModule = OperModule.VIDEOREMIT, operType = OperType.VIDEO_EXPORT)
public void downloadByGet(@RequestParam("idList") List<String> idList, HttpServletResponse response) throws IOException {
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.addHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + URLEncoder.encode("file.zip", "UTF-8"));
response.addHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + URLEncoder.encode("video.zip", "UTF-8"));
final Map<String, InputStream> map = new LinkedHashMap<>(idList.size());
final List<Asset> assetList = assetService.listByIds(idList);
for (final Asset asset : assetList) {
final String fileUrlCrypto = asset.getFileUrlCrypto();
for (Asset asset : assetList) {
ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
FastDFSUtils.downloadFile(fileUrlCrypto, byteOutputStream);
final Set<MetaData> fileMetaData = FastDFSUtils.getFileMetaData(fileUrlCrypto);
String fileName = fileMetaData.stream().filter(x -> "MD5".equals(x.getName())).map(MetaData::getValue).findFirst().get() + ".chnmuseum";
map.put(fileName, VideoEncryptUtil.encrypt(new ByteArrayInputStream(byteOutputStream.toByteArray()), VideoEncryptUtil.cipher));
FastDFSUtils.downloadFile(asset.getFileUrlCrypto(), byteOutputStream);
map.put(asset.getMd5() + ".chnmuseum", VideoEncryptUtil.encrypt(new ByteArrayInputStream(byteOutputStream.toByteArray()), VideoEncryptUtil.cipher));
}
ServletOutputStream outputStream = response.getOutputStream();
String[] paths = map.keySet().toArray(new String[0]);
InputStream[] ins = map.values().toArray(new InputStream[0]);
ZipUtil.zip(outputStream, paths, ins);
ZipUtil.zip(response.getOutputStream(), paths, ins);
}
@ApiOperation(value = "视频文件汇出GET", notes = "视频文件汇出GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "idList", value = "视频文件标识ID集合", dataType = "String", paramType = "query")
})
@GetMapping("/downloadCipher")
@ApiOperation(value = "导出所有机顶盒的文件加密密钥", notes = "导出所有机顶盒的文件加密密钥")
@PostMapping("/downloadCipher")
@RequiresAuthentication
@MethodLog(operModule = OperModule.VIDEOREMIT, operType = OperType.VIDEO_EXPORT)
public void downloadCipher(@RequestParam("idList") List<String> idList, HttpServletResponse response) throws IOException {
public void downloadCipher(HttpServletResponse response) throws IOException {
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.addHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + URLEncoder.encode("file.zip", "UTF-8"));
final Map<String, InputStream> map = new LinkedHashMap<>(idList.size() + 1);
// final TBoxOperation tBoxOperation = this.tBoxOperationService.getOne(Wrappers.<TBoxOperation>lambdaQuery().eq(TBoxOperation::getOrganId, user.getOrgId()));
// map.put("cipher.txt", IoUtil.toStream(RSAUtils.encrypt(VideoEncryptUtil.cipher, tBoxOperation.getPublicKey()), StandardCharsets.UTF_8));
response.addHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + URLEncoder.encode("cipher.zip", "UTF-8"));
final List<TBoxOperation> tBoxOperationList = assetService.listBoxByOrgan();
final Map<String, InputStream> map = new LinkedHashMap<>(tBoxOperationList.size());
for (TBoxOperation tBoxOperation : tBoxOperationList) {
map.put(tBoxOperation.getOrganName() + ".cipher", IoUtil.toStream(RSAUtils.encrypt(VideoEncryptUtil.cipher, tBoxOperation.getPublicKey()), StandardCharsets.UTF_8));
}
ServletOutputStream outputStream = response.getOutputStream();
String[] paths = map.keySet().toArray(new String[0]);
InputStream[] ins = map.values().toArray(new InputStream[0]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment