Commit 2580bdfa authored by liqin's avatar liqin 💬

bug fixed

parent a7f88b77
package cn.wisenergy.chnmuseum.party.mapper; package cn.wisenergy.chnmuseum.party.mapper;
import cn.wisenergy.chnmuseum.party.model.Asset; 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.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.util.List;
/** /**
* <p> * <p>
* 视频 Mapper 接口 * 视频 Mapper 接口
...@@ -31,4 +34,11 @@ public interface AssetMapper extends BaseMapper<Asset> { ...@@ -31,4 +34,11 @@ public interface AssetMapper extends BaseMapper<Asset> {
"</script>") "</script>")
Page<Asset> selectPageByConditions(Page<Object> page, String videoContentCatId, String videoContentCopyrightOwnerId); 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; package cn.wisenergy.chnmuseum.party.service;
import cn.wisenergy.chnmuseum.party.model.Asset; 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/** /**
* <p> * <p>
* 视频 服务类 * 视频 服务类
...@@ -16,4 +19,6 @@ public interface AssetService extends IService<Asset> { ...@@ -16,4 +19,6 @@ public interface AssetService extends IService<Asset> {
Page<Asset> pageByConditions(Page<Object> page, String videoContentCatId, String videoContentCopyrightOwnerId); Page<Asset> pageByConditions(Page<Object> page, String videoContentCatId, String videoContentCopyrightOwnerId);
List<TBoxOperation> listBoxByOrgan();
} }
...@@ -2,12 +2,14 @@ package cn.wisenergy.chnmuseum.party.service.impl; ...@@ -2,12 +2,14 @@ package cn.wisenergy.chnmuseum.party.service.impl;
import cn.wisenergy.chnmuseum.party.mapper.AssetMapper; import cn.wisenergy.chnmuseum.party.mapper.AssetMapper;
import cn.wisenergy.chnmuseum.party.model.Asset; 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.AssetService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
/** /**
* <p> * <p>
...@@ -28,4 +30,9 @@ public class AssetServiceImpl extends ServiceImpl<AssetMapper, Asset> implements ...@@ -28,4 +30,9 @@ public class AssetServiceImpl extends ServiceImpl<AssetMapper, Asset> implements
return assetMapper.selectPageByConditions(page, videoContentCatId, videoContentCopyrightOwnerId); return assetMapper.selectPageByConditions(page, videoContentCatId, videoContentCopyrightOwnerId);
} }
@Override
public List<TBoxOperation> listBoxByOrgan() {
return assetMapper.selectBoxListByOrgan();
}
} }
package cn.wisenergy.chnmuseum.party.web.controller; package cn.wisenergy.chnmuseum.party.web.controller;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ZipUtil; import cn.hutool.core.util.ZipUtil;
import cn.wisenergy.chnmuseum.party.common.dfs.FastDFSUtils; import cn.wisenergy.chnmuseum.party.common.dfs.FastDFSUtils;
import cn.wisenergy.chnmuseum.party.common.log.MethodLog; import cn.wisenergy.chnmuseum.party.common.log.MethodLog;
import cn.wisenergy.chnmuseum.party.common.log.OperModule; import cn.wisenergy.chnmuseum.party.common.log.OperModule;
import cn.wisenergy.chnmuseum.party.common.log.OperType; 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.video.VideoEncryptUtil;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam; import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.model.Asset; 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.AssetService;
import cn.wisenergy.chnmuseum.party.service.TBoxOperationService; import cn.wisenergy.chnmuseum.party.service.TBoxOperationService;
import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController; import cn.wisenergy.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
...@@ -33,10 +35,10 @@ import java.io.ByteArrayOutputStream; ...@@ -33,10 +35,10 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* <pre> * <pre>
...@@ -110,18 +112,14 @@ public class AssetController extends BaseController { ...@@ -110,18 +112,14 @@ public class AssetController extends BaseController {
final Map<String, InputStream> map = new LinkedHashMap<>(idList.size()); final Map<String, InputStream> map = new LinkedHashMap<>(idList.size());
final List<Asset> assetList = assetService.listByIds(idList); final List<Asset> assetList = assetService.listByIds(idList);
for (final Asset asset : assetList) { for (Asset asset : assetList) {
final String fileUrlCrypto = asset.getFileUrlCrypto();
ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
FastDFSUtils.downloadFile(fileUrlCrypto, byteOutputStream); FastDFSUtils.downloadFile(asset.getFileUrlCrypto(), byteOutputStream);
final Set<MetaData> fileMetaData = FastDFSUtils.getFileMetaData(fileUrlCrypto); map.put(asset.getMd5() + ".chnmuseum", VideoEncryptUtil.encrypt(new ByteArrayInputStream(byteOutputStream.toByteArray()), VideoEncryptUtil.cipher));
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));
} }
ServletOutputStream outputStream = response.getOutputStream();
String[] paths = map.keySet().toArray(new String[0]); String[] paths = map.keySet().toArray(new String[0]);
InputStream[] ins = map.values().toArray(new InputStream[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") @ApiOperation(value = "视频文件汇出GET", notes = "视频文件汇出GET")
...@@ -133,39 +131,33 @@ public class AssetController extends BaseController { ...@@ -133,39 +131,33 @@ public class AssetController extends BaseController {
@MethodLog(operModule = OperModule.VIDEOREMIT, operType = OperType.VIDEO_EXPORT) @MethodLog(operModule = OperModule.VIDEOREMIT, operType = OperType.VIDEO_EXPORT)
public void downloadByGet(@RequestParam("idList") List<String> idList, HttpServletResponse response) throws IOException { public void downloadByGet(@RequestParam("idList") List<String> idList, HttpServletResponse response) throws IOException {
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); 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 Map<String, InputStream> map = new LinkedHashMap<>(idList.size());
final List<Asset> assetList = assetService.listByIds(idList); final List<Asset> assetList = assetService.listByIds(idList);
for (final Asset asset : assetList) { for (Asset asset : assetList) {
final String fileUrlCrypto = asset.getFileUrlCrypto();
ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
FastDFSUtils.downloadFile(fileUrlCrypto, byteOutputStream); FastDFSUtils.downloadFile(asset.getFileUrlCrypto(), byteOutputStream);
final Set<MetaData> fileMetaData = FastDFSUtils.getFileMetaData(fileUrlCrypto); map.put(asset.getMd5() + ".chnmuseum", VideoEncryptUtil.encrypt(new ByteArrayInputStream(byteOutputStream.toByteArray()), VideoEncryptUtil.cipher));
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));
} }
ServletOutputStream outputStream = response.getOutputStream();
String[] paths = map.keySet().toArray(new String[0]); String[] paths = map.keySet().toArray(new String[0]);
InputStream[] ins = map.values().toArray(new InputStream[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") @ApiOperation(value = "导出所有机顶盒的文件加密密钥", notes = "导出所有机顶盒的文件加密密钥")
@ApiImplicitParams({ @PostMapping("/downloadCipher")
@ApiImplicitParam(name = "idList", value = "视频文件标识ID集合", dataType = "String", paramType = "query")
})
@GetMapping("/downloadCipher")
@RequiresAuthentication @RequiresAuthentication
@MethodLog(operModule = OperModule.VIDEOREMIT, operType = OperType.VIDEO_EXPORT) @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.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("cipher.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));
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(); ServletOutputStream outputStream = response.getOutputStream();
String[] paths = map.keySet().toArray(new String[0]); String[] paths = map.keySet().toArray(new String[0]);
InputStream[] ins = map.values().toArray(new InputStream[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