Commit 04d254e0 authored by tangtuo's avatar tangtuo

添加转让nft的短信模板

修改主题接口
parent d32bd475
......@@ -7,6 +7,7 @@ import com.fzm.common.service.LabelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -26,9 +27,9 @@ public class LabelController {
@Resource
private LabelService labelService;
@GetMapping("/list")
@ApiOperation(value = "查询所有标签信息")
public ResponseModel<List<Label>> list() {
return ResponseModel.success(labelService.listAll());
@GetMapping("/list/{categoryId}")
@ApiOperation(value = "查询所有主题信息")
public ResponseModel<List<Label>> list(@PathVariable Integer categoryId) {
return ResponseModel.success(labelService.listAll(categoryId));
}
}
package com.fzm.common.properties;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
......@@ -13,17 +14,35 @@ import org.springframework.stereotype.Component;
@ConfigurationProperties(prefix = "sms")
public class SmsProperties {
@ApiModelProperty("app key")
private String appKey;
@ApiModelProperty("app秘钥")
private String appSecret;
@ApiModelProperty("发送短信验证码接口地址")
private String sendSmsUrl;
@ApiModelProperty("校验验证码接口地址")
private String validateCodeUrl;
private String messageLoginCodetype;
@ApiModelProperty("登录短信验证码模板")
private String loginMessageCodetype;
@ApiModelProperty("登录邮件验证码模板")
private String loginMailCodetype;
@ApiModelProperty("登录语音验证码模板")
private String loginVoiceCodetype;
@ApiModelProperty("转让nft短信验证码模板")
private String transferNftMessageCodetype;
@ApiModelProperty("转让nft邮件验证码模板")
private String transferNftEmailCodetype;
@ApiModelProperty("转让nft语言验证码模板")
private String transferNftVoiceCodetype;
private String emailLoginCodetype;
private String voiceLoginCodetype;
}
......@@ -12,6 +12,6 @@ import java.util.List;
*/
public interface LabelService extends IService<Label> {
List<Label> listAll();
List<Label> listAll(Integer categoryId);
}
......@@ -79,9 +79,6 @@ public class CommemorateNftServiceImpl extends ServiceImpl<CommemorateNftMapper,
long tokenId = Long.parseLong(split[1]);
// 构建上链信息
HashMap<String, String> map = new HashMap<>();
map.put("publishAddress", user.getWallet());
map.put("name", commemorateNft.getName());
map.put("author", user.getNickname());
map.put("hash", commemorateNft.getFileHash());
String tokenInfo = JSONUtil.toJsonStr(map);
log.info("加密上链数据: {}", tokenInfo);
......
package com.fzm.common.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.entity.Category;
import com.fzm.common.entity.Label;
......@@ -10,6 +11,7 @@ import com.fzm.common.service.LabelService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
......@@ -19,10 +21,14 @@ import java.util.List;
@Service
public class LabelServiceImpl extends ServiceImpl<LabelMapper, Label> implements LabelService {
@Resource
private LabelMapper labelMapper;
@Override
@Cacheable(value = "label",key = "'list'")
public List<Label> listAll() {
return list();
@Cacheable(value = "label:list", key = "#categoryId")
public List<Label> listAll(Integer categoryId) {
QueryWrapper<Label> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("category_id", categoryId);
return labelMapper.selectList(queryWrapper);
}
}
......@@ -126,7 +126,7 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
if (StringUtils.isBlank(tradeHash)) {
throw GlobalException.newException(ResultCode.PUBLISH_ERROR, "nft发行失败");
}
log.info("tokenInfo:{}",paraChainClient.evmGetTokenInfo(contractName, paraChainClient.evmQueryAddrByName(contractName), tokenId, wallet));
log.info("tokenInfo:{}", paraChainClient.evmGetTokenInfo(contractName, paraChainClient.evmQueryAddrByName(contractName), tokenId, wallet));
// 确认交易结果
TxResult txResult = paraChainClient.cycleConfirmTxWithHash(hash, true, 1000);
if (!TxStatusEnum.SUCCESS.equals(txResult.getStatus())) {
......@@ -160,8 +160,7 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
throw GlobalException.newException(ResultCode.TRANSFER_ERROR, "您无权转让他人的nft");
}
// 校验短信验证码
// todo 现在用的是登录验证码模板,后续需要修改短信模板
if (!smsUtil.validateCode(smsProperties.getMessageLoginCodetype(), user.getTelephone(), param.getCode(), param.getCodeType())) {
if (!smsUtil.validateCode(getCodeType(param.getCodeType()), user.getTelephone(), param.getCode(), param.getCodeType())) {
throw GlobalException.newException(ResultCode.TRANSFER_ERROR, "短信验证码校验失败");
}
// 校验接收人的个人信息
......@@ -204,6 +203,19 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
return true;
}
private String getCodeType(String type) {
switch (type) {
case "sms":
return smsProperties.getTransferNftMessageCodetype();
case "email":
return smsProperties.getTransferNftEmailCodetype();
case "voice":
return smsProperties.getTransferNftVoiceCodetype();
default:
throw GlobalException.newException(ResultCode.VALIDATE_FAILED, "短信类型【" + type + "】的传参有误,取值范围是{sms,email,voice}");
}
}
@Override
public List<Nft> list(Integer pageNum, Integer pageSize, Integer categoryId) {
return nftMapper.list(pageNum, pageSize, categoryId);
......
......@@ -138,11 +138,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
public String getLoginCodeType(String type) {
switch (type) {
case "sms":
return smsProperties.getMessageLoginCodetype();
return smsProperties.getLoginMessageCodetype();
case "email":
return smsProperties.getEmailLoginCodetype();
return smsProperties.getLoginMailCodetype();
case "voice":
return smsProperties.getVoiceLoginCodetype();
return smsProperties.getLoginVoiceCodetype();
default:
throw GlobalException.newException(ResultCode.VALIDATE_FAILED, "短信类型【" + type + "】的传参有误,取值范围是{sms,email,voice}");
}
......
......@@ -6,6 +6,7 @@ import com.fzm.common.service.LabelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -24,9 +25,9 @@ public class LabelController {
@Resource
private LabelService labelService;
@GetMapping("/list")
@GetMapping("/list/{categoryId}")
@ApiOperation(value = "查询所有主题信息")
public ResponseModel<List<Label>> list() {
return ResponseModel.success(labelService.listAll());
public ResponseModel<List<Label>> list(@PathVariable Integer categoryId) {
return ResponseModel.success(labelService.listAll(categoryId));
}
}
......@@ -58,7 +58,7 @@ public class VerificationCodeController {
if (user == null || StringUtils.isBlank(user.getTelephone())) {
throw GlobalException.newException(ResultCode.UNAUTHORIZED, "当前用户的手机号为空");
}
Boolean result = smsUtil.sendSms(smsProperties.getMessageLoginCodetype(), user.getTelephone());
Boolean result = smsUtil.sendSms(smsProperties.getTransferNftMessageCodetype(), user.getTelephone());
return ResponseModel.success(result);
}
......@@ -66,7 +66,7 @@ public class VerificationCodeController {
private String getCodeType(Integer type) {
switch (type) {
case 1:
return smsProperties.getMessageLoginCodetype();
return smsProperties.getLoginMessageCodetype();
default:
throw GlobalException.newException(ResultCode.CODE_ERROR);
}
......
......@@ -70,11 +70,14 @@ swagger:
sms:
app-key: Yiru
app-secret: mx5oaR^RY8!(ziHn
message-login-codetype: quick
email-login-codetype: quick
voice-login-codetype: quick
login-message-codetype: quick
login-email-codetype: quick
login-voice-codetype: quick
send-sms-url: http://118.31.52.32/send/sms2
validate-code-url: http://118.31.52.32/validate/code
transfer-nft-message-codetype: notice_transfer
transfer-nft-email-codetype: notice_transfer
transfer-nft-voice-codetype: notice_transfer
chain:
para:
......
......@@ -87,11 +87,14 @@ aliyun:
sms:
app-key: Yiru
app-secret: mx5oaR^RY8!(ziHn
message-login-codetype: quick
email-login-codetype: quick
voice-login-codetype: quick
login-message-codetype: quick
login-email-codetype: quick
login-voice-codetype: quick
send-sms-url: http://118.31.52.32/send/sms2
validate-code-url: http://118.31.52.32/validate/code
transfer-nft-message-codetype: notice_transfer
transfer-nft-email-codetype: notice_transfer
transfer-nft-voice-codetype: notice_transfer
chain:
para:
......
......@@ -79,11 +79,14 @@ swagger:
sms:
app-key: Yiru
app-secret: mx5oaR^RY8!(ziHn
message-login-codetype: quick
email-login-codetype: quick
voice-login-codetype: quick
login-message-codetype: quick
login-email-codetype: quick
login-voice-codetype: quick
send-sms-url: http://118.31.52.32/send/sms2
validate-code-url: http://118.31.52.32/validate/code
transfer-nft-message-codetype: notice_transfer
transfer-nft-email-codetype: notice_transfer
transfer-nft-voice-codetype: notice_transfer
chain:
para:
......
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