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()); + } + }