Compare commits
3 Commits
218f4c6974
...
226c28885b
| Author | SHA1 | Date | |
|---|---|---|---|
| 226c28885b | |||
| 5eb3c7b58e | |||
| 2b2cd2be70 |
66
.idea/MyBatisCodeHelperDatasource.xml
generated
66
.idea/MyBatisCodeHelperDatasource.xml
generated
@@ -11,11 +11,11 @@
|
|||||||
<option name="generateServiceInterface" value="true" />
|
<option name="generateServiceInterface" value="true" />
|
||||||
<option name="insertMethodEnabled" value="false" />
|
<option name="insertMethodEnabled" value="false" />
|
||||||
<option name="insertSelectiveMethodEnabled" value="false" />
|
<option name="insertSelectiveMethodEnabled" value="false" />
|
||||||
<option name="javaMapperPackage" value="com.hanserwei.hannote.note.biz.domain.mapper" />
|
<option name="javaMapperPackage" value="com.hanserwei.hannote.comment.biz.domain.mapper" />
|
||||||
<option name="javaMapperPath" value="$PROJECT_DIR$/han-note-note/han-note-note-biz/src/main/java" />
|
<option name="javaMapperPath" value="$PROJECT_DIR$/han-note-comment/han-note-comment-biz/src/main/java" />
|
||||||
<option name="javaModelPackage" value="com.hanserwei.hannote.note.biz.domain.dataobject" />
|
<option name="javaModelPackage" value="com.hanserwei.hannote.comment.biz.domain.dataobject" />
|
||||||
<option name="javaModelPath" value="$PROJECT_DIR$/han-note-note/han-note-note-biz/src/main/java" />
|
<option name="javaModelPath" value="$PROJECT_DIR$/han-note-comment/han-note-comment-biz/src/main/java" />
|
||||||
<option name="lastDatabaseCrudChooseModuleName" value="han-note-note-biz" />
|
<option name="lastDatabaseCrudChooseModuleName" value="han-note-comment-biz" />
|
||||||
<option name="lombokAllArgConstructor" value="true" />
|
<option name="lombokAllArgConstructor" value="true" />
|
||||||
<option name="lombokDataAnnotation" value="true" />
|
<option name="lombokDataAnnotation" value="true" />
|
||||||
<option name="lombokNoArgsConstructor" value="true" />
|
<option name="lombokNoArgsConstructor" value="true" />
|
||||||
@@ -46,6 +46,22 @@
|
|||||||
</UserPackageAndPathInfoByModule>
|
</UserPackageAndPathInfoByModule>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry key="han-note-comment-biz">
|
||||||
|
<value>
|
||||||
|
<UserPackageAndPathInfoByModule>
|
||||||
|
<option name="javaMapperPackage" value="com.hanserwei.hannote.comment.biz.domain.mapper" />
|
||||||
|
<option name="javaMapperPath" value="$PROJECT_DIR$/han-note-comment/han-note-comment-biz/src/main/java" />
|
||||||
|
<option name="javaModelPacakge" value="com.hanserwei.hannote.comment.biz.domain.dataobject" />
|
||||||
|
<option name="javaModelPath" value="$PROJECT_DIR$/han-note-comment/han-note-comment-biz/src/main/java" />
|
||||||
|
<option name="javaServiceInterfacePackage" value="com.hanserwei.hannote.comment.biz.service" />
|
||||||
|
<option name="javaServiceInterfacePath" value="$PROJECT_DIR$/han-note-comment/han-note-comment-biz/src/main/java" />
|
||||||
|
<option name="javaServicePackage" value="com.hanserwei.hannote.comment.biz.service.impl" />
|
||||||
|
<option name="javaServicePath" value="$PROJECT_DIR$/han-note-comment/han-note-comment-biz/src/main/java" />
|
||||||
|
<option name="xmlPackage" value="mapperxml" />
|
||||||
|
<option name="xmlPath" value="$PROJECT_DIR$/han-note-comment/han-note-comment-biz/src/main/resources" />
|
||||||
|
</UserPackageAndPathInfoByModule>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
<entry key="han-note-count-biz">
|
<entry key="han-note-count-biz">
|
||||||
<value>
|
<value>
|
||||||
<UserPackageAndPathInfoByModule>
|
<UserPackageAndPathInfoByModule>
|
||||||
@@ -122,6 +138,44 @@
|
|||||||
</TableGenerateConfig>
|
</TableGenerateConfig>
|
||||||
</value>
|
</value>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry key="han_note:t_comment">
|
||||||
|
<value>
|
||||||
|
<TableGenerateConfig>
|
||||||
|
<option name="deleteByPrimayKeyEnabled" value="false" />
|
||||||
|
<option name="generatedKey" value="id" />
|
||||||
|
<option name="insertMethodEnabled" value="false" />
|
||||||
|
<option name="insertSelectiveMethodEnabled" value="false" />
|
||||||
|
<option name="javaModelName" value="CommentDO" />
|
||||||
|
<option name="moduleName" value="han-note-comment-biz" />
|
||||||
|
<option name="mybatisplusIdType" value="AUTO" />
|
||||||
|
<option name="selectByPrimaryKeyEnabled" value="false" />
|
||||||
|
<option name="sequenceColumn" value="" />
|
||||||
|
<option name="sequenceId" value="" />
|
||||||
|
<option name="updateByPrimaryKeySelectiveEnabled" value="false" />
|
||||||
|
<option name="updateByPrimaykeyEnabled" value="false" />
|
||||||
|
<option name="useActualColumnName" value="false" />
|
||||||
|
</TableGenerateConfig>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="han_note:t_comment_like">
|
||||||
|
<value>
|
||||||
|
<TableGenerateConfig>
|
||||||
|
<option name="deleteByPrimayKeyEnabled" value="false" />
|
||||||
|
<option name="generatedKey" value="id" />
|
||||||
|
<option name="insertMethodEnabled" value="false" />
|
||||||
|
<option name="insertSelectiveMethodEnabled" value="false" />
|
||||||
|
<option name="javaModelName" value="CommentLikeDO" />
|
||||||
|
<option name="moduleName" value="han-note-comment-biz" />
|
||||||
|
<option name="mybatisplusIdType" value="AUTO" />
|
||||||
|
<option name="selectByPrimaryKeyEnabled" value="false" />
|
||||||
|
<option name="sequenceColumn" value="" />
|
||||||
|
<option name="sequenceId" value="" />
|
||||||
|
<option name="updateByPrimaryKeySelectiveEnabled" value="false" />
|
||||||
|
<option name="updateByPrimaykeyEnabled" value="false" />
|
||||||
|
<option name="useActualColumnName" value="false" />
|
||||||
|
</TableGenerateConfig>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
<entry key="han_note:t_fans">
|
<entry key="han_note:t_fans">
|
||||||
<value>
|
<value>
|
||||||
<TableGenerateConfig>
|
<TableGenerateConfig>
|
||||||
@@ -375,7 +429,7 @@
|
|||||||
<option name="updateByPrimaykeyEnabled" value="false" />
|
<option name="updateByPrimaykeyEnabled" value="false" />
|
||||||
<option name="userMybatisPlus" value="true" />
|
<option name="userMybatisPlus" value="true" />
|
||||||
<option name="xmlMapperPackage" value="mapperxml" />
|
<option name="xmlMapperPackage" value="mapperxml" />
|
||||||
<option name="xmlMapperPath" value="$PROJECT_DIR$/han-note-note/han-note-note-biz/src/main/resources" />
|
<option name="xmlMapperPath" value="$PROJECT_DIR$/han-note-comment/han-note-comment-biz/src/main/resources" />
|
||||||
</ProjectProfile>
|
</ProjectProfile>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
21
.idea/compiler.xml
generated
21
.idea/compiler.xml
generated
@@ -15,27 +15,30 @@
|
|||||||
<processorPath useClasspath="false">
|
<processorPath useClasspath="false">
|
||||||
<entry name="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar" />
|
<entry name="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.30/lombok-1.18.30.jar" />
|
||||||
</processorPath>
|
</processorPath>
|
||||||
|
<module name="han-note-distributed-id-generator-api" />
|
||||||
|
<module name="han-note-data-align" />
|
||||||
|
<module name="han-note-note-biz" />
|
||||||
|
<module name="han-note-user-relation-api" />
|
||||||
|
<module name="han-note-user-api" />
|
||||||
|
<module name="han-note-user-biz" />
|
||||||
|
<module name="han-note-distributed-id-generator-biz" />
|
||||||
|
<module name="han-note-user-relation-biz" />
|
||||||
<module name="han-note-oss-biz" />
|
<module name="han-note-oss-biz" />
|
||||||
|
<module name="han-note-comment-biz" />
|
||||||
<module name="han-note-count-api" />
|
<module name="han-note-count-api" />
|
||||||
<module name="han-note-oss-api" />
|
<module name="han-note-oss-api" />
|
||||||
<module name="han-note-count-biz" />
|
<module name="han-note-count-biz" />
|
||||||
|
<module name="han-note-comment-api" />
|
||||||
<module name="hanserwei-spring-boot-starter-biz-operationlog" />
|
<module name="hanserwei-spring-boot-starter-biz-operationlog" />
|
||||||
<module name="han-note-gateway" />
|
<module name="han-note-gateway" />
|
||||||
<module name="han-note-note-api" />
|
<module name="han-note-note-api" />
|
||||||
<module name="hanserwei-spring-boot-starter-jackson" />
|
<module name="hanserwei-spring-boot-starter-jackson" />
|
||||||
<module name="han-note-distributed-id-generator-api" />
|
|
||||||
<module name="han-note-data-align" />
|
|
||||||
<module name="han-note-kv-api" />
|
<module name="han-note-kv-api" />
|
||||||
<module name="han-note-note-biz" />
|
<module name="han-note-search-api" />
|
||||||
<module name="han-note-search" />
|
|
||||||
<module name="han-note-user-relation-api" />
|
|
||||||
<module name="han-note-user-api" />
|
|
||||||
<module name="han-note-user-biz" />
|
|
||||||
<module name="han-note-kv-biz" />
|
<module name="han-note-kv-biz" />
|
||||||
<module name="hanserwei-common" />
|
<module name="hanserwei-common" />
|
||||||
<module name="han-note-distributed-id-generator-biz" />
|
|
||||||
<module name="han-note-auth" />
|
<module name="han-note-auth" />
|
||||||
<module name="han-note-user-relation-biz" />
|
<module name="han-note-search-biz" />
|
||||||
<module name="hanserwei-spring-boot-starter-biz-context" />
|
<module name="hanserwei-spring-boot-starter-biz-context" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
|
|||||||
1
.idea/data_source_mapping.xml
generated
1
.idea/data_source_mapping.xml
generated
@@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DataSourcePerFileMappings">
|
<component name="DataSourcePerFileMappings">
|
||||||
|
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/19b59a4f-95b9-451e-9051-bb3d5ce210ee/console.sql" value="19b59a4f-95b9-451e-9051-bb3d5ce210ee" />
|
||||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/5b969fbe-0f66-42be-8d30-ff21036ab8a4/console.sql" value="5b969fbe-0f66-42be-8d30-ff21036ab8a4" />
|
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/5b969fbe-0f66-42be-8d30-ff21036ab8a4/console.sql" value="5b969fbe-0f66-42be-8d30-ff21036ab8a4" />
|
||||||
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/f2474a4a-e4f1-4afa-bd43-7ae7738b47c5/console.sql" value="f2474a4a-e4f1-4afa-bd43-7ae7738b47c5" />
|
<file url="file://$APPLICATION_CONFIG_DIR$/consoles/db/f2474a4a-e4f1-4afa-bd43-7ae7738b47c5/console.sql" value="f2474a4a-e4f1-4afa-bd43-7ae7738b47c5" />
|
||||||
<file url="file://$PROJECT_DIR$/han-note-data-align/src/main/resources/mapperxml/InsertMapper.xml" value="f2474a4a-e4f1-4afa-bd43-7ae7738b47c5" />
|
<file url="file://$PROJECT_DIR$/han-note-data-align/src/main/resources/mapperxml/InsertMapper.xml" value="f2474a4a-e4f1-4afa-bd43-7ae7738b47c5" />
|
||||||
|
|||||||
10
.idea/encodings.xml
generated
10
.idea/encodings.xml
generated
@@ -3,6 +3,12 @@
|
|||||||
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
|
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
|
||||||
<file url="file://$PROJECT_DIR$/han-note-auth/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/han-note-auth/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/han-note-auth/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/han-note-auth/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/han-note-comment/han-note-comment-api/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/han-note-comment/han-note-comment-api/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/han-note-comment/han-note-comment-biz/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/han-note-comment/han-note-comment-biz/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/han-note-comment/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/han-note-comment/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/han-note-count/han-note-count-api/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/han-note-count/han-note-count-api/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/han-note-count/han-note-count-api/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/han-note-count/han-note-count-api/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/han-note-count/han-note-count-biz/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/han-note-count/han-note-count-biz/src/main/java" charset="UTF-8" />
|
||||||
@@ -37,6 +43,10 @@
|
|||||||
<file url="file://$PROJECT_DIR$/han-note-oss/han-note-oss-biz/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/han-note-oss/han-note-oss-biz/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/han-note-oss/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/han-note-oss/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/han-note-oss/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/han-note-oss/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/han-note-search/han-note-search-api/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/han-note-search/han-note-search-api/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/han-note-search/han-note-search-biz/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/han-note-search/han-note-search-biz/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/han-note-search/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/han-note-search/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/han-note-search/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/han-note-search/src/main/resources" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/han-note-user-relation/han-note-user-relation-api/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/han-note-user-relation/han-note-user-relation-api/src/main/java" charset="UTF-8" />
|
||||||
|
|||||||
24
han-note-comment/han-note-comment-api/pom.xml
Normal file
24
han-note-comment/han-note-comment-api/pom.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<!-- 指定父项目 -->
|
||||||
|
<parent>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>han-note-comment</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<!-- 打包方式 -->
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<artifactId>han-note-comment-api</artifactId>
|
||||||
|
<name>${project.artifactId}</name>
|
||||||
|
<description>RPC层, 供其他服务调用</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>hanserwei-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
98
han-note-comment/han-note-comment-biz/pom.xml
Normal file
98
han-note-comment/han-note-comment-biz/pom.xml
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<!-- 指定父项目 -->
|
||||||
|
<parent>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>han-note-comment</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<!-- 打包方式 -->
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<artifactId>han-note-comment-biz</artifactId>
|
||||||
|
<name>${project.artifactId}</name>
|
||||||
|
<description>评论服务业务层</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>hanserwei-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 业务接口日志组件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>hanserwei-spring-boot-starter-biz-operationlog</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 上下文组件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>hanserwei-spring-boot-starter-biz-context</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Jackson 组件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>hanserwei-spring-boot-starter-jackson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mybatis-plus -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MySQL 驱动 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Druid 数据库连接池 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 服务发现 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Rocket MQ -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.rocketmq</groupId>
|
||||||
|
<artifactId>rocketmq-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz;
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@MapperScan("com.hanserwei.hannote.comment.biz.domain.mapper")
|
||||||
|
public class HannoteCommentApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(HannoteCommentApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.config;
|
||||||
|
|
||||||
|
import org.apache.rocketmq.spring.autoconfigure.RocketMQAutoConfiguration;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@Import(RocketMQAutoConfiguration.class)
|
||||||
|
public class RocketMQConfig {
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.constants;
|
||||||
|
|
||||||
|
public interface MQConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Topic: 评论发布
|
||||||
|
*/
|
||||||
|
String TOPIC_PUBLISH_COMMENT = "PublishCommentTopic";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.controller;
|
||||||
|
|
||||||
|
import com.hanserwei.framework.biz.operationlog.aspect.ApiOperationLog;
|
||||||
|
import com.hanserwei.framework.common.response.Response;
|
||||||
|
import com.hanserwei.hannote.comment.biz.model.vo.PublishCommentReqVO;
|
||||||
|
import com.hanserwei.hannote.comment.biz.service.CommentService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/comment")
|
||||||
|
@Slf4j
|
||||||
|
public class CommentController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CommentService commentService;
|
||||||
|
|
||||||
|
@PostMapping("/publish")
|
||||||
|
@ApiOperationLog(description = "发布评论")
|
||||||
|
public Response<?> publishComment(@Validated @RequestBody PublishCommentReqVO publishCommentReqVO) {
|
||||||
|
return commentService.publishComment(publishCommentReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.domain.dataobject;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论表
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName(value = "t_comment")
|
||||||
|
public class CommentDO {
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联的笔记ID
|
||||||
|
*/
|
||||||
|
@TableField(value = "note_id")
|
||||||
|
private Long noteId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布者用户ID
|
||||||
|
*/
|
||||||
|
@TableField(value = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论内容UUID
|
||||||
|
*/
|
||||||
|
@TableField(value = "content_uuid")
|
||||||
|
private String contentUuid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容是否为空(0:不为空 1:为空)
|
||||||
|
*/
|
||||||
|
@TableField(value = "is_content_empty")
|
||||||
|
private Boolean isContentEmpty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论附加图片URL
|
||||||
|
*/
|
||||||
|
@TableField(value = "image_url")
|
||||||
|
private String imageUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 级别(1:一级评论 2:二级评论)
|
||||||
|
*/
|
||||||
|
@TableField(value = "`level`")
|
||||||
|
private Integer level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论被回复次数,仅一级评论需要
|
||||||
|
*/
|
||||||
|
@TableField(value = "reply_total")
|
||||||
|
private Long replyTotal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论被点赞次数
|
||||||
|
*/
|
||||||
|
@TableField(value = "like_total")
|
||||||
|
private Long likeTotal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父ID (若是对笔记的评论,则此字段存储笔记ID; 若是二级评论,则此字段存储一级评论的ID)
|
||||||
|
*/
|
||||||
|
@TableField(value = "parent_id")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回复哪个的评论 (0表示是对笔记的评论,若是对他人评论的回复,则存储回复评论的ID)
|
||||||
|
*/
|
||||||
|
@TableField(value = "reply_comment_id")
|
||||||
|
private Long replyCommentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回复的哪个用户, 存储用户ID
|
||||||
|
*/
|
||||||
|
@TableField(value = "reply_user_id")
|
||||||
|
private Long replyUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否置顶(0:不置顶 1:置顶)
|
||||||
|
*/
|
||||||
|
@TableField(value = "is_top")
|
||||||
|
private Boolean isTop;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "create_time")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "update_time")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.domain.dataobject;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论点赞表
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName(value = "t_comment_like")
|
||||||
|
public class CommentLikeDO {
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@TableField(value = "user_id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论ID
|
||||||
|
*/
|
||||||
|
@TableField(value = "comment_id")
|
||||||
|
private Long commentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "create_time")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.domain.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.hanserwei.hannote.comment.biz.domain.dataobject.CommentDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CommentDOMapper extends BaseMapper<CommentDO> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.domain.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.hanserwei.hannote.comment.biz.domain.dataobject.CommentLikeDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CommentLikeDOMapper extends BaseMapper<CommentLikeDO> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.enums;
|
||||||
|
|
||||||
|
import com.hanserwei.framework.common.exception.BaseExceptionInterface;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum ResponseCodeEnum implements BaseExceptionInterface {
|
||||||
|
|
||||||
|
// ----------- 通用异常状态码 -----------
|
||||||
|
SYSTEM_ERROR("COMMENT-10000", "出错啦,后台小哥正在努力修复中..."),
|
||||||
|
PARAM_NOT_VALID("COMMENT-10001", "参数错误"),
|
||||||
|
|
||||||
|
// ----------- 业务异常状态码 -----------
|
||||||
|
;
|
||||||
|
|
||||||
|
// 异常码
|
||||||
|
private final String errorCode;
|
||||||
|
// 错误信息
|
||||||
|
private final String errorMsg;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.exception;
|
||||||
|
|
||||||
|
import com.hanserwei.framework.common.exception.ApiException;
|
||||||
|
import com.hanserwei.framework.common.response.Response;
|
||||||
|
import com.hanserwei.hannote.comment.biz.enums.ResponseCodeEnum;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@SuppressWarnings("LoggingSimilarMessage")
|
||||||
|
@ControllerAdvice
|
||||||
|
@Slf4j
|
||||||
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 捕获自定义业务异常
|
||||||
|
*
|
||||||
|
* @return Response.fail(e)
|
||||||
|
*/
|
||||||
|
@ExceptionHandler({ApiException.class})
|
||||||
|
@ResponseBody
|
||||||
|
public Response<Object> handleApiException(HttpServletRequest request, ApiException e) {
|
||||||
|
log.warn("{} request fail, errorCode: {}, errorMessage: {}", request.getRequestURI(), e.getErrorCode(), e.getErrorMsg());
|
||||||
|
return Response.fail(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 捕获参数校验异常
|
||||||
|
*
|
||||||
|
* @return Response.fail(errorCode, errorMessage)
|
||||||
|
*/
|
||||||
|
@ExceptionHandler({MethodArgumentNotValidException.class})
|
||||||
|
@ResponseBody
|
||||||
|
public Response<Object> handleMethodArgumentNotValidException(HttpServletRequest request, MethodArgumentNotValidException e) {
|
||||||
|
// 参数错误异常码
|
||||||
|
String errorCode = ResponseCodeEnum.PARAM_NOT_VALID.getErrorCode();
|
||||||
|
|
||||||
|
// 获取 BindingResult
|
||||||
|
BindingResult bindingResult = e.getBindingResult();
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
// 获取校验不通过的字段,并组合错误信息,格式为: email 邮箱格式不正确, 当前值: '123124qq.com';
|
||||||
|
Optional.of(bindingResult.getFieldErrors()).ifPresent(errors -> {
|
||||||
|
errors.forEach(error ->
|
||||||
|
sb.append(error.getField())
|
||||||
|
.append(" ")
|
||||||
|
.append(error.getDefaultMessage())
|
||||||
|
.append(", 当前值: '")
|
||||||
|
.append(error.getRejectedValue())
|
||||||
|
.append("'; ")
|
||||||
|
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 错误信息
|
||||||
|
String errorMessage = sb.toString();
|
||||||
|
|
||||||
|
log.warn("{} request error, errorCode: {}, errorMessage: {}", request.getRequestURI(), errorCode, errorMessage);
|
||||||
|
|
||||||
|
return Response.fail(errorCode, errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 捕获 guava 参数校验异常
|
||||||
|
*
|
||||||
|
* @return Response.fail(ResponseCodeEnum.PARAM_NOT_VALID)
|
||||||
|
*/
|
||||||
|
@ExceptionHandler({IllegalArgumentException.class})
|
||||||
|
@ResponseBody
|
||||||
|
public Response<Object> handleIllegalArgumentException(HttpServletRequest request, IllegalArgumentException e) {
|
||||||
|
// 参数错误异常码
|
||||||
|
String errorCode = ResponseCodeEnum.PARAM_NOT_VALID.getErrorCode();
|
||||||
|
|
||||||
|
// 错误信息
|
||||||
|
String errorMessage = e.getMessage();
|
||||||
|
|
||||||
|
log.warn("{} request error, errorCode: {}, errorMessage: {}", request.getRequestURI(), errorCode, errorMessage);
|
||||||
|
|
||||||
|
return Response.fail(errorCode, errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 其他类型异常
|
||||||
|
*
|
||||||
|
* @param request 请求
|
||||||
|
* @param e 异常
|
||||||
|
* @return Response.fail(ResponseCodeEnum.SYSTEM_ERROR)
|
||||||
|
*/
|
||||||
|
@ExceptionHandler({Exception.class})
|
||||||
|
@ResponseBody
|
||||||
|
public Response<Object> handleOtherException(HttpServletRequest request, Exception e) {
|
||||||
|
log.error("{} request error, ", request.getRequestURI(), e);
|
||||||
|
return Response.fail(ResponseCodeEnum.SYSTEM_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.model.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class PublishCommentMqDTO {
|
||||||
|
|
||||||
|
private Long noteId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论图片链接
|
||||||
|
*/
|
||||||
|
private String imageUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回复的哪个评论(评论 ID)
|
||||||
|
*/
|
||||||
|
private Long replyCommentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布者 ID
|
||||||
|
*/
|
||||||
|
private Long creatorId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.model.vo;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class PublishCommentReqVO {
|
||||||
|
|
||||||
|
@NotNull(message = "笔记 ID 不能为空")
|
||||||
|
private Long noteId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论图片链接
|
||||||
|
*/
|
||||||
|
private String imageUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回复的哪个评论(评论 ID)
|
||||||
|
*/
|
||||||
|
private Long replyCommentId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.hanserwei.hannote.comment.biz.domain.dataobject.CommentLikeDO;
|
||||||
|
|
||||||
|
public interface CommentLikeService extends IService<CommentLikeDO> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.hanserwei.framework.common.response.Response;
|
||||||
|
import com.hanserwei.hannote.comment.biz.domain.dataobject.CommentDO;
|
||||||
|
import com.hanserwei.hannote.comment.biz.model.vo.PublishCommentReqVO;
|
||||||
|
|
||||||
|
public interface CommentService extends IService<CommentDO> {
|
||||||
|
/**
|
||||||
|
* 发布评论
|
||||||
|
*
|
||||||
|
* @param publishCommentReqVO 发布评论请求
|
||||||
|
* @return 响应
|
||||||
|
*/
|
||||||
|
Response<?> publishComment(PublishCommentReqVO publishCommentReqVO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.hanserwei.hannote.comment.biz.domain.dataobject.CommentLikeDO;
|
||||||
|
import com.hanserwei.hannote.comment.biz.domain.mapper.CommentLikeDOMapper;
|
||||||
|
import com.hanserwei.hannote.comment.biz.service.CommentLikeService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CommentLikeServiceImpl extends ServiceImpl<CommentLikeDOMapper, CommentLikeDO> implements CommentLikeService {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package com.hanserwei.hannote.comment.biz.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.hanserwei.framework.biz.context.holder.LoginUserContextHolder;
|
||||||
|
import com.hanserwei.framework.common.response.Response;
|
||||||
|
import com.hanserwei.framework.common.utils.JsonUtils;
|
||||||
|
import com.hanserwei.hannote.comment.biz.constants.MQConstants;
|
||||||
|
import com.hanserwei.hannote.comment.biz.domain.dataobject.CommentDO;
|
||||||
|
import com.hanserwei.hannote.comment.biz.domain.mapper.CommentDOMapper;
|
||||||
|
import com.hanserwei.hannote.comment.biz.model.dto.PublishCommentMqDTO;
|
||||||
|
import com.hanserwei.hannote.comment.biz.model.vo.PublishCommentReqVO;
|
||||||
|
import com.hanserwei.hannote.comment.biz.service.CommentService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.rocketmq.client.producer.SendCallback;
|
||||||
|
import org.apache.rocketmq.client.producer.SendResult;
|
||||||
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||||
|
import org.springframework.messaging.Message;
|
||||||
|
import org.springframework.messaging.support.MessageBuilder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class CommentServiceImpl extends ServiceImpl<CommentDOMapper, CommentDO> implements CommentService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RocketMQTemplate rocketMQTemplate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response<?> publishComment(PublishCommentReqVO publishCommentReqVO) {
|
||||||
|
// 评论正文
|
||||||
|
String content = publishCommentReqVO.getContent();
|
||||||
|
// 附近图片
|
||||||
|
String imageUrl = publishCommentReqVO.getImageUrl();
|
||||||
|
|
||||||
|
// 评论内容和图片不能同时为空
|
||||||
|
Preconditions.checkArgument(StringUtils.isNotBlank(content) || StringUtils.isNotBlank(imageUrl),
|
||||||
|
"评论正文和图片不能同时为空");
|
||||||
|
|
||||||
|
// 发布者ID
|
||||||
|
Long creatorId = LoginUserContextHolder.getUserId();
|
||||||
|
|
||||||
|
// 发送消息
|
||||||
|
// 构造MQ消息体
|
||||||
|
PublishCommentMqDTO publishCommentMqDTO = PublishCommentMqDTO.builder()
|
||||||
|
.noteId(publishCommentReqVO.getNoteId())
|
||||||
|
.content(content)
|
||||||
|
.imageUrl(imageUrl)
|
||||||
|
.replyCommentId(publishCommentReqVO.getReplyCommentId())
|
||||||
|
.createTime(LocalDateTime.now())
|
||||||
|
.creatorId(creatorId)
|
||||||
|
.build();
|
||||||
|
// 构建消息对象,并将 DTO 转成 Json 字符串设置到消息体中
|
||||||
|
Message<String> message = MessageBuilder
|
||||||
|
.withPayload(JsonUtils.toJsonString(publishCommentMqDTO))
|
||||||
|
.build();
|
||||||
|
// 异步发送 MQ 消息,提升接口响应速度
|
||||||
|
rocketMQTemplate.asyncSend(MQConstants.TOPIC_PUBLISH_COMMENT, message, new SendCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(SendResult sendResult) {
|
||||||
|
log.info("==> 【评论发布】MQ 发送成功,SendResult: {}", sendResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onException(Throwable throwable) {
|
||||||
|
log.error("==> 【评论发布】MQ 发送异常: ", throwable);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return Response.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
server:
|
||||||
|
port: 8093 # 项目启动的端口
|
||||||
|
|
||||||
|
spring:
|
||||||
|
profiles:
|
||||||
|
active: dev # 默认激活 dev 本地开发环境
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
max-file-size: 20MB # 单个文件最大大小
|
||||||
|
max-request-size: 100MB # 单次请求最大大小(包含多个文件)
|
||||||
|
mybatis-plus:
|
||||||
|
configuration:
|
||||||
|
map-underscore-to-camel-case: true
|
||||||
|
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||||
|
global-config:
|
||||||
|
banner: false
|
||||||
|
mapper-locations: classpath*:/mapperxml/*.xml
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: han-note-comment # 应用名称
|
||||||
|
profiles:
|
||||||
|
active: dev # 默认激活 dev 本地开发环境
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
enabled: true # 启用服务发现
|
||||||
|
group: DEFAULT_GROUP # 所属组
|
||||||
|
namespace: han-note # 命名空间
|
||||||
|
server-addr: 127.0.0.1:8848 # 指定 Nacos 配置中心的服务器地址
|
||||||
|
config:
|
||||||
|
server-addr: http://127.0.0.1:8848 # 指定 Nacos 配置中心的服务器地址
|
||||||
|
prefix: ${spring.application.name} # 配置 Data Id 前缀,这里使用应用名称作为前缀
|
||||||
|
group: DEFAULT_GROUP # 所属组
|
||||||
|
namespace: han-note # 命名空间
|
||||||
|
file-extension: yaml # 配置文件格式
|
||||||
|
refresh-enabled: true # 是否开启动态刷新
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<configuration>
|
||||||
|
<!-- 引用 Spring Boot 的 logback 基础配置 -->
|
||||||
|
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||||
|
|
||||||
|
<!-- 应用名称 -->
|
||||||
|
<property scope="context" name="appName" value="comment"/>
|
||||||
|
<!-- 自定义日志输出路径,以及日志名称前缀 -->
|
||||||
|
<property name="LOG_FILE" value="./logs/${appName}.%d{yyyy-MM-dd}"/>
|
||||||
|
<!-- 每行日志输出的格式 -->
|
||||||
|
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n"/>
|
||||||
|
|
||||||
|
<!-- 文件输出 -->
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件的命名格式 -->
|
||||||
|
<fileNamePattern>${LOG_FILE}-%i.log</fileNamePattern>
|
||||||
|
<!-- 保留 30 天的日志文件 -->
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
<!-- 单个日志文件最大大小 -->
|
||||||
|
<maxFileSize>10MB</maxFileSize>
|
||||||
|
<!-- 日志文件的总大小,0 表示不限制 -->
|
||||||
|
<totalSizeCap>0</totalSizeCap>
|
||||||
|
<!-- 重启服务时,是否清除历史日志,不推荐清理 -->
|
||||||
|
<cleanHistoryOnStart>false</cleanHistoryOnStart>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||||
|
<pattern>${LOG_PATTERN}</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 异步写入日志,提升性能 -->
|
||||||
|
<appender name="ASYNC_FILE" class="ch.qos.logback.classic.AsyncAppender">
|
||||||
|
<!-- 是否丢弃日志, 0 表示不丢弃。默认情况下,如果队列满 80%, 会丢弃 TRACE、DEBUG、INFO 级别的日志 -->
|
||||||
|
<discardingThreshold>0</discardingThreshold>
|
||||||
|
<!-- 队列大小。默认值为 256 -->
|
||||||
|
<queueSize>256</queueSize>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 本地 dev 开发环境 -->
|
||||||
|
<springProfile name="dev">
|
||||||
|
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="CONSOLE"/> <!-- 输出控制台日志 -->
|
||||||
|
<appender-ref ref="ASYNC_FILE"/> <!-- 打印日志到文件中。PS: 本地环境下,如果不想打印日志到文件,可注释掉此行 -->
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<!-- 其它环境 -->
|
||||||
|
<springProfile name="prod">
|
||||||
|
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="ASYNC_FILE"/> <!-- 生产环境下,仅打印日志到文件中 -->
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.hanserwei.hannote.comment.biz.domain.mapper.CommentDOMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.hanserwei.hannote.comment.biz.domain.dataobject.CommentDO">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
<!--@Table t_comment-->
|
||||||
|
<id column="id" jdbcType="BIGINT" property="id" />
|
||||||
|
<result column="note_id" jdbcType="BIGINT" property="noteId" />
|
||||||
|
<result column="user_id" jdbcType="BIGINT" property="userId" />
|
||||||
|
<result column="content_uuid" jdbcType="VARCHAR" property="contentUuid" />
|
||||||
|
<result column="is_content_empty" jdbcType="BIT" property="isContentEmpty" />
|
||||||
|
<result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
|
||||||
|
<result column="level" jdbcType="TINYINT" property="level" />
|
||||||
|
<result column="reply_total" jdbcType="BIGINT" property="replyTotal" />
|
||||||
|
<result column="like_total" jdbcType="BIGINT" property="likeTotal" />
|
||||||
|
<result column="parent_id" jdbcType="BIGINT" property="parentId" />
|
||||||
|
<result column="reply_comment_id" jdbcType="BIGINT" property="replyCommentId" />
|
||||||
|
<result column="reply_user_id" jdbcType="BIGINT" property="replyUserId" />
|
||||||
|
<result column="is_top" jdbcType="TINYINT" property="isTop" />
|
||||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
id, note_id, user_id, content_uuid, is_content_empty, image_url, `level`, reply_total,
|
||||||
|
like_total, parent_id, reply_comment_id, reply_user_id, is_top, create_time, update_time
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.hanserwei.hannote.comment.biz.domain.mapper.CommentLikeDOMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.hanserwei.hannote.comment.biz.domain.dataobject.CommentLikeDO">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
<!--@Table t_comment_like-->
|
||||||
|
<id column="id" jdbcType="BIGINT" property="id" />
|
||||||
|
<result column="user_id" jdbcType="BIGINT" property="userId" />
|
||||||
|
<result column="comment_id" jdbcType="BIGINT" property="commentId" />
|
||||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
id, user_id, comment_id, create_time
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
||||||
25
han-note-comment/pom.xml
Normal file
25
han-note-comment/pom.xml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<!-- 指定父项目 -->
|
||||||
|
<parent>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>han-note</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<!-- 多模块项目需要配置打包方式为 pom -->
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<!-- 子模块管理 -->
|
||||||
|
<modules>
|
||||||
|
<module>han-note-comment-api</module>
|
||||||
|
<module>han-note-comment-biz</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<artifactId>han-note-comment</artifactId>
|
||||||
|
<!-- 项目名称 -->
|
||||||
|
<name>${project.artifactId}</name>
|
||||||
|
<!-- 项目描述 -->
|
||||||
|
<description>评论服务</description>
|
||||||
|
</project>
|
||||||
@@ -96,6 +96,11 @@
|
|||||||
<artifactId>rocketmq-spring-boot-starter</artifactId>
|
<artifactId>rocketmq-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>han-note-search-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ package com.hanserwei.hannote.data.align;
|
|||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@MapperScan("com.hanserwei.hannote.data.align.domain.mapper")
|
@MapperScan("com.hanserwei.hannote.data.align.domain.mapper")
|
||||||
|
@EnableFeignClients(basePackages = "com.hanserwei.hannote")
|
||||||
public class HannoteDataAlignApplication {
|
public class HannoteDataAlignApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(HannoteDataAlignApplication.class, args);
|
SpringApplication.run(HannoteDataAlignApplication.class, args);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.hanserwei.hannote.data.align.constant.TableConstants;
|
|||||||
import com.hanserwei.hannote.data.align.domain.mapper.DeleteRecordMapper;
|
import com.hanserwei.hannote.data.align.domain.mapper.DeleteRecordMapper;
|
||||||
import com.hanserwei.hannote.data.align.domain.mapper.SelectRecordMapper;
|
import com.hanserwei.hannote.data.align.domain.mapper.SelectRecordMapper;
|
||||||
import com.hanserwei.hannote.data.align.domain.mapper.UpdateRecordMapper;
|
import com.hanserwei.hannote.data.align.domain.mapper.UpdateRecordMapper;
|
||||||
|
import com.hanserwei.hannote.data.align.rpc.SearchRpcService;
|
||||||
import com.xxl.job.core.context.XxlJobHelper;
|
import com.xxl.job.core.context.XxlJobHelper;
|
||||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@@ -29,6 +30,8 @@ public class FansCountShardingXxlJob {
|
|||||||
private DeleteRecordMapper deleteRecordMapper;
|
private DeleteRecordMapper deleteRecordMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private RedisTemplate<String, Object> redisTemplate;
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
@Resource
|
||||||
|
private SearchRpcService searchRpcService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分片广播任务
|
* 分片广播任务
|
||||||
@@ -80,6 +83,8 @@ public class FansCountShardingXxlJob {
|
|||||||
redisTemplate.opsForHash().put(redisKey, RedisKeyConstants.FIELD_FANS_TOTAL, fansTotal);
|
redisTemplate.opsForHash().put(redisKey, RedisKeyConstants.FIELD_FANS_TOTAL, fansTotal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 远程 RPC, 调用搜索服务,重新构建索引
|
||||||
|
searchRpcService.rebuildUserDocument(userId);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 删除t_data_align_fans_count_temp_日期_分片序号中的记录
|
// 删除t_data_align_fans_count_temp_日期_分片序号中的记录
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.hanserwei.hannote.data.align.constant.TableConstants;
|
|||||||
import com.hanserwei.hannote.data.align.domain.mapper.DeleteRecordMapper;
|
import com.hanserwei.hannote.data.align.domain.mapper.DeleteRecordMapper;
|
||||||
import com.hanserwei.hannote.data.align.domain.mapper.SelectRecordMapper;
|
import com.hanserwei.hannote.data.align.domain.mapper.SelectRecordMapper;
|
||||||
import com.hanserwei.hannote.data.align.domain.mapper.UpdateRecordMapper;
|
import com.hanserwei.hannote.data.align.domain.mapper.UpdateRecordMapper;
|
||||||
|
import com.hanserwei.hannote.data.align.rpc.SearchRpcService;
|
||||||
import com.xxl.job.core.context.XxlJobHelper;
|
import com.xxl.job.core.context.XxlJobHelper;
|
||||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@@ -33,6 +34,9 @@ public class NoteCollectCountShardingXxlJob {
|
|||||||
@Resource
|
@Resource
|
||||||
private RedisTemplate<String, Object> redisTemplate;
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SearchRpcService searchRpcService;
|
||||||
|
|
||||||
@XxlJob("noteCollectCountShardingJobHandler")
|
@XxlJob("noteCollectCountShardingJobHandler")
|
||||||
public void noteCollectCountShardingJobHandler() throws Exception {
|
public void noteCollectCountShardingJobHandler() throws Exception {
|
||||||
// 获取分片参数
|
// 获取分片参数
|
||||||
@@ -81,6 +85,8 @@ public class NoteCollectCountShardingXxlJob {
|
|||||||
redisTemplate.opsForHash().put(redisKey, RedisKeyConstants.FIELD_COLLECT_TOTAL, likeTotal);
|
redisTemplate.opsForHash().put(redisKey, RedisKeyConstants.FIELD_COLLECT_TOTAL, likeTotal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 远程 RPC, 调用搜索服务,重新构建文档
|
||||||
|
searchRpcService.rebuildNoteDocument(noteId);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 4. 批量物理删除这一批次记录
|
// 4. 批量物理删除这一批次记录
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.hanserwei.hannote.data.align.constant.TableConstants;
|
|||||||
import com.hanserwei.hannote.data.align.domain.mapper.DeleteRecordMapper;
|
import com.hanserwei.hannote.data.align.domain.mapper.DeleteRecordMapper;
|
||||||
import com.hanserwei.hannote.data.align.domain.mapper.SelectRecordMapper;
|
import com.hanserwei.hannote.data.align.domain.mapper.SelectRecordMapper;
|
||||||
import com.hanserwei.hannote.data.align.domain.mapper.UpdateRecordMapper;
|
import com.hanserwei.hannote.data.align.domain.mapper.UpdateRecordMapper;
|
||||||
|
import com.hanserwei.hannote.data.align.rpc.SearchRpcService;
|
||||||
import com.xxl.job.core.context.XxlJobHelper;
|
import com.xxl.job.core.context.XxlJobHelper;
|
||||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@@ -33,6 +34,9 @@ public class NoteLikeCountShardingXxlJob {
|
|||||||
@Resource
|
@Resource
|
||||||
private DeleteRecordMapper deleteRecordMapper;
|
private DeleteRecordMapper deleteRecordMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SearchRpcService searchRpcService;
|
||||||
|
|
||||||
@XxlJob("noteLikeCountShardingJobHandler")
|
@XxlJob("noteLikeCountShardingJobHandler")
|
||||||
public void noteLikeCountShardingJobHandler() throws Exception {
|
public void noteLikeCountShardingJobHandler() throws Exception {
|
||||||
// 获取分片参数
|
// 获取分片参数
|
||||||
@@ -83,6 +87,9 @@ public class NoteLikeCountShardingXxlJob {
|
|||||||
redisTemplate.opsForHash().put(redisKey, RedisKeyConstants.FIELD_LIKE_TOTAL, likeTotal);
|
redisTemplate.opsForHash().put(redisKey, RedisKeyConstants.FIELD_LIKE_TOTAL, likeTotal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 远程 RPC, 调用搜索服务,重新构建文档
|
||||||
|
searchRpcService.rebuildNoteDocument(noteId);
|
||||||
});
|
});
|
||||||
// 4. 批量物理删除这一批次记录
|
// 4. 批量物理删除这一批次记录
|
||||||
deleteRecordMapper.batchDeleteDataAlignNoteLikeCountTempTable(tableNameSuffix, noteIds);
|
deleteRecordMapper.batchDeleteDataAlignNoteLikeCountTempTable(tableNameSuffix, noteIds);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.hanserwei.hannote.data.align.constant.TableConstants;
|
|||||||
import com.hanserwei.hannote.data.align.domain.mapper.DeleteRecordMapper;
|
import com.hanserwei.hannote.data.align.domain.mapper.DeleteRecordMapper;
|
||||||
import com.hanserwei.hannote.data.align.domain.mapper.SelectRecordMapper;
|
import com.hanserwei.hannote.data.align.domain.mapper.SelectRecordMapper;
|
||||||
import com.hanserwei.hannote.data.align.domain.mapper.UpdateRecordMapper;
|
import com.hanserwei.hannote.data.align.domain.mapper.UpdateRecordMapper;
|
||||||
|
import com.hanserwei.hannote.data.align.rpc.SearchRpcService;
|
||||||
import com.xxl.job.core.context.XxlJobHelper;
|
import com.xxl.job.core.context.XxlJobHelper;
|
||||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@@ -29,6 +30,8 @@ public class NotePublishCountShardingXxlJob {
|
|||||||
private DeleteRecordMapper deleteRecordMapper;
|
private DeleteRecordMapper deleteRecordMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private RedisTemplate<String, Object> redisTemplate;
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
@Resource
|
||||||
|
private SearchRpcService searchRpcService;
|
||||||
|
|
||||||
@XxlJob("notePublishCountShardingJobHandler")
|
@XxlJob("notePublishCountShardingJobHandler")
|
||||||
public void notePublishCountShardingJobHandler() throws Exception {
|
public void notePublishCountShardingJobHandler() throws Exception {
|
||||||
@@ -72,6 +75,8 @@ public class NotePublishCountShardingXxlJob {
|
|||||||
redisTemplate.opsForHash().put(redisKey, RedisKeyConstants.FIELD_NOTE_TOTAL, notePublishTotal);
|
redisTemplate.opsForHash().put(redisKey, RedisKeyConstants.FIELD_NOTE_TOTAL, notePublishTotal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 远程 RPC, 调用搜索服务,重新构建索引
|
||||||
|
searchRpcService.rebuildUserDocument(userId);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 删除 t_data_align_note_publish_count_temp_日期_分片序号
|
// 删除 t_data_align_note_publish_count_temp_日期_分片序号
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.hanserwei.hannote.data.align.rpc;
|
||||||
|
|
||||||
|
import com.hanserwei.hannote.search.api.SearchFeignApi;
|
||||||
|
import com.hanserwei.hannote.search.dto.RebuildNoteDocumentReqDTO;
|
||||||
|
import com.hanserwei.hannote.search.dto.RebuildUserDocumentReqDTO;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SearchRpcService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SearchFeignApi searchFeignApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用重建笔记文档接口
|
||||||
|
*
|
||||||
|
* @param noteId 笔记ID
|
||||||
|
*/
|
||||||
|
public void rebuildNoteDocument(Long noteId) {
|
||||||
|
RebuildNoteDocumentReqDTO rebuildNoteDocumentReqDTO = RebuildNoteDocumentReqDTO.builder()
|
||||||
|
.id(noteId)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
searchFeignApi.rebuildNoteDocument(rebuildNoteDocumentReqDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用重建用户文档接口
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
*/
|
||||||
|
public void rebuildUserDocument(Long userId) {
|
||||||
|
RebuildUserDocumentReqDTO rebuildUserDocumentReqDTO = RebuildUserDocumentReqDTO.builder()
|
||||||
|
.id(userId)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
searchFeignApi.rebuildUserDocument(rebuildUserDocumentReqDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -28,6 +28,12 @@ spring:
|
|||||||
- Path=/relation/**
|
- Path=/relation/**
|
||||||
filters:
|
filters:
|
||||||
- StripPrefix=1
|
- StripPrefix=1
|
||||||
|
- id: comment
|
||||||
|
uri: lb://han-note-comment
|
||||||
|
predicates:
|
||||||
|
- Path=/comment/**
|
||||||
|
filters:
|
||||||
|
- StripPrefix=1
|
||||||
data:
|
data:
|
||||||
redis:
|
redis:
|
||||||
database: 5 # Redis 数据库索引(默认为 0)
|
database: 5 # Redis 数据库索引(默认为 0)
|
||||||
|
|||||||
38
han-note-search/han-note-search-api/pom.xml
Normal file
38
han-note-search/han-note-search-api/pom.xml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>han-note-search</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<!-- 打包方式 -->
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<artifactId>han-note-search-api</artifactId>
|
||||||
|
<name>${project.artifactId}</name>
|
||||||
|
<description>RPC层, 供其他服务调用</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>hanserwei-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- OpenFeign -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 负载均衡 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.hanserwei.hannote.search.api;
|
||||||
|
|
||||||
|
import com.hanserwei.framework.common.response.Response;
|
||||||
|
import com.hanserwei.hannote.search.constant.ApiConstants;
|
||||||
|
import com.hanserwei.hannote.search.dto.RebuildNoteDocumentReqDTO;
|
||||||
|
import com.hanserwei.hannote.search.dto.RebuildUserDocumentReqDTO;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
@FeignClient(name = ApiConstants.SERVICE_NAME)
|
||||||
|
public interface SearchFeignApi {
|
||||||
|
|
||||||
|
String PREFIX = "/search";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重建笔记文档
|
||||||
|
*
|
||||||
|
* @param rebuildNoteDocumentReqDTO 重建笔记文档请求参数对象,包含重建所需的相关信息
|
||||||
|
* @return 返回重建操作的结果响应对象
|
||||||
|
*/
|
||||||
|
@PostMapping(value = PREFIX + "/note/document/rebuild")
|
||||||
|
Response<?> rebuildNoteDocument(@RequestBody RebuildNoteDocumentReqDTO rebuildNoteDocumentReqDTO);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重建用户文档
|
||||||
|
*
|
||||||
|
* @param rebuildUserDocumentReqDTO 重建用户文档请求参数对象,包含重建所需的相关信息
|
||||||
|
* @return 返回重建操作的结果响应对象
|
||||||
|
*/
|
||||||
|
@PostMapping(value = PREFIX + "/user/document/rebuild")
|
||||||
|
Response<?> rebuildUserDocument(@RequestBody RebuildUserDocumentReqDTO rebuildUserDocumentReqDTO);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.hanserwei.hannote.search.constant;
|
||||||
|
|
||||||
|
public interface ApiConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务名称
|
||||||
|
*/
|
||||||
|
String SERVICE_NAME = "han-note-search";
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.hanserwei.hannote.search.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class RebuildNoteDocumentReqDTO {
|
||||||
|
|
||||||
|
@NotNull(message = "笔记 ID 不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.hanserwei.hannote.search.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class RebuildUserDocumentReqDTO {
|
||||||
|
|
||||||
|
@NotNull(message = "用户 ID 不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
}
|
||||||
108
han-note-search/han-note-search-biz/pom.xml
Normal file
108
han-note-search/han-note-search-biz/pom.xml
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<!-- 指定父项目 -->
|
||||||
|
<parent>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>han-note-search</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<!-- 指定打包方式 -->
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<artifactId>han-note-search-biz</artifactId>
|
||||||
|
<name>${project.artifactId}</name>
|
||||||
|
<description>搜索服务</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>hanserwei-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 业务接口日志组件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>hanserwei-spring-boot-starter-biz-operationlog</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Jackson 组件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>hanserwei-spring-boot-starter-jackson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 服务注册发现 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Elasticsearch 分布式搜索引擎 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>co.elastic.clients</groupId>
|
||||||
|
<artifactId>elasticsearch-java</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.elasticsearch.client</groupId>
|
||||||
|
<artifactId>elasticsearch-rest-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Canal -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.otter</groupId>
|
||||||
|
<artifactId>canal.client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.otter</groupId>
|
||||||
|
<artifactId>canal.common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.otter</groupId>
|
||||||
|
<artifactId>canal.protocol</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- Druid 数据库连接池 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>han-note-search-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search;
|
package com.hanserwei.hannote.search.biz;
|
||||||
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
@@ -7,7 +7,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@MapperScan("com.hanserwei.hannote.search.domain.mapper")
|
@MapperScan("com.hanserwei.hannote.search.biz.domain.mapper")
|
||||||
public class HannoteSearchApplication {
|
public class HannoteSearchApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(HannoteSearchApplication.class, args);
|
SpringApplication.run(HannoteSearchApplication.class, args);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.canal;
|
package com.hanserwei.hannote.search.biz.canal;
|
||||||
|
|
||||||
import com.alibaba.otter.canal.client.CanalConnector;
|
import com.alibaba.otter.canal.client.CanalConnector;
|
||||||
import com.alibaba.otter.canal.client.CanalConnectors;
|
import com.alibaba.otter.canal.client.CanalConnectors;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.canal;
|
package com.hanserwei.hannote.search.biz.canal;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.canal;
|
package com.hanserwei.hannote.search.biz.canal;
|
||||||
|
|
||||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||||
import co.elastic.clients.elasticsearch.core.BulkRequest;
|
import co.elastic.clients.elasticsearch.core.BulkRequest;
|
||||||
@@ -9,11 +9,11 @@ import com.alibaba.otter.canal.protocol.CanalEntry;
|
|||||||
import com.alibaba.otter.canal.protocol.Message;
|
import com.alibaba.otter.canal.protocol.Message;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.hanserwei.framework.common.enums.StatusEnum;
|
import com.hanserwei.framework.common.enums.StatusEnum;
|
||||||
import com.hanserwei.hannote.search.domain.mapper.SelectMapper;
|
import com.hanserwei.hannote.search.biz.domain.mapper.SelectMapper;
|
||||||
import com.hanserwei.hannote.search.enums.NoteStatusEnum;
|
import com.hanserwei.hannote.search.biz.enums.NoteStatusEnum;
|
||||||
import com.hanserwei.hannote.search.enums.NoteVisibleEnum;
|
import com.hanserwei.hannote.search.biz.enums.NoteVisibleEnum;
|
||||||
import com.hanserwei.hannote.search.index.NoteIndex;
|
import com.hanserwei.hannote.search.biz.index.NoteIndex;
|
||||||
import com.hanserwei.hannote.search.index.UserIndex;
|
import com.hanserwei.hannote.search.biz.index.UserIndex;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.config;
|
package com.hanserwei.hannote.search.biz.config;
|
||||||
|
|
||||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||||
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
|
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.hanserwei.hannote.search.controller;
|
package com.hanserwei.hannote.search.biz.controller;
|
||||||
|
|
||||||
import com.hanserwei.framework.biz.operationlog.aspect.ApiOperationLog;
|
import com.hanserwei.framework.biz.operationlog.aspect.ApiOperationLog;
|
||||||
import com.hanserwei.hannote.search.service.ExtDictService;
|
import com.hanserwei.hannote.search.biz.service.ExtDictService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.hanserwei.hannote.search.controller;
|
package com.hanserwei.hannote.search.biz.controller;
|
||||||
|
|
||||||
import com.hanserwei.framework.biz.operationlog.aspect.ApiOperationLog;
|
import com.hanserwei.framework.biz.operationlog.aspect.ApiOperationLog;
|
||||||
import com.hanserwei.framework.common.response.PageResponse;
|
import com.hanserwei.framework.common.response.PageResponse;
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchNoteReqVO;
|
import com.hanserwei.framework.common.response.Response;
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchNoteRspVO;
|
import com.hanserwei.hannote.search.biz.model.vo.SearchNoteReqVO;
|
||||||
import com.hanserwei.hannote.search.service.NoteService;
|
import com.hanserwei.hannote.search.biz.model.vo.SearchNoteRspVO;
|
||||||
|
import com.hanserwei.hannote.search.biz.service.NoteService;
|
||||||
|
import com.hanserwei.hannote.search.dto.RebuildNoteDocumentReqDTO;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -27,4 +29,10 @@ public class NoteController {
|
|||||||
return noteService.searchNote(searchNoteReqVO);
|
return noteService.searchNote(searchNoteReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===================================== 对其他服务提供的接口 =====================================
|
||||||
|
@PostMapping("/note/document/rebuild")
|
||||||
|
@ApiOperationLog(description = "用户文档重建")
|
||||||
|
public Response<Long> rebuildDocument(@Validated @RequestBody RebuildNoteDocumentReqDTO rebuildNoteDocumentReqDTO) {
|
||||||
|
return noteService.rebuildDocument(rebuildNoteDocumentReqDTO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.hanserwei.hannote.search.controller;
|
package com.hanserwei.hannote.search.biz.controller;
|
||||||
|
|
||||||
import com.hanserwei.framework.biz.operationlog.aspect.ApiOperationLog;
|
import com.hanserwei.framework.biz.operationlog.aspect.ApiOperationLog;
|
||||||
import com.hanserwei.framework.common.response.PageResponse;
|
import com.hanserwei.framework.common.response.PageResponse;
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchUserReqVO;
|
import com.hanserwei.framework.common.response.Response;
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchUserRspVO;
|
import com.hanserwei.hannote.search.biz.model.vo.SearchUserReqVO;
|
||||||
import com.hanserwei.hannote.search.service.UserService;
|
import com.hanserwei.hannote.search.biz.model.vo.SearchUserRspVO;
|
||||||
|
import com.hanserwei.hannote.search.biz.service.UserService;
|
||||||
|
import com.hanserwei.hannote.search.dto.RebuildUserDocumentReqDTO;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -27,4 +29,11 @@ public class UserController {
|
|||||||
return userService.searchUser(searchUserReqVO);
|
return userService.searchUser(searchUserReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===================================== 对其他服务提供的接口 =====================================
|
||||||
|
@PostMapping("/user/document/rebuild")
|
||||||
|
@ApiOperationLog(description = "用户文档重建")
|
||||||
|
public Response<Long> rebuildDocument(@Validated @RequestBody RebuildUserDocumentReqDTO rebuildUserDocumentReqDTO) {
|
||||||
|
return userService.rebuildDocument(rebuildUserDocumentReqDTO);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.domain.mapper;
|
package com.hanserwei.hannote.search.biz.domain.mapper;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.enums;
|
package com.hanserwei.hannote.search.biz.enums;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.enums;
|
package com.hanserwei.hannote.search.biz.enums;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.enums;
|
package com.hanserwei.hannote.search.biz.enums;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.enums;
|
package com.hanserwei.hannote.search.biz.enums;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.enums;
|
package com.hanserwei.hannote.search.biz.enums;
|
||||||
|
|
||||||
import com.hanserwei.framework.common.exception.BaseExceptionInterface;
|
import com.hanserwei.framework.common.exception.BaseExceptionInterface;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.hanserwei.hannote.search.exception;
|
package com.hanserwei.hannote.search.biz.exception;
|
||||||
|
|
||||||
import com.hanserwei.framework.common.exception.ApiException;
|
import com.hanserwei.framework.common.exception.ApiException;
|
||||||
import com.hanserwei.framework.common.response.Response;
|
import com.hanserwei.framework.common.response.Response;
|
||||||
import com.hanserwei.hannote.search.enums.ResponseCodeEnum;
|
import com.hanserwei.hannote.search.biz.enums.ResponseCodeEnum;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.index;
|
package com.hanserwei.hannote.search.biz.index;
|
||||||
|
|
||||||
public class NoteIndex {
|
public class NoteIndex {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.index;
|
package com.hanserwei.hannote.search.biz.index;
|
||||||
|
|
||||||
public class UserIndex {
|
public class UserIndex {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.model.vo;
|
package com.hanserwei.hannote.search.biz.model.vo;
|
||||||
|
|
||||||
import jakarta.validation.constraints.Min;
|
import jakarta.validation.constraints.Min;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.model.vo;
|
package com.hanserwei.hannote.search.biz.model.vo;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.model.vo;
|
package com.hanserwei.hannote.search.biz.model.vo;
|
||||||
|
|
||||||
import jakarta.validation.constraints.Min;
|
import jakarta.validation.constraints.Min;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.model.vo;
|
package com.hanserwei.hannote.search.biz.model.vo;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.hanserwei.hannote.search.service;
|
package com.hanserwei.hannote.search.biz.service;
|
||||||
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.hanserwei.hannote.search.biz.service;
|
||||||
|
|
||||||
|
import com.hanserwei.framework.common.response.PageResponse;
|
||||||
|
import com.hanserwei.framework.common.response.Response;
|
||||||
|
import com.hanserwei.hannote.search.biz.model.vo.SearchNoteReqVO;
|
||||||
|
import com.hanserwei.hannote.search.biz.model.vo.SearchNoteRspVO;
|
||||||
|
import com.hanserwei.hannote.search.dto.RebuildNoteDocumentReqDTO;
|
||||||
|
|
||||||
|
public interface NoteService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索笔记
|
||||||
|
*
|
||||||
|
* @param searchNoteReqVO 搜索笔记请求
|
||||||
|
* @return 搜索笔记响应
|
||||||
|
*/
|
||||||
|
PageResponse<SearchNoteRspVO> searchNote(SearchNoteReqVO searchNoteReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重建笔记文档
|
||||||
|
*
|
||||||
|
* @param rebuildNoteDocumentReqDTO 重建笔记文档请求
|
||||||
|
* @return 响应
|
||||||
|
*/
|
||||||
|
Response<Long> rebuildDocument(RebuildNoteDocumentReqDTO rebuildNoteDocumentReqDTO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.hanserwei.hannote.search.biz.service;
|
||||||
|
|
||||||
|
import com.hanserwei.framework.common.response.PageResponse;
|
||||||
|
import com.hanserwei.framework.common.response.Response;
|
||||||
|
import com.hanserwei.hannote.search.biz.model.vo.SearchUserReqVO;
|
||||||
|
import com.hanserwei.hannote.search.biz.model.vo.SearchUserRspVO;
|
||||||
|
import com.hanserwei.hannote.search.dto.RebuildUserDocumentReqDTO;
|
||||||
|
|
||||||
|
public interface UserService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索用户
|
||||||
|
*
|
||||||
|
* @param searchUserReqVO 搜索用户请求
|
||||||
|
* @return 搜索用户响应
|
||||||
|
*/
|
||||||
|
PageResponse<SearchUserRspVO> searchUser(SearchUserReqVO searchUserReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重建用户文档
|
||||||
|
*
|
||||||
|
* @param rebuildUserDocumentReqDTO 重建用户文档请求
|
||||||
|
* @return 响应
|
||||||
|
*/
|
||||||
|
Response<Long> rebuildDocument(RebuildUserDocumentReqDTO rebuildUserDocumentReqDTO);
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.hanserwei.hannote.search.service.impl;
|
package com.hanserwei.hannote.search.biz.service.impl;
|
||||||
|
|
||||||
import com.hanserwei.hannote.search.service.ExtDictService;
|
import com.hanserwei.hannote.search.biz.service.ExtDictService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
package com.hanserwei.hannote.search.service.impl;
|
package com.hanserwei.hannote.search.biz.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||||
import co.elastic.clients.elasticsearch._types.SortOptions;
|
import co.elastic.clients.elasticsearch._types.SortOptions;
|
||||||
import co.elastic.clients.elasticsearch._types.SortOrder;
|
import co.elastic.clients.elasticsearch._types.SortOrder;
|
||||||
import co.elastic.clients.elasticsearch._types.query_dsl.*;
|
import co.elastic.clients.elasticsearch._types.query_dsl.*;
|
||||||
|
import co.elastic.clients.elasticsearch.core.IndexRequest;
|
||||||
import co.elastic.clients.elasticsearch.core.SearchRequest;
|
import co.elastic.clients.elasticsearch.core.SearchRequest;
|
||||||
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
||||||
import co.elastic.clients.elasticsearch.core.search.Highlight;
|
import co.elastic.clients.elasticsearch.core.search.Highlight;
|
||||||
@@ -13,14 +14,17 @@ import co.elastic.clients.elasticsearch.core.search.Hit;
|
|||||||
import co.elastic.clients.util.NamedValue;
|
import co.elastic.clients.util.NamedValue;
|
||||||
import com.hanserwei.framework.common.constant.DateConstants;
|
import com.hanserwei.framework.common.constant.DateConstants;
|
||||||
import com.hanserwei.framework.common.response.PageResponse;
|
import com.hanserwei.framework.common.response.PageResponse;
|
||||||
|
import com.hanserwei.framework.common.response.Response;
|
||||||
import com.hanserwei.framework.common.utils.DateUtils;
|
import com.hanserwei.framework.common.utils.DateUtils;
|
||||||
import com.hanserwei.framework.common.utils.NumberUtils;
|
import com.hanserwei.framework.common.utils.NumberUtils;
|
||||||
import com.hanserwei.hannote.search.enums.NotePublishTimeRangeEnum;
|
import com.hanserwei.hannote.search.biz.domain.mapper.SelectMapper;
|
||||||
import com.hanserwei.hannote.search.enums.NoteSortTypeEnum;
|
import com.hanserwei.hannote.search.biz.enums.NotePublishTimeRangeEnum;
|
||||||
import com.hanserwei.hannote.search.index.NoteIndex;
|
import com.hanserwei.hannote.search.biz.enums.NoteSortTypeEnum;
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchNoteReqVO;
|
import com.hanserwei.hannote.search.biz.index.NoteIndex;
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchNoteRspVO;
|
import com.hanserwei.hannote.search.biz.model.vo.SearchNoteReqVO;
|
||||||
import com.hanserwei.hannote.search.service.NoteService;
|
import com.hanserwei.hannote.search.biz.model.vo.SearchNoteRspVO;
|
||||||
|
import com.hanserwei.hannote.search.biz.service.NoteService;
|
||||||
|
import com.hanserwei.hannote.search.dto.RebuildNoteDocumentReqDTO;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -39,6 +43,8 @@ public class NoteServiceImpl implements NoteService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ElasticsearchClient client;
|
private ElasticsearchClient client;
|
||||||
|
@Resource
|
||||||
|
private SelectMapper selectMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResponse<SearchNoteRspVO> searchNote(SearchNoteReqVO searchNoteReqVO) {
|
public PageResponse<SearchNoteRspVO> searchNote(SearchNoteReqVO searchNoteReqVO) {
|
||||||
@@ -295,4 +301,30 @@ public class NoteServiceImpl implements NoteService {
|
|||||||
return PageResponse.success(searchNoteRspVOS, pageNo, total);
|
return PageResponse.success(searchNoteRspVOS, pageNo, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response<Long> rebuildDocument(RebuildNoteDocumentReqDTO rebuildNoteDocumentReqDTO) {
|
||||||
|
Long noteId = rebuildNoteDocumentReqDTO.getId();
|
||||||
|
|
||||||
|
// 从数据库查询 Elasticsearch 索引数据
|
||||||
|
List<Map<String, Object>> result = selectMapper.selectEsNoteIndexData(noteId, null);
|
||||||
|
|
||||||
|
// 遍历查询结果,将每条记录同步到 Elasticsearch
|
||||||
|
for (Map<String, Object> recordMap : result) {
|
||||||
|
IndexRequest<Object> request = IndexRequest.of(r -> r
|
||||||
|
// 创建索引请求对象,指定索引名称
|
||||||
|
.index(NoteIndex.NAME)
|
||||||
|
// 设置文档的 ID,使用记录中的主键 “id” 字段值
|
||||||
|
.id((String.valueOf(recordMap.get(NoteIndex.FIELD_NOTE_ID))))
|
||||||
|
// 设置文档的内容,使用查询结果的记录数据
|
||||||
|
.document(recordMap));
|
||||||
|
try {
|
||||||
|
// 将数据写入 Elasticsearch 索引
|
||||||
|
client.index(request);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("==> 同步笔记数据异常: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Response.success();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
package com.hanserwei.hannote.search.service.impl;
|
package com.hanserwei.hannote.search.biz.service.impl;
|
||||||
|
|
||||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||||
import co.elastic.clients.elasticsearch._types.SortOptions;
|
import co.elastic.clients.elasticsearch._types.SortOptions;
|
||||||
import co.elastic.clients.elasticsearch._types.SortOrder;
|
import co.elastic.clients.elasticsearch._types.SortOrder;
|
||||||
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
||||||
import co.elastic.clients.elasticsearch._types.query_dsl.TextQueryType;
|
import co.elastic.clients.elasticsearch._types.query_dsl.TextQueryType;
|
||||||
|
import co.elastic.clients.elasticsearch.core.IndexRequest;
|
||||||
import co.elastic.clients.elasticsearch.core.SearchRequest;
|
import co.elastic.clients.elasticsearch.core.SearchRequest;
|
||||||
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
||||||
import co.elastic.clients.elasticsearch.core.search.Highlight;
|
import co.elastic.clients.elasticsearch.core.search.Highlight;
|
||||||
@@ -12,11 +13,14 @@ import co.elastic.clients.elasticsearch.core.search.HighlightField;
|
|||||||
import co.elastic.clients.elasticsearch.core.search.Hit;
|
import co.elastic.clients.elasticsearch.core.search.Hit;
|
||||||
import co.elastic.clients.util.NamedValue;
|
import co.elastic.clients.util.NamedValue;
|
||||||
import com.hanserwei.framework.common.response.PageResponse;
|
import com.hanserwei.framework.common.response.PageResponse;
|
||||||
|
import com.hanserwei.framework.common.response.Response;
|
||||||
import com.hanserwei.framework.common.utils.NumberUtils;
|
import com.hanserwei.framework.common.utils.NumberUtils;
|
||||||
import com.hanserwei.hannote.search.index.UserIndex;
|
import com.hanserwei.hannote.search.biz.domain.mapper.SelectMapper;
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchUserReqVO;
|
import com.hanserwei.hannote.search.biz.index.UserIndex;
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchUserRspVO;
|
import com.hanserwei.hannote.search.biz.model.vo.SearchUserReqVO;
|
||||||
import com.hanserwei.hannote.search.service.UserService;
|
import com.hanserwei.hannote.search.biz.model.vo.SearchUserRspVO;
|
||||||
|
import com.hanserwei.hannote.search.biz.service.UserService;
|
||||||
|
import com.hanserwei.hannote.search.dto.RebuildUserDocumentReqDTO;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -32,6 +36,8 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ElasticsearchClient client;
|
private ElasticsearchClient client;
|
||||||
|
@Resource
|
||||||
|
private SelectMapper selectMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResponse<SearchUserRspVO> searchUser(SearchUserReqVO searchUserReqVO) {
|
public PageResponse<SearchUserRspVO> searchUser(SearchUserReqVO searchUserReqVO) {
|
||||||
@@ -114,4 +120,30 @@ public class UserServiceImpl implements UserService {
|
|||||||
}
|
}
|
||||||
return PageResponse.success(searchUserRspVOS, pageNo, total);
|
return PageResponse.success(searchUserRspVOS, pageNo, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Response<Long> rebuildDocument(RebuildUserDocumentReqDTO rebuildUserDocumentReqDTO) {
|
||||||
|
Long userId = rebuildUserDocumentReqDTO.getId();
|
||||||
|
|
||||||
|
// 从数据库查询 Elasticsearch 索引数据
|
||||||
|
List<Map<String, Object>> result = selectMapper.selectEsUserIndexData(userId);
|
||||||
|
|
||||||
|
// 遍历查询结果,将每条记录同步到 Elasticsearch
|
||||||
|
for (Map<String, Object> recordMap : result) {
|
||||||
|
IndexRequest<Object> request = IndexRequest.of(indexRequest -> indexRequest
|
||||||
|
// 创建索引请求对象,指定索引名称
|
||||||
|
.index(UserIndex.NAME)
|
||||||
|
// 设置文档的 ID,使用记录中的主键 “id” 字段值
|
||||||
|
.id((String.valueOf(recordMap.get(UserIndex.FIELD_USER_ID))))
|
||||||
|
// 设置文档的内容,使用查询结果的记录数据
|
||||||
|
.document(recordMap));
|
||||||
|
// 将数据写入 Elasticsearch 索引
|
||||||
|
try {
|
||||||
|
client.index(request);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("==> 同步用户数据到 Elasticsearch 索引中失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Response.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="com.hanserwei.hannote.search.domain.mapper.SelectMapper">
|
<mapper namespace="com.hanserwei.hannote.search.biz.domain.mapper.SelectMapper">
|
||||||
|
|
||||||
<select id="selectEsNoteIndexData" resultType="map" parameterType="map">
|
<select id="selectEsNoteIndexData" resultType="map" parameterType="map">
|
||||||
select n.id,
|
select n.id,
|
||||||
n.title,
|
n.title,
|
||||||
n.topic_name as topic,
|
n.topic_name as topic,
|
||||||
n.type,
|
n.type,
|
||||||
n.img_uris,
|
SUBSTRING_INDEX(n.img_uris, ',', 1) AS cover,
|
||||||
DATE_FORMAT(n.create_time, '%Y-%m-%d %H:%i:%s') AS create_time,
|
DATE_FORMAT(n.create_time, '%Y-%m-%d %H:%i:%s') AS create_time,
|
||||||
DATE_FORMAT(n.update_time, '%Y-%m-%d %H:%i:%s') AS update_time,
|
DATE_FORMAT(n.update_time, '%Y-%m-%d %H:%i:%s') AS update_time,
|
||||||
u.nickname,
|
u.nickname AS creator_nickname,
|
||||||
u.avatar,
|
u.avatar AS creator_avatar,
|
||||||
IFNULL(nc.like_total, 0) as like_total,
|
IFNULL(nc.like_total, 0) as like_total,
|
||||||
IFNULL(nc.collect_total, 0) as collect_total,
|
IFNULL(nc.collect_total, 0) as collect_total,
|
||||||
IFNULL(nc.comment_total, 0) as comment_total
|
IFNULL(nc.comment_total, 0) as comment_total
|
||||||
@@ -3,7 +3,7 @@ package com.hanserwei.hannote.search;
|
|||||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||||
import co.elastic.clients.elasticsearch._types.SortOrder;
|
import co.elastic.clients.elasticsearch._types.SortOrder;
|
||||||
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
import co.elastic.clients.elasticsearch.core.SearchResponse;
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchUserRspVO;
|
import com.hanserwei.hannote.search.biz.model.vo.SearchUserRspVO;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -8,96 +8,17 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<!-- 指定打包方式 -->
|
<!-- 多模块项目需要配置打包方式为 pom -->
|
||||||
<packaging>jar</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>han-note-search-biz</module>
|
||||||
|
<module>han-note-search-api</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
<artifactId>han-note-search</artifactId>
|
<artifactId>han-note-search</artifactId>
|
||||||
|
<!-- 项目名称 -->
|
||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
|
<!-- 项目描述 -->
|
||||||
<description>搜索服务</description>
|
<description>搜索服务</description>
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.hanserwei</groupId>
|
|
||||||
<artifactId>hanserwei-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 业务接口日志组件 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.hanserwei</groupId>
|
|
||||||
<artifactId>hanserwei-spring-boot-starter-biz-operationlog</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Jackson 组件 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.hanserwei</groupId>
|
|
||||||
<artifactId>hanserwei-spring-boot-starter-jackson</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 服务注册发现 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Elasticsearch 分布式搜索引擎 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>co.elastic.clients</groupId>
|
|
||||||
<artifactId>elasticsearch-java</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.elasticsearch.client</groupId>
|
|
||||||
<artifactId>elasticsearch-rest-client</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- Canal -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.otter</groupId>
|
|
||||||
<artifactId>canal.client</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.otter</groupId>
|
|
||||||
<artifactId>canal.common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.otter</groupId>
|
|
||||||
<artifactId>canal.protocol</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baomidou</groupId>
|
|
||||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- Druid 数据库连接池 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>druid-spring-boot-3-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.hanserwei.hannote.search.service;
|
|
||||||
|
|
||||||
import com.hanserwei.framework.common.response.PageResponse;
|
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchNoteReqVO;
|
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchNoteRspVO;
|
|
||||||
|
|
||||||
public interface NoteService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 搜索笔记
|
|
||||||
*
|
|
||||||
* @param searchNoteReqVO 搜索笔记请求
|
|
||||||
* @return 搜索笔记响应
|
|
||||||
*/
|
|
||||||
PageResponse<SearchNoteRspVO> searchNote(SearchNoteReqVO searchNoteReqVO);
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.hanserwei.hannote.search.service;
|
|
||||||
|
|
||||||
import com.hanserwei.framework.common.response.PageResponse;
|
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchUserReqVO;
|
|
||||||
import com.hanserwei.hannote.search.model.vo.SearchUserRspVO;
|
|
||||||
|
|
||||||
public interface UserService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 搜索用户
|
|
||||||
*
|
|
||||||
* @param searchUserReqVO 搜索用户请求
|
|
||||||
* @return 搜索用户响应
|
|
||||||
*/
|
|
||||||
PageResponse<SearchUserRspVO> searchUser(SearchUserReqVO searchUserReqVO);
|
|
||||||
}
|
|
||||||
@@ -75,13 +75,15 @@ Authorization: Bearer {{token}}
|
|||||||
{
|
{
|
||||||
"type": 0,
|
"type": 0,
|
||||||
"imgUris": [
|
"imgUris": [
|
||||||
"https://cdn.pixabay.com/photo/2025/10/05/15/06/autumn-9875155_1280.jpg"
|
"http://116.62.199.48:9000/weblog/c58c6db953d24922803a65ca4f79a0a9.png",
|
||||||
|
"http://116.62.199.48:9000/weblog/04c7312e0b4b41be996004517c247e2b.jpg"
|
||||||
],
|
],
|
||||||
"title": "bug修复2",
|
"title": "最美的风景不是诗和远方,而就在身边",
|
||||||
"content": "bugbugbug",
|
"content": "最美的风景不是诗和远方,而就在身边",
|
||||||
"topicId": 1
|
"topicId": 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
### 发布视频笔记
|
### 发布视频笔记
|
||||||
POST http://localhost:8000/note/note/publish
|
POST http://localhost:8000/note/note/publish
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
@@ -288,3 +290,14 @@ Content-Type: application/json
|
|||||||
"keyword": "憨憨",
|
"keyword": "憨憨",
|
||||||
"pageNo": 1
|
"pageNo": 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###
|
||||||
|
POST http://localhost:8000/comment/comment/publish
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"noteId": 1862481582414102549,
|
||||||
|
"content": "这是一个评论",
|
||||||
|
"imageUrl": "https://cdn.pixabay.com/photo/2025/10/05/15/06/autumn-9875155_1280.jpg"
|
||||||
|
}
|
||||||
6
pom.xml
6
pom.xml
@@ -24,6 +24,7 @@
|
|||||||
<module>han-note-count</module>
|
<module>han-note-count</module>
|
||||||
<module>han-note-data-align</module>
|
<module>han-note-data-align</module>
|
||||||
<module>han-note-search</module>
|
<module>han-note-search</module>
|
||||||
|
<module>han-note-comment</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -331,6 +332,11 @@
|
|||||||
<artifactId>canal.protocol</artifactId>
|
<artifactId>canal.protocol</artifactId>
|
||||||
<version>${canal.version}</version>
|
<version>${canal.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.hanserwei</groupId>
|
||||||
|
<artifactId>han-note-search-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
@@ -240,5 +240,44 @@ CREATE TABLE `t_user_count`
|
|||||||
COLLATE = utf8mb4_unicode_ci
|
COLLATE = utf8mb4_unicode_ci
|
||||||
COMMENT ='用户计数表';
|
COMMENT ='用户计数表';
|
||||||
|
|
||||||
|
-- 表:t_comment
|
||||||
|
CREATE TABLE `t_comment`
|
||||||
|
(
|
||||||
|
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||||
|
`note_id` bigint unsigned NOT NULL COMMENT '关联的笔记ID',
|
||||||
|
`user_id` bigint unsigned NOT NULL COMMENT '发布者用户ID',
|
||||||
|
`content_uuid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '评论内容UUID',
|
||||||
|
`is_content_empty` bit NOT NULL DEFAULT b'0' COMMENT '内容是否为空(0:不为空 1:为空)',
|
||||||
|
`image_url` varchar(60) NOT NULL DEFAULT '' COMMENT '评论附加图片URL',
|
||||||
|
`level` tinyint NOT NULL DEFAULT '1' COMMENT '级别(1:一级评论 2:二级评论)',
|
||||||
|
`reply_total` bigint unsigned DEFAULT 0 COMMENT '评论被回复次数,仅一级评论需要',
|
||||||
|
`like_total` bigint DEFAULT 0 COMMENT '评论被点赞次数',
|
||||||
|
`parent_id` bigint unsigned DEFAULT 0 COMMENT '父ID (若是对笔记的评论,则此字段存储笔记ID; 若是二级评论,则此字段存储一级评论的ID)',
|
||||||
|
`reply_comment_id` bigint unsigned DEFAULT 0 COMMENT '回复哪个的评论 (0表示是对笔记的评论,若是对他人评论的回复,则存储回复评论的ID)',
|
||||||
|
`reply_user_id` bigint unsigned DEFAULT 0 COMMENT '回复的哪个用户, 存储用户ID',
|
||||||
|
`is_top` tinyint NOT NULL DEFAULT '0' COMMENT '是否置顶(0:不置顶 1:置顶)',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
KEY `idx_note_id` (`note_id`) USING BTREE,
|
||||||
|
KEY `idx_user_id` (`user_id`) USING BTREE,
|
||||||
|
KEY `idx_parent_id` (`parent_id`) USING BTREE,
|
||||||
|
KEY `idx_create_time` (`create_time`) USING BTREE,
|
||||||
|
KEY `idx_reply_comment_id` (`reply_comment_id`) USING BTREE,
|
||||||
|
KEY `idx_reply_user_id` (`reply_user_id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB COMMENT = '评论表';
|
||||||
|
|
||||||
|
-- 表:t_comment_like
|
||||||
|
CREATE TABLE `t_comment_like`
|
||||||
|
(
|
||||||
|
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||||
|
`user_id` bigint NOT NULL COMMENT '用户ID',
|
||||||
|
`comment_id` bigint NOT NULL COMMENT '评论ID',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_user_id_comment_id` (`user_id`, `comment_id`)
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4
|
||||||
|
COLLATE = utf8mb4_unicode_ci COMMENT ='评论点赞表';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user