提交 4d8b89f5 authored 作者: 133's avatar 133

[用户] [清退] [专管员统计] 代码提交

上级 9276e8c2
......@@ -57,33 +57,33 @@ public class BlockchaController {
}
@ApiOperation(value = "添加")
@GetMapping(value = "/sendHash/{code}/{content}")
public ResponseEntity sendHash(@PathVariable Integer code,@PathVariable String content){
@GetMapping(value = "/sendHash/{index}/{code}/{content}")
public ResponseEntity sendHash(@PathVariable Integer index,@PathVariable Integer code,@PathVariable String content){
// content= HexUtil.string2HexUTF8(content);
return ResponseEntity.ok(blockChainUtil.sendHash(code,"8a4df5a249be4b3890eeea22bd238feb"));
return ResponseEntity.ok(blockChainUtil.sendHash(index,code,"8a4df5a249be4b3890eeea22bd238feb"));
}
@ApiOperation(value = "文本添加")
@GetMapping(value = "/sendHash1/{code}/{content}")
public ResponseEntity sendHash1(@PathVariable Integer code,@PathVariable String content){
@GetMapping(value = "/sendHash1/{index}/{code}/{content}")
public ResponseEntity sendHash1(@PathVariable Integer index,@PathVariable Integer code,@PathVariable String content){
// content= HexUtil.string2HexUTF8(content);
return ResponseEntity.ok(blockChainUtil.sendText(code,content));
return ResponseEntity.ok(blockChainUtil.sendText(index,code,content));
}
@ApiOperation(value = "文本最佳添加")
@GetMapping(value = "/sendHash2/{id}/{content}")
public ResponseEntity sendHash2(@PathVariable String id,@PathVariable String content){
@GetMapping(value = "/sendHash2/{index}/{id}/{content}")
public ResponseEntity sendHash2(@PathVariable Integer index,@PathVariable String id,@PathVariable String content){
// content= HexUtil.string2HexUTF8(content);
return ResponseEntity.ok(blockChainUtil.appendText(content,id));
return ResponseEntity.ok(blockChainUtil.appendText(index,content,id));
}
@ApiOperation(value = "文本篡改验证")
@GetMapping(value = "/sendHash3/{id}/{content}")
public ResponseEntity sendHash3(@PathVariable String id,@PathVariable String content){
// content= HexUtil.string2HexUTF8(content);
return ResponseEntity.ok(blockChainUtil.verifyText(content,id));
}
// @ApiOperation(value = "文本篡改验证")
// @GetMapping(value = "/sendHash3/{key}/{id}")
// public ResponseEntity sendHash3(@PathVariable String key,@PathVariable String id,@PathVariable String content){
//// content= HexUtil.string2HexUTF8(content);
// return ResponseEntity.ok(blockChainUtil.verifyText(index,content,id));
// }
@GetMapping(value = "/fetchRecord/{id}")
......
......@@ -37,8 +37,17 @@ public interface BlockChainUtil {
* @param content 文本 200k以内
* @return bt
*/
BcText sendText(Integer index,Integer subCode, String content);
/**
* 文本上链
* @param subCode
* @param content
* @return
*/
BcText sendText(Integer subCode, String content);
/**
* hash 上链
*
......@@ -46,7 +55,7 @@ public interface BlockChainUtil {
* @param content 内容哈希,256bits hex编码。 方法可参考本模块HexUtil,方法内已转换,直接传入内容即可
* @return bh
*/
BcHash sendHash(Integer subCode, String content);
BcHash sendHash(Integer index,Integer subCode, String content);
/**
* 记录查询
......@@ -77,6 +86,15 @@ public interface BlockChainUtil {
*/
BcHistory fetchHistory(Map<String, Object> map);
/**
* 文本追加更新
*
* @param content 内容文本,上限为200KB
* @param recordId 本条记录上次上链或追加返回的记录id, 确保顺序追加
* @return bc
*/
BcText appendText(Integer index,String content, String recordId);
/**
* 文本追加更新
*
......@@ -93,7 +111,7 @@ public interface BlockChainUtil {
* @param recordId 本条记录上次上链或追加返回的记录id, 确保顺序追加
* @return bc
*/
BcHash appendHash(String content, String recordId);
BcHash appendHash(Integer index,String content, String recordId);
/**
* 哈希防篡改校验
......
......@@ -27,9 +27,14 @@ import java.util.UUID;
@Component
public class BlockChainUtilImpl implements BlockChainUtil {
private final static String SECRET_KEY = "3RJWStDCXN7mqJyZAB8rF59f87arGShdk9aKyDN3wKbzq9JnaXom1Hpe6mHT1k2yx9zfE7VFWidqwuxyT7DtPjCs";
private final static String SECRET_ID = "JAjQyTZdR8bmbHaU6iiFGvrCuUik4cG4U4ostk8KKrbS";
private final static String BLOCK_CHAIN_URL = "http://192.168.0.80:8076";
public String SECRET_KEY = "3mdeM1dw2FfHrd5h6WAuhB3WYdDG6ZAgz96CcM1nzxbiYA8QaaZHW75Je9xKixTTD2rwujyb1gVUNPYm5W6FPZQ8";
public String SECRET_ID = "3yXRRiL9xsLfbt2kv7qRH2so6ChJX3rFkay7Njcsxfbp";
private final static String BLOCK_CHAIN_URL = "http://10.153.4.12:8076";
private final static String BLOCK_CHAIN_URL2 = "http://10.153.8.10:8076";
private final static String BLOCK_CHAIN_URL3 = "http://10.153.8.11:8076";
private final static String BLOCK_CHAIN_URL4 = "http://10.153.110.10:8076";
private final static String BLOCK_CHAIN_URL5 = "http://10.153.6.11:8076";
@Override
......@@ -59,13 +64,45 @@ public class BlockChainUtilImpl implements BlockChainUtil {
}
@Override
public BcText sendText(Integer subCode, String content) {
public BcText sendText(Integer index,Integer subCode, String content) {
SortedMap<Object, Object> request = getRequest();
request.put("content", content);
request.put("subCode", subCode);
request.put("apiSignature", ApiSignatureUtil.getApiSignature(request, SECRET_KEY));
switch (index){
case 1:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL + BcUrl.SEND_TEXT,
request,
BcText.class
);
case 2:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL2 + BcUrl.SEND_TEXT,
request,
BcText.class
);
case 3:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL3 + BcUrl.SEND_TEXT,
request,
BcText.class
);
case 4:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL4 + BcUrl.SEND_TEXT,
request,
BcText.class
);
case 5:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL5 + BcUrl.SEND_TEXT,
request,
BcText.class
);
}
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL + BcUrl.SEND_TEXT,
request,
......@@ -73,19 +110,66 @@ public class BlockChainUtilImpl implements BlockChainUtil {
);
}
public static void main(String[] args) {
new BlockChainUtilImpl().sendHash(1,"阿斯顿好看");
@Override
public BcText sendText(Integer subCode, String content) {
SortedMap<Object, Object> request = getRequest();
request.put("content", content);
request.put("subCode", subCode);
request.put("apiSignature", ApiSignatureUtil.getApiSignature(request, SECRET_KEY));
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL + BcUrl.SEND_TEXT,
request,
BcText.class
);
}
// public static void main(String[] args) {
// new BlockChainUtilImpl().sendHash(1,"阿斯顿好看");
// }
@Override
public BcHash sendHash(Integer subCode, String content) {
public BcHash sendHash(Integer index,Integer subCode, String content) {
SortedMap<Object, Object> request = getRequest();
request.put("content", HexUtil.hex64(content));
request.put("subCode", subCode);
String s = ApiSignatureUtil.getApiSignature(request, SECRET_KEY);
log.info("apiSignature:{}",s);
request.put("apiSignature", s);
switch (index){
case 1:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL + BcUrl.SEND_HASH,
request,
BcHash.class
);
case 2:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL2 + BcUrl.SEND_HASH,
request,
BcHash.class
);
case 3:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL3 + BcUrl.SEND_HASH,
request,
BcHash.class
);
case 4:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL4 + BcUrl.SEND_HASH,
request,
BcHash.class
);
case 5:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL5 + BcUrl.SEND_HASH,
request,
BcHash.class
);
}
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL + BcUrl.SEND_HASH,
request,
......@@ -118,6 +202,50 @@ public class BlockChainUtilImpl implements BlockChainUtil {
);
}
@Override
public BcText appendText(Integer index,String content, String recordId) {
SortedMap<Object, Object> request = getRequest();
request.put("content", content);
request.put("recordID", recordId);
String s = ApiSignatureUtil.getApiSignature(request, SECRET_KEY);
request.put("apiSignature", s);
switch (index){
case 1:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL + BcUrl.APPEND_TEXT,
request,
BcText.class);
case 2:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL2 + BcUrl.APPEND_TEXT,
request,
BcText.class);
case 3:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL3 + BcUrl.APPEND_TEXT,
request,
BcText.class);
case 4:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL4 + BcUrl.APPEND_TEXT,
request,
BcText.class);
case 5:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL5 + BcUrl.APPEND_TEXT,
request,
BcText.class);
}
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL + BcUrl.APPEND_TEXT,
request,
BcText.class);
}
@Override
public BcText appendText(String content, String recordId) {
SortedMap<Object, Object> request = getRequest();
......@@ -133,13 +261,47 @@ public class BlockChainUtilImpl implements BlockChainUtil {
}
@Override
public BcHash appendHash(String content, String recordId) {
public BcHash appendHash(Integer index,String content, String recordId) {
SortedMap<Object, Object> request = getRequest();
request.put("content", HexUtil.hex64(content));
request.put("recordID", recordId);
String s = ApiSignatureUtil.getApiSignature(request, SECRET_KEY);
request.put("apiSignature", s);
switch (index){
case 1:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL + BcUrl.APPEND_HASH,
request,
BcHash.class
);
case 2:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL2 + BcUrl.APPEND_HASH,
request,
BcHash.class
);
case 3:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL3 + BcUrl.APPEND_HASH,
request,
BcHash.class
);
case 4:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL4 + BcUrl.APPEND_HASH,
request,
BcHash.class
);
case 5:
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL5 + BcUrl.APPEND_HASH,
request,
BcHash.class
);
}
return new RestTemplate().postForObject(
BLOCK_CHAIN_URL + BcUrl.APPEND_HASH,
request,
......
package com.tykj.dev.config.domin;
import java.util.Date;
/**
* @author zjm
* @version 1.0.0
* @ClassName SystemLog.java
* @Description TODO
* @createTime 2020年12月03日 14:14:00
*/
public class SystemLog {
/**
* 日志数据id
*/
private Integer id;
/**
* 创建时间
*/
private Date createTime = new Date();
/**
* 操作人名称
*/
private String operatorName;
}
......@@ -69,7 +69,7 @@ public class Swagger2Config {
}
private SecurityScheme securityScheme() {
GrantType grantType = new ResourceOwnerPasswordCredentialsGrant("/userLogin");
GrantType grantType = new ResourceOwnerPasswordCredentialsGrant("/equip/userLogin");
return new OAuthBuilder()
.name("spring_oauth")
......
......@@ -105,7 +105,7 @@ public class FileController {
if (!file1.exists()) {
file1.mkdirs();
}
String fileName = UUID.randomUUID().toString() + ".pdf";
String fileName = UUID.randomUUID().toString().replace("-", "")+ ".pdf";
File file = new File(url + "print/" + fileName);
// 第一步:创建一个document对象。
......@@ -145,7 +145,7 @@ public class FileController {
OutputStream os = null;
String[] split = originalFilename.split("\\.");
String newName = UUID.randomUUID().toString() + "." + split[split.length - 1];
String newName = UUID.randomUUID().toString().replace("-", "") + "." + split[split.length - 1];
byte[] typeByte = new byte[1024 * 1024 * 10];
try {
inputStream = file.getInputStream();
......
......@@ -98,7 +98,7 @@ public class UseReportFIleServiceImpl implements UseReportFIleService {
String fileName = wrodParameter.getTitle1() + ".doc";
url = url + UUID.randomUUID().toString() + ".doc";
url = url + UUID.randomUUID().toString().replace("-", "") + ".doc";
FileOutputStream out = new FileOutputStream(url);
doc.write(out);
out.close();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论