Commit 16f962bc authored by tangtuo's avatar tangtuo

新增对外服务接口

parent aa5a62be
......@@ -19,6 +19,7 @@ public enum ResultCode implements IErrorCode {
ID_CARD_VERIFICATION_ERROR(417, "身份证验证失败"),
OPERATION_FAILED(418, "操作失败"),
COPYRIGHT_FAILED(420, "版权申请失败"),
SELECT_FAILED(421, "查询失败"),
;
......
......@@ -73,7 +73,6 @@ public interface NftService extends IService<Nft> {
* @param pageSize
* @param categoryId
* @param name
* @param theme
* @param telephone
* @param status
* @param start
......@@ -152,4 +151,12 @@ public interface NftService extends IService<Nft> {
* @return
*/
List<CollectionNftVo> listCopyright(Integer userId);
/**
* 根据tokenId查询nft
*
* @param tokenId
* @return
*/
Nft getByTokenId(Long tokenId);
}
......@@ -234,6 +234,14 @@ public class NftServiceImpl extends ServiceImpl<NftMapper, Nft> implements NftSe
return nftMapper.listCopyright(userId);
}
@Override
public Nft getByTokenId(Long tokenId) {
QueryWrapper<Nft> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("token_id", tokenId);
return this.getOne(queryWrapper);
}
private String getCodeType(String type) {
switch (type) {
case "sms":
......
......@@ -99,7 +99,7 @@
FROM tb_nft a
WHERE a.user_id = #{userId}
AND a.nft_hash != ''
AND nft_hash NOT IN ( SELECT nft_hash FROM tb_copyright_apply WHERE user_id = #{userId} AND register_state IN ( 0, 2, 4 ) )
AND nft_hash NOT IN ( SELECT nft_hash FROM tb_copyright_apply WHERE user_id = #{userId} )
</select>
</mapper>
\ No newline at end of file
package com.fzm.portal.controller.open;
import com.fzm.common.entity.Nft;
import com.fzm.common.enums.ResultCode;
import com.fzm.common.exception.GlobalException;
import com.fzm.common.model.ResponseModel;
import com.fzm.common.service.NftService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @author tangtuo
* @date 2021/12/22 14:13
*/
@RestController
@Api(tags = "对外服务")
@RequestMapping("/open/nft")
public class NftApiController {
@Resource
private NftService nftService;
@GetMapping(value = "/hash")
@ApiOperation(value = "根据tokenId获取nft哈希")
public ResponseModel<String> getNftHash(@RequestParam Long tokenId) {
Nft nft = nftService.getByTokenId(tokenId);
if (nft == null) {
throw GlobalException.newException(ResultCode.SELECT_FAILED, "未查询到此tokenId对应的nft");
}
return ResponseModel.success(nft.getNftHash());
}
}
2021-12-22 14:20:10.146 [main] INFO com.fzm.portal.JoyingPortalApplication-Starting JoyingPortalApplication on LAPTOP-AT8CNAMK with PID 20028 (D:\workspace\fzm-joying\joying-portal\target\classes started by tangtuo in D:\workspace\fzm-joying)
2021-12-22 14:20:10.149 [main] INFO com.fzm.portal.JoyingPortalApplication-The following profiles are active: dev
2021-12-22 14:20:11.120 [main] INFO o.s.d.r.config.RepositoryConfigurationDelegate-Multiple Spring Data modules found, entering strict repository configuration mode!
2021-12-22 14:20:11.122 [main] INFO o.s.d.r.config.RepositoryConfigurationDelegate-Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2021-12-22 14:20:11.153 [main] INFO o.s.d.r.config.RepositoryConfigurationDelegate-Finished Spring Data repository scanning in 11ms. Found 0 Redis repository interfaces.
2021-12-22 14:20:12.047 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer-Tomcat initialized with port(s): 8001 (http)
2021-12-22 14:20:12.055 [main] INFO org.apache.coyote.http11.Http11NioProtocol-Initializing ProtocolHandler ["http-nio-8001"]
2021-12-22 14:20:12.056 [main] INFO org.apache.catalina.core.StandardService-Starting service [Tomcat]
2021-12-22 14:20:12.056 [main] INFO org.apache.catalina.core.StandardEngine-Starting Servlet engine: [Apache Tomcat/9.0.35]
2021-12-22 14:20:12.199 [main] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/]-Initializing Spring embedded WebApplicationContext
2021-12-22 14:20:12.200 [main] INFO org.springframework.web.context.ContextLoader-Root WebApplicationContext: initialization completed in 2011 ms
2021-12-22 14:20:12.392 [main] INFO c.a.d.s.b.a.DruidDataSourceAutoConfigure-Init DruidDataSource
2021-12-22 14:20:13.891 [main] INFO com.alibaba.druid.pool.DruidDataSource-{dataSource-1} inited
2021-12-22 14:20:15.407 [main] INFO org.redisson.Version-Redisson 3.16.0
2021-12-22 14:20:16.248 [redisson-netty-4-13] INFO o.r.connection.pool.MasterPubSubConnectionPool-1 connections initialized for 172.16.101.135/172.16.101.135:6379
2021-12-22 14:20:16.368 [redisson-netty-4-20] INFO org.redisson.connection.pool.MasterConnectionPool-24 connections initialized for 172.16.101.135/172.16.101.135:6379
2021-12-22 14:20:16.684 [main] WARN c.b.mybatisplus.core.metadata.TableInfoHelper-Warn: Could not find @TableId in Class: com.fzm.common.entity.CopyrightApplyOwnerRelation.
2021-12-22 14:20:16.762 [main] WARN c.b.mybatisplus.core.metadata.TableInfoHelper-Warn: Could not find @TableId in Class: com.fzm.common.entity.CopyrightAuthorityRelation.
2021-12-22 14:20:16.829 [main] INFO o.s.scheduling.concurrent.ThreadPoolTaskExecutor-Initializing ExecutorService 'threadPoolTaskExecutor'
2021-12-22 14:20:17.439 [main] INFO s.d.s.w.PropertySourcedRequestMappingHandlerMapping-Mapped URL path [/v2/api-docs] onto method [springfox.documentation.swagger2.web.Swagger2Controller#getDocumentation(String, HttpServletRequest)]
2021-12-22 14:20:18.020 [main] INFO org.apache.coyote.http11.Http11NioProtocol-Starting ProtocolHandler ["http-nio-8001"]
2021-12-22 14:20:18.032 [main] INFO o.s.boot.web.embedded.tomcat.TomcatWebServer-Tomcat started on port(s): 8001 (http) with context path ''
2021-12-22 14:20:18.033 [main] INFO s.d.s.web.plugins.DocumentationPluginsBootstrapper-Context refreshed
2021-12-22 14:20:18.046 [main] INFO s.d.s.web.plugins.DocumentationPluginsBootstrapper-Found 1 custom documentation plugin(s)
2021-12-22 14:20:18.073 [main] INFO s.d.spring.web.scanners.ApiListingReferenceScanner-Scanning for api listing references
2021-12-22 14:20:18.179 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: listUsingGET_1
2021-12-22 14:20:18.191 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: listUsingGET_2
2021-12-22 14:20:18.209 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: listUsingGET_3
2021-12-22 14:20:18.235 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: getByIdUsingGET_1
2021-12-22 14:20:18.252 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: listUsingGET_4
2021-12-22 14:20:18.272 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: addUsingPOST_1
2021-12-22 14:20:18.273 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: deleteUsingPOST_1
2021-12-22 14:20:18.279 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: listUsingGET_5
2021-12-22 14:20:18.281 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: updateUsingPOST_1
2021-12-22 14:20:18.282 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: deleteUsingPOST_2
2021-12-22 14:20:18.287 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: listUsingGET_6
2021-12-22 14:20:18.307 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: getByIdUsingGET_2
2021-12-22 14:20:18.319 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: listUsingGET_7
2021-12-22 14:20:18.324 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: publishUsingPOST_1
2021-12-22 14:20:18.339 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: saveUsingPOST_1
2021-12-22 14:20:18.347 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: getDetailUsingGET_1
2021-12-22 14:20:18.350 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: listUsingGET_8
2021-12-22 14:20:18.353 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: listUsingGET_9
2021-12-22 14:20:18.354 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: deleteUsingPOST_3
2021-12-22 14:20:18.355 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: downloadUsingPOST_1
2021-12-22 14:20:18.359 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: uploadUsingPOST_1
2021-12-22 14:20:18.382 [main] INFO s.d.s.w.r.operation.CachingOperationNameGenerator-Generating unique operation named: updateUsingPOST_2
2021-12-22 14:20:18.401 [main] INFO com.fzm.portal.JoyingPortalApplication-Started JoyingPortalApplication in 8.673 seconds (JVM running for 10.384)
2021-12-22 14:20:40.874 [http-nio-8001-exec-5] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/]-Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-12-22 14:20:40.874 [http-nio-8001-exec-5] INFO org.springframework.web.servlet.DispatcherServlet-Initializing Servlet 'dispatcherServlet'
2021-12-22 14:20:40.881 [http-nio-8001-exec-5] INFO org.springframework.web.servlet.DispatcherServlet-Completed initialization in 7 ms
2021-12-22 14:21:32.072 [http-nio-8001-exec-9] INFO com.fzm.portal.aop.LogAop-请求路径: /open/nft/hash,请求参数:[{tokenId=1431186204212203520}]
2021-12-22 14:21:32.165 [http-nio-8001-exec-9] DEBUG com.fzm.common.mapper.NftMapper.selectOne-==> Preparing: SELECT id,category_id,user_id,publish_address,name,cover,author,synopsis,file_name,file_url,file_hash,nft_id,nft_hash,token_id,publish_time,transfer_hash,commemorate_id,is_top,status,is_commemorate,create_date,update_date,create_time,update_time FROM tb_nft WHERE (token_id = ?)
2021-12-22 14:21:32.259 [http-nio-8001-exec-9] DEBUG com.fzm.common.mapper.NftMapper.selectOne-==> Parameters: 1431186204212203520(Long)
2021-12-22 14:21:32.322 [http-nio-8001-exec-9] DEBUG com.fzm.common.mapper.NftMapper.selectOne-<== Total: 1
2021-12-22 14:21:32.336 [http-nio-8001-exec-9] INFO com.fzm.portal.aop.LogAop-请求路径:/open/nft/hash,接口耗时:268ms
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