Browse Source

删除通过信息先删除上传的文档

wangcahngsheng 1 year ago
parent
commit
baf7bf2544

+ 1 - 15
ims-service/ims-eval/src/main/java/com/ims/eval/controller/NoticeManagementController.java

@@ -146,7 +146,7 @@ public class NoticeManagementController {
 	public R deleteAll(@PathVariable("ids") String ids) {
 		try {
 			String[] strings = ids.split(",");
-			boolean b = evaluationNoticeService.removeByIds(Arrays.asList(strings));
+			boolean b = evaluationNoticeService.removeByIds(Arrays.asList(strings), request);
 			if (b) {
 				return R.ok().data(b);
 			} else {
@@ -251,18 +251,4 @@ public class NoticeManagementController {
 		List<EvaluationNotice> list = evaluationNoticeService.circularDisplay(deptId, noticeTitle, beginDataTime, endDataTime);
 		return R.ok().data(list);
 	}
-
-	/**
-	 * 文件预览
-	 *
-	 * @param url 文件路径
-	 * @return 结果
-	 */
-	@GetMapping(value = "/filePreview")
-	public R convertToHtml(@RequestParam("url") String url) throws UnknownHostException {
-		InetAddress localHost = InetAddress.getLocalHost();
-		String ip = localHost.getHostAddress();
-		String httpUrl = "http://" + ip + ":28900/file/" + url;
-		return R.ok().data(httpUrl);
-	}
 }

+ 2 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IEvaluationNoticeService.java

@@ -22,4 +22,6 @@ public interface IEvaluationNoticeService extends IService<EvaluationNotice> {
 	boolean deleteAttachment(String id, String docPath, HttpServletRequest request);
 
 	List<EvaluationNotice> circularDisplay(String deptId, String noticeTitle, String beginDataTime, String endDataTime);
+
+	boolean removeByIds(List<String> ids, HttpServletRequest request);
 }

+ 30 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluationNoticeServiceImpl.java

@@ -232,4 +232,34 @@ public class EvaluationNoticeServiceImpl extends ServiceImpl<EvaluationNoticeMap
 		}
 		return list;
 	}
+
+	@Override
+	public boolean removeByIds(List<String> ids, HttpServletRequest request) {
+		for (String id : ids) {
+			EvaluationNotice evaluationNotice = baseMapper.selectById(id);
+			if (null != evaluationNotice) {
+				if (evaluationNotice.getNoticeAnnex().length() > 0) {
+					String[] docPaths = evaluationNotice.getNoticeAnnex().split(",");
+					for (String docPath : docPaths) {
+						HttpHeaders headers = new HttpHeaders();
+						headers.add("iamAccessToken", request.getHeader("Blade-Auth"));
+						headers.add("iamCode", request.getHeader("code"));
+						HttpEntity<Map> param = new HttpEntity<>(null, headers);
+						ResponseEntity<String> responseEntity2 = restTemplate.exchange(imaConfig.getGatewayUrl() + "f-center/dm/dmDoc/remove?docPath={1}", HttpMethod.GET, param, String.class, docPath);
+						log.info("\n code:{}\n header:{}\n body:{}\n", responseEntity2.getStatusCodeValue(), responseEntity2.getHeaders(), responseEntity2.getBody());
+						if (200 == responseEntity2.getStatusCodeValue()) {
+							ResultInfo resultInfo = JSON.parseObject(responseEntity2.getBody(), ResultInfo.class);
+							if ("删除成功".equals(resultInfo.getMessage())) {
+								System.out.println("删除" + docPath + "文件成功!");
+							} else {
+								System.out.println("删除" + docPath + "文件失败!失败原因为" + resultInfo.getMessage() + "!");
+							}
+						}
+					}
+				}
+			}
+		}
+		baseMapper.deleteBatchIds(ids);
+		return true;
+	}
 }