Browse Source

新增查询铸造接口

master
long 3 years ago
parent
commit
d4c21ec847
  1. 11
      conflux-admin/src/main/java/com/conflux/web/controller/api/ConfluxAipController.java
  2. 2
      conflux-admin/src/main/java/com/conflux/web/controller/nft/mapper/NftCollectionMapper.java
  3. 2
      conflux-admin/src/main/java/com/conflux/web/controller/nft/service/ConfluxService.java
  4. 8
      conflux-admin/src/main/java/com/conflux/web/controller/nft/service/INftCollectionService.java
  5. 49
      conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/ConfluxServiceImpl.java
  6. 5
      conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/NftCollectionServiceImpl.java
  7. 2
      conflux-admin/src/main/java/com/conflux/web/controller/util/AESUtil.java
  8. 8
      conflux-system/src/main/resources/mapper/system/NftCollectionMapper.xml

11
conflux-admin/src/main/java/com/conflux/web/controller/api/ConfluxAipController.java

@ -49,4 +49,15 @@ public class ConfluxAipController {
public AjaxResult getToken() {
return confluxService.getToken();
}
/**
* 查询id是否铸造成功
* @param ids
* @return
*/
@ApiOperation("查询id是否铸造成功")
@GetMapping("/getNftStatus")
public AjaxResult getNftStatus(@RequestParam("ids") String[] ids){
return confluxService.getNftStatus(ids);
}
}

2
conflux-admin/src/main/java/com/conflux/web/controller/nft/mapper/NftCollectionMapper.java

@ -31,7 +31,7 @@ public interface NftCollectionMapper
* @return nft上链集合
*/
public List<NftCollection> selectNftCollectionList(NftCollection nftCollection);
public List<NftCollection> selectNftCollectionListByIds(@Param("stringIds")String[] stringIds,@Param("onChainStatus") Integer onChainStatus);
/**
* 新增nft上链
*

2
conflux-admin/src/main/java/com/conflux/web/controller/nft/service/ConfluxService.java

@ -19,4 +19,6 @@ public interface ConfluxService {
* @return
*/
AjaxResult getToken();
AjaxResult getNftStatus(String[] ids);
}

8
conflux-admin/src/main/java/com/conflux/web/controller/nft/service/INftCollectionService.java

@ -30,6 +30,14 @@ public interface INftCollectionService
*/
public List<NftCollection> selectNftCollectionList(NftCollection nftCollection);
/**
* 查询nft上链的id
* @param stringIds
* @param onChainStatus
* @return
*/
public List<NftCollection> selectNftCollectionListByIds(String[] stringIds,Integer onChainStatus);
/**
* 新增nft上链
*

49
conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/ConfluxServiceImpl.java

@ -78,6 +78,15 @@ public class ConfluxServiceImpl implements ConfluxService {
if (checkArgs.getIds().length > 100) {
return AjaxResult.error("上链数量超出100!");
}
String[] ids = checkArgs.getIds();
List<NftCollection> nftCollections = nftCollectionService.selectNftCollectionListByIds(ids, null);
if (nftCollections != null) {
List list = new ArrayList();
for (NftCollection n : nftCollections) {
list.add(n.getInformationTableId());
}
return AjaxResult.error("已经上链的id", list);
}
String checkArgsToken = AESUtil.decrypt(checkArgs.getToken(), ConfluxArt.AESKEY);
String token = (String) redisUtils.get(checkArgsToken);
if (null == token) {
@ -153,9 +162,14 @@ public class ConfluxServiceImpl implements ConfluxService {
if (executeMakeUp(contract, contractConfig.getUnitName())) {
isFalg = false;
}
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("--------正在铸造----------->");
}
});
System.out.println("------------------->");
return AjaxResult.success("上链成功!");
}
return AjaxResult.error();
@ -173,9 +187,26 @@ public class ConfluxServiceImpl implements ConfluxService {
return AjaxResult.success(map);
}
@Override
public AjaxResult getNftStatus(String[] ids) {
List<NftCollection> nftCollections = nftCollectionService.selectNftCollectionListByIds(ids, 2);
if (nftCollections.size() > 0) {
List list = new ArrayList();
for (NftCollection n : nftCollections) {
list.add(n.getInformationTableId());
}
return AjaxResult.success("上链成功的id", list);
}
return AjaxResult.error("暂无数据");
}
public boolean executeMakeUp(String contract, String markName) {
log.info("[dispatchHandler]{}", "开始监听数据");
CollectConfig collect = collectConfigService.selectCollectConfigByStatus();
CollectConfig collect = (CollectConfig) redisUtils.get(contract);
if (null == collect) {
collect = collectConfigService.selectCollectConfigByStatus();
redisUtils.set(contract, collect);
}
if (collect.getOnPause()) {
log.info("[dispatchHandler]{}", "暂停中");
try {
@ -212,7 +243,11 @@ public class ConfluxServiceImpl implements ConfluxService {
}
FilterMapVO vo = getFilter(eventParams);
//获取数据高度
long from = collect.getEpochNumber();
String keyNumber = contract + "number";
long from = (long) redisUtils.get(keyNumber);
if (null == redisUtils.get(contract + "number")) {
from = collect.getEpochNumber();
}
// Invoke cfx method
BigInteger epoch = cfx.getEpochNumber().sendAndGet();
log.info("[executeMakeUp][Current epoch]:{}", epoch);
@ -277,13 +312,17 @@ public class ConfluxServiceImpl implements ConfluxService {
if (isSuccess) {
t.setEpochNumber(to);
log.info("[dispatchHandler][更新高度]:{}", to);
redisUtils.set(contract + "number", to);
}
if (logList.size() > 0) {
int i = collectConfigService.updateCollectConfig(t);
if (i <= 0) {
log.error("[dispatchHandler][更新高度失败]:{}", to);
throw new RuntimeException("更新高度失败");
}
}
if (logList.size() > 0) {
log.info("[dispatchHandler][更新高度成功]:{}", to);
redisUtils.del(contract);
redisUtils.del(keyNumber);
return true;
}
return false;

5
conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/NftCollectionServiceImpl.java

@ -50,6 +50,11 @@ public class NftCollectionServiceImpl implements INftCollectionService {
return nftCollectionMapper.selectNftCollectionList(nftCollection);
}
@Override
public List<NftCollection> selectNftCollectionListByIds(String[] stringIds,Integer onChainStatus) {
return nftCollectionMapper.selectNftCollectionListByIds(stringIds,onChainStatus);
}
@Override
public int insertNftCollection(NftCollection nftCollection) {
return nftCollectionMapper.insertNftCollection(nftCollection);

2
conflux-admin/src/main/java/com/conflux/web/controller/util/AESUtil.java

@ -175,7 +175,7 @@ public final class AESUtil {
public static void main(String[] args) {
try {
String encrypt = encrypt("a92ccc5a-d74c-4b58-9092-c91ff4a4fb9a","CONFLUX@123");
String encrypt = encrypt("0x7803ec04eed7bd4f3fd9c3fc824408a80e0b20b599b5e726cbaa609d48a2082d","CONFLUX@123");
System.err.println(encrypt);
} catch (Exception e) {
e.printStackTrace();

8
conflux-system/src/main/resources/mapper/system/NftCollectionMapper.xml

@ -40,6 +40,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectNftCollectionVo"/>
where information_table_id = #{hexTokenId}
</select>
<select id="selectNftCollectionListByIds" resultMap="NftCollectionResult">
select id,information_table_id from nft_collection
where information_table_id in
<foreach collection="stringIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach >
<if test="onChainStatus != null "> and on_chain_status = #{onChainStatus}</if>
</select>
<insert id="insertNftCollection" parameterType="NftCollection" useGeneratedKeys="true" keyProperty="id">
insert into nft_collection

Loading…
Cancel
Save