From f33c66c5d267dce9a3703973322c78630fe2ac48 Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <773861846@qq.com> Date: Sun, 29 May 2022 15:23:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=BD=9C=E5=AE=B6?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../novel/controller/author/AuthorController.java | 10 +++++++++- .../xxyopen/novel/core/auth/AuthorAuthStrategy.java | 5 ++++- .../io/github/xxyopen/novel/service/AuthorService.java | 7 +++++++ .../xxyopen/novel/service/impl/AuthorServiceImpl.java | 6 ++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/xxyopen/novel/controller/author/AuthorController.java b/src/main/java/io/github/xxyopen/novel/controller/author/AuthorController.java index 38dea2c..dbe95b2 100644 --- a/src/main/java/io/github/xxyopen/novel/controller/author/AuthorController.java +++ b/src/main/java/io/github/xxyopen/novel/controller/author/AuthorController.java @@ -40,6 +40,14 @@ public class AuthorController { return authorService.register(dto); } + /** + * 查询作家状态接口 + * */ + @GetMapping("status") + public RestResp getStatus(){ + return authorService.getStatus(UserHolder.getUserId()); + } + /** * 小说发布接口 */ @@ -65,7 +73,7 @@ public class AuthorController { } /** - * 小说发布章节列表查询接口 + * 小说章节发布列表查询接口 */ @GetMapping("book/chapters/{bookId}") public RestResp> listBookChapters(@PathVariable("bookId") Long bookId, PageReqDto dto) { diff --git a/src/main/java/io/github/xxyopen/novel/core/auth/AuthorAuthStrategy.java b/src/main/java/io/github/xxyopen/novel/core/auth/AuthorAuthStrategy.java index d6abcd6..599bfbf 100644 --- a/src/main/java/io/github/xxyopen/novel/core/auth/AuthorAuthStrategy.java +++ b/src/main/java/io/github/xxyopen/novel/core/auth/AuthorAuthStrategy.java @@ -32,7 +32,10 @@ public class AuthorAuthStrategy implements AuthStrategy { /** * 不需要进行作家权限认证的 URI * */ - private static final List EXCLUDE_URI = List.of(ApiRouterConsts.API_AUTHOR_URL_PREFIX + "/register"); + private static final List EXCLUDE_URI = List.of( + ApiRouterConsts.API_AUTHOR_URL_PREFIX + "/register", + ApiRouterConsts.API_AUTHOR_URL_PREFIX +"/status" + ); @Override public void auth(String token, String requestUri) throws BusinessException { diff --git a/src/main/java/io/github/xxyopen/novel/service/AuthorService.java b/src/main/java/io/github/xxyopen/novel/service/AuthorService.java index 672daa7..bf7c95a 100644 --- a/src/main/java/io/github/xxyopen/novel/service/AuthorService.java +++ b/src/main/java/io/github/xxyopen/novel/service/AuthorService.java @@ -18,4 +18,11 @@ public interface AuthorService { * @return void */ RestResp register(AuthorRegisterReqDto dto); + + /** + * 查询作家状态 + * @param userId 用户ID + * @return 作家状态 + * */ + RestResp getStatus(Long userId); } diff --git a/src/main/java/io/github/xxyopen/novel/service/impl/AuthorServiceImpl.java b/src/main/java/io/github/xxyopen/novel/service/impl/AuthorServiceImpl.java index 6c731bb..faa5bbf 100644 --- a/src/main/java/io/github/xxyopen/novel/service/impl/AuthorServiceImpl.java +++ b/src/main/java/io/github/xxyopen/novel/service/impl/AuthorServiceImpl.java @@ -54,4 +54,10 @@ public class AuthorServiceImpl implements AuthorService { return RestResp.ok(); } + @Override + public RestResp getStatus(Long userId) { + AuthorInfoDto author = authorInfoCacheManager.getAuthor(userId); + return Objects.isNull(author) ? RestResp.ok(null) : RestResp.ok(author.getStatus()); + } + }