├── gradle ├── plugins │ ├── build.gradle.kts │ ├── common │ │ ├── src │ │ │ └── main │ │ │ │ └── kotlin │ │ │ │ ├── realworld.settings.settings.gradle.kts │ │ │ │ ├── realworld.project-conventions.gradle.kts │ │ │ │ └── realworld.java-conventions.gradle.kts │ │ └── build.gradle.kts │ └── settings.gradle.kts ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── libs.versions.toml ├── lombok.config ├── .gitattributes ├── example-logo.png ├── .gitignore ├── .github ├── renovate.json └── release-changelog-builder.json ├── settings.gradle.kts ├── service-bus ├── build.gradle.kts └── src │ └── main │ └── java │ └── com │ └── github │ └── al │ └── bus │ ├── Query.java │ ├── Command.java │ ├── QueryHandler.java │ ├── CommandHandler.java │ ├── Bus.java │ ├── QueryHandlerProvider.java │ ├── CommandHandlerProvider.java │ └── DefaultBus.java ├── service └── src │ ├── main │ ├── resources │ │ ├── db │ │ │ └── database-changelog.xml │ │ └── logback.xml │ └── java │ │ └── com │ │ └── github │ │ └── al │ │ └── realworld │ │ ├── application │ │ ├── service │ │ │ ├── AuthenticationService.java │ │ │ ├── JwtService.java │ │ │ ├── NoopPasswordEncoder.java │ │ │ ├── DefaultAuthenticationService.java │ │ │ ├── PasswordEncoder.java │ │ │ ├── SlugService.java │ │ │ └── DefaultJwtService.java │ │ ├── ProfileAssembler.java │ │ ├── UserAssembler.java │ │ ├── CommentAssembler.java │ │ ├── exception │ │ │ └── Exceptions.java │ │ ├── query │ │ │ ├── GetTagsHandler.java │ │ │ ├── GetProfileHandler.java │ │ │ ├── GetCurrentUserHandler.java │ │ │ ├── GetArticleHandler.java │ │ │ ├── GetArticlesHandler.java │ │ │ └── GetCommentsHandler.java │ │ ├── ArticleAssembler.java │ │ └── command │ │ │ └── DeleteArticleHandler.java │ │ ├── domain │ │ ├── repository │ │ │ ├── TagRepository.java │ │ │ ├── UserRepository.java │ │ │ ├── FollowRelationRepository.java │ │ │ └── ArticleRepository.java │ │ └── model │ │ │ ├── FollowRelationId.java │ │ │ ├── Tag.java │ │ │ ├── FollowRelation.java │ │ │ ├── Comment.java │ │ │ └── User.java │ │ ├── App.java │ │ └── infrastructure │ │ ├── db │ │ └── jpa │ │ │ ├── DataTagRepository.java │ │ │ ├── DataUserRepository.java │ │ │ ├── JpaTagRepositoryAdapter.java │ │ │ ├── DataFollowRelationRepository.java │ │ │ ├── JpaUserRepositoryAdapter.java │ │ │ ├── JpaFollowRelationRepositoryAdapter.java │ │ │ └── DataArticleRepository.java │ │ ├── config │ │ ├── SecurityConfig.java │ │ └── GraalConfig.java │ │ └── web │ │ ├── TagController.java │ │ └── ProfileController.java │ └── intTest │ └── java │ └── com │ └── github │ └── al │ └── realworld │ ├── api │ └── operation │ │ ├── TagClient.java │ │ ├── UserClient.java │ │ ├── ArticleClient.java │ │ └── ProfileClient.java │ └── rest │ ├── TagApiTest.java │ └── auth │ └── AuthFilter.java ├── service-api ├── build.gradle.kts └── src │ └── main │ └── java │ └── com │ └── github │ └── al │ └── realworld │ └── api │ ├── command │ ├── DeleteArticleResult.java │ ├── DeleteCommentResult.java │ ├── FollowProfile.java │ ├── DeleteArticle.java │ ├── UnfollowProfile.java │ ├── FavoriteArticle.java │ ├── UnfavoriteArticle.java │ ├── DeleteComment.java │ ├── LoginUserResult.java │ ├── UpdateUserResult.java │ ├── RegisterUserResult.java │ ├── AddCommentResult.java │ ├── CreateArticleResult.java │ ├── FollowProfileResult.java │ ├── UpdateArticleResult.java │ ├── FavoriteArticleResult.java │ ├── UnfollowProfileResult.java │ ├── UnfavoriteArticleResult.java │ ├── LoginUser.java │ ├── RegisterUser.java │ ├── UpdateUser.java │ ├── CreateArticle.java │ ├── AddComment.java │ └── UpdateArticle.java │ ├── query │ ├── GetTags.java │ ├── GetCurrentUser.java │ ├── GetArticle.java │ ├── GetComments.java │ ├── GetProfile.java │ ├── GetComment.java │ ├── GetFeed.java │ ├── GetArticleResult.java │ ├── GetCurrentUserResult.java │ ├── GetTagsResult.java │ ├── GetCommentResult.java │ ├── GetProfileResult.java │ ├── GetFeedResult.java │ ├── GetArticlesResult.java │ ├── GetCommentsResult.java │ └── GetArticles.java │ ├── operation │ ├── TagOperations.java │ ├── ProfileOperations.java │ └── UserOperations.java │ └── dto │ ├── AddCommentDto.java │ ├── ProfileDto.java │ ├── UpdateArticleDto.java │ ├── UserDto.java │ ├── LoginUserDto.java │ ├── CommentDto.java │ ├── UpdateUserDto.java │ ├── RegisterUserDto.java │ ├── CreateArticleDto.java │ └── ArticleDto.java ├── LICENSE ├── openapi.properties └── src └── spotless └── mit-license.java /gradle/plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lombok.config: -------------------------------------------------------------------------------- 1 | lombok.addLombokGeneratedAnnotation = true -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | *.png binary 3 | *.key binary 4 | *.jar binary 5 | -------------------------------------------------------------------------------- /example-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexey-lapin/realworld-backend-micronaut/HEAD/example-logo.png -------------------------------------------------------------------------------- /gradle/plugins/common/src/main/kotlin/realworld.settings.settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("io.micronaut.platform.catalog") 3 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexey-lapin/realworld-backend-micronaut/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/plugins/common/src/main/kotlin/realworld.project-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | version = rootProject.version 2 | 3 | repositories { 4 | mavenCentral() 5 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Thumbs.db 2 | .DS_Store 3 | .gradle 4 | build/ 5 | target/ 6 | out/ 7 | .idea 8 | *.iml 9 | *.ipr 10 | *.iws 11 | .project 12 | .settings 13 | .classpath -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base", 5 | "schedule:daily", 6 | ":semanticPrefixChore", 7 | ":label(chore)" 8 | ] 9 | } -------------------------------------------------------------------------------- /gradle/plugins/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | versionCatalogs { 3 | create("libs") { 4 | from(files("../libs.versions.toml")) 5 | } 6 | } 7 | } 8 | 9 | rootProject.name = "plugins" 10 | include("common") 11 | -------------------------------------------------------------------------------- /gradle/plugins/common/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | gradlePluginPortal() 8 | } 9 | 10 | dependencies { 11 | implementation(libs.gradle.plugin.micronaut) 12 | implementation(libs.gradle.plugin.spotless) 13 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("gradle/plugins") 3 | repositories { 4 | gradlePluginPortal() 5 | } 6 | } 7 | 8 | plugins { 9 | id("realworld.settings") 10 | } 11 | 12 | rootProject.name = "realworld-backend-micronaut" 13 | include("service-api") 14 | include("service-bus") 15 | include("service") 16 | -------------------------------------------------------------------------------- /service-bus/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("realworld.java-conventions") 3 | alias(libs.plugins.micronaut.library) 4 | } 5 | 6 | micronaut { 7 | importMicronautPlatform = false 8 | processing { 9 | annotations("com.github.al.realworld.*") 10 | } 11 | } 12 | 13 | dependencies { 14 | annotationProcessor(mn.lombok) 15 | compileOnly(mn.lombok) 16 | } -------------------------------------------------------------------------------- /service/src/main/resources/db/database-changelog.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /service-api/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("realworld.java-conventions") 3 | alias(libs.plugins.micronaut.library) 4 | } 5 | 6 | micronaut { 7 | importMicronautPlatform = false 8 | processing { 9 | annotations("com.github.al.realworld.*") 10 | } 11 | } 12 | 13 | dependencies { 14 | annotationProcessor(mn.lombok) 15 | compileOnly(mn.lombok) 16 | 17 | annotationProcessor(mn.micronaut.validation.processor) 18 | 19 | implementation(project(":service-bus")) 20 | 21 | implementation(mn.micronaut.http) 22 | implementation(mn.jackson.annotations) 23 | implementation(mn.validation) 24 | } -------------------------------------------------------------------------------- /gradle/plugins/common/src/main/kotlin/realworld.java-conventions.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | java 3 | jacoco 4 | id("com.diffplug.spotless") 5 | id("realworld.project-conventions") 6 | } 7 | 8 | configure { 9 | sourceCompatibility = JavaVersion.VERSION_17 10 | targetCompatibility = JavaVersion.VERSION_17 11 | } 12 | 13 | spotless { 14 | val headerFile = rootProject.file("src/spotless/mit-license.java") 15 | 16 | java { 17 | licenseHeaderFile(headerFile, "(package|import|open|module) ") 18 | removeUnusedImports() 19 | trimTrailingWhitespace() 20 | endWithNewline() 21 | } 22 | } 23 | 24 | tasks { 25 | withType().configureEach { 26 | shouldRunAfter("spotlessJavaCheck") 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /service/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | 6 | 7 | 8 | 9 | %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | jacoco = "0.8.7" 3 | micronaut = "4.10.5" 4 | micronaut-gradle-plugin = "4.6.1" 5 | 6 | [libraries] 7 | # renovate hint 8 | micronaut-platform = { module = "io.micronaut.platform:micronaut-platform", version.ref = "micronaut" } 9 | gradle-plugin-micronaut = { group = "io.micronaut.gradle", name = "micronaut-platform-catalog-plugin", version.ref = "micronaut-gradle-plugin" } 10 | gradle-plugin-spotless = { group = "com.diffplug.spotless", name = "spotless-plugin-gradle", version = "8.1.0" } 11 | 12 | [plugins] 13 | git-properties = { id = "com.gorylenko.gradle-git-properties", version = "2.5.3" } 14 | micronaut-aot = { id = "io.micronaut.aot", version.ref = "micronaut-gradle-plugin" } 15 | micronaut-application = { id = "io.micronaut.application", version.ref = "micronaut-gradle-plugin" } 16 | micronaut-library = { id = "io.micronaut.library", version.ref = "micronaut-gradle-plugin" } 17 | release = { id = "pl.allegro.tech.build.axion-release", version = "1.21.0" } 18 | shadow = { id = "com.gradleup.shadow", version = "9.3.0" } 19 | versions = { id = "com.github.ben-manes.versions", version = "0.53.0" } 20 | -------------------------------------------------------------------------------- /.github/release-changelog-builder.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "#{{CHANGELOG}}", 3 | "pr_template": "* #{{TITLE}} @#{{AUTHOR}} (##{{NUMBER}})", 4 | "categories": [ 5 | { 6 | "title": "## 🚀 Features", 7 | "labels": [ 8 | "feature", 9 | "enhancement" 10 | ] 11 | }, 12 | { 13 | "title": "## 🐛 Fixes", 14 | "labels": [ 15 | "fix", 16 | "bug" 17 | ] 18 | }, 19 | { 20 | "title": "## 📝 Documentation", 21 | "labels": [ 22 | "documentation", 23 | "docs" 24 | ] 25 | }, 26 | { 27 | "title": "## 🏗️ Maintenance", 28 | "labels": [ 29 | "maintenance" 30 | ] 31 | }, 32 | { 33 | "title": "## 🚧 Chore", 34 | "labels": [ 35 | "chore" 36 | ] 37 | }, 38 | { 39 | "title": "## 🧰 Refactor", 40 | "labels": [ 41 | "refactor" 42 | ] 43 | }, 44 | { 45 | "title": "## 🧪 Tests", 46 | "labels": [ 47 | "test" 48 | ] 49 | }, 50 | { 51 | "title": "## 📦 Uncategorized", 52 | "labels": [] 53 | } 54 | ] 55 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 - present Alexey Lapin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /openapi.properties: -------------------------------------------------------------------------------- 1 | swagger-ui.enabled=true 2 | endpoints.enabled=true 3 | endpoints.tags=_Management 4 | endpoints.info.class=io.micronaut.management.endpoint.info.InfoEndpoint 5 | endpoints.health.class=io.micronaut.management.endpoint.health.HealthEndpoint 6 | endpoints.loggers.class=io.micronaut.management.endpoint.loggers.LoggersEndpoint 7 | endpoints.routes.class=io.micronaut.management.endpoint.routes.RoutesEndpoint 8 | micronaut.openapi.expand.api.version=api 9 | micronaut.openapi.expand.app.name=${name} 10 | micronaut.openapi.expand.app.version=${version} 11 | micronaut.openapi.expand.app.description=${description} 12 | micronaut.openapi.expand.app.license.name=MIT 13 | micronaut.openapi.expand.app.license.url=https://github.com/alexey-lapin/realworld-backend-micronaut/blob/master/LICENSE 14 | micronaut.openapi.expand.app.contact.name=Alexey Lapin 15 | micronaut.openapi.expand.app.contact.email=alexey-lapin@protonmail.com 16 | micronaut.openapi.expand.app.contact.url=https://github.com/alexey-lapin 17 | micronaut.openapi.expand.app.docs.desc=GitHub alexey-lapin/realworld-backend-micronaut 18 | micronaut.openapi.expand.app.docs.url=https://github.com/alexey-lapin/realworld-backend-micronaut -------------------------------------------------------------------------------- /src/spotless/mit-license.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | -------------------------------------------------------------------------------- /service-bus/src/main/java/com/github/al/bus/Query.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.bus; 25 | 26 | public interface Query { 27 | } 28 | -------------------------------------------------------------------------------- /service-bus/src/main/java/com/github/al/bus/Command.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.bus; 25 | 26 | public interface Command { 27 | } 28 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/DeleteArticleResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | public class DeleteArticleResult { 27 | } 28 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/DeleteCommentResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | public class DeleteCommentResult { 27 | } 28 | -------------------------------------------------------------------------------- /service-bus/src/main/java/com/github/al/bus/QueryHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.bus; 25 | 26 | public interface QueryHandler> { 27 | 28 | R handle(Q query); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /service-bus/src/main/java/com/github/al/bus/CommandHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.bus; 25 | 26 | public interface CommandHandler> { 27 | 28 | R handle(C command); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetTags.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.bus.Query; 27 | 28 | public class GetTags implements Query { 29 | } 30 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/service/AuthenticationService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.service; 25 | 26 | public interface AuthenticationService { 27 | 28 | String currentUsername(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /service-bus/src/main/java/com/github/al/bus/Bus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.bus; 25 | 26 | public interface Bus { 27 | 28 | > R executeCommand(C command); 29 | 30 | > R executeQuery(Q query); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /service/src/intTest/java/com/github/al/realworld/api/operation/TagClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.operation; 25 | 26 | import io.micronaut.http.client.annotation.Client; 27 | 28 | @Client("${api.version}") 29 | public interface TagClient extends TagOperations { 30 | } 31 | -------------------------------------------------------------------------------- /service/src/intTest/java/com/github/al/realworld/api/operation/UserClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.operation; 25 | 26 | import io.micronaut.http.client.annotation.Client; 27 | 28 | @Client("${api.version}") 29 | public interface UserClient extends UserOperations { 30 | } 31 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/service/JwtService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.service; 25 | 26 | import com.github.al.realworld.domain.model.User; 27 | 28 | public interface JwtService { 29 | 30 | String getToken(User user); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /service/src/intTest/java/com/github/al/realworld/api/operation/ArticleClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.operation; 25 | 26 | import io.micronaut.http.client.annotation.Client; 27 | 28 | @Client("${api.version}") 29 | public interface ArticleClient extends ArticleOperations { 30 | } 31 | -------------------------------------------------------------------------------- /service/src/intTest/java/com/github/al/realworld/api/operation/ProfileClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.operation; 25 | 26 | import io.micronaut.http.client.annotation.Client; 27 | 28 | @Client("${api.version}") 29 | public interface ProfileClient extends ProfileOperations { 30 | } 31 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/operation/TagOperations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.operation; 25 | 26 | import com.github.al.realworld.api.query.GetTagsResult; 27 | import io.micronaut.http.annotation.Get; 28 | 29 | public interface TagOperations { 30 | 31 | @Get("/tags") 32 | GetTagsResult findAll(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/domain/repository/TagRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.domain.repository; 25 | 26 | import com.github.al.realworld.domain.model.Tag; 27 | 28 | import java.util.Optional; 29 | 30 | public interface TagRepository { 31 | 32 | Optional findByName(String name); 33 | 34 | Iterable findAll(); 35 | } 36 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetCurrentUser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.bus.Query; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | 30 | @AllArgsConstructor 31 | @Getter 32 | public class GetCurrentUser implements Query { 33 | 34 | private String username; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetArticle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.bus.Query; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | 30 | @AllArgsConstructor 31 | @Getter 32 | public class GetArticle implements Query { 33 | 34 | private String currentUsername; 35 | private String slug; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetComments.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.bus.Query; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | 30 | @AllArgsConstructor 31 | @Getter 32 | public class GetComments implements Query { 33 | 34 | private String currentUsername; 35 | private String slug; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetProfile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.bus.Query; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | 30 | @AllArgsConstructor 31 | @Getter 32 | public class GetProfile implements Query { 33 | 34 | private String currentUsername; 35 | private String username; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/FollowProfile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.bus.Command; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | 30 | @AllArgsConstructor 31 | @Getter 32 | public class FollowProfile implements Command { 33 | 34 | private String follower; 35 | private String followee; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/domain/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.domain.repository; 25 | 26 | import com.github.al.realworld.domain.model.User; 27 | 28 | import java.util.Optional; 29 | 30 | public interface UserRepository { 31 | 32 | Optional findByEmail(String email); 33 | 34 | Optional findByUsername(String username); 35 | 36 | User save(User user); 37 | } 38 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/DeleteArticle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.bus.Command; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | 30 | @AllArgsConstructor 31 | @Getter 32 | public class DeleteArticle implements Command { 33 | 34 | private String currentUsername; 35 | private String slug; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/UnfollowProfile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.bus.Command; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | 30 | @AllArgsConstructor 31 | @Getter 32 | public class UnfollowProfile implements Command { 33 | 34 | private String follower; 35 | private String followee; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/FavoriteArticle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.bus.Command; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | 30 | @AllArgsConstructor 31 | @Getter 32 | public class FavoriteArticle implements Command { 33 | 34 | private String currentUsername; 35 | private String slug; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/UnfavoriteArticle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.bus.Command; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | 30 | @AllArgsConstructor 31 | @Getter 32 | public class UnfavoriteArticle implements Command { 33 | 34 | private String currentUsername; 35 | private String slug; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetComment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.bus.Query; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | 30 | @AllArgsConstructor 31 | @Getter 32 | public class GetComment implements Query { 33 | 34 | private String currentUsername; 35 | private String slug; 36 | private Long id; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetFeed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.bus.Query; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | 30 | @AllArgsConstructor 31 | @Getter 32 | public class GetFeed implements Query { 33 | 34 | private String currentUsername; 35 | private Integer limit; 36 | private Integer offset; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/dto/AddCommentDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.dto; 25 | 26 | import io.micronaut.core.annotation.ReflectiveAccess; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | import lombok.NoArgsConstructor; 30 | 31 | @NoArgsConstructor 32 | @AllArgsConstructor 33 | @Getter 34 | @ReflectiveAccess 35 | public class AddCommentDto { 36 | 37 | private String body; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/DeleteComment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.bus.Command; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | 30 | @AllArgsConstructor 31 | @Getter 32 | public class DeleteComment implements Command { 33 | 34 | private String currentUsername; 35 | private String slug; 36 | private Long id; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetArticleResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.realworld.api.dto.ArticleDto; 27 | import io.micronaut.core.annotation.ReflectiveAccess; 28 | import lombok.AllArgsConstructor; 29 | import lombok.Getter; 30 | 31 | @AllArgsConstructor 32 | @Getter 33 | @ReflectiveAccess 34 | public class GetArticleResult { 35 | 36 | private ArticleDto article; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetCurrentUserResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.realworld.api.dto.UserDto; 27 | import io.micronaut.core.annotation.ReflectiveAccess; 28 | import lombok.AllArgsConstructor; 29 | import lombok.Getter; 30 | 31 | @AllArgsConstructor 32 | @Getter 33 | @ReflectiveAccess 34 | public class GetCurrentUserResult { 35 | 36 | private UserDto user; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/App.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld; 25 | 26 | import io.micronaut.runtime.Micronaut; 27 | import org.slf4j.bridge.SLF4JBridgeHandler; 28 | 29 | public class App { 30 | 31 | public static void main(String[] args) { 32 | // make liquibase and other jul-lovers log to slf4j 33 | SLF4JBridgeHandler.removeHandlersForRootLogger(); 34 | SLF4JBridgeHandler.install(); 35 | Micronaut.run(args); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetTagsResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import io.micronaut.core.annotation.ReflectiveAccess; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | import lombok.NoArgsConstructor; 30 | 31 | import java.util.List; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Getter 36 | @ReflectiveAccess 37 | public class GetTagsResult { 38 | 39 | private List tags; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /service-bus/src/main/java/com/github/al/bus/QueryHandlerProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.bus; 25 | 26 | import io.micronaut.context.ApplicationContext; 27 | import lombok.RequiredArgsConstructor; 28 | 29 | @RequiredArgsConstructor 30 | class QueryHandlerProvider> { 31 | 32 | private final ApplicationContext applicationContext; 33 | private final Class type; 34 | 35 | H get() { 36 | return applicationContext.getBean(type); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /service-bus/src/main/java/com/github/al/bus/CommandHandlerProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.bus; 25 | 26 | import io.micronaut.context.ApplicationContext; 27 | import lombok.RequiredArgsConstructor; 28 | 29 | @RequiredArgsConstructor 30 | class CommandHandlerProvider> { 31 | 32 | private final ApplicationContext applicationContext; 33 | private final Class type; 34 | 35 | H get() { 36 | return applicationContext.getBean(type); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/infrastructure/db/jpa/DataTagRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.infrastructure.db.jpa; 25 | 26 | import com.github.al.realworld.domain.model.Tag; 27 | import io.micronaut.data.annotation.Repository; 28 | import io.micronaut.data.repository.CrudRepository; 29 | 30 | import java.util.Optional; 31 | 32 | @Repository 33 | public interface DataTagRepository extends CrudRepository { 34 | 35 | Optional findByName(String name); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetCommentResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.realworld.api.dto.CommentDto; 27 | import io.micronaut.core.annotation.ReflectiveAccess; 28 | import lombok.AllArgsConstructor; 29 | import lombok.Getter; 30 | import lombok.NoArgsConstructor; 31 | 32 | @NoArgsConstructor 33 | @AllArgsConstructor 34 | @Getter 35 | @ReflectiveAccess 36 | public class GetCommentResult { 37 | 38 | private CommentDto comment; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetProfileResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.realworld.api.dto.ProfileDto; 27 | import io.micronaut.core.annotation.ReflectiveAccess; 28 | import lombok.AllArgsConstructor; 29 | import lombok.Getter; 30 | import lombok.NoArgsConstructor; 31 | 32 | @NoArgsConstructor 33 | @AllArgsConstructor 34 | @Getter 35 | @ReflectiveAccess 36 | public class GetProfileResult { 37 | 38 | private ProfileDto profile; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /service/src/intTest/java/com/github/al/realworld/rest/TagApiTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.rest; 25 | 26 | import com.github.al.realworld.api.operation.TagClient; 27 | import io.micronaut.test.extensions.junit5.annotation.MicronautTest; 28 | import jakarta.inject.Inject; 29 | import org.junit.jupiter.api.Test; 30 | 31 | @MicronautTest 32 | public class TagApiTest { 33 | 34 | @Inject 35 | private TagClient tagClient; 36 | 37 | @Test 38 | void test() { 39 | tagClient.findAll(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/dto/ProfileDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.dto; 25 | 26 | import io.micronaut.core.annotation.ReflectiveAccess; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Getter; 29 | import lombok.NoArgsConstructor; 30 | 31 | @NoArgsConstructor 32 | @AllArgsConstructor 33 | @Getter 34 | @ReflectiveAccess 35 | public class ProfileDto { 36 | 37 | private String username; 38 | private String bio; 39 | private String image; 40 | private Boolean following; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/dto/UpdateArticleDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.dto; 25 | 26 | import io.micronaut.core.annotation.ReflectiveAccess; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Builder; 29 | import lombok.Getter; 30 | import lombok.NoArgsConstructor; 31 | 32 | @NoArgsConstructor 33 | @AllArgsConstructor 34 | @Builder 35 | @Getter 36 | @ReflectiveAccess 37 | public class UpdateArticleDto { 38 | 39 | private String title; 40 | 41 | private String description; 42 | 43 | private String body; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/LoginUserResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.realworld.api.dto.UserDto; 27 | import io.micronaut.core.annotation.Introspected; 28 | import io.micronaut.core.annotation.ReflectiveAccess; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Introspected 36 | @ReflectiveAccess 37 | @Getter 38 | public class LoginUserResult { 39 | 40 | private UserDto user; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/UpdateUserResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.realworld.api.dto.UserDto; 27 | import io.micronaut.core.annotation.Introspected; 28 | import io.micronaut.core.annotation.ReflectiveAccess; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Introspected 36 | @ReflectiveAccess 37 | @Getter 38 | public class UpdateUserResult { 39 | 40 | private UserDto user; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/RegisterUserResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.realworld.api.dto.UserDto; 27 | import io.micronaut.core.annotation.Introspected; 28 | import io.micronaut.core.annotation.ReflectiveAccess; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Getter 36 | @Introspected 37 | @ReflectiveAccess 38 | public class RegisterUserResult { 39 | 40 | private UserDto user; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/AddCommentResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.realworld.api.dto.CommentDto; 27 | import io.micronaut.core.annotation.Introspected; 28 | import io.micronaut.core.annotation.ReflectiveAccess; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Introspected 36 | @ReflectiveAccess 37 | @Getter 38 | public class AddCommentResult { 39 | 40 | private CommentDto comment; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetFeedResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.realworld.api.dto.ArticleDto; 27 | import io.micronaut.core.annotation.ReflectiveAccess; 28 | import lombok.AllArgsConstructor; 29 | import lombok.Getter; 30 | import lombok.NoArgsConstructor; 31 | 32 | import java.util.List; 33 | 34 | @NoArgsConstructor 35 | @AllArgsConstructor 36 | @Getter 37 | @ReflectiveAccess 38 | public class GetFeedResult { 39 | 40 | private List articles; 41 | private Integer articlesCount; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/CreateArticleResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.realworld.api.dto.ArticleDto; 27 | import io.micronaut.core.annotation.Introspected; 28 | import io.micronaut.core.annotation.ReflectiveAccess; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Introspected 36 | @ReflectiveAccess 37 | @Getter 38 | public class CreateArticleResult { 39 | 40 | private ArticleDto article; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/FollowProfileResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.realworld.api.dto.ProfileDto; 27 | import io.micronaut.core.annotation.Introspected; 28 | import io.micronaut.core.annotation.ReflectiveAccess; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Introspected 36 | @ReflectiveAccess 37 | @Getter 38 | public class FollowProfileResult { 39 | 40 | private ProfileDto profile; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/UpdateArticleResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.realworld.api.dto.ArticleDto; 27 | import io.micronaut.core.annotation.Introspected; 28 | import io.micronaut.core.annotation.ReflectiveAccess; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Introspected 36 | @ReflectiveAccess 37 | @Getter 38 | public class UpdateArticleResult { 39 | 40 | private ArticleDto article; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/dto/UserDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.dto; 25 | 26 | import io.micronaut.core.annotation.ReflectiveAccess; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Builder; 29 | import lombok.Getter; 30 | import lombok.NoArgsConstructor; 31 | 32 | @NoArgsConstructor 33 | @AllArgsConstructor 34 | @Builder 35 | @Getter 36 | @ReflectiveAccess 37 | public class UserDto { 38 | 39 | private String email; 40 | private String token; 41 | private String username; 42 | private String bio; 43 | private String image; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetArticlesResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.realworld.api.dto.ArticleDto; 27 | import io.micronaut.core.annotation.ReflectiveAccess; 28 | import lombok.AllArgsConstructor; 29 | import lombok.Getter; 30 | import lombok.NoArgsConstructor; 31 | 32 | import java.util.List; 33 | 34 | @NoArgsConstructor 35 | @AllArgsConstructor 36 | @Getter 37 | @ReflectiveAccess 38 | public class GetArticlesResult { 39 | 40 | private List articles; 41 | private Integer articlesCount; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/service/NoopPasswordEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.service; 25 | 26 | import jakarta.inject.Singleton; 27 | import java.util.Objects; 28 | 29 | @Singleton 30 | public class NoopPasswordEncoder implements PasswordEncoder { 31 | 32 | @Override 33 | public String encode(String rawPassword) { 34 | return rawPassword; 35 | } 36 | 37 | @Override 38 | public boolean matches(String rawPassword, String encodedPassword) { 39 | return Objects.equals(rawPassword, encodedPassword); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/FavoriteArticleResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.realworld.api.dto.ArticleDto; 27 | import io.micronaut.core.annotation.Introspected; 28 | import io.micronaut.core.annotation.ReflectiveAccess; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Introspected 36 | @ReflectiveAccess 37 | @Getter 38 | public class FavoriteArticleResult { 39 | 40 | private ArticleDto article; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/UnfollowProfileResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.realworld.api.dto.ProfileDto; 27 | import io.micronaut.core.annotation.Introspected; 28 | import io.micronaut.core.annotation.ReflectiveAccess; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Introspected 36 | @ReflectiveAccess 37 | @Getter 38 | public class UnfollowProfileResult { 39 | 40 | private ProfileDto profile; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/UnfavoriteArticleResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.realworld.api.dto.ArticleDto; 27 | import io.micronaut.core.annotation.Introspected; 28 | import io.micronaut.core.annotation.ReflectiveAccess; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Introspected 36 | @ReflectiveAccess 37 | @Getter 38 | public class UnfavoriteArticleResult { 39 | 40 | private ArticleDto article; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/dto/LoginUserDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.dto; 25 | 26 | import io.micronaut.core.annotation.ReflectiveAccess; 27 | import jakarta.validation.constraints.Email; 28 | import jakarta.validation.constraints.NotBlank; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Getter 36 | @ReflectiveAccess 37 | public class LoginUserDto { 38 | 39 | @Email 40 | private String email; 41 | 42 | @NotBlank 43 | private String password; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetCommentsResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.realworld.api.dto.CommentDto; 27 | import io.micronaut.core.annotation.Introspected; 28 | import io.micronaut.core.annotation.ReflectiveAccess; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | import java.util.List; 34 | 35 | @NoArgsConstructor 36 | @AllArgsConstructor 37 | @Getter 38 | @Introspected 39 | @ReflectiveAccess 40 | public class GetCommentsResult { 41 | 42 | private List comments; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/service/DefaultAuthenticationService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.service; 25 | 26 | import io.micronaut.security.utils.SecurityService; 27 | import lombok.RequiredArgsConstructor; 28 | 29 | import jakarta.inject.Singleton; 30 | 31 | @RequiredArgsConstructor 32 | @Singleton 33 | public class DefaultAuthenticationService implements AuthenticationService { 34 | 35 | private final SecurityService securityService; 36 | 37 | @Override 38 | public String currentUsername() { 39 | return securityService.username().orElse(null); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/query/GetArticles.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.query; 25 | 26 | import com.github.al.bus.Query; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Builder; 29 | import lombok.Getter; 30 | import lombok.NoArgsConstructor; 31 | 32 | @AllArgsConstructor 33 | @NoArgsConstructor 34 | @Builder 35 | @Getter 36 | public class GetArticles implements Query { 37 | 38 | private String currentUsername; 39 | private String tag; 40 | private String author; 41 | private String favorited; 42 | private Integer limit; 43 | private Integer offset; 44 | 45 | } 46 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/LoginUser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.bus.Command; 27 | import com.github.al.realworld.api.dto.LoginUserDto; 28 | import io.micronaut.core.annotation.Introspected; 29 | import io.micronaut.core.annotation.ReflectiveAccess; 30 | import lombok.AllArgsConstructor; 31 | import lombok.Getter; 32 | import lombok.NoArgsConstructor; 33 | 34 | @NoArgsConstructor 35 | @AllArgsConstructor 36 | @Getter 37 | @Introspected 38 | @ReflectiveAccess 39 | public class LoginUser implements Command { 40 | 41 | private LoginUserDto user; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/service/PasswordEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.service; 25 | 26 | public interface PasswordEncoder { 27 | 28 | /** 29 | * @param rawPassword The plain text password 30 | * @return The result of encoding the password 31 | */ 32 | String encode(String rawPassword); 33 | 34 | /** 35 | * 36 | * @param rawPassword The plain text password 37 | * @param encodedPassword The encoded password to match against 38 | * @return true if the passwords match 39 | */ 40 | boolean matches(String rawPassword, String encodedPassword); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/domain/repository/FollowRelationRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.domain.repository; 25 | 26 | import com.github.al.realworld.domain.model.FollowRelation; 27 | import com.github.al.realworld.domain.model.User; 28 | 29 | import java.util.List; 30 | import java.util.UUID; 31 | 32 | public interface FollowRelationRepository { 33 | 34 | FollowRelation save(FollowRelation entity); 35 | 36 | List findByFollowerId(UUID followerId); 37 | 38 | List findByFolloweeId(UUID followeeId); 39 | 40 | void deleteByFollowerAndFollowee(User follower, User followee); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/infrastructure/db/jpa/DataUserRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.infrastructure.db.jpa; 25 | 26 | import com.github.al.realworld.domain.model.User; 27 | import io.micronaut.core.annotation.Nullable; 28 | import io.micronaut.data.annotation.Repository; 29 | import io.micronaut.data.repository.CrudRepository; 30 | 31 | import java.util.Optional; 32 | import java.util.UUID; 33 | 34 | @Repository 35 | public interface DataUserRepository extends CrudRepository { 36 | 37 | Optional findByEmail(String email); 38 | 39 | Optional findByUsername(@Nullable String username); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/dto/CommentDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.dto; 25 | 26 | import io.micronaut.core.annotation.ReflectiveAccess; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Builder; 29 | import lombok.Getter; 30 | import lombok.NoArgsConstructor; 31 | 32 | import java.time.ZonedDateTime; 33 | 34 | @NoArgsConstructor 35 | @AllArgsConstructor 36 | @Builder 37 | @Getter 38 | @ReflectiveAccess 39 | public class CommentDto { 40 | 41 | private Long id; 42 | private ZonedDateTime createdAt; 43 | private ZonedDateTime updatedAt; 44 | private String body; 45 | private ProfileDto author; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/RegisterUser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.github.al.bus.Command; 27 | import com.github.al.realworld.api.dto.RegisterUserDto; 28 | import io.micronaut.core.annotation.Introspected; 29 | import io.micronaut.core.annotation.ReflectiveAccess; 30 | import lombok.AllArgsConstructor; 31 | import lombok.Getter; 32 | import lombok.NoArgsConstructor; 33 | 34 | @NoArgsConstructor 35 | @AllArgsConstructor 36 | @Getter 37 | @Introspected 38 | @ReflectiveAccess 39 | public class RegisterUser implements Command { 40 | 41 | private RegisterUserDto user; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/ProfileAssembler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application; 25 | 26 | import com.github.al.realworld.api.dto.ProfileDto; 27 | import com.github.al.realworld.domain.model.User; 28 | 29 | public class ProfileAssembler { 30 | 31 | public static ProfileDto assemble(User user, User currentUser) { 32 | boolean isFollow = currentUser != null && user.getFollowers().stream() 33 | .map(followRelation -> followRelation.getFollower().getId()) 34 | .anyMatch(uuid -> uuid.equals(currentUser.getId())); 35 | return new ProfileDto(user.getUsername(), user.getBio(), user.getImage(), isFollow); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/infrastructure/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.infrastructure.config; 25 | 26 | import io.micronaut.context.annotation.Factory; 27 | import io.micronaut.security.token.bearer.BearerTokenConfigurationProperties; 28 | import io.micronaut.security.token.bearer.BearerTokenReader; 29 | import jakarta.inject.Singleton; 30 | 31 | @Factory 32 | public class SecurityConfig { 33 | 34 | @Singleton 35 | public BearerTokenReader tokenPrefixBearerTokenReader() { 36 | var properties = new BearerTokenConfigurationProperties(); 37 | properties.setPrefix("Token"); 38 | return new BearerTokenReader(properties); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/dto/UpdateUserDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.dto; 25 | 26 | import io.micronaut.core.annotation.ReflectiveAccess; 27 | import jakarta.validation.constraints.Email; 28 | import lombok.AllArgsConstructor; 29 | import lombok.Builder; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | @NoArgsConstructor 34 | @AllArgsConstructor 35 | @Builder(toBuilder = true) 36 | @Getter 37 | @ReflectiveAccess 38 | public class UpdateUserDto { 39 | 40 | @Email 41 | private String email; 42 | 43 | private String username; 44 | 45 | private String password; 46 | 47 | private String image; 48 | 49 | private String bio; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/dto/RegisterUserDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.dto; 25 | 26 | import io.micronaut.core.annotation.ReflectiveAccess; 27 | import jakarta.validation.constraints.Email; 28 | import jakarta.validation.constraints.NotBlank; 29 | import lombok.AllArgsConstructor; 30 | import lombok.Builder; 31 | import lombok.Getter; 32 | import lombok.NoArgsConstructor; 33 | 34 | @NoArgsConstructor 35 | @AllArgsConstructor 36 | @Builder 37 | @Getter 38 | @ReflectiveAccess 39 | public class RegisterUserDto { 40 | 41 | @Email 42 | private String email; 43 | 44 | @NotBlank 45 | private String username; 46 | 47 | @NotBlank 48 | private String password; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/UserAssembler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application; 25 | 26 | import com.github.al.realworld.api.dto.UserDto; 27 | import com.github.al.realworld.application.service.JwtService; 28 | import com.github.al.realworld.domain.model.User; 29 | 30 | public class UserAssembler { 31 | 32 | public static UserDto assemble(User user, JwtService jwtService) { 33 | return UserDto.builder() 34 | .email(user.getEmail()) 35 | .username(user.getUsername()) 36 | .token(jwtService.getToken(user)) 37 | .bio(user.getBio()) 38 | .image(user.getImage()) 39 | .build(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/domain/repository/ArticleRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.domain.repository; 25 | 26 | import com.github.al.realworld.domain.model.Article; 27 | 28 | import java.util.List; 29 | import java.util.Optional; 30 | import java.util.UUID; 31 | 32 | public interface ArticleRepository { 33 | 34 | Optional
findBySlug(String slug); 35 | 36 | Optional
findByTitle(String title); 37 | 38 | List
findByFilters(String tag, String author, String favorited, Integer limit, Integer offset); 39 | 40 | List
findByFollowees(List followees, Integer limit, Integer offset); 41 | 42 | void delete(Article article); 43 | 44 | Article save(Article article); 45 | } 46 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/infrastructure/config/GraalConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.infrastructure.config; 25 | 26 | import io.micronaut.core.annotation.TypeHint; 27 | 28 | @TypeHint( 29 | typeNames = { 30 | "ch.qos.logback.classic.jul.LevelChangePropagator", 31 | "java.util.UUID", 32 | "io.jsonwebtoken.impl.DefaultJwtBuilder", 33 | "io.jsonwebtoken.impl.DefaultJwtParserBuilder" 34 | }, 35 | accessType = { 36 | TypeHint.AccessType.ALL_DECLARED_CONSTRUCTORS, 37 | TypeHint.AccessType.ALL_DECLARED_FIELDS, 38 | TypeHint.AccessType.ALL_PUBLIC_METHODS 39 | } 40 | ) 41 | public class GraalConfig { 42 | } 43 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/domain/model/FollowRelationId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.domain.model; 25 | 26 | import io.micronaut.core.annotation.ReflectiveAccess; 27 | import io.micronaut.core.annotation.TypeHint; 28 | import lombok.AllArgsConstructor; 29 | import lombok.EqualsAndHashCode; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | import jakarta.persistence.Embeddable; 34 | import java.io.Serializable; 35 | import java.util.UUID; 36 | 37 | @NoArgsConstructor 38 | @AllArgsConstructor 39 | @Getter 40 | @EqualsAndHashCode 41 | @TypeHint 42 | @ReflectiveAccess 43 | @Embeddable 44 | public class FollowRelationId implements Serializable { 45 | 46 | private UUID followerId; 47 | private UUID followeeId; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/dto/CreateArticleDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.dto; 25 | 26 | import io.micronaut.core.annotation.ReflectiveAccess; 27 | import jakarta.validation.constraints.NotBlank; 28 | import lombok.AllArgsConstructor; 29 | import lombok.Builder; 30 | import lombok.Getter; 31 | import lombok.NoArgsConstructor; 32 | 33 | import java.util.List; 34 | 35 | @NoArgsConstructor 36 | @AllArgsConstructor 37 | @Builder(toBuilder = true) 38 | @Getter 39 | @ReflectiveAccess 40 | public class CreateArticleDto { 41 | 42 | @NotBlank 43 | private String title; 44 | 45 | @NotBlank 46 | private String description; 47 | 48 | @NotBlank 49 | private String body; 50 | 51 | private List tagList; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/CommentAssembler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application; 25 | 26 | import com.github.al.realworld.api.dto.CommentDto; 27 | import com.github.al.realworld.domain.model.Comment; 28 | import com.github.al.realworld.domain.model.User; 29 | 30 | public class CommentAssembler { 31 | 32 | public static CommentDto assemble(Comment comment, User currentUser) { 33 | return CommentDto.builder() 34 | .id(comment.getId()) 35 | .createdAt(comment.getCreatedAt()) 36 | .updatedAt(comment.getUpdatedAt()) 37 | .body(comment.getBody()) 38 | .author(ProfileAssembler.assemble(comment.getAuthor(), currentUser)) 39 | .build(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/domain/model/Tag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.domain.model; 25 | 26 | import io.micronaut.configuration.hibernate.jpa.proxy.GenerateProxy; 27 | import jakarta.persistence.Table; 28 | import lombok.Getter; 29 | import lombok.NoArgsConstructor; 30 | 31 | import jakarta.persistence.Column; 32 | import jakarta.persistence.Entity; 33 | import jakarta.persistence.GeneratedValue; 34 | import jakarta.persistence.Id; 35 | 36 | @NoArgsConstructor 37 | @Getter 38 | @GenerateProxy 39 | @Entity 40 | @Table(name = "tbl_tag") 41 | public class Tag { 42 | 43 | @Id 44 | @GeneratedValue 45 | private Long id; 46 | 47 | @Column(unique = true) 48 | private String name; 49 | 50 | public Tag(String name) { 51 | this.name = name; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/UpdateUser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.fasterxml.jackson.annotation.JsonIgnore; 27 | import com.github.al.bus.Command; 28 | import com.github.al.realworld.api.dto.UpdateUserDto; 29 | import io.micronaut.core.annotation.Introspected; 30 | import io.micronaut.core.annotation.ReflectiveAccess; 31 | import lombok.AllArgsConstructor; 32 | import lombok.Getter; 33 | import lombok.NoArgsConstructor; 34 | import lombok.With; 35 | 36 | @NoArgsConstructor 37 | @AllArgsConstructor 38 | @Getter 39 | @Introspected 40 | @ReflectiveAccess 41 | public class UpdateUser implements Command { 42 | 43 | @With 44 | @JsonIgnore 45 | private String currentUsername; 46 | 47 | private UpdateUserDto user; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/infrastructure/web/TagController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.infrastructure.web; 25 | 26 | import com.github.al.bus.Bus; 27 | import com.github.al.realworld.api.operation.TagOperations; 28 | import com.github.al.realworld.api.query.GetTags; 29 | import com.github.al.realworld.api.query.GetTagsResult; 30 | import io.micronaut.http.annotation.Controller; 31 | import io.swagger.v3.oas.annotations.tags.Tag; 32 | import lombok.RequiredArgsConstructor; 33 | 34 | @RequiredArgsConstructor 35 | @Tag(name = "Tags") 36 | @Controller("${api.version}") 37 | public class TagController implements TagOperations { 38 | 39 | private final Bus bus; 40 | 41 | @Override 42 | public GetTagsResult findAll() { 43 | return bus.executeQuery(new GetTags()); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/infrastructure/db/jpa/JpaTagRepositoryAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.infrastructure.db.jpa; 25 | 26 | import com.github.al.realworld.domain.model.Tag; 27 | import com.github.al.realworld.domain.repository.TagRepository; 28 | import lombok.RequiredArgsConstructor; 29 | 30 | import jakarta.inject.Singleton; 31 | import java.util.Optional; 32 | 33 | @RequiredArgsConstructor 34 | @Singleton 35 | public class JpaTagRepositoryAdapter implements TagRepository { 36 | 37 | private final DataTagRepository repository; 38 | 39 | @Override 40 | public Optional findByName(String name) { 41 | return repository.findByName(name); 42 | } 43 | 44 | @Override 45 | public Iterable findAll() { 46 | return repository.findAll(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/CreateArticle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.fasterxml.jackson.annotation.JsonIgnore; 27 | import com.github.al.bus.Command; 28 | import com.github.al.realworld.api.dto.CreateArticleDto; 29 | import io.micronaut.core.annotation.Introspected; 30 | import io.micronaut.core.annotation.ReflectiveAccess; 31 | import lombok.AllArgsConstructor; 32 | import lombok.Getter; 33 | import lombok.NoArgsConstructor; 34 | import lombok.With; 35 | 36 | @NoArgsConstructor 37 | @AllArgsConstructor 38 | @Getter 39 | @Introspected 40 | @ReflectiveAccess 41 | public class CreateArticle implements Command { 42 | 43 | @With 44 | @JsonIgnore 45 | private String currentUsername; 46 | 47 | private CreateArticleDto article; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/infrastructure/db/jpa/DataFollowRelationRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.infrastructure.db.jpa; 25 | 26 | import com.github.al.realworld.domain.model.FollowRelation; 27 | import com.github.al.realworld.domain.model.FollowRelationId; 28 | import com.github.al.realworld.domain.model.User; 29 | import io.micronaut.data.annotation.Repository; 30 | import io.micronaut.data.repository.CrudRepository; 31 | 32 | import java.util.List; 33 | import java.util.UUID; 34 | 35 | @Repository 36 | public interface DataFollowRelationRepository extends CrudRepository { 37 | 38 | List findByFollowerId(UUID followerId); 39 | 40 | List findByFolloweeId(UUID followeeId); 41 | 42 | void deleteByFollowerAndFollowee(User follower, User followee); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/dto/ArticleDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.dto; 25 | 26 | import io.micronaut.core.annotation.ReflectiveAccess; 27 | import lombok.AllArgsConstructor; 28 | import lombok.Builder; 29 | import lombok.Getter; 30 | import lombok.NoArgsConstructor; 31 | 32 | import java.time.ZonedDateTime; 33 | import java.util.List; 34 | 35 | @NoArgsConstructor 36 | @AllArgsConstructor 37 | @Builder 38 | @Getter 39 | @ReflectiveAccess 40 | public class ArticleDto { 41 | 42 | private String slug; 43 | private String title; 44 | private String description; 45 | private String body; 46 | private List tagList; 47 | private ZonedDateTime createdAt; 48 | private ZonedDateTime updatedAt; 49 | private Boolean favorited; 50 | private Integer favoritesCount; 51 | private ProfileDto author; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /service/src/intTest/java/com/github/al/realworld/rest/auth/AuthFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.rest.auth; 25 | 26 | import io.micronaut.http.HttpHeaders; 27 | import io.micronaut.http.HttpResponse; 28 | import io.micronaut.http.MutableHttpRequest; 29 | import io.micronaut.http.annotation.Filter; 30 | import io.micronaut.http.filter.ClientFilterChain; 31 | import io.micronaut.http.filter.HttpClientFilter; 32 | import org.reactivestreams.Publisher; 33 | 34 | @Filter("/**") 35 | public class AuthFilter implements HttpClientFilter { 36 | 37 | @Override 38 | public Publisher> doFilter(MutableHttpRequest request, ClientFilterChain chain) { 39 | String token = AuthSupport.TokenHolder.token; 40 | if (token != null) { 41 | request.header(HttpHeaders.AUTHORIZATION, "Token " + token); 42 | } 43 | return chain.proceed(request); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/AddComment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.fasterxml.jackson.annotation.JsonIgnore; 27 | import com.github.al.bus.Command; 28 | import com.github.al.realworld.api.dto.AddCommentDto; 29 | import io.micronaut.core.annotation.Introspected; 30 | import io.micronaut.core.annotation.ReflectiveAccess; 31 | import lombok.AllArgsConstructor; 32 | import lombok.Builder; 33 | import lombok.Getter; 34 | import lombok.NoArgsConstructor; 35 | import lombok.With; 36 | 37 | @NoArgsConstructor 38 | @AllArgsConstructor 39 | @Builder 40 | @Getter 41 | @Introspected 42 | @ReflectiveAccess 43 | public class AddComment implements Command { 44 | 45 | @With 46 | @JsonIgnore 47 | private String slug; 48 | 49 | @With 50 | @JsonIgnore 51 | private String currentUsername; 52 | 53 | private AddCommentDto comment; 54 | 55 | } 56 | -------------------------------------------------------------------------------- /service-bus/src/main/java/com/github/al/bus/DefaultBus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.bus; 25 | 26 | import lombok.RequiredArgsConstructor; 27 | 28 | import jakarta.inject.Singleton; 29 | 30 | @RequiredArgsConstructor 31 | @Singleton 32 | public class DefaultBus implements Bus { 33 | 34 | private final Registry registry; 35 | 36 | @SuppressWarnings("unchecked") 37 | @Override 38 | public > R executeCommand(C command) { 39 | CommandHandler commandHandler = (CommandHandler) registry.getCommandHandler(command.getClass()); 40 | return commandHandler.handle(command); 41 | } 42 | 43 | @SuppressWarnings("unchecked") 44 | @Override 45 | public > R executeQuery(Q query) { 46 | QueryHandler queryHandler = (QueryHandler) registry.getQueryHandler(query.getClass()); 47 | return queryHandler.handle(query); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/command/UpdateArticle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.command; 25 | 26 | import com.fasterxml.jackson.annotation.JsonIgnore; 27 | import com.github.al.bus.Command; 28 | import com.github.al.realworld.api.dto.UpdateArticleDto; 29 | import io.micronaut.core.annotation.Introspected; 30 | import io.micronaut.core.annotation.ReflectiveAccess; 31 | import lombok.AllArgsConstructor; 32 | import lombok.Builder; 33 | import lombok.Getter; 34 | import lombok.NoArgsConstructor; 35 | import lombok.With; 36 | 37 | @NoArgsConstructor 38 | @AllArgsConstructor 39 | @Builder 40 | @Getter 41 | @Introspected 42 | @ReflectiveAccess 43 | public class UpdateArticle implements Command { 44 | 45 | @With 46 | @JsonIgnore 47 | private String currentUsername; 48 | 49 | @With 50 | @JsonIgnore 51 | private String slug; 52 | 53 | private UpdateArticleDto article; 54 | 55 | } 56 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/service/SlugService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.service; 25 | 26 | import jakarta.inject.Singleton; 27 | import java.text.Normalizer; 28 | import java.util.Locale; 29 | import java.util.regex.Pattern; 30 | 31 | @Singleton 32 | public class SlugService { 33 | 34 | private static final Pattern NONLATIN = Pattern.compile("[^\\w_-]"); 35 | private static final Pattern SEPARATORS = Pattern.compile("[\\s\\p{Punct}&&[^-]]"); 36 | 37 | public String makeSlug(String input) { 38 | String noseparators = SEPARATORS.matcher(input).replaceAll("-"); 39 | String normalized = Normalizer.normalize(noseparators, Normalizer.Form.NFD); 40 | String slug = NONLATIN.matcher(normalized).replaceAll(""); 41 | return slug.toLowerCase(Locale.ENGLISH) 42 | .replaceAll("-{2,}", "-") 43 | .replaceAll("^-|-$", ""); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/operation/ProfileOperations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.operation; 25 | 26 | import com.github.al.realworld.api.command.FollowProfileResult; 27 | import com.github.al.realworld.api.command.UnfollowProfileResult; 28 | import com.github.al.realworld.api.query.GetProfileResult; 29 | import io.micronaut.http.annotation.Delete; 30 | import io.micronaut.http.annotation.Get; 31 | import io.micronaut.http.annotation.PathVariable; 32 | import io.micronaut.http.annotation.Post; 33 | 34 | public interface ProfileOperations { 35 | 36 | @Get("/profiles/{username}") 37 | GetProfileResult findByUsername(@PathVariable("username") String username); 38 | 39 | @Post("/profiles/{username}/follow") 40 | FollowProfileResult follow(@PathVariable("username") String username); 41 | 42 | @Delete("/profiles/{username}/follow") 43 | UnfollowProfileResult unfollow(@PathVariable("username") String username); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/service/DefaultJwtService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.service; 25 | 26 | import com.github.al.realworld.domain.model.User; 27 | import io.micronaut.security.authentication.ServerAuthentication; 28 | import io.micronaut.security.token.generator.AccessRefreshTokenGenerator; 29 | import io.micronaut.security.token.render.AccessRefreshToken; 30 | import jakarta.inject.Singleton; 31 | 32 | @Singleton 33 | public class DefaultJwtService implements JwtService { 34 | 35 | private final AccessRefreshTokenGenerator tokenGenerator; 36 | 37 | public DefaultJwtService(AccessRefreshTokenGenerator tokenGenerator) { 38 | this.tokenGenerator = tokenGenerator; 39 | } 40 | 41 | @Override 42 | public String getToken(User user) { 43 | ServerAuthentication authentication = new ServerAuthentication(user.getUsername(), null, null); 44 | return tokenGenerator.generate(authentication).map(AccessRefreshToken::getAccessToken).orElse(null); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/exception/Exceptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.exception; 25 | 26 | import io.micronaut.http.HttpStatus; 27 | import io.micronaut.http.exceptions.HttpStatusException; 28 | 29 | public class Exceptions { 30 | 31 | public static HttpStatusException notFound(String message, Object... args) { 32 | return new HttpStatusException(HttpStatus.NOT_FOUND, String.format(message, args)); 33 | } 34 | 35 | public static HttpStatusException badRequest(String message, Object... args) { 36 | return new HttpStatusException(HttpStatus.BAD_REQUEST, String.format(message, args)); 37 | } 38 | 39 | public static HttpStatusException forbidden(String message, Object... args) { 40 | return new HttpStatusException(HttpStatus.FORBIDDEN, String.format(message, args)); 41 | } 42 | 43 | public static HttpStatusException unauthorized(String message, Object... args) { 44 | return new HttpStatusException(HttpStatus.UNAUTHORIZED, String.format(message, args)); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/domain/model/FollowRelation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.domain.model; 25 | 26 | import lombok.AllArgsConstructor; 27 | import lombok.EqualsAndHashCode; 28 | import lombok.Getter; 29 | import lombok.NoArgsConstructor; 30 | 31 | import jakarta.persistence.EmbeddedId; 32 | import jakarta.persistence.Entity; 33 | import jakarta.persistence.FetchType; 34 | import jakarta.persistence.ManyToOne; 35 | import jakarta.persistence.MapsId; 36 | import jakarta.persistence.Table; 37 | 38 | @NoArgsConstructor 39 | @AllArgsConstructor 40 | @Getter 41 | @EqualsAndHashCode(onlyExplicitlyIncluded = true) 42 | @Entity 43 | @Table(name = "tbl_follow_relation") 44 | public class FollowRelation { 45 | 46 | @EmbeddedId 47 | private FollowRelationId id; 48 | 49 | @EqualsAndHashCode.Include 50 | @ManyToOne(fetch = FetchType.LAZY) 51 | @MapsId("followerId") 52 | private User follower; 53 | 54 | @EqualsAndHashCode.Include 55 | @ManyToOne(fetch = FetchType.LAZY) 56 | @MapsId("followeeId") 57 | private User followee; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/infrastructure/db/jpa/JpaUserRepositoryAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.infrastructure.db.jpa; 25 | 26 | import com.github.al.realworld.domain.model.User; 27 | import com.github.al.realworld.domain.repository.UserRepository; 28 | import lombok.RequiredArgsConstructor; 29 | 30 | import jakarta.inject.Singleton; 31 | import java.util.Optional; 32 | 33 | @RequiredArgsConstructor 34 | @Singleton 35 | public class JpaUserRepositoryAdapter implements UserRepository { 36 | 37 | private final DataUserRepository repository; 38 | 39 | @Override 40 | public Optional findByEmail(String email) { 41 | return repository.findByEmail(email); 42 | } 43 | 44 | @Override 45 | public Optional findByUsername(String username) { 46 | return repository.findByUsername(username); 47 | } 48 | 49 | @Override 50 | public User save(User user) { 51 | if (repository.existsById(user.getId())) { 52 | return repository.update(user); 53 | } 54 | return repository.save(user); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /service-api/src/main/java/com/github/al/realworld/api/operation/UserOperations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.api.operation; 25 | 26 | import com.github.al.realworld.api.command.LoginUser; 27 | import com.github.al.realworld.api.command.LoginUserResult; 28 | import com.github.al.realworld.api.command.RegisterUser; 29 | import com.github.al.realworld.api.command.RegisterUserResult; 30 | import com.github.al.realworld.api.command.UpdateUser; 31 | import com.github.al.realworld.api.command.UpdateUserResult; 32 | import com.github.al.realworld.api.query.GetCurrentUserResult; 33 | import io.micronaut.http.annotation.Body; 34 | import io.micronaut.http.annotation.Get; 35 | import io.micronaut.http.annotation.Post; 36 | import io.micronaut.http.annotation.Put; 37 | 38 | import jakarta.validation.Valid; 39 | 40 | public interface UserOperations { 41 | 42 | @Post("/users/login") 43 | LoginUserResult login(@Valid @Body LoginUser command); 44 | 45 | @Post("/users") 46 | RegisterUserResult register(@Valid @Body RegisterUser command); 47 | 48 | @Get("/user") 49 | GetCurrentUserResult current(); 50 | 51 | @Put("/user") 52 | UpdateUserResult update(@Valid @Body UpdateUser command); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/query/GetTagsHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.query; 25 | 26 | import com.github.al.realworld.api.query.GetTags; 27 | import com.github.al.realworld.api.query.GetTagsResult; 28 | import com.github.al.bus.QueryHandler; 29 | import com.github.al.realworld.domain.model.Tag; 30 | import com.github.al.realworld.domain.repository.TagRepository; 31 | import lombok.RequiredArgsConstructor; 32 | 33 | import jakarta.inject.Singleton; 34 | import jakarta.transaction.Transactional; 35 | 36 | import java.util.ArrayList; 37 | import java.util.stream.StreamSupport; 38 | 39 | @RequiredArgsConstructor 40 | @Singleton 41 | public class GetTagsHandler implements QueryHandler { 42 | 43 | private final TagRepository tagRepository; 44 | 45 | @Transactional 46 | @Override 47 | public GetTagsResult handle(GetTags query) { 48 | GetTagsResult result = new GetTagsResult(new ArrayList<>()); 49 | 50 | StreamSupport.stream(tagRepository.findAll().spliterator(), false) 51 | .map(Tag::getName) 52 | .forEach(t -> result.getTags().add(t)); 53 | 54 | return result; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/domain/model/Comment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.domain.model; 25 | 26 | import io.micronaut.configuration.hibernate.jpa.proxy.GenerateProxy; 27 | import jakarta.persistence.Entity; 28 | import jakarta.persistence.GeneratedValue; 29 | import jakarta.persistence.GenerationType; 30 | import jakarta.persistence.Id; 31 | import jakarta.persistence.Lob; 32 | import jakarta.persistence.OneToOne; 33 | import jakarta.persistence.Table; 34 | import lombok.AllArgsConstructor; 35 | import lombok.Builder; 36 | import lombok.EqualsAndHashCode; 37 | import lombok.Getter; 38 | import lombok.NoArgsConstructor; 39 | 40 | import java.time.ZonedDateTime; 41 | 42 | @NoArgsConstructor 43 | @AllArgsConstructor 44 | @Builder 45 | @Getter 46 | @EqualsAndHashCode(onlyExplicitlyIncluded = true) 47 | @GenerateProxy 48 | @Entity 49 | @Table(name = "tbl_comment") 50 | public class Comment { 51 | 52 | @EqualsAndHashCode.Include 53 | @Id 54 | @GeneratedValue(strategy = GenerationType.AUTO) 55 | private Long id; 56 | private ZonedDateTime createdAt; 57 | private ZonedDateTime updatedAt; 58 | @Lob 59 | private String body; 60 | @OneToOne 61 | private User author; 62 | 63 | } 64 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/ArticleAssembler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application; 25 | 26 | import com.github.al.realworld.api.dto.ArticleDto; 27 | import com.github.al.realworld.domain.model.Article; 28 | import com.github.al.realworld.domain.model.Tag; 29 | import com.github.al.realworld.domain.model.User; 30 | 31 | import java.util.stream.Collectors; 32 | 33 | public class ArticleAssembler { 34 | 35 | public static ArticleDto assemble(Article article, User currentUser) { 36 | return ArticleDto.builder() 37 | .slug(article.getSlug()) 38 | .title(article.getTitle()) 39 | .description(article.getDescription()) 40 | .body(article.getBody()) 41 | .tagList(article.getTags().stream().map(Tag::getName).sorted().collect(Collectors.toList())) 42 | .createdAt(article.getCreatedAt()) 43 | .updatedAt(article.getUpdatedAt()) 44 | .favorited(currentUser != null && article.getFavoredUsers().contains(currentUser)) 45 | .favoritesCount(article.getFavoredUsers().size()) 46 | .author(ProfileAssembler.assemble(article.getAuthor(), currentUser)) 47 | .build(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/domain/model/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.domain.model; 25 | 26 | import io.micronaut.configuration.hibernate.jpa.proxy.GenerateProxy; 27 | import jakarta.persistence.CascadeType; 28 | import jakarta.persistence.Entity; 29 | import jakarta.persistence.Id; 30 | import jakarta.persistence.OneToMany; 31 | import jakarta.persistence.Table; 32 | import lombok.AllArgsConstructor; 33 | import lombok.Builder; 34 | import lombok.EqualsAndHashCode; 35 | import lombok.Getter; 36 | import lombok.NoArgsConstructor; 37 | import lombok.Singular; 38 | 39 | import java.util.Set; 40 | import java.util.UUID; 41 | 42 | @NoArgsConstructor 43 | @AllArgsConstructor 44 | @Builder(toBuilder = true) 45 | @Getter 46 | @EqualsAndHashCode(onlyExplicitlyIncluded = true) 47 | @GenerateProxy 48 | @Entity 49 | @Table(name = "tbl_user") 50 | public class User { 51 | 52 | @EqualsAndHashCode.Include 53 | @Id 54 | private UUID id; 55 | private String username; 56 | private String email; 57 | private String password; 58 | private String bio; 59 | private String image; 60 | 61 | @Singular 62 | @OneToMany( 63 | mappedBy = "followee", 64 | cascade = CascadeType.ALL, 65 | orphanRemoval = true 66 | ) 67 | private Set followers; 68 | 69 | } 70 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/infrastructure/db/jpa/JpaFollowRelationRepositoryAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.infrastructure.db.jpa; 25 | 26 | import com.github.al.realworld.domain.model.FollowRelation; 27 | import com.github.al.realworld.domain.model.User; 28 | import com.github.al.realworld.domain.repository.FollowRelationRepository; 29 | import lombok.RequiredArgsConstructor; 30 | 31 | import jakarta.inject.Singleton; 32 | import java.util.List; 33 | import java.util.UUID; 34 | 35 | @RequiredArgsConstructor 36 | @Singleton 37 | public class JpaFollowRelationRepositoryAdapter implements FollowRelationRepository { 38 | 39 | private final DataFollowRelationRepository repository; 40 | 41 | @Override 42 | public FollowRelation save(FollowRelation entity) { 43 | return repository.save(entity); 44 | } 45 | 46 | @Override 47 | public List findByFollowerId(UUID followerId) { 48 | return repository.findByFollowerId(followerId); 49 | } 50 | 51 | @Override 52 | public List findByFolloweeId(UUID followeeId) { 53 | return repository.findByFolloweeId(followeeId); 54 | } 55 | 56 | @Override 57 | public void deleteByFollowerAndFollowee(User follower, User followee) { 58 | repository.deleteByFollowerAndFollowee(follower, followee); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/query/GetProfileHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.query; 25 | 26 | import com.github.al.realworld.api.query.GetProfile; 27 | import com.github.al.realworld.api.query.GetProfileResult; 28 | import com.github.al.realworld.application.ProfileAssembler; 29 | import com.github.al.bus.QueryHandler; 30 | import com.github.al.realworld.domain.model.User; 31 | import com.github.al.realworld.domain.repository.UserRepository; 32 | import lombok.RequiredArgsConstructor; 33 | 34 | import jakarta.inject.Singleton; 35 | import jakarta.transaction.Transactional; 36 | 37 | import static com.github.al.realworld.application.exception.Exceptions.notFound; 38 | 39 | @RequiredArgsConstructor 40 | @Singleton 41 | public class GetProfileHandler implements QueryHandler { 42 | 43 | private final UserRepository userRepository; 44 | 45 | @Transactional 46 | @Override 47 | public GetProfileResult handle(GetProfile query) { 48 | User currentUser = userRepository.findByUsername(query.getCurrentUsername()) 49 | .orElse(null); 50 | 51 | User user = userRepository.findByUsername(query.getUsername()) 52 | .orElseThrow(() -> notFound("user [name=%s] does not exist", query.getUsername())); 53 | 54 | return new GetProfileResult(ProfileAssembler.assemble(user, currentUser)); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/query/GetCurrentUserHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.query; 25 | 26 | import com.github.al.realworld.api.query.GetCurrentUser; 27 | import com.github.al.realworld.api.query.GetCurrentUserResult; 28 | import com.github.al.realworld.application.UserAssembler; 29 | import com.github.al.realworld.application.service.JwtService; 30 | import com.github.al.bus.QueryHandler; 31 | import com.github.al.realworld.domain.model.User; 32 | import com.github.al.realworld.domain.repository.UserRepository; 33 | import lombok.RequiredArgsConstructor; 34 | 35 | import jakarta.inject.Singleton; 36 | import jakarta.transaction.Transactional; 37 | 38 | import static com.github.al.realworld.application.exception.Exceptions.badRequest; 39 | 40 | @RequiredArgsConstructor 41 | @Singleton 42 | public class GetCurrentUserHandler implements QueryHandler { 43 | 44 | private final UserRepository userRepository; 45 | private final JwtService jwtService; 46 | 47 | @Transactional 48 | @Override 49 | public GetCurrentUserResult handle(GetCurrentUser query) { 50 | User user = userRepository.findByUsername(query.getUsername()) 51 | .orElseThrow(() -> badRequest("user [name=%s] does not exist", query.getUsername())); 52 | 53 | return new GetCurrentUserResult(UserAssembler.assemble(user, jwtService)); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/query/GetArticleHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.query; 25 | 26 | import com.github.al.realworld.api.query.GetArticle; 27 | import com.github.al.realworld.api.query.GetArticleResult; 28 | import com.github.al.realworld.application.ArticleAssembler; 29 | import com.github.al.bus.QueryHandler; 30 | import com.github.al.realworld.domain.model.Article; 31 | import com.github.al.realworld.domain.model.User; 32 | import com.github.al.realworld.domain.repository.ArticleRepository; 33 | import com.github.al.realworld.domain.repository.UserRepository; 34 | import lombok.RequiredArgsConstructor; 35 | 36 | import jakarta.inject.Singleton; 37 | import jakarta.transaction.Transactional; 38 | 39 | import static com.github.al.realworld.application.exception.Exceptions.notFound; 40 | 41 | @RequiredArgsConstructor 42 | @Singleton 43 | public class GetArticleHandler implements QueryHandler { 44 | 45 | private final ArticleRepository articleRepository; 46 | private final UserRepository userRepository; 47 | 48 | @Transactional 49 | @Override 50 | public GetArticleResult handle(GetArticle query) { 51 | Article article = articleRepository.findBySlug(query.getSlug()) 52 | .orElseThrow(() -> notFound("article [slug=%s] does not exists", query.getSlug())); 53 | 54 | User currentUser = userRepository.findByUsername(query.getCurrentUsername()) 55 | .orElse(null); 56 | 57 | return new GetArticleResult(ArticleAssembler.assemble(article, currentUser)); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/infrastructure/db/jpa/DataArticleRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.infrastructure.db.jpa; 25 | 26 | import com.github.al.realworld.domain.model.Article; 27 | import io.micronaut.core.annotation.Nullable; 28 | import io.micronaut.data.annotation.Query; 29 | import io.micronaut.data.annotation.Repository; 30 | import io.micronaut.data.model.Pageable; 31 | import io.micronaut.data.repository.CrudRepository; 32 | 33 | import java.util.List; 34 | import java.util.Optional; 35 | import java.util.UUID; 36 | 37 | @Repository 38 | public interface DataArticleRepository extends CrudRepository { 39 | 40 | Optional
findBySlug(String slug); 41 | 42 | Optional
findByTitle(String title); 43 | 44 | @Query("SELECT DISTINCT article_ FROM Article article_ " + 45 | "LEFT JOIN article_.tags t " + 46 | "LEFT JOIN article_.author p " + 47 | "LEFT JOIN article_.favoredUsers f " + 48 | "WHERE " + 49 | "(:tag IS NULL OR t.name = :tag) AND " + 50 | "(:author IS NULL OR p.username = :author) AND " + 51 | "(:favorited IS NULL OR f.username = :favorited)") 52 | List
findByFilters(@Nullable String tag, 53 | @Nullable String author, 54 | @Nullable String favorited, 55 | Pageable pageable); 56 | 57 | @Query("SELECT article_ FROM Article article_ JOIN article_.author au WHERE au.id IN :followees") 58 | List
findByFollowees(List followees, Pageable pageable); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/command/DeleteArticleHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.command; 25 | 26 | import com.github.al.realworld.api.command.DeleteArticle; 27 | import com.github.al.realworld.api.command.DeleteArticleResult; 28 | import com.github.al.bus.CommandHandler; 29 | import com.github.al.realworld.domain.model.Article; 30 | import com.github.al.realworld.domain.repository.ArticleRepository; 31 | import lombok.RequiredArgsConstructor; 32 | 33 | import jakarta.inject.Singleton; 34 | import jakarta.transaction.Transactional; 35 | 36 | import java.util.Objects; 37 | 38 | import static com.github.al.realworld.application.exception.Exceptions.forbidden; 39 | import static com.github.al.realworld.application.exception.Exceptions.notFound; 40 | 41 | @RequiredArgsConstructor 42 | @Singleton 43 | public class DeleteArticleHandler implements CommandHandler { 44 | 45 | private final ArticleRepository articleRepository; 46 | 47 | @Transactional 48 | @Override 49 | public DeleteArticleResult handle(DeleteArticle command) { 50 | Article article = articleRepository.findBySlug(command.getSlug()) 51 | .orElseThrow(() -> notFound("article [slug=%s] does not exist", command.getSlug())); 52 | 53 | if (!Objects.equals(article.getAuthor().getUsername(), command.getCurrentUsername())) { 54 | throw forbidden("article [slug=%s] is not owned by %s", command.getSlug(), command.getCurrentUsername()); 55 | } 56 | 57 | articleRepository.delete(article); 58 | 59 | return new DeleteArticleResult(); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/infrastructure/web/ProfileController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.infrastructure.web; 25 | 26 | import com.github.al.bus.Bus; 27 | import com.github.al.realworld.api.command.FollowProfile; 28 | import com.github.al.realworld.api.command.FollowProfileResult; 29 | import com.github.al.realworld.api.command.UnfollowProfile; 30 | import com.github.al.realworld.api.command.UnfollowProfileResult; 31 | import com.github.al.realworld.api.operation.ProfileOperations; 32 | import com.github.al.realworld.api.query.GetProfile; 33 | import com.github.al.realworld.api.query.GetProfileResult; 34 | import com.github.al.realworld.application.service.AuthenticationService; 35 | import io.micronaut.http.annotation.Controller; 36 | import io.swagger.v3.oas.annotations.tags.Tag; 37 | import lombok.RequiredArgsConstructor; 38 | 39 | @RequiredArgsConstructor 40 | @Tag(name = "Profiles") 41 | @Controller("${api.version}") 42 | public class ProfileController implements ProfileOperations { 43 | 44 | private final Bus bus; 45 | private final AuthenticationService auth; 46 | 47 | @Override 48 | public GetProfileResult findByUsername(String username) { 49 | return bus.executeQuery(new GetProfile(auth.currentUsername(), username)); 50 | } 51 | 52 | @Override 53 | public FollowProfileResult follow(String username) { 54 | return bus.executeCommand(new FollowProfile(auth.currentUsername(), username)); 55 | } 56 | 57 | @Override 58 | public UnfollowProfileResult unfollow(String username) { 59 | return bus.executeCommand(new UnfollowProfile(auth.currentUsername(), username)); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/query/GetArticlesHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.query; 25 | 26 | import com.github.al.bus.QueryHandler; 27 | import com.github.al.realworld.api.dto.ArticleDto; 28 | import com.github.al.realworld.api.query.GetArticles; 29 | import com.github.al.realworld.api.query.GetArticlesResult; 30 | import com.github.al.realworld.application.ArticleAssembler; 31 | import com.github.al.realworld.domain.model.Article; 32 | import com.github.al.realworld.domain.model.User; 33 | import com.github.al.realworld.domain.repository.ArticleRepository; 34 | import com.github.al.realworld.domain.repository.UserRepository; 35 | import lombok.RequiredArgsConstructor; 36 | 37 | import jakarta.inject.Singleton; 38 | import jakarta.transaction.Transactional; 39 | import java.util.ArrayList; 40 | import java.util.List; 41 | 42 | @RequiredArgsConstructor 43 | @Singleton 44 | public class GetArticlesHandler implements QueryHandler { 45 | 46 | private final ArticleRepository articleRepository; 47 | private final UserRepository userRepository; 48 | 49 | @Transactional 50 | @Override 51 | public GetArticlesResult handle(GetArticles query) { 52 | List
articles = articleRepository 53 | .findByFilters(query.getTag(), query.getAuthor(), query.getFavorited(), query.getLimit(), query.getOffset()); 54 | 55 | User currentUser = userRepository.findByUsername(query.getCurrentUsername()) 56 | .orElse(null); 57 | 58 | List results = new ArrayList<>(); 59 | 60 | articles.forEach(article -> results.add(ArticleAssembler.assemble(article, currentUser))); 61 | 62 | return new GetArticlesResult(results, results.size()); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /service/src/main/java/com/github/al/realworld/application/query/GetCommentsHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020 - present Alexey Lapin 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.github.al.realworld.application.query; 25 | 26 | import com.github.al.realworld.api.dto.CommentDto; 27 | import com.github.al.realworld.api.query.GetComments; 28 | import com.github.al.realworld.api.query.GetCommentsResult; 29 | import com.github.al.realworld.application.CommentAssembler; 30 | import com.github.al.bus.QueryHandler; 31 | import com.github.al.realworld.domain.model.Article; 32 | import com.github.al.realworld.domain.model.User; 33 | import com.github.al.realworld.domain.repository.ArticleRepository; 34 | import com.github.al.realworld.domain.repository.UserRepository; 35 | import lombok.RequiredArgsConstructor; 36 | 37 | import jakarta.inject.Singleton; 38 | import jakarta.transaction.Transactional; 39 | 40 | import java.util.ArrayList; 41 | 42 | import static com.github.al.realworld.application.exception.Exceptions.notFound; 43 | 44 | @RequiredArgsConstructor 45 | @Singleton 46 | public class GetCommentsHandler implements QueryHandler { 47 | 48 | private final ArticleRepository articleRepository; 49 | private final UserRepository userRepository; 50 | 51 | @Transactional 52 | @Override 53 | public GetCommentsResult handle(GetComments query) { 54 | Article article = articleRepository.findBySlug(query.getSlug()) 55 | .orElseThrow(() -> notFound("article [slug=%s] does not exists", query.getSlug())); 56 | 57 | User currentUser = userRepository.findByUsername(query.getCurrentUsername()) 58 | .orElse(null); 59 | 60 | ArrayList result = new ArrayList<>(); 61 | 62 | article.getComments().forEach(comment -> result.add(CommentAssembler.assemble(comment, currentUser))); 63 | 64 | return new GetCommentsResult(result); 65 | } 66 | 67 | } 68 | --------------------------------------------------------------------------------