Browse Source

完成上链操作

master
long 3 years ago
parent
commit
24447b5ac5
  1. 7
      conflux-admin/src/main/java/com/conflux/web/controller/api/ConfluxAipController.java
  2. 19
      conflux-admin/src/main/java/com/conflux/web/controller/contract/service/impl/ContractConfigServiceImpl.java
  3. 99
      conflux-admin/src/main/java/com/conflux/web/controller/nft/controller/NftCollectionController.java
  4. 99
      conflux-admin/src/main/java/com/conflux/web/controller/nft/controller/NftLogController.java
  5. 55
      conflux-admin/src/main/java/com/conflux/web/controller/nft/domain/NftCollection.java
  6. 34
      conflux-admin/src/main/java/com/conflux/web/controller/nft/domain/NftLog.java
  7. 66
      conflux-admin/src/main/java/com/conflux/web/controller/nft/mapper/NftCollectionMapper.java
  8. 63
      conflux-admin/src/main/java/com/conflux/web/controller/nft/mapper/NftLogMapper.java
  9. 71
      conflux-admin/src/main/java/com/conflux/web/controller/nft/service/INftCollectionService.java
  10. 63
      conflux-admin/src/main/java/com/conflux/web/controller/nft/service/INftLogService.java
  11. 47
      conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/ConfluxServiceImpl.java
  12. 93
      conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/NftCollectionServiceImpl.java
  13. 97
      conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/NftLogServiceImpl.java
  14. 2
      conflux-admin/src/main/java/com/conflux/web/controller/util/AESUtil.java
  15. 2
      conflux-system/src/main/resources/mapper/system/CollectConfigMapper.xml
  16. 6
      conflux-system/src/main/resources/mapper/system/ContractConfigMapper.xml
  17. 94
      conflux-system/src/main/resources/mapper/system/NftCollectionMapper.xml
  18. 65
      conflux-system/src/main/resources/mapper/system/NftLogMapper.xml

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

@ -27,7 +27,12 @@ public class ConfluxAipController {
@ApiOperation("上链")
@PostMapping("/push")
public AjaxResult confluxPush(@RequestBody CheckArgs checkArgs) {
return confluxService.confluxPush(checkArgs);
try {
return confluxService.confluxPush(checkArgs);
}catch (Exception e){
return AjaxResult.error("服务器异常,请稍后再试!");
}
}
/**

19
conflux-admin/src/main/java/com/conflux/web/controller/contract/service/impl/ContractConfigServiceImpl.java

@ -5,6 +5,7 @@ import com.conflux.common.utils.DateUtils;
import com.conflux.web.controller.contract.domain.ContractConfig;
import com.conflux.web.controller.contract.mapper.ContractConfigMapper;
import com.conflux.web.controller.contract.service.IContractConfigService;
import com.conflux.web.controller.util.AESUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -29,7 +30,13 @@ public class ContractConfigServiceImpl implements IContractConfigService {
*/
@Override
public ContractConfig selectContractConfigById(Long id) {
return contractConfigMapper.selectContractConfigById(id);
ContractConfig contractConfig = contractConfigMapper.selectContractConfigById(id);
try {
contractConfig.setPrivateKey(AESUtil.decrypt(contractConfig.getPrivateKey()));
} catch (Exception e) {
e.printStackTrace();
}
return contractConfig;
}
/**
@ -52,6 +59,11 @@ public class ContractConfigServiceImpl implements IContractConfigService {
@Override
public int insertContractConfig(ContractConfig contractConfig) {
contractConfig.setCreateTime(DateUtils.getNowDate());
try {
contractConfig.setPrivateKey(AESUtil.encrypt(contractConfig.getPrivateKey()));
} catch (Exception e) {
e.printStackTrace();
}
return contractConfigMapper.insertContractConfig(contractConfig);
}
@ -64,6 +76,11 @@ public class ContractConfigServiceImpl implements IContractConfigService {
@Override
public int updateContractConfig(ContractConfig contractConfig) {
contractConfig.setUpdateTime(DateUtils.getNowDate());
try {
contractConfig.setPrivateKey(AESUtil.encrypt(contractConfig.getPrivateKey()));
} catch (Exception e) {
e.printStackTrace();
}
return contractConfigMapper.updateContractConfig(contractConfig);
}

99
conflux-admin/src/main/java/com/conflux/web/controller/nft/controller/NftCollectionController.java

@ -0,0 +1,99 @@
package com.conflux.web.controller.nft.controller;
import com.conflux.common.annotation.Log;
import com.conflux.common.core.controller.BaseController;
import com.conflux.common.core.domain.AjaxResult;
import com.conflux.common.core.page.TableDataInfo;
import com.conflux.common.enums.BusinessType;
import com.conflux.common.utils.poi.ExcelUtil;
import com.conflux.web.controller.nft.domain.NftCollection;
import com.conflux.web.controller.nft.service.INftCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* nft上链Controller
*
* @author conflux
* @date 2022-06-02
*/
@RestController
@RequestMapping("/system/collection")
public class NftCollectionController extends BaseController
{
@Autowired
private INftCollectionService nftCollectionService;
/**
* 查询nft上链列表
*/
@PreAuthorize("@ss.hasPermi('system:collection:list')")
@GetMapping("/list")
public TableDataInfo list(NftCollection nftCollection)
{
startPage();
List<NftCollection> list = nftCollectionService.selectNftCollectionList(nftCollection);
return getDataTable(list);
}
/**
* 导出nft上链列表
*/
@PreAuthorize("@ss.hasPermi('system:collection:export')")
@Log(title = "nft上链", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, NftCollection nftCollection)
{
List<NftCollection> list = nftCollectionService.selectNftCollectionList(nftCollection);
ExcelUtil<NftCollection> util = new ExcelUtil<NftCollection>(NftCollection.class);
util.exportExcel(response, list, "nft上链数据");
}
/**
* 获取nft上链详细信息
*/
@PreAuthorize("@ss.hasPermi('system:collection:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(nftCollectionService.selectNftCollectionById(id));
}
/**
* 新增nft上链
*/
@PreAuthorize("@ss.hasPermi('system:collection:add')")
@Log(title = "nft上链", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody NftCollection nftCollection)
{
return toAjax(nftCollectionService.insertNftCollection(nftCollection));
}
/**
* 修改nft上链
*/
@PreAuthorize("@ss.hasPermi('system:collection:edit')")
@Log(title = "nft上链", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody NftCollection nftCollection)
{
return toAjax(nftCollectionService.updateNftCollection(nftCollection));
}
/**
* 删除nft上链
*/
@PreAuthorize("@ss.hasPermi('system:collection:remove')")
@Log(title = "nft上链", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(nftCollectionService.deleteNftCollectionByIds(ids));
}
}

99
conflux-admin/src/main/java/com/conflux/web/controller/nft/controller/NftLogController.java

@ -0,0 +1,99 @@
package com.conflux.web.controller.nft.controller;
import com.conflux.common.annotation.Log;
import com.conflux.common.core.controller.BaseController;
import com.conflux.common.core.domain.AjaxResult;
import com.conflux.common.core.page.TableDataInfo;
import com.conflux.common.enums.BusinessType;
import com.conflux.common.utils.poi.ExcelUtil;
import com.conflux.web.controller.nft.domain.NftLog;
import com.conflux.web.controller.nft.service.INftLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* nft日志Controller
*
* @author conflux
* @date 2022-06-02
*/
@RestController
@RequestMapping("/system/log")
public class NftLogController extends BaseController
{
@Autowired
private INftLogService nftLogService;
/**
* 查询nft日志列表
*/
@PreAuthorize("@ss.hasPermi('system:log:list')")
@GetMapping("/list")
public TableDataInfo list(NftLog nftLog)
{
startPage();
List<NftLog> list = nftLogService.selectNftLogList(nftLog);
return getDataTable(list);
}
/**
* 导出nft日志列表
*/
@PreAuthorize("@ss.hasPermi('system:log:export')")
@Log(title = "nft日志", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, NftLog nftLog)
{
List<NftLog> list = nftLogService.selectNftLogList(nftLog);
ExcelUtil<NftLog> util = new ExcelUtil<NftLog>(NftLog.class);
util.exportExcel(response, list, "nft日志数据");
}
/**
* 获取nft日志详细信息
*/
@PreAuthorize("@ss.hasPermi('system:log:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(nftLogService.selectNftLogById(id));
}
/**
* 新增nft日志
*/
@PreAuthorize("@ss.hasPermi('system:log:add')")
@Log(title = "nft日志", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody NftLog nftLog)
{
return toAjax(nftLogService.insertNftLog(nftLog));
}
/**
* 修改nft日志
*/
@PreAuthorize("@ss.hasPermi('system:log:edit')")
@Log(title = "nft日志", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody NftLog nftLog)
{
return toAjax(nftLogService.updateNftLog(nftLog));
}
/**
* 删除nft日志
*/
@PreAuthorize("@ss.hasPermi('system:log:remove')")
@Log(title = "nft日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(nftLogService.deleteNftLogByIds(ids));
}
}

55
conflux-admin/src/main/java/com/conflux/web/controller/nft/domain/NftCollection.java

@ -0,0 +1,55 @@
package com.conflux.web.controller.nft.domain;
import java.util.Date;
import com.conflux.common.core.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.conflux.common.annotation.Excel;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* nft上链对象 nft_collection
*
* @author conflux
* @date 2022-06-02
*/
@Data
public class NftCollection extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** unitID */
@Excel(name = "unitID")
private String unitName;
/** 上链藏品ID */
@Excel(name = "上链藏品ID")
private String informationTableId;
/** (0待铸造 1已铸造 2链上已确认) */
@Excel(name = "(0待铸造 1已铸造 2链上已确认)")
private Long onChainStatus;
/** 创建公司 */
@Excel(name = "创建公司")
private String createdBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdTime;
/** 更新人 */
@Excel(name = "更新人")
private String updatedBy;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedTime;
}

34
conflux-admin/src/main/java/com/conflux/web/controller/nft/domain/NftLog.java

@ -0,0 +1,34 @@
package com.conflux.web.controller.nft.domain;
import com.conflux.common.annotation.Excel;
import com.conflux.common.core.domain.BaseEntity;
import lombok.Data;
/**
* nft日志对象 nft_log
*
* @author conflux
* @date 2022-06-02
*/
@Data
public class NftLog extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* $column.columnComment
*/
private Long id;
/**
* 公司名称
*/
@Excel(name = "公司名称")
private String unitName;
/**
* 上链数量
*/
@Excel(name = "上链数量")
private Integer nftNum;
}

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

@ -0,0 +1,66 @@
package com.conflux.web.controller.nft.mapper;
import com.conflux.web.controller.nft.domain.NftCollection;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* nft上链Mapper接口
*
* @author conflux
* @date 2022-06-02
*/
public interface NftCollectionMapper
{
/**
* 查询nft上链
*
* @param id nft上链主键
* @return nft上链
*/
public NftCollection selectNftCollectionById(Long id);
/**
* 查询nft上链列表
*
* @param nftCollection nft上链
* @return nft上链集合
*/
public List<NftCollection> selectNftCollectionList(NftCollection nftCollection);
/**
* 新增nft上链
*
* @param nftCollection nft上链
* @return 结果
*/
public int insertNftCollection(NftCollection nftCollection);
public int insertListNftCollection(@Param("unitName") String unitName, @Param("stringList") List<String> stringList);
/**
* 修改nft上链
*
* @param nftCollection nft上链
* @return 结果
*/
public int updateNftCollection(NftCollection nftCollection);
/**
* 删除nft上链
*
* @param id nft上链主键
* @return 结果
*/
public int deleteNftCollectionById(Long id);
/**
* 批量删除nft上链
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteNftCollectionByIds(Long[] ids);
}

63
conflux-admin/src/main/java/com/conflux/web/controller/nft/mapper/NftLogMapper.java

@ -0,0 +1,63 @@
package com.conflux.web.controller.nft.mapper;
import com.conflux.web.controller.nft.domain.NftLog;
import java.util.List;
/**
* nft日志Mapper接口
*
* @author conflux
* @date 2022-06-02
*/
public interface NftLogMapper
{
/**
* 查询nft日志
*
* @param id nft日志主键
* @return nft日志
*/
public NftLog selectNftLogById(Long id);
/**
* 查询nft日志列表
*
* @param nftLog nft日志
* @return nft日志集合
*/
public List<NftLog> selectNftLogList(NftLog nftLog);
/**
* 新增nft日志
*
* @param nftLog nft日志
* @return 结果
*/
public int insertNftLog(NftLog nftLog);
/**
* 修改nft日志
*
* @param nftLog nft日志
* @return 结果
*/
public int updateNftLog(NftLog nftLog);
/**
* 删除nft日志
*
* @param id nft日志主键
* @return 结果
*/
public int deleteNftLogById(Long id);
/**
* 批量删除nft日志
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteNftLogByIds(Long[] ids);
}

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

@ -0,0 +1,71 @@
package com.conflux.web.controller.nft.service;
import com.conflux.web.controller.nft.domain.NftCollection;
import java.util.List;
/**
* nft上链Service接口
*
* @author conflux
* @date 2022-06-02
*/
public interface INftCollectionService
{
/**
* 查询nft上链
*
* @param id nft上链主键
* @return nft上链
*/
public NftCollection selectNftCollectionById(Long id);
/**
* 查询nft上链列表
*
* @param nftCollection nft上链
* @return nft上链集合
*/
public List<NftCollection> selectNftCollectionList(NftCollection nftCollection);
/**
* 新增nft上链
*
* @param nftCollection nft上链
* @return 结果
*/
public int insertNftCollection(NftCollection nftCollection);
/**
* 新增nft上链 (批量
*
* @param unitName,strings nft上链
* @return 结果
*/
public int insertListNftCollection(String unitName,List<String> strings);
/**
* 修改nft上链
*
* @param nftCollection nft上链
* @return 结果
*/
public int updateNftCollection(NftCollection nftCollection);
/**
* 批量删除nft上链
*
* @param ids 需要删除的nft上链主键集合
* @return 结果
*/
public int deleteNftCollectionByIds(Long[] ids);
/**
* 删除nft上链信息
*
* @param id nft上链主键
* @return 结果
*/
public int deleteNftCollectionById(Long id);
}

63
conflux-admin/src/main/java/com/conflux/web/controller/nft/service/INftLogService.java

@ -0,0 +1,63 @@
package com.conflux.web.controller.nft.service;
import com.conflux.web.controller.nft.domain.NftLog;
import java.util.List;
/**
* nft日志Service接口
*
* @author conflux
* @date 2022-06-02
*/
public interface INftLogService
{
/**
* 查询nft日志
*
* @param id nft日志主键
* @return nft日志
*/
public NftLog selectNftLogById(Long id);
/**
* 查询nft日志列表
*
* @param nftLog nft日志
* @return nft日志集合
*/
public List<NftLog> selectNftLogList(NftLog nftLog);
/**
* 新增nft日志
*
* @param nftLog nft日志
* @return 结果
*/
public int insertNftLog(NftLog nftLog);
/**
* 修改nft日志
*
* @param nftLog nft日志
* @return 结果
*/
public int updateNftLog(NftLog nftLog);
/**
* 批量删除nft日志
*
* @param ids 需要删除的nft日志主键集合
* @return 结果
*/
public int deleteNftLogByIds(Long[] ids);
/**
* 删除nft日志信息
*
* @param id nft日志主键
* @return 结果
*/
public int deleteNftLogById(Long id);
}

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

@ -8,10 +8,10 @@ import com.conflux.web.controller.collect.domain.CollectConfig;
import com.conflux.web.controller.collect.service.ICollectConfigService;
import com.conflux.web.controller.contract.domain.ContractConfig;
import com.conflux.web.controller.contract.service.IContractConfigService;
import com.conflux.web.controller.nft.domain.CheckArgs;
import com.conflux.web.controller.nft.domain.ConfluxArt;
import com.conflux.web.controller.nft.domain.ConfluxExecutor;
import com.conflux.web.controller.nft.domain.*;
import com.conflux.web.controller.nft.service.ConfluxService;
import com.conflux.web.controller.nft.service.INftCollectionService;
import com.conflux.web.controller.nft.service.INftLogService;
import com.conflux.web.controller.util.AESUtil;
import com.conflux.web.controller.util.AddressUtil;
import com.conflux.web.controller.util.redis.RedisUtils;
@ -19,9 +19,11 @@ import conflux.web3j.Account;
import conflux.web3j.Cfx;
import conflux.web3j.response.UsedGasAndCollateral;
import conflux.web3j.types.Address;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigInteger;
@ -43,8 +45,14 @@ public class ConfluxServiceImpl implements ConfluxService {
private ICollectConfigService collectConfigService;
@Autowired
private IContractConfigService contractConfigService;
@Autowired
private INftCollectionService nftCollectionService;
@Autowired
private INftLogService nftLogService;
@SneakyThrows
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult confluxPush(CheckArgs checkArgs) {
//判断参数
if (null == checkArgs) {
@ -56,7 +64,6 @@ public class ConfluxServiceImpl implements ConfluxService {
if (checkArgs.getIds().length > 100) {
return AjaxResult.error("上链数量超出100!");
}
try {
String checkArgsToken = AESUtil.decrypt(checkArgs.getToken(), ConfluxArt.AESKEY);
String token = (String) redisUtils.get(checkArgsToken);
String sign = AESUtil.decrypt(checkArgs.getSign(), ConfluxArt.AESKEY);
@ -74,7 +81,7 @@ public class ConfluxServiceImpl implements ConfluxService {
//判断上链的数量
CollectConfig collectConfig = collectConfigService.selectCollectConfigByStatus();
if (collectConfig.getMintPause()) {
log.info("[mintNft][start pause]");
log.info("[--------------------->mintNft][start pause]");
Thread.sleep(5000);
return AjaxResult.error("pause参数异常!");
}
@ -88,9 +95,9 @@ public class ConfluxServiceImpl implements ConfluxService {
opt.withGasPrice(contractConfig.getGasPrice());
//获取余额
BigInteger balance = cfx.getBalance(account.getAddress()).sendAndGet();
log.info("[mintNft][balance]{}", balance);
log.info("[--------------------->mintNft][balance]{}", balance);
if (balance.compareTo(new BigInteger("50000000000000000000")) < 0) {
log.info("[mintNft][balance not enough 50]{}", balance);
log.info("[--------------------->mintNft][balance not enough 50]{}", balance);
//sms notice
return AjaxResult.error("账户余额不足!");
}
@ -99,27 +106,31 @@ public class ConfluxServiceImpl implements ConfluxService {
ConfluxExecutor confluxExecutor=new ConfluxExecutor(account,contract);
List<String> list = Arrays.asList(checkArgs.getIds());
long start = DateUtil.currentSeconds();
log.info("[mintNft][time]{}", new SimpleDateFormat("HH:mm:ss").format(new Date(start * 1000)));
log.info("[--------------------->mintNft][time]{}", new SimpleDateFormat("HH:mm:ss").format(new Date(start * 1000)));
List<BigInteger> tokenIds = list.stream().map(n -> new BigInteger(n, 16)).collect(Collectors.toList());
log.info("[mintNft][tokenIds]:{}", tokenIds);
log.info("[--------------------->mintNft][tokenIds]:{}", tokenIds);
UsedGasAndCollateral est = confluxExecutor.getEstimate(cfx, new Address(owner),
new Address(contract), AddressUtil.getHexAddress(owner), tokenIds);
log.info("[mintNft][GasUsed]{}", est.getGasUsed());
log.info("[mintNft][StorageCollateralized]{}", est.getStorageCollateralized());
log.info("[--------------------->mintNft][GasUsed]{}", est.getGasUsed());
log.info("[--------------------->mintNft][StorageCollateralized]{}", est.getStorageCollateralized());
opt.withGasLimit(est.getGasUsed());
opt.withStorageLimit(est.getStorageCollateralized());
String hash = confluxExecutor.mulMint(opt,
AddressUtil.getHexAddress(owner), tokenIds
);
log.info("[mintNft][hash],{}", hash);
log.info("[mintNft][time end]{}", +(DateUtil.currentSeconds() - start));
//
log.info("[--------------------->mintNft][hash],{}", hash);
log.info("[--------------------->mintNft][time end]{}", +(DateUtil.currentSeconds() - start));
//保存上链的id
nftCollectionService.insertListNftCollection(contractConfig.getUnitName(),list);
//保存日志记录
NftLog nftLog=new NftLog();
nftLog.setUnitName(contractConfig.getUnitName());
nftLog.setCreateTime(new Date());
nftLog.setNftNum(checkArgs.getIds().length);
nftLogService.insertNftLog(nftLog);
log.info("上链日志----->:{"+contractConfig.getUnitName()+"}{"+new Date()+"}{"+checkArgs.getIds().length+"}");
return AjaxResult.success("上链成功!");
}
} catch (Exception e) {
log.error("--------->校验token和sign签名出错:", e);
return AjaxResult.error("参数错误!");
}
return AjaxResult.error();
}

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

@ -0,0 +1,93 @@
package com.conflux.web.controller.nft.service.impl;
import com.conflux.web.controller.nft.domain.NftCollection;
import com.conflux.web.controller.nft.mapper.NftCollectionMapper;
import com.conflux.web.controller.nft.service.INftCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* nft上链Service业务层处理
*
* @author conflux
* @date 2022-06-02
*/
@Service
public class NftCollectionServiceImpl implements INftCollectionService {
@Autowired
private NftCollectionMapper nftCollectionMapper;
/**
* 查询nft上链
*
* @param id nft上链主键
* @return nft上链
*/
@Override
public NftCollection selectNftCollectionById(Long id) {
return nftCollectionMapper.selectNftCollectionById(id);
}
/**
* 查询nft上链列表
*
* @param nftCollection nft上链
* @return nft上链
*/
@Override
public List<NftCollection> selectNftCollectionList(NftCollection nftCollection) {
return nftCollectionMapper.selectNftCollectionList(nftCollection);
}
@Override
public int insertNftCollection(NftCollection nftCollection) {
return nftCollectionMapper.insertNftCollection(nftCollection);
}
/**
* 新增nft上链
*
* @param unitName,strings nft上链
* @return 结果
*/
@Override
public int insertListNftCollection(String unitName,List<String> strings) {
return nftCollectionMapper.insertListNftCollection(unitName,strings);
}
/**
* 修改nft上链
*
* @param nftCollection nft上链
* @return 结果
*/
@Override
public int updateNftCollection(NftCollection nftCollection) {
return nftCollectionMapper.updateNftCollection(nftCollection);
}
/**
* 批量删除nft上链
*
* @param ids 需要删除的nft上链主键
* @return 结果
*/
@Override
public int deleteNftCollectionByIds(Long[] ids) {
return nftCollectionMapper.deleteNftCollectionByIds(ids);
}
/**
* 删除nft上链信息
*
* @param id nft上链主键
* @return 结果
*/
@Override
public int deleteNftCollectionById(Long id) {
return nftCollectionMapper.deleteNftCollectionById(id);
}
}

97
conflux-admin/src/main/java/com/conflux/web/controller/nft/service/impl/NftLogServiceImpl.java

@ -0,0 +1,97 @@
package com.conflux.web.controller.nft.service.impl;
import com.conflux.common.utils.DateUtils;
import com.conflux.web.controller.nft.domain.NftLog;
import com.conflux.web.controller.nft.mapper.NftLogMapper;
import com.conflux.web.controller.nft.service.INftLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* nft日志Service业务层处理
*
* @author conflux
* @date 2022-06-02
*/
@Service
public class NftLogServiceImpl implements INftLogService
{
@Autowired
private NftLogMapper nftLogMapper;
/**
* 查询nft日志
*
* @param id nft日志主键
* @return nft日志
*/
@Override
public NftLog selectNftLogById(Long id)
{
return nftLogMapper.selectNftLogById(id);
}
/**
* 查询nft日志列表
*
* @param nftLog nft日志
* @return nft日志
*/
@Override
public List<NftLog> selectNftLogList(NftLog nftLog)
{
return nftLogMapper.selectNftLogList(nftLog);
}
/**
* 新增nft日志
*
* @param nftLog nft日志
* @return 结果
*/
@Override
public int insertNftLog(NftLog nftLog)
{
nftLog.setCreateTime(DateUtils.getNowDate());
return nftLogMapper.insertNftLog(nftLog);
}
/**
* 修改nft日志
*
* @param nftLog nft日志
* @return 结果
*/
@Override
public int updateNftLog(NftLog nftLog)
{
return nftLogMapper.updateNftLog(nftLog);
}
/**
* 批量删除nft日志
*
* @param ids 需要删除的nft日志主键
* @return 结果
*/
@Override
public int deleteNftLogByIds(Long[] ids)
{
return nftLogMapper.deleteNftLogByIds(ids);
}
/**
* 删除nft日志信息
*
* @param id nft日志主键
* @return 结果
*/
@Override
public int deleteNftLogById(Long id)
{
return nftLogMapper.deleteNftLogById(id);
}
}

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("da0b8d9f-8eca-4365-8a30-b343f914a97c","CONFLUX@123");
String encrypt = encrypt("cbe3bbb2-8a6e-48e5-9a4f-42377d381b9c","CONFLUX@123");
System.err.println(encrypt);
} catch (Exception e) {
e.printStackTrace();

2
conflux-system/src/main/resources/mapper/system/CollectConfigMapper.xml

@ -39,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectCollectConfigByStatus"
resultMap="CollectConfigResult">
<include refid="selectCollectConfigVo"/>
where status=0
where status='0'
</select>
<insert id="insertCollectConfig" parameterType="CollectConfig" useGeneratedKeys="true" keyProperty="id">

6
conflux-system/src/main/resources/mapper/system/ContractConfigMapper.xml

@ -42,16 +42,20 @@
<insert id="insertContractConfig" parameterType="ContractConfig" useGeneratedKeys="true" keyProperty="id">
insert into contract_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="unitName != null">unit_name,</if>
<if test="contract != null">contract,</if>
<if test="owner != null">owner,</if>
<if test="privateKey != null">private_key,</if>
<if test="gasPrice != null">gas_price,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="unitName != null">#{unitName},</if>
<if test="contract != null">#{contract},</if>
<if test="owner != null">#{owner},</if>
<if test="privateKey != null">#{privateKey},</if>
<if test="gasPrice != null">#{gasPrice},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
@ -60,9 +64,11 @@
<update id="updateContractConfig" parameterType="ContractConfig">
update contract_config
<trim prefix="SET" suffixOverrides=",">
<if test="unitName != null">unit_name = #{unitName},</if>
<if test="contract != null">contract = #{contract},</if>
<if test="owner != null">owner = #{owner},</if>
<if test="privateKey != null">private_key = #{privateKey},</if>
<if test="gasPrice != null">gas_price = #{gasPrice},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>

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

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.conflux.web.controller.nft.mapper.NftCollectionMapper">
<resultMap type="NftCollection" id="NftCollectionResult">
<result property="id" column="id" />
<result property="unitName" column="unit_name" />
<result property="informationTableId" column="information_table_id" />
<result property="onChainStatus" column="on_chain_status" />
<result property="createdBy" column="created_by" />
<result property="createdTime" column="created_time" />
<result property="updatedBy" column="updated_by" />
<result property="updatedTime" column="updated_time" />
</resultMap>
<sql id="selectNftCollectionVo">
select id, unit_name, information_table_id, on_chain_status, created_by, created_time, updated_by, updated_time from nft_collection
</sql>
<select id="selectNftCollectionList" parameterType="NftCollection" resultMap="NftCollectionResult">
<include refid="selectNftCollectionVo"/>
<where>
<if test="unitName != null and unitName != ''"> and unit_name = #{unitName}</if>
<if test="informationTableId != null and informationTableId != ''"> and information_table_id = #{informationTableId}</if>
<if test="onChainStatus != null "> and on_chain_status = #{onChainStatus}</if>
<if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''"> and updated_by = #{updatedBy}</if>
<if test="updatedTime != null "> and updated_time = #{updatedTime}</if>
</where>
</select>
<select id="selectNftCollectionById" parameterType="Long" resultMap="NftCollectionResult">
<include refid="selectNftCollectionVo"/>
where id = #{id}
</select>
<insert id="insertNftCollection" parameterType="NftCollection" useGeneratedKeys="true" keyProperty="id">
insert into nft_collection
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="unitName != null">unit_name,</if>
<if test="informationTableId != null">information_table_id,</if>
<if test="onChainStatus != null">on_chain_status,</if>
<if test="createdBy != null">created_by,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedBy != null">updated_by,</if>
<if test="updatedTime != null">updated_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="unitName != null">#{unitName},</if>
<if test="informationTableId != null">#{informationTableId},</if>
<if test="onChainStatus != null">#{onChainStatus},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedBy != null">#{updatedBy},</if>
<if test="updatedTime != null">#{updatedTime},</if>
</trim>
</insert>
<insert id="insertListNftCollection">
insert into nft_collection
(unit_name, information_table_id,on_chain_status)
VALUES
<foreach collection ="stringList" item="item" separator =",">
(#{unitName}, #{item},1)
</foreach >
</insert>
<update id="updateNftCollection" parameterType="NftCollection">
update nft_collection
<trim prefix="SET" suffixOverrides=",">
<if test="unitName != null">unit_name = #{unitName},</if>
<if test="informationTableId != null">information_table_id = #{informationTableId},</if>
<if test="onChainStatus != null">on_chain_status = #{onChainStatus},</if>
<if test="createdBy != null">created_by = #{createdBy},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteNftCollectionById" parameterType="Long">
delete from nft_collection where id = #{id}
</delete>
<delete id="deleteNftCollectionByIds" parameterType="String">
delete from nft_collection where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

65
conflux-system/src/main/resources/mapper/system/NftLogMapper.xml

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.conflux.web.controller.nft.mapper.NftLogMapper">
<resultMap type="NftLog" id="NftLogResult">
<result property="id" column="id" />
<result property="unitName" column="unit_name" />
<result property="nftNum" column="nft_num" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectNftLogVo">
select id, unit_name, nft_num, create_time from nft_log
</sql>
<select id="selectNftLogList" parameterType="NftLog" resultMap="NftLogResult">
<include refid="selectNftLogVo"/>
<where>
<if test="unitName != null and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
<if test="nftNum != null "> and nft_num = #{nftNum}</if>
</where>
</select>
<select id="selectNftLogById" parameterType="Long" resultMap="NftLogResult">
<include refid="selectNftLogVo"/>
where id = #{id}
</select>
<insert id="insertNftLog" parameterType="NftLog" useGeneratedKeys="true" keyProperty="id">
insert into nft_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="unitName != null">unit_name,</if>
<if test="nftNum != null">nft_num,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="unitName != null">#{unitName},</if>
<if test="nftNum != null">#{nftNum},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateNftLog" parameterType="NftLog">
update nft_log
<trim prefix="SET" suffixOverrides=",">
<if test="unitName != null">unit_name = #{unitName},</if>
<if test="nftNum != null">nft_num = #{nftNum},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteNftLogById" parameterType="Long">
delete from nft_log where id = #{id}
</delete>
<delete id="deleteNftLogByIds" parameterType="String">
delete from nft_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save