├── project-screenshot ├── default.png ├── 微信图片_20240910165649.jpg ├── 微信图片_20240910165704.jpg ├── 微信图片_20240910165709.jpg ├── 微信图片_20240910165714.jpg ├── 微信图片_20240910165718.jpg ├── 微信图片_20240910165723.jpg ├── 微信图片_20240910165728.jpg ├── 微信图片_20240910165733.jpg ├── 微信图片_20240910165738.jpg ├── 微信图片_20240910165743.jpg ├── 微信图片_20240910165942.jpg └── Screenshot_20240910_165224.png ├── .idea ├── .gitignore ├── vcs.xml ├── sqldialects.xml ├── UniappTool.xml ├── JavaSceneConfigState.xml ├── UniappProjectData.xml ├── misc.xml ├── ProjectStorage.xml ├── dataSources.xml └── encodings.xml ├── xfs-common ├── common-mybatis │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── spring.factories │ │ │ └── java │ │ │ └── com │ │ │ └── yyh │ │ │ └── xfs │ │ │ └── common │ │ │ └── mybatis │ │ │ ├── config │ │ │ └── MybatisPlusConfig.java │ │ │ └── handler │ │ │ └── MyMetaObjectHandler.java │ └── pom.xml ├── common-base │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── yyh │ │ │ └── xfs │ │ │ └── common │ │ │ ├── utils │ │ │ ├── Md5Util.java │ │ │ ├── TimeUtil.java │ │ │ ├── FieldValidationUtil.java │ │ │ ├── HtmlParseUtils.java │ │ │ ├── ResultUtil.java │ │ │ └── CodeUtil.java │ │ │ ├── domain │ │ │ ├── Result.java │ │ │ └── PageParam.java │ │ │ ├── constant │ │ │ ├── RocketMQTopicConstant.java │ │ │ ├── RocketMQConsumerGroupConstant.java │ │ │ └── StatusCode.java │ │ │ └── myEnum │ │ │ ├── MessageTypeEnum.java │ │ │ └── ExceptionMsgEnum.java │ └── pom.xml ├── common-redis │ ├── src │ │ └── main │ │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── spring.factories │ │ │ └── java │ │ │ └── com │ │ │ └── yyh │ │ │ └── xfs │ │ │ └── common │ │ │ └── redis │ │ │ ├── utils │ │ │ └── RedisKey.java │ │ │ ├── constant │ │ │ └── BloomFilterMap.java │ │ │ ├── properties │ │ │ └── RedisProperties.java │ │ │ └── config │ │ │ ├── RedissonConfig.java │ │ │ └── CustomRedisConfig.java │ └── pom.xml ├── common-web │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── com │ │ │ │ └── yyh │ │ │ │ └── xfs │ │ │ │ └── common │ │ │ │ └── web │ │ │ │ ├── aop │ │ │ │ ├── bloomFilter │ │ │ │ │ └── BloomFilterProcessing.java │ │ │ │ └── idempotent │ │ │ │ │ └── Idempotent.java │ │ │ │ ├── properties │ │ │ │ ├── GaoDeMapProperties.java │ │ │ │ ├── TrtcProperties.java │ │ │ │ └── JwtProperties.java │ │ │ │ ├── exception │ │ │ │ ├── OnlyWarnException.java │ │ │ │ ├── SystemException.java │ │ │ │ ├── BusinessException.java │ │ │ │ └── handler │ │ │ │ │ └── GlobalExceptionHandler.java │ │ │ │ ├── config │ │ │ │ ├── FeignConfig.java │ │ │ │ ├── SwaggerConfig.java │ │ │ │ └── WebMvcConfig.java │ │ │ │ └── utils │ │ │ │ └── JWTUtil.java │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── spring.factories │ └── pom.xml └── pom.xml ├── config ├── init-message.js ├── run.sh ├── elasticsearch.yml └── broker.conf ├── xfs-modules-server ├── xfs-search-server │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── yyh │ │ │ │ └── xfs │ │ │ │ └── search │ │ │ │ ├── service │ │ │ │ ├── ElasticSearchInitService.java │ │ │ │ ├── UserSearchService.java │ │ │ │ ├── NotesSearchService.java │ │ │ │ └── impl │ │ │ │ │ └── ElasticSearchInitServiceImpl.java │ │ │ │ ├── feign │ │ │ │ └── UserFeign.java │ │ │ │ ├── SearchApplication.java │ │ │ │ ├── consumer │ │ │ │ ├── notes │ │ │ │ │ ├── NotesDeleteEsConsumer.java │ │ │ │ │ ├── NotesAddEsConsumer.java │ │ │ │ │ ├── NotesUpdateEsConsumer.java │ │ │ │ │ └── NotesUpdateCountConsumer.java │ │ │ │ └── user │ │ │ │ │ ├── UserUpdateEsConsumer.java │ │ │ │ │ └── UserAddEsConsumer.java │ │ │ │ ├── controller │ │ │ │ ├── UserSearchController.java │ │ │ │ ├── ElasticSearchInitController.java │ │ │ │ └── NotesSearchController.java │ │ │ │ └── config │ │ │ │ └── EsConfig.java │ │ └── resources │ │ │ └── bootstrap.yml │ │ └── test │ │ └── java │ │ └── com │ │ └── yyh │ │ └── xfs │ │ └── search │ │ └── SearchApplicationTest.java ├── xfs-notes-server │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── yyh │ │ │ └── xfs │ │ │ └── notes │ │ │ ├── service │ │ │ ├── NotesCategoryService.java │ │ │ ├── impl │ │ │ │ └── NotesCategoryServiceImpl.java │ │ │ └── NotesService.java │ │ │ ├── mapper │ │ │ ├── NotesTopicMapper.java │ │ │ ├── UserLikeNotesMapper.java │ │ │ ├── UserCollectNotesMapper.java │ │ │ ├── NotesTopicRelationMapper.java │ │ │ ├── UserViewsRecordNotesMapper.java │ │ │ ├── NotesCategoryMapper.java │ │ │ └── NotesMapper.java │ │ │ ├── config │ │ │ ├── BaiduAiConfig.java │ │ │ └── NotesConfig.java │ │ │ ├── NotesApplication.java │ │ │ ├── feign │ │ │ └── UserFeign.java │ │ │ ├── controller │ │ │ └── NotesCategoryController.java │ │ │ └── consumer │ │ │ └── RemoveCacheConsumer.java │ │ └── resources │ │ ├── bootstrap.yml │ │ └── mapper │ │ ├── NotesTopicRelationMapper.xml │ │ ├── UserLikeNotesMapper.xml │ │ ├── UserCollectNotesMapper.xml │ │ ├── NotesCategoryMapper.xml │ │ ├── UserViewsRecordNotesMapper.xml │ │ └── NotesTopicMapper.xml ├── xfs-im-server │ └── src │ │ ├── main │ │ ├── resources │ │ │ └── bootstrap.yml │ │ └── java │ │ │ └── com │ │ │ └── yyh │ │ │ └── xfs │ │ │ └── im │ │ │ ├── handler │ │ │ └── types │ │ │ │ └── AttentionHandler.java │ │ │ ├── config │ │ │ └── ImConfig.java │ │ │ ├── IMApplication.java │ │ │ ├── feign │ │ │ └── user │ │ │ │ └── UserFeign.java │ │ │ ├── initialzer │ │ │ └── IMServerInitialzer.java │ │ │ └── consumer │ │ │ ├── PraiseAndCollectNotificationConsumer.java │ │ │ └── FindUserConsumer.java │ │ └── test │ │ └── java │ │ └── com │ │ └── yyh │ │ └── xfs │ │ └── im │ │ └── IMApplicationTest.java ├── xfs-user-server │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── yyh │ │ │ └── xfs │ │ │ └── user │ │ │ ├── mapper │ │ │ ├── UserMapper.java │ │ │ ├── UserBlackMapper.java │ │ │ ├── UserFansMapper.java │ │ │ └── UserAttentionMapper.java │ │ │ ├── UserApplication.java │ │ │ ├── service │ │ │ └── UserRelationService.java │ │ │ └── config │ │ │ └── UserConfig.java │ │ └── resources │ │ ├── bootstrap.yml │ │ └── mapper │ │ ├── UserBlackMapper.xml │ │ ├── UserFansMapper.xml │ │ ├── UserAttentionMapper.xml │ │ └── UserMapper.xml ├── xfs-comment-server │ └── src │ │ ├── main │ │ ├── resources │ │ │ └── bootstrap.yml │ │ └── java │ │ │ └── com │ │ │ └── yyh │ │ │ └── xfs │ │ │ └── comment │ │ │ ├── feign │ │ │ ├── NotesFeign.java │ │ │ └── UserFeign.java │ │ │ ├── CommentApplication.java │ │ │ ├── service │ │ │ └── CommentService.java │ │ │ └── consumer │ │ │ └── NotesDeleteCommentConsumer.java │ │ └── test │ │ └── java │ │ └── com │ │ └── yyh │ │ └── xfs │ │ └── comment │ │ └── CommentApplicationTest.java └── pom.xml ├── xfs-job-server └── src │ └── main │ ├── java │ └── com │ │ └── yyh │ │ └── xfs │ │ └── job │ │ ├── service │ │ ├── impl │ │ │ └── UserServiceImpl.java │ │ ├── UserService.java │ │ └── NotesService.java │ │ ├── mapper │ │ ├── user │ │ │ └── UserMapper.java │ │ └── notes │ │ │ └── NotesMapper.java │ │ ├── JobApplication.java │ │ └── config │ │ ├── XxlJobConfig.java │ │ ├── NotesDataSourceConfig.java │ │ └── UserDataSourceConfig.java │ └── resources │ ├── bootstrap.yml │ └── mapper │ ├── notes │ └── NotesMapper.xml │ └── user │ └── UserMapper.xml ├── xfs-modules-api ├── xfs-notes-api │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── yyh │ │ │ └── xfs │ │ │ └── notes │ │ │ ├── dto │ │ │ └── ResourcesDTO.java │ │ │ ├── vo │ │ │ ├── NotesPageVO.java │ │ │ ├── NotesPublishVO.java │ │ │ └── NotesVO.java │ │ │ └── domain │ │ │ ├── NotesTopicRelationDO.java │ │ │ ├── UserLikeNotesDO.java │ │ │ ├── UserViewsRecordNotesDO.java │ │ │ ├── UserCollectNotesDO.java │ │ │ ├── NotesCategoryDO.java │ │ │ ├── NotesTopicDO.java │ │ │ └── NotesDO.java │ └── pom.xml ├── xfs-user-api │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── yyh │ │ │ └── xfs │ │ │ └── user │ │ │ ├── vo │ │ │ ├── PasswordVO.java │ │ │ ├── UserTrtcVO.java │ │ │ ├── UserBindThirdStateVO.java │ │ │ ├── RegisterInfoVO.java │ │ │ ├── UserRelationVO.java │ │ │ └── ViewUserVO.java │ │ │ └── domain │ │ │ ├── UserFansDO.java │ │ │ ├── UserBlackDO.java │ │ │ └── UserAttentionDO.java │ └── pom.xml ├── xfs-comment-api │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── com │ │ │ └── yyh │ │ │ └── xfs │ │ │ └── comment │ │ │ ├── vo │ │ │ └── CommentVO.java │ │ │ └── domain │ │ │ └── CommentDO.java │ └── pom.xml ├── xfs-im-api │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── yyh │ │ └── xfs │ │ └── im │ │ ├── domain │ │ └── MessageDO.java │ │ └── vo │ │ └── MessageVO.java ├── xfs-search-api │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── yyh │ │ └── xfs │ │ └── search │ │ └── domain │ │ ├── UserEsDO.java │ │ └── NotesEsDO.java └── pom.xml ├── xfs-third-server └── src │ └── main │ ├── resources │ └── bootstrap.yml │ └── java │ └── com │ └── yyh │ └── xfs │ └── third │ ├── ThirdApplication.java │ ├── sevice │ ├── AliyunOssService.java │ └── AliyunSmsService.java │ ├── config │ ├── AliyunOss.java │ └── AliyunSms.java │ └── controller │ └── UploadFileController.java ├── xfs-gateway └── src │ └── main │ ├── resources │ └── bootstrap.yml │ └── java │ └── com │ └── yyh │ └── xfs │ └── gateway │ ├── GatewayApplication.java │ ├── properties │ ├── ReleasePath.java │ └── JwtProperties.java │ └── utils │ └── JWTUtil.java ├── xfs-auth └── src │ └── main │ ├── resources │ └── bootstrap.yml │ └── java │ └── com │ └── yyh │ └── xfs │ └── auth │ ├── AuthApplication.java │ └── utils │ └── UserInfoUtil.java ├── xiaofanshu-arm.dockerfile ├── xiaofanshu-amd.dockerfile ├── .gitignore └── xiaofanshu-docker.md /project-screenshot/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/default.png -------------------------------------------------------------------------------- /project-screenshot/微信图片_20240910165649.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/微信图片_20240910165649.jpg -------------------------------------------------------------------------------- /project-screenshot/微信图片_20240910165704.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/微信图片_20240910165704.jpg -------------------------------------------------------------------------------- /project-screenshot/微信图片_20240910165709.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/微信图片_20240910165709.jpg -------------------------------------------------------------------------------- /project-screenshot/微信图片_20240910165714.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/微信图片_20240910165714.jpg -------------------------------------------------------------------------------- /project-screenshot/微信图片_20240910165718.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/微信图片_20240910165718.jpg -------------------------------------------------------------------------------- /project-screenshot/微信图片_20240910165723.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/微信图片_20240910165723.jpg -------------------------------------------------------------------------------- /project-screenshot/微信图片_20240910165728.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/微信图片_20240910165728.jpg -------------------------------------------------------------------------------- /project-screenshot/微信图片_20240910165733.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/微信图片_20240910165733.jpg -------------------------------------------------------------------------------- /project-screenshot/微信图片_20240910165738.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/微信图片_20240910165738.jpg -------------------------------------------------------------------------------- /project-screenshot/微信图片_20240910165743.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/微信图片_20240910165743.jpg -------------------------------------------------------------------------------- /project-screenshot/微信图片_20240910165942.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/微信图片_20240910165942.jpg -------------------------------------------------------------------------------- /project-screenshot/Screenshot_20240910_165224.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/123yyh123/xiaofanshu/HEAD/project-screenshot/Screenshot_20240910_165224.png -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # 默认忽略的文件 2 | /shelf/ 3 | /workspace.xml 4 | # 基于编辑器的 HTTP 客户端请求 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /xfs-common/common-mybatis/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.yyh.xfs.common.mybatis.config.MybatisPlusConfig,\ 3 | com.yyh.xfs.common.mybatis.handler.MyMetaObjectHandler -------------------------------------------------------------------------------- /config/init-message.js: -------------------------------------------------------------------------------- 1 | // 切换到 messagedb 数据库(不存在会自动创建) 2 | db = db.getSiblingDB('messagedb'); 3 | 4 | // 创建用户 admin,密码 123456,拥有 messagedb 的读写权限 5 | db.createUser({ 6 | user: "admin", 7 | pwd: "123456", 8 | roles: [ 9 | { role: "readWrite", db: "messagedb" } 10 | ] 11 | }); 12 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/service/ElasticSearchInitService.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.service; 2 | 3 | /** 4 | * @author yyh 5 | * @date 2024-01-24 6 | */ 7 | public interface ElasticSearchInitService { 8 | void initElasticSearch(); 9 | } 10 | -------------------------------------------------------------------------------- /.idea/sqldialects.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /xfs-job-server/src/main/java/com/yyh/xfs/job/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.job.service.impl; 2 | 3 | import com.yyh.xfs.job.service.UserService; 4 | import org.springframework.stereotype.Service; 5 | /** 6 | * @author yyh 7 | * @date 2023-12-23 8 | */ 9 | @Service 10 | public class UserServiceImpl implements UserService { 11 | } 12 | -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/utils/Md5Util.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.utils; 2 | 3 | import org.apache.commons.codec.digest.DigestUtils; 4 | 5 | /** 6 | * @author yyh 7 | * @date 2023-12-09 8 | */ 9 | public class Md5Util { 10 | public static String getMd5(String str) { 11 | return DigestUtils.md5Hex(str); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /xfs-job-server/src/main/java/com/yyh/xfs/job/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.job.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.yyh.xfs.user.domain.UserDO; 5 | import com.yyh.xfs.user.vo.UserVO; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2023-12-23 12 | */ 13 | public interface UserService{ 14 | } 15 | -------------------------------------------------------------------------------- /xfs-common/common-redis/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.yyh.xfs.common.redis.config.CustomRedisConfig,\ 3 | com.yyh.xfs.common.redis.config.RedissonConfig,\ 4 | com.yyh.xfs.common.redis.properties.RedisProperties,\ 5 | com.yyh.xfs.common.redis.utils.BloomFilterUtils,\ 6 | com.yyh.xfs.common.redis.utils.RedisCache -------------------------------------------------------------------------------- /xfs-modules-api/xfs-notes-api/src/main/java/com/yyh/xfs/notes/dto/ResourcesDTO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.dto; 2 | 3 | import lombok.Data; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-02-02 12 | */ 13 | @Data 14 | public class ResourcesDTO implements Serializable { 15 | private String url; 16 | } 17 | -------------------------------------------------------------------------------- /xfs-third-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: xfs-third 4 | ## 开发环境 5 | profiles: 6 | active: dev 7 | cloud: 8 | nacos: 9 | ## Nacos服务注册中心地址 10 | config: 11 | ## 配置文件所在的命名空间 12 | namespace: 54c5b22b-7b63-4073-9a77-f07142769f1f 13 | file-extension: yaml 14 | server-addr: 192.168.124.100:8848 15 | shared-configs: redis.yaml 16 | -------------------------------------------------------------------------------- /xfs-gateway/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: xfs-gateway 4 | ## 开发环境 5 | profiles: 6 | active: dev 7 | cloud: 8 | nacos: 9 | ## Nacos服务注册中心地址 10 | config: 11 | ## 配置文件所在的命名空间 12 | namespace: 54c5b22b-7b63-4073-9a77-f07142769f1f 13 | file-extension: yaml 14 | server-addr: 192.168.124.100:8848 15 | shared-configs: jwt.yaml,redis.yaml 16 | -------------------------------------------------------------------------------- /xfs-job-server/src/main/java/com/yyh/xfs/job/mapper/user/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.job.mapper.user; 2 | 3 | import com.yyh.xfs.user.domain.UserDO; 4 | import io.lettuce.core.ScanIterator; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2024-02-09 11 | */ 12 | public interface UserMapper{ 13 | void updateUser(UserDO user); 14 | 15 | List getAllUserId(); 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-user-api/src/main/java/com/yyh/xfs/user/vo/PasswordVO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.vo; 2 | 3 | import lombok.Data; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-02-21 12 | */ 13 | @Data 14 | public class PasswordVO implements Serializable { 15 | private String oldPassword; 16 | private String newPassword; 17 | } 18 | -------------------------------------------------------------------------------- /xfs-auth/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: xfs-auth 4 | ## 开发环境 5 | profiles: 6 | active: dev 7 | cloud: 8 | nacos: 9 | ## Nacos服务注册中心地址 10 | config: 11 | ## 配置文件所在的命名空间 12 | namespace: 54c5b22b-7b63-4073-9a77-f07142769f1f 13 | file-extension: yaml 14 | server-addr: 192.168.124.100:8848 15 | shared-configs: mybatis-plus.yaml,redis.yaml,jwt.yaml -------------------------------------------------------------------------------- /xfs-job-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: xfs-job 4 | ## 开发环境 5 | profiles: 6 | active: dev 7 | cloud: 8 | nacos: 9 | ## Nacos服务注册中心地址 10 | config: 11 | ## 配置文件所在的命名空间 12 | namespace: 54c5b22b-7b63-4073-9a77-f07142769f1f 13 | file-extension: yaml 14 | server-addr: 192.168.124.100:8848 15 | shared-configs: redis.yaml,thread-pool.yaml 16 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/service/NotesCategoryService.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.service; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import com.yyh.xfs.notes.domain.NotesCategoryDO; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2024-02-23 11 | */ 12 | public interface NotesCategoryService { 13 | Result>getNotesCategory(); 14 | } 15 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/mapper/NotesTopicMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.yyh.xfs.notes.domain.NotesTopicDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-01-22 10 | */ 11 | @Mapper 12 | public interface NotesTopicMapper extends BaseMapper { 13 | } 14 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: xfs-search 4 | ## 开发环境 5 | profiles: 6 | active: dev 7 | cloud: 8 | nacos: 9 | ## Nacos服务注册中心地址 10 | config: 11 | ## 配置文件所在的命名空间 12 | namespace: 54c5b22b-7b63-4073-9a77-f07142769f1f 13 | file-extension: yaml 14 | server-addr: 192.168.124.100:8848 15 | shared-configs: redis.yaml,jwt.yaml -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/domain/Result.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.domain; 2 | 3 | import lombok.*; 4 | import java.io.Serializable; 5 | 6 | /** 7 | * @author yyh 8 | * @date 2023-12-11 9 | * @desc 返回结果 10 | */ 11 | 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class Result implements Serializable { 16 | private Integer code; 17 | private String msg; 18 | private T data; 19 | } 20 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/mapper/UserLikeNotesMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.yyh.xfs.notes.domain.UserLikeNotesDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-01-28 10 | */ 11 | @Mapper 12 | public interface UserLikeNotesMapper extends BaseMapper{ 13 | } 14 | -------------------------------------------------------------------------------- /xfs-common/common-redis/src/main/java/com/yyh/xfs/common/redis/utils/RedisKey.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.redis.utils; 2 | 3 | /** 4 | * @author yyh 5 | * @date 2023-12-15 6 | */ 7 | public class RedisKey { 8 | /** 9 | * 构建redis key 10 | * @param prefix 前缀 11 | * @param key key 12 | * @return redis key 13 | */ 14 | public static String build(String prefix, String key) { 15 | return prefix + key; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/aop/bloomFilter/BloomFilterProcessing.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.aop.bloomFilter; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author yyh 7 | * @date 2024-02-24 8 | */ 9 | @Target({ElementType.METHOD}) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Documented 12 | public @interface BloomFilterProcessing { 13 | String map() default ""; 14 | String[] keys() default {}; 15 | } 16 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-im-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: xfs-im 4 | ## 开发环境 5 | profiles: 6 | active: dev 7 | cloud: 8 | nacos: 9 | ## Nacos服务注册中心地址 10 | config: 11 | ## 配置文件所在的命名空间 12 | namespace: 54c5b22b-7b63-4073-9a77-f07142769f1f 13 | file-extension: yaml 14 | server-addr: 192.168.124.100:8848 15 | shared-configs: redis.yaml,jwt.yaml,thread-pool.yaml 16 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: xfs-notes 4 | ## 开发环境 5 | profiles: 6 | active: dev 7 | cloud: 8 | nacos: 9 | ## Nacos服务注册中心地址 10 | config: 11 | ## 配置文件所在的命名空间 12 | namespace: 54c5b22b-7b63-4073-9a77-f07142769f1f 13 | file-extension: yaml 14 | server-addr: 192.168.124.100:8848 15 | shared-configs: mybatis-plus.yaml,redis.yaml,jwt.yaml -------------------------------------------------------------------------------- /xfs-modules-server/xfs-user-server/src/main/java/com/yyh/xfs/user/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.yyh.xfs.user.domain.UserDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2023-12-23 10 | * @desc 用户表 11 | */ 12 | @Mapper 13 | public interface UserMapper extends BaseMapper { 14 | 15 | } 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-user-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: xfs-user 4 | ## 开发环境 5 | profiles: 6 | active: dev 7 | cloud: 8 | nacos: 9 | ## Nacos服务注册中心地址 10 | config: 11 | ## 配置文件所在的命名空间 12 | namespace: 54c5b22b-7b63-4073-9a77-f07142769f1f 13 | file-extension: yaml 14 | server-addr: 192.168.124.100:8848 15 | shared-configs: mybatis-plus.yaml,redis.yaml,jwt.yaml -------------------------------------------------------------------------------- /.idea/UniappTool.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | -------------------------------------------------------------------------------- /xfs-job-server/src/main/java/com/yyh/xfs/job/service/NotesService.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.job.service; 2 | 3 | /** 4 | * @author yyh 5 | * @date 2024-02-08 6 | */ 7 | public interface NotesService { 8 | void updateNotesLikeNum(String key,Long notesId, Integer notesLikeNum); 9 | 10 | void updateNotesCollectionNum(String key, Long notesId, Integer notesCollectionNum); 11 | 12 | void updateNotesViewNum(String key, Long notesId, Integer notesViewNum); 13 | } 14 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/mapper/UserCollectNotesMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.yyh.xfs.notes.domain.UserCollectNotesDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-01-28 10 | */ 11 | @Mapper 12 | public interface UserCollectNotesMapper extends BaseMapper{ 13 | } 14 | -------------------------------------------------------------------------------- /.idea/JavaSceneConfigState.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/UniappProjectData.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/domain/PageParam.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.domain; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-01-29 10 | */ 11 | @Data 12 | public class PageParam implements Serializable { 13 | private Integer page; 14 | private Integer pageSize; 15 | private Double longitude; 16 | private Double latitude; 17 | private String keyword; 18 | } 19 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-notes-api/src/main/java/com/yyh/xfs/notes/vo/NotesPageVO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.List; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2024-01-26 11 | */ 12 | @Data 13 | public class NotesPageVO implements Serializable { 14 | private List list; 15 | private Integer total; 16 | private Integer page; 17 | private Integer pageSize; 18 | } 19 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-comment-server/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: xfs-comment 4 | ## 开发环境 5 | profiles: 6 | active: dev 7 | cloud: 8 | nacos: 9 | ## Nacos服务注册中心地址 10 | config: 11 | ## 配置文件所在的命名空间 12 | namespace: 54c5b22b-7b63-4073-9a77-f07142769f1f 13 | file-extension: yaml 14 | server-addr: 192.168.124.100:8848 15 | shared-configs: redis.yaml,thread-pool.yaml,jwt.yaml 16 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/mapper/NotesTopicRelationMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.yyh.xfs.notes.domain.NotesTopicRelationDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-01-22 10 | */ 11 | @Mapper 12 | public interface NotesTopicRelationMapper extends BaseMapper { 13 | } 14 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/mapper/UserViewsRecordNotesMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.yyh.xfs.notes.domain.UserViewsRecordNotesDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-01-28 10 | */ 11 | @Mapper 12 | public interface UserViewsRecordNotesMapper extends BaseMapper{ 13 | } 14 | -------------------------------------------------------------------------------- /xfs-third-server/src/main/java/com/yyh/xfs/third/ThirdApplication.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.third; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * @author yyh 8 | * @date 2023-12-12 9 | */ 10 | @SpringBootApplication 11 | public class ThirdApplication { 12 | public static void main(String[] args) { 13 | SpringApplication.run(ThirdApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /xiaofanshu-arm.dockerfile: -------------------------------------------------------------------------------- 1 | FROM fmww/alpine-jdk8 2 | MAINTAINER yyh 3 | EXPOSE 9000 4 | # 创建应用目录 5 | WORKDIR /app 6 | # 复制 JAR 包和启动脚本到容器中 7 | COPY jar/*.jar /app/ 8 | COPY config/run.sh /app/run.sh 9 | 10 | #创建启动脚本 11 | RUN chmod 777 /app/run.sh 12 | 13 | # 创建日志目录 14 | RUN mkdir /app/logs 15 | 16 | # 设置时区 17 | RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 18 | RUN echo "Asia/Shanghai" > /etc/timezone 19 | 20 | #执行命令 21 | ENTRYPOINT ["sh","/app/run.sh"] -------------------------------------------------------------------------------- /xfs-gateway/src/main/java/com/yyh/xfs/gateway/GatewayApplication.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.gateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * @author yyh 8 | * @date 2023-12-09 9 | */ 10 | @SpringBootApplication 11 | public class GatewayApplication { 12 | public static void main(String[] args) { 13 | SpringApplication.run(GatewayApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /xiaofanshu-amd.dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jdk-alpine 2 | MAINTAINER yyh 3 | EXPOSE 9000 4 | # 创建应用目录 5 | WORKDIR /app 6 | # 复制 JAR 包和启动脚本到容器中 7 | COPY jar/*.jar /app/ 8 | COPY config/run.sh /app/run.sh 9 | 10 | #创建启动脚本 11 | RUN chmod 777 /app/run.sh 12 | 13 | # 创建日志目录 14 | RUN mkdir /app/logs 15 | 16 | # 设置时区 17 | RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 18 | RUN echo "Asia/Shanghai" > /etc/timezone 19 | 20 | #执行命令 21 | ENTRYPOINT ["sh","/app/run.sh"] -------------------------------------------------------------------------------- /xfs-modules-server/xfs-user-server/src/main/java/com/yyh/xfs/user/UserApplication.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | /** 7 | * @author yyh 8 | * @date 2023-12-11 9 | */ 10 | @SpringBootApplication 11 | public class UserApplication { 12 | public static void main(String[] args) { 13 | SpringApplication.run(UserApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /config/run.sh: -------------------------------------------------------------------------------- 1 | # 定义 JAR 文件所在目录 2 | jar_directory="/app" 3 | 4 | # 循环启动每个 JAR 文件 5 | for jar_file in "$jar_directory"/*.jar 6 | do 7 | # 获取 JAR 文件名(不带路径) 8 | project=$(basename "$jar_file" .jar) 9 | 10 | echo "启动 $project..." 11 | java -Dfile.encoding=utf-8 -jar "$jar_file" --spring.cloud.nacos.config.server-addr="172.17.0.1:8848" > "$jar_directory/logs/$project.log" 2>&1 & 12 | echo "$project 已启动并输出到 $jar_directory/logs/$project.log" 13 | done 14 | 15 | echo "所有项目已启动。" 16 | 17 | # 保持容器运行 18 | wait -------------------------------------------------------------------------------- /xfs-modules-api/xfs-user-api/src/main/java/com/yyh/xfs/user/vo/UserTrtcVO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.vo; 2 | 3 | import lombok.Data; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-01-13 12 | */ 13 | @Data 14 | public class UserTrtcVO implements Serializable { 15 | private static final long serialVersionUID = 1L; 16 | private String userId; 17 | private long sdkAppId; 18 | private String userSig; 19 | } 20 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-user-server/src/main/java/com/yyh/xfs/user/mapper/UserBlackMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.yyh.xfs.user.domain.UserBlackDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2023-12-30 10 | */ 11 | @Mapper 12 | public interface UserBlackMapper extends BaseMapper { 13 | Boolean selectOneByUserIdAndBlackIdIsExist(Long userId, Long blackId); 14 | } 15 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-user-api/src/main/java/com/yyh/xfs/user/vo/UserBindThirdStateVO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.vo; 2 | 3 | import lombok.Data; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-02-20 12 | */ 13 | @Data 14 | public class UserBindThirdStateVO implements Serializable { 15 | private static final long serialVersionUID = 1L; 16 | private Boolean wechatBind; 17 | private Boolean qqBind; 18 | private Boolean facebookBind; 19 | } 20 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/service/UserSearchService.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.service; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import com.yyh.xfs.search.domain.UserEsDO; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2024-02-21 11 | */ 12 | public interface UserSearchService { 13 | Result> getUser(String keyword, Integer page, Integer pageSize); 14 | 15 | void addUser(UserEsDO userEsDO); 16 | 17 | void updateUser(UserEsDO userEsDO); 18 | } 19 | -------------------------------------------------------------------------------- /config/elasticsearch.yml: -------------------------------------------------------------------------------- 1 | #集群名称 2 | cluster.name: my-application 3 | #节点名称 4 | node.name: es-node-1 5 | #数据和日志的存储目录 6 | path.data: /usr/share/elasticsearch/data 7 | path.logs: /usr/share/elasticsearch/logs 8 | ##设置绑定的ip,设置为0.0.0.0以后就可以让任何计算机节点访问到了 9 | network.host: 0.0.0.0 10 | #端口 11 | http.port: 9200 12 | ##设置在集群中的所有节点名称,这个节点名称就是之前所修改的,当然你也可以采用默认的也行,目前 是单机,放入一个节点即可 13 | cluster.initial_master_nodes: ["es-node-1"] 14 | xpack.security.enabled: true 15 | xpack.license.self_generated.type: basic 16 | xpack.security.transport.ssl.enabled: true 17 | ingest.geoip.downloader.enabled: false -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/utils/TimeUtil.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.utils; 2 | 3 | import java.time.LocalDate; 4 | import java.time.Period; 5 | 6 | /** 7 | * @author yyh 8 | * @date 2023-12-22 9 | */ 10 | public class TimeUtil { 11 | public static int calculateAge(LocalDate birthDate) { 12 | LocalDate currentDate = LocalDate.now(); 13 | if (birthDate != null) { 14 | return Period.between(birthDate, currentDate).getYears(); 15 | } else { 16 | return 0; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-comment-server/src/main/java/com/yyh/xfs/comment/feign/NotesFeign.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.comment.feign; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RequestParam; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-02-11 10 | */ 11 | @FeignClient("xfs-notes") 12 | public interface NotesFeign { 13 | 14 | @GetMapping("/notes/getNotesBelongUser") 15 | Long getNotesBelongUser(@RequestParam("notesId") Long notesId); 16 | } 17 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/config/BaiduAiConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.config; 2 | 3 | import lombok.Getter; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-01-22 10 | */ 11 | @Configuration 12 | @Getter 13 | public class BaiduAiConfig { 14 | @Value("${baiduyun.ai.apiKey}") 15 | private String apiKey; 16 | 17 | @Value("${baiduyun.ai.secretKey}") 18 | private String secretKey; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/aop/idempotent/Idempotent.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.aop.idempotent; 2 | 3 | import java.lang.annotation.*; 4 | 5 | /** 6 | * @author yyh 7 | * @date 2024-02-26 8 | */ 9 | @Target({ElementType.METHOD}) 10 | @Retention(RetentionPolicy.RUNTIME) 11 | @Documented 12 | 13 | public @interface Idempotent { 14 | /** 15 | * 唯一标识 16 | * @return String 17 | */ 18 | String value() default ""; 19 | /** 20 | * 过期时间 21 | * @return long 单位毫秒 22 | */ 23 | long expireTime() default 1000; 24 | } 25 | -------------------------------------------------------------------------------- /xfs-gateway/src/main/java/com/yyh/xfs/gateway/properties/ReleasePath.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.gateway.properties; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author yyh 12 | * @date 2023-12-11 13 | * @desc 不需要token的路径 14 | */ 15 | @Component 16 | @Getter 17 | @Setter 18 | @ConfigurationProperties(prefix = "release.auth") 19 | public class ReleasePath { 20 | private List path; 21 | } 22 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/NotesApplication.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-01-19 10 | */ 11 | @SpringBootApplication 12 | @EnableFeignClients 13 | public class NotesApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(NotesApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /xfs-job-server/src/main/java/com/yyh/xfs/job/JobApplication.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.job; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2023-12-23 10 | */ 11 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 12 | public class JobApplication { 13 | public static void main(String[] args) { 14 | SpringApplication.run(JobApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-comment-server/src/main/java/com/yyh/xfs/comment/CommentApplication.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.comment; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-02-05 10 | */ 11 | @SpringBootApplication 12 | @EnableFeignClients 13 | public class CommentApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(CommentApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-comment-server/src/main/java/com/yyh/xfs/comment/feign/UserFeign.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.comment.feign; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2024-01-26 11 | */ 12 | @FeignClient("xfs-user") 13 | public interface UserFeign { 14 | 15 | @GetMapping("/user/getUserInfo") 16 | Result getUserInfo(@RequestParam("userId") Long userId); 17 | } 18 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/feign/UserFeign.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.feign; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2024-01-26 11 | */ 12 | @FeignClient("xfs-user") 13 | public interface UserFeign { 14 | 15 | @GetMapping("/user/getUserInfo") 16 | Result getUserInfo(@RequestParam("userId") Long userId); 17 | } 18 | -------------------------------------------------------------------------------- /xfs-third-server/src/main/java/com/yyh/xfs/third/sevice/AliyunOssService.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.third.sevice; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import org.springframework.web.multipart.MultipartFile; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2023-12-21 11 | */ 12 | public interface AliyunOssService { 13 | Result uploadImg(MultipartFile file); 14 | 15 | Result> uploadImgs(MultipartFile[] file); 16 | 17 | Result uploadAudio(MultipartFile file); 18 | 19 | Result uploadVideo(MultipartFile file); 20 | } 21 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/properties/GaoDeMapProperties.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.properties; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.boot.context.properties.ConfigurationProperties; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-02-03 12 | */ 13 | @Configuration 14 | @Getter 15 | @Setter 16 | @ConfigurationProperties(prefix = "gaode.map") 17 | public class GaoDeMapProperties { 18 | private String key; 19 | } 20 | -------------------------------------------------------------------------------- /xfs-auth/src/main/java/com/yyh/xfs/auth/AuthApplication.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.auth; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2023-12-09 10 | */ 11 | @SpringBootApplication 12 | @ComponentScan(basePackages = {"com.yyh.xfs.auth", "com.yyh.xfs.user", "com.yyh.xfs.common"}) 13 | public class AuthApplication { 14 | public static void main(String[] args) { 15 | SpringApplication.run(AuthApplication.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/properties/TrtcProperties.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.properties; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2024-01-13 11 | */ 12 | @Configuration 13 | @ConfigurationProperties(prefix = "tencentyun.trtc") 14 | @Getter 15 | @Setter 16 | public class TrtcProperties { 17 | private long sdkAppId; 18 | private String secretKey; 19 | private long expireTime; 20 | } 21 | -------------------------------------------------------------------------------- /xfs-common/common-redis/src/main/java/com/yyh/xfs/common/redis/constant/BloomFilterMap.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.redis.constant; 2 | 3 | /** 4 | * @author yyh 5 | * @date 2024-02-24 6 | */ 7 | public class BloomFilterMap { 8 | /** 9 | * 笔记id布隆过滤器 10 | */ 11 | public static final String NOTES_ID_BLOOM_FILTER = "notesIdBloomFilter"; 12 | /** 13 | * 用户id布隆过滤器 14 | */ 15 | public static final String USER_ID_BLOOM_FILTER = "userIdBloomFilter"; 16 | /** 17 | * rocketmq幂等布隆过滤器 18 | */ 19 | public static final String ROCKETMQ_IDEMPOTENT_BLOOM_FILTER = "rocketmqIdempotentBloomFilter"; 20 | } 21 | -------------------------------------------------------------------------------- /xfs-common/common-redis/src/main/java/com/yyh/xfs/common/redis/properties/RedisProperties.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.redis.properties; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.stereotype.Component; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-02-24 10 | */ 11 | @Data 12 | @Component 13 | @ConfigurationProperties(prefix = "spring.redis") 14 | public class RedisProperties { 15 | private String host; 16 | private int port; 17 | private String password; 18 | private int database; 19 | private int lockWatchdogTimeout; 20 | } 21 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-user-api/src/main/java/com/yyh/xfs/user/vo/RegisterInfoVO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.vo; 2 | 3 | import lombok.Data; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2023-12-12 12 | */ 13 | @Data 14 | public class RegisterInfoVO implements Serializable { 15 | private static final long serialVersionUID = 1L; 16 | private String phoneNumber; 17 | private String password; 18 | private String smsCode; 19 | private Integer registerType; 20 | private String openId; 21 | private String nickname; 22 | private String avatarUrl; 23 | } 24 | -------------------------------------------------------------------------------- /xfs-gateway/src/main/java/com/yyh/xfs/gateway/properties/JwtProperties.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.gateway.properties; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2023-12-11 11 | */ 12 | @Configuration 13 | @ConfigurationProperties(prefix = "jwt") 14 | @Getter 15 | @Setter 16 | public class JwtProperties { 17 | // 密钥 18 | private String secret; 19 | // token过期时间 20 | private long expireTime; 21 | // 剩余多久时间刷新token 22 | private long refreshTime; 23 | } 24 | -------------------------------------------------------------------------------- /config/broker.conf: -------------------------------------------------------------------------------- 1 | terName = DefaultCluster 2 | #broker名称,master和slave使用相同的名称,表明他们的主从关系 3 | autoCreateTopicEnable = true 4 | brokerName = broker-a 5 | #0表示Master,大于0表示不同的slave 6 | brokerId = 0 7 | #表示几点做消息删除动作,默认是凌晨4点 8 | deleteWhen = 04 9 | #在磁盘上保留消息的时长,单位是小时 10 | fileReservedTime = 48 11 | #有三个值:SYNC_MASTER,ASYNC_MASTER,SLAVE;同步和异步表示Master和Slave之间同步数据的机制; 12 | brokerRole = ASYNC_MASTER 13 | #刷盘策略,取值为:ASYNC_FLUSH,SYNC_FLUSH表示同步刷盘和异步刷盘;SYNC_FLUSH消息写入磁盘后才返回成功状态,ASYNC_FLUSH不需要; 14 | flushDiskType = ASYNC_FLUSH 15 | #ip为宿主机的ip,如192.168.12.17,不是docker容器的ip 16 | brokerIP1 = 127.0.0.1 17 | # 磁盘使用达到95%之后,生产者再写入消息会报错 CODE: 14 DESC: service not available now, maybe disk full 18 | diskMaxUsedSpaceRatio=95 -------------------------------------------------------------------------------- /xfs-third-server/src/main/java/com/yyh/xfs/third/sevice/AliyunSmsService.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.third.sevice; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | 5 | /** 6 | * @author yyh 7 | * @date 2023-12-15 8 | */ 9 | public interface AliyunSmsService { 10 | Result sendBindPhoneSms(String phoneNumber); 11 | 12 | Result sendResetPhoneSms(String phoneNumber); 13 | 14 | Result sendRegisterPhoneSms(String phoneNumber); 15 | 16 | Result checkResetSmsCode(String phoneNumber, String smsCode); 17 | 18 | Result checkBindSmsCode(String phoneNumber, String smsCode); 19 | 20 | Result sendLoginPhoneSms(String phoneNumber); 21 | } 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### 日志 ### 7 | logs 8 | 9 | ### IntelliJ IDEA ### 10 | .idea/modules.xml 11 | .idea/jarRepositories.xml 12 | .idea/compiler.xml 13 | .idea/libraries/ 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### Eclipse ### 19 | .apt_generated 20 | .classpath 21 | .factorypath 22 | .project 23 | .settings 24 | .springBeans 25 | .sts4-cache 26 | 27 | ### NetBeans ### 28 | /nbproject/private/ 29 | /nbbuild/ 30 | /dist/ 31 | /nbdist/ 32 | /.nb-gradle/ 33 | build/ 34 | !**/src/main/**/build/ 35 | !**/src/test/**/build/ 36 | 37 | ### VS Code ### 38 | .vscode/ 39 | 40 | ### Mac OS ### 41 | .DS_Store -------------------------------------------------------------------------------- /xfs-modules-api/xfs-user-api/src/main/java/com/yyh/xfs/user/vo/UserRelationVO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author yyh 7 | * @date 2024-01-15 8 | * @desc 用户关系视图对象 9 | */ 10 | @Data 11 | public class UserRelationVO { 12 | /** 13 | * 用户id 14 | */ 15 | private Long userId; 16 | 17 | /** 18 | * 用户昵称(当有备注时,显示备注) 19 | */ 20 | private String nickname; 21 | 22 | /** 23 | * 用户头像 24 | */ 25 | private String avatarUrl; 26 | 27 | /** 28 | * 用户简介 29 | */ 30 | private String selfIntroduction; 31 | 32 | /** 33 | * 是否为双向关系 34 | */ 35 | private Boolean bidirectional; 36 | } 37 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/test/java/com/yyh/xfs/search/SearchApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2024-01-24 11 | */ 12 | @SpringBootTest 13 | public class SearchApplicationTest { 14 | @Autowired 15 | private ElasticsearchRestTemplate elasticsearchRestTemplate; 16 | @Test 17 | void test1() { 18 | System.out.println(elasticsearchRestTemplate); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/properties/JwtProperties.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.properties; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2023-12-11 11 | * @desc jwt配置 12 | */ 13 | @Configuration 14 | @ConfigurationProperties(prefix = "jwt") 15 | @Getter 16 | @Setter 17 | 18 | public class JwtProperties { 19 | // 密钥 20 | private String secret; 21 | // token过期时间 22 | private long expireTime; 23 | // 剩余多久时间刷新token 24 | private long refreshTime; 25 | } 26 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/SearchApplication.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2024-01-24 11 | */ 12 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) 13 | @EnableFeignClients 14 | public class SearchApplication { 15 | public static void main(String[] args) { 16 | SpringApplication.run(SearchApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/resources/mapper/NotesTopicRelationMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, notes_id, topic_id 14 | 15 | 16 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/mapper/NotesCategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.yyh.xfs.notes.domain.NotesCategoryDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Select; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author yyh 12 | * @date 2024-01-22 13 | */ 14 | @Mapper 15 | public interface NotesCategoryMapper extends BaseMapper { 16 | 17 | /** 18 | * 获取笔记分类,去除id为1的默认分类,按照category_sort排序 19 | * @return 笔记分类 20 | */ 21 | @Select("select * from notes_category where id != 1 order by category_sort") 22 | List getNotesCategory(); 23 | } 24 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | com.yyh.xfs.common.web.config.FeignConfig,\ 3 | com.yyh.xfs.common.web.config.WebMvcConfig,\ 4 | com.yyh.xfs.common.web.config.SwaggerConfig,\ 5 | com.yyh.xfs.common.web.config.ThreadPoolConfig,\ 6 | com.yyh.xfs.common.web.utils.JWTUtil,\ 7 | com.yyh.xfs.common.web.utils.AddressUtil,\ 8 | com.yyh.xfs.common.web.properties.JwtProperties,\ 9 | com.yyh.xfs.common.web.properties.TrtcProperties,\ 10 | com.yyh.xfs.common.web.properties.GaoDeMapProperties,\ 11 | com.yyh.xfs.common.web.aop.bloomFilter.BloomFilterAspect,\ 12 | com.yyh.xfs.common.web.aop.idempotent.IdempotentAspect,\ 13 | com.yyh.xfs.common.web.exception.handler.GlobalExceptionHandler -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/exception/OnlyWarnException.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.exception; 2 | 3 | import com.yyh.xfs.common.myEnum.ExceptionMsgEnum; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import lombok.ToString; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2023-12-23 11 | */ 12 | @Getter 13 | @Setter 14 | @ToString 15 | public class OnlyWarnException extends RuntimeException{ 16 | private ExceptionMsgEnum exceptionMsgEnum; 17 | public OnlyWarnException(ExceptionMsgEnum exceptionMsgEnum) { 18 | this.exceptionMsgEnum=exceptionMsgEnum; 19 | } 20 | public OnlyWarnException(ExceptionMsgEnum exceptionMsgEnum,Throwable e){ 21 | super(e); 22 | this.exceptionMsgEnum=exceptionMsgEnum; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /xfs-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | xiaofanshu 9 | 1.0-SNAPSHOT 10 | 11 | xfs-common 12 | pom 13 | 14 | common-web 15 | common-base 16 | common-mybatis 17 | common-redis 18 | 19 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-notes-api/src/main/java/com/yyh/xfs/notes/domain/NotesTopicRelationDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableId; 4 | import com.baomidou.mybatisplus.annotation.TableName; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-01-22 12 | */ 13 | @Data 14 | @TableName("notes_topic_relation") 15 | public class NotesTopicRelationDO implements Serializable { 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | @TableId 20 | private Long id; 21 | 22 | /** 23 | * 笔记id 24 | */ 25 | private Long notesId; 26 | 27 | /** 28 | * 话题id 29 | */ 30 | private Long topicId; 31 | } 32 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/exception/SystemException.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.exception; 2 | 3 | import com.yyh.xfs.common.myEnum.ExceptionMsgEnum; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import lombok.ToString; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2023-12-15 11 | * @desc 系统异常 12 | */ 13 | @Getter 14 | @Setter 15 | @ToString 16 | public class SystemException extends RuntimeException{ 17 | private ExceptionMsgEnum exceptionMsgEnum; 18 | public SystemException(ExceptionMsgEnum exceptionMsgEnum) { 19 | this.exceptionMsgEnum=exceptionMsgEnum; 20 | } 21 | public SystemException(ExceptionMsgEnum exceptionMsgEnum,Throwable e){ 22 | super(e); 23 | this.exceptionMsgEnum=exceptionMsgEnum; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-notes-api/src/main/java/com/yyh/xfs/notes/domain/UserLikeNotesDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableId; 4 | import com.baomidou.mybatisplus.annotation.TableName; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | /** 11 | * @author yyh 12 | * @date 2024-01-28 13 | */ 14 | @Data 15 | @TableName("user_like_notes") 16 | public class UserLikeNotesDO implements Serializable { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | @TableId 21 | private Long id; 22 | 23 | /** 24 | * 用户id 25 | */ 26 | private Long userId; 27 | 28 | /** 29 | * 笔记id 30 | */ 31 | private Long notesId; 32 | 33 | private Date createTime; 34 | } 35 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.exception; 2 | 3 | import com.yyh.xfs.common.myEnum.ExceptionMsgEnum; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import lombok.ToString; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2023-12-15 11 | * @desc 业务异常类 12 | */ 13 | @Getter 14 | @Setter 15 | @ToString 16 | public class BusinessException extends RuntimeException{ 17 | private ExceptionMsgEnum exceptionMsgEnum; 18 | public BusinessException(ExceptionMsgEnum exceptionMsgEnum) { 19 | this.exceptionMsgEnum=exceptionMsgEnum; 20 | } 21 | public BusinessException(ExceptionMsgEnum exceptionMsgEnum,Throwable e){ 22 | super(e); 23 | this.exceptionMsgEnum=exceptionMsgEnum; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/config/FeignConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.config; 2 | 3 | import feign.RequestInterceptor; 4 | import feign.RequestTemplate; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2023-12-11 12 | */ 13 | @Configuration 14 | public class FeignConfig implements RequestInterceptor { 15 | private final HttpServletRequest request; 16 | 17 | public FeignConfig(HttpServletRequest request) { 18 | this.request = request; 19 | } 20 | 21 | @Override 22 | public void apply(RequestTemplate requestTemplate) { 23 | String token = request.getHeader("token"); 24 | requestTemplate.header("token",token); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-notes-api/src/main/java/com/yyh/xfs/notes/vo/NotesPublishVO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-01-22 10 | */ 11 | @Data 12 | public class NotesPublishVO implements Serializable { 13 | private static final long serialVersionUID = 1L; 14 | private Long notesId; 15 | private String title; 16 | private String realContent; 17 | private String content; 18 | private Integer belongCategory; 19 | private Long belongUserId; 20 | private Integer notesType; 21 | private String coverPicture; 22 | private String notesResources; 23 | private String address; 24 | private Double longitude; 25 | private Double latitude; 26 | private Integer authority; 27 | } 28 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-user-server/src/main/java/com/yyh/xfs/user/mapper/UserFansMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.yyh.xfs.user.domain.UserFansDO; 5 | import com.yyh.xfs.user.vo.UserRelationVO; 6 | import com.yyh.xfs.user.vo.ViewUserVO; 7 | import org.apache.ibatis.annotations.Mapper; 8 | import org.apache.ibatis.annotations.Select; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2023-12-30 15 | */ 16 | @Mapper 17 | public interface UserFansMapper extends BaseMapper { 18 | 19 | @Select("select count(*) from user_fans where user_id=#{userId}") 20 | Integer getCountById(Long userId); 21 | 22 | List selectFansList(Long userId, Integer offset, Integer pageSize); 23 | } 24 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-notes-api/src/main/java/com/yyh/xfs/notes/domain/UserViewsRecordNotesDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableId; 4 | import com.baomidou.mybatisplus.annotation.TableName; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | /** 11 | * @author yyh 12 | * @date 2024-01-28 13 | */ 14 | @Data 15 | @TableName("user_views_record_notes") 16 | public class UserViewsRecordNotesDO implements Serializable { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | @TableId 21 | private Long id; 22 | 23 | /** 24 | * 用户id 25 | */ 26 | private Long userId; 27 | 28 | /** 29 | * 笔记id 30 | */ 31 | private Long notesId; 32 | 33 | private Date createTime; 34 | } 35 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/resources/mapper/UserLikeNotesMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, user_id, notes_id, create_time 14 | 15 | 16 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-user-api/src/main/java/com/yyh/xfs/user/vo/ViewUserVO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.vo; 2 | import lombok.Data; 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2024-01-15 11 | */ 12 | @Data 13 | public class ViewUserVO implements Serializable { 14 | private static final long serialVersionUID = 1L; 15 | private Long id; 16 | private String uid; 17 | private String nickname; 18 | private String avatarUrl; 19 | private Integer age; 20 | private Integer sex; 21 | private String area; 22 | private String birthday; 23 | private String selfIntroduction; 24 | private String homePageBackground; 25 | private Integer attentionNum; 26 | private Integer fansNum; 27 | private Integer attentionStatus; 28 | } 29 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/resources/mapper/UserCollectNotesMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, user_id, notes_id, create_time 14 | 15 | 16 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-notes-api/src/main/java/com/yyh/xfs/notes/domain/UserCollectNotesDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableId; 4 | import com.baomidou.mybatisplus.annotation.TableName; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | import java.util.Date; 9 | 10 | /** 11 | * @author yyh 12 | * @date 2024-01-28 13 | */ 14 | @Data 15 | @TableName("user_collect_notes") 16 | public class UserCollectNotesDO implements Serializable { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | @TableId 21 | private Long id; 22 | /** 23 | * 用户id 24 | */ 25 | private Long userId; 26 | 27 | /** 28 | * 笔记id 29 | */ 30 | private Long notesId; 31 | 32 | /** 33 | * 创建时间 34 | */ 35 | private Date createTime; 36 | } 37 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/resources/mapper/NotesCategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, category_name, category_sort, icon 14 | 15 | 16 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-user-api/src/main/java/com/yyh/xfs/user/domain/UserFansDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2023-12-30 15 | */ 16 | @Data 17 | @TableName("user_fans") 18 | public class UserFansDO implements Serializable { 19 | @TableField(exist = false) 20 | private static final long serialVersionUID = 1L; 21 | @TableId(type = IdType.AUTO) 22 | private Long id; 23 | 24 | private Long userId; 25 | 26 | private Long fansId; 27 | 28 | private Date createTime; 29 | } 30 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/resources/mapper/UserViewsRecordNotesMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | id, user_id, notes_id, create_time 14 | 15 | 16 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/service/NotesSearchService.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.service; 2 | 3 | import com.yyh.xfs.common.domain.PageParam; 4 | import com.yyh.xfs.common.domain.Result; 5 | import com.yyh.xfs.notes.domain.NotesDO; 6 | import com.yyh.xfs.notes.vo.NotesPageVO; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author yyh 12 | * @date 2024-01-24 13 | */ 14 | public interface NotesSearchService { 15 | void addNotes(NotesDO notesDO); 16 | 17 | Result getNotesNearBy(PageParam pageParam); 18 | 19 | void updateNotes(NotesDO notesDO); 20 | 21 | void deleteNotes(Long notesId); 22 | 23 | Result getNotesByKeyword(String keyword, Integer page, Integer pageSize, Integer noteType, Integer hot); 24 | 25 | void updateCount(Map map); 26 | } 27 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-user-api/src/main/java/com/yyh/xfs/user/domain/UserBlackDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2023-12-30 15 | */ 16 | @Data 17 | @TableName("user_black_list") 18 | public class UserBlackDO implements Serializable { 19 | @TableField(exist = false) 20 | private static final long serialVersionUID = 1L; 21 | @TableId(type = IdType.AUTO) 22 | private Long id; 23 | 24 | private Long userId; 25 | 26 | private Long blackId; 27 | 28 | private Date createTime; 29 | } 30 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-im-server/src/test/java/com/yyh/xfs/im/IMApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.im; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.data.mongodb.core.MongoTemplate; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2023-12-25 15 | */ 16 | @SpringBootTest 17 | public class IMApplicationTest { 18 | @Autowired 19 | private MongoTemplate mongoTemplate; 20 | @Test 21 | void test1() { 22 | System.out.println("IMApplicationTest"); 23 | } 24 | 25 | @Test 26 | void test2() { 27 | System.out.println(Runtime.getRuntime().availableProcessors()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-im-server/src/main/java/com/yyh/xfs/im/handler/types/AttentionHandler.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.im.handler.types; 2 | 3 | import com.yyh.xfs.im.vo.MessageVO; 4 | import io.netty.channel.Channel; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.stereotype.Component; 7 | import static com.yyh.xfs.im.handler.IMServerHandler.USER_CHANNEL_MAP; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-01-16 12 | */ 13 | @Component 14 | @Slf4j 15 | public class AttentionHandler { 16 | private final ChatHandler chatHandler; 17 | 18 | public AttentionHandler(ChatHandler chatHandler) { 19 | this.chatHandler = chatHandler; 20 | } 21 | 22 | public void execute(MessageVO messageVO) { 23 | Channel channel = USER_CHANNEL_MAP.get(messageVO.getTo()); 24 | chatHandler.sendMessage(channel, messageVO); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-comment-api/src/main/java/com/yyh/xfs/comment/vo/CommentVO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.comment.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2024-02-05 10 | */ 11 | @Data 12 | public class CommentVO implements Serializable { 13 | private String id; 14 | private String content; 15 | private String province; 16 | private Long commentUserId; 17 | private String commentUserName; 18 | private String commentUserAvatar; 19 | private String parentId; 20 | private Long replyUserId; 21 | private String replyUserName; 22 | private String pictureUrl; 23 | private Integer commentLikeNum; 24 | // 评论回复数,只在为一级评论时有效 25 | private Integer commentReplyNum; 26 | private Long notesId; 27 | private Boolean isTop; 28 | private Boolean isLike; 29 | private Long createTime; 30 | } 31 | -------------------------------------------------------------------------------- /xfs-common/common-mybatis/src/main/java/com/yyh/xfs/common/mybatis/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.mybatis.config; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 4 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2023-12-09 11 | */ 12 | @Configuration 13 | public class MybatisPlusConfig { 14 | 15 | /** 16 | * 配置分页插件 17 | */ 18 | @Bean 19 | public MybatisPlusInterceptor mybatisPlusInterceptor(){ 20 | MybatisPlusInterceptor mybatisPlusInterceptor=new MybatisPlusInterceptor(); 21 | mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor()); 22 | return mybatisPlusInterceptor; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/resources/mapper/NotesTopicMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | id, topic_name, topic_desc, create_time, create_user 16 | 17 | 18 | -------------------------------------------------------------------------------- /xfs-third-server/src/main/java/com/yyh/xfs/third/config/AliyunOss.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.third.config; 2 | 3 | import lombok.Getter; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author yyh 10 | * @date 2023-12-21 11 | */ 12 | @Configuration 13 | @Slf4j 14 | @Getter 15 | public class AliyunOss { 16 | @Value("${aliyun.oss.endpoint}") 17 | private String endpoint; 18 | @Value("${aliyun.oss.accessKeyId}") 19 | private String accessKeyId; 20 | @Value("${aliyun.oss.accessKeySecret}") 21 | private String accessKeySecret; 22 | @Value("${aliyun.oss.bucketName}") 23 | private String bucketName; 24 | @Value("${spring.servlet.multipart.max-file-size}") 25 | private String maxFileSize; 26 | @Value("${spring.servlet.multipart.max-request-size}") 27 | private String maxRequestSize; 28 | } 29 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/feign/UserFeign.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.feign; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author yyh 12 | * @date 2024-01-26 13 | */ 14 | @FeignClient("xfs-user") 15 | public interface UserFeign { 16 | 17 | @GetMapping("/user/getUserInfo") 18 | Result getUserInfo(@RequestParam("userId") Long userId); 19 | 20 | @GetMapping("/user/relation/isAttention") 21 | Result selectOneByUserIdAndAttentionIdIsExist(@RequestParam("toId") Long toId, @RequestParam("fromId") Long fromId); 22 | 23 | @GetMapping("/user/relation/getAttentionUserId") 24 | Result> getAttentionUserId(@RequestParam("userId") Long userId); 25 | } 26 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-user-api/src/main/java/com/yyh/xfs/user/domain/UserAttentionDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import io.swagger.annotations.ApiModel; 8 | import lombok.Data; 9 | 10 | import java.io.Serializable; 11 | import java.util.Date; 12 | 13 | /** 14 | * @author yyh 15 | * @date 2023-12-30 16 | */ 17 | @Data 18 | @TableName("user_attention") 19 | public class UserAttentionDO implements Serializable { 20 | @TableField(exist = false) 21 | private static final long serialVersionUID = 1L; 22 | 23 | @TableId(type = IdType.AUTO) 24 | private Long id; 25 | 26 | private Long userId; 27 | 28 | private Long attentionId; 29 | private String remarkName; 30 | 31 | private Date createTime; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/utils/FieldValidationUtil.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.utils; 2 | 3 | /** 4 | * @author yyh 5 | * @date 2023-12-11 6 | */ 7 | public class FieldValidationUtil { 8 | /** 9 | * 判断是否是手机号 10 | * @param phoneNumber 手机号 11 | * @return 是否是手机号 12 | */ 13 | public static boolean isPhoneNumber(String phoneNumber) { 14 | return phoneNumber.matches("^1[3-9]\\d{9}$"); 15 | } 16 | 17 | /** 18 | * 判断密码是否合法,密码长度为6-16位,必须包含数字和字母,可以包含特殊字符 19 | * @param password 密码 20 | * @return 是否合法 21 | */ 22 | public static boolean isPassword(String password) { 23 | return password.matches("^(?=.*[0-9])(?=.*[a-zA-Z])(.{6,16})$"); 24 | } 25 | 26 | /** 27 | * 判断验证码格式是否正确,验证码为6位数字组成的字符串 28 | * @param smsCode 验证码 29 | * @return 是否合法 30 | */ 31 | public static boolean isSmsCode(String smsCode) { 32 | return smsCode.matches("^\\d{6}$"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-comment-server/src/test/java/com/yyh/xfs/comment/CommentApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.comment; 2 | 3 | import com.yyh.xfs.comment.domain.CommentDO; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.data.mongodb.core.MongoTemplate; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-02-05 12 | */ 13 | @SpringBootTest 14 | public class CommentApplicationTest { 15 | @Autowired 16 | private MongoTemplate mongoTemplate; 17 | @Test 18 | void test1() { 19 | CommentDO commentDO = new CommentDO(); 20 | commentDO.setCommentUserId(234343242L); 21 | commentDO.setNotesId(234343242L); 22 | commentDO.setContent("test"); 23 | mongoTemplate.insert(commentDO); 24 | System.out.println(commentDO.getId()); 25 | System.out.println(commentDO); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-notes-api/src/main/java/com/yyh/xfs/notes/domain/NotesCategoryDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableId; 4 | import com.baomidou.mybatisplus.annotation.TableName; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | * @author yyh 13 | * @date 2024-01-22 14 | */ 15 | 16 | @Data 17 | @TableName("notes_category") 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | public class NotesCategoryDO implements Serializable { 21 | 22 | private static final long serialVersionUID = 1L; 23 | 24 | /** 25 | * 分类id 26 | */ 27 | @TableId 28 | private Integer id; 29 | 30 | /** 31 | * 分类名称 32 | */ 33 | private String categoryName; 34 | 35 | /** 36 | * 排序,越大越靠前 37 | */ 38 | private Integer categorySort; 39 | 40 | /** 41 | * 图标 42 | */ 43 | private String icon; 44 | } 45 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-comment-server/src/main/java/com/yyh/xfs/comment/service/CommentService.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.comment.service; 2 | 3 | import com.yyh.xfs.comment.domain.CommentDO; 4 | import com.yyh.xfs.comment.vo.CommentVO; 5 | import com.yyh.xfs.common.domain.Result; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-02-05 12 | */ 13 | public interface CommentService { 14 | Result addComment(CommentDO commentDO); 15 | 16 | Result getCommentCount(Long notesId); 17 | 18 | Result> getCommentFirstList(Long notesId, Integer page, Integer pageSize); 19 | 20 | Result> getCommentSecondList(Long notesId,String parentId, Integer page, Integer pageSize); 21 | 22 | Result praiseComment(String commentId, Long userId, Long targetUserId); 23 | 24 | Result setTopComment(String commentId); 25 | 26 | Result deleteComment(String commentId); 27 | 28 | void deleteCommentByNotesId(Long notesId); 29 | } 30 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-user-server/src/main/java/com/yyh/xfs/user/service/UserRelationService.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.service; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import com.yyh.xfs.user.vo.UserRelationVO; 5 | import com.yyh.xfs.user.vo.ViewUserVO; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-01-15 12 | */ 13 | public interface UserRelationService { 14 | Result selectOneByUserIdAndBlackIdIsExist(Long toId, Long fromId); 15 | 16 | Result selectOneByUserIdAndAttentionIdIsExist(Long toId, Long fromId); 17 | 18 | Result> selectAttentionList(Long userId, Integer pageNum, Integer pageSize); 19 | 20 | Result> selectFansList(Long userId, Integer pageNum, Integer pageSize); 21 | 22 | Result attention(Long userId, Long targetUserId); 23 | 24 | Result updateRemarkName(Long userId, Long targetUserId, String remarkName); 25 | 26 | Result> getAttentionUserId(Long userId); 27 | } 28 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-user-server/src/main/resources/mapper/UserBlackMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 23 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-im-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | xfs-modules-api 9 | 1.0-SNAPSHOT 10 | 11 | 12 | xfs-im-api 13 | 14 | 15 | 8 16 | 8 17 | UTF-8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-data-mongodb 23 | 24 | 25 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-notes-api/src/main/java/com/yyh/xfs/notes/vo/NotesVO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.vo; 2 | 3 | import com.yyh.xfs.notes.dto.ResourcesDTO; 4 | import lombok.Data; 5 | import java.io.Serializable; 6 | import java.util.Date; 7 | import java.util.List; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-01-26 12 | */ 13 | @Data 14 | public class NotesVO implements Serializable { 15 | private Long id; 16 | private String title; 17 | private String content; 18 | private String coverPicture; 19 | private String nickname; 20 | private String avatarUrl; 21 | private Long belongUserId; 22 | private Integer notesLikeNum; 23 | private Integer notesCollectNum; 24 | private Integer notesViewNum; 25 | private Integer notesType; 26 | private Boolean isLike; 27 | private Boolean isCollect; 28 | private Boolean isFollow; 29 | private List notesResources; 30 | private String address; 31 | private String province; 32 | private Date createTime; 33 | private Date updateTime; 34 | } 35 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-comment-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | xfs-modules-api 9 | 1.0-SNAPSHOT 10 | 11 | 12 | xfs-comment-api 13 | 14 | 15 | 8 16 | 8 17 | UTF-8 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-data-mongodb 23 | 24 | 25 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-search-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | xfs-modules-api 9 | 1.0-SNAPSHOT 10 | 11 | 12 | xfs-search-api 13 | 14 | 15 | 8 16 | 8 17 | UTF-8 18 | 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-data-elasticsearch 24 | 25 | 26 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-user-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | xfs-modules-api 9 | 1.0-SNAPSHOT 10 | 11 | 12 | xfs-user-api 13 | 14 | 15 | 8 16 | 8 17 | UTF-8 18 | 19 | 20 | 21 | 22 | org.example 23 | common-mybatis 24 | 1.0-SNAPSHOT 25 | 26 | 27 | -------------------------------------------------------------------------------- /xfs-common/common-mybatis/src/main/java/com/yyh/xfs/common/mybatis/handler/MyMetaObjectHandler.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.mybatis.handler; 2 | 3 | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; 4 | import org.apache.ibatis.reflection.MetaObject; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2023-12-09 12 | */ 13 | @Configuration 14 | public class MyMetaObjectHandler implements MetaObjectHandler { 15 | @Override 16 | public void insertFill(MetaObject metaObject) { 17 | 18 | if (metaObject.hasGetter("createTime")) { 19 | metaObject.setValue("createTime", new Date()); 20 | } 21 | if (metaObject.hasGetter("updateTime")) { 22 | metaObject.setValue("updateTime", new Date()); 23 | } 24 | } 25 | 26 | @Override 27 | public void updateFill(MetaObject metaObject) { 28 | if(metaObject.hasGetter("updateTime")) { 29 | metaObject.setValue("updateTime", new Date()); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /xfs-modules-api/xfs-notes-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | xfs-modules-api 9 | 1.0-SNAPSHOT 10 | 11 | 12 | xfs-notes-api 13 | 14 | 15 | 8 16 | 8 17 | UTF-8 18 | 19 | 20 | 21 | 22 | org.example 23 | common-mybatis 24 | 1.0-SNAPSHOT 25 | 26 | 27 | -------------------------------------------------------------------------------- /xfs-modules-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | xiaofanshu 9 | 1.0-SNAPSHOT 10 | 11 | 12 | xfs-modules-server 13 | pom 14 | 15 | xfs-user-server 16 | xfs-im-server 17 | xfs-notes-server 18 | xfs-search-server 19 | xfs-comment-server 20 | 21 | 22 | 23 | 8 24 | 8 25 | UTF-8 26 | 27 | 28 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-notes-api/src/main/java/com/yyh/xfs/notes/domain/NotesTopicDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.FieldFill; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2024-01-22 15 | */ 16 | @Data 17 | @TableName("notes_topic") 18 | public class NotesTopicDO implements Serializable { 19 | 20 | private static final long serialVersionUID = 1L; 21 | 22 | /** 23 | * 话题id 24 | */ 25 | @TableId 26 | private Long id; 27 | 28 | /** 29 | * 话题名称 30 | */ 31 | private String topicName; 32 | 33 | /** 34 | * 话题描述 35 | */ 36 | private String topicDesc; 37 | 38 | /** 39 | * 创建时间 40 | */ 41 | @TableField(fill = FieldFill.INSERT) 42 | private Date createTime; 43 | 44 | /** 45 | * 创建人 46 | */ 47 | private Long createUser; 48 | } 49 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-im-api/src/main/java/com/yyh/xfs/im/domain/MessageDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.im.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.springframework.data.mongodb.core.mapping.Document; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * @author yyh 12 | * @date 2023-12-25 13 | */ 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @Document(value = "message") 18 | public class MessageDO implements Serializable { 19 | /** 20 | * 发送者id 21 | */ 22 | private String from; 23 | /** 24 | * 接收者id 25 | */ 26 | private String to; 27 | /** 28 | * 消息内容 29 | */ 30 | private String content; 31 | /** 32 | * 发送时间 33 | */ 34 | private Long time; 35 | /** 36 | * 0:不是聊天信息 37 | * 1:文本信息 38 | * 2:图片信息 39 | * 3:文件信息 40 | * 4:语音信息 41 | */ 42 | private Integer chatType; 43 | /** 44 | * 0:好友消息 45 | * 1:陌生人消息 46 | */ 47 | private Integer friendType; 48 | /** 49 | * 语音时长,单位秒 50 | */ 51 | private Integer audioTime; 52 | } 53 | -------------------------------------------------------------------------------- /xfs-gateway/src/main/java/com/yyh/xfs/gateway/utils/JWTUtil.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.gateway.utils; 2 | 3 | import com.yyh.xfs.gateway.properties.JwtProperties; 4 | import io.jsonwebtoken.Jwts; 5 | import io.jsonwebtoken.SignatureAlgorithm; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import java.util.Map; 10 | 11 | /** 12 | * @author yyh 13 | * @date 2023-12-09 14 | */ 15 | @Configuration 16 | public class JWTUtil { 17 | 18 | private static JwtProperties jwtProperties; 19 | 20 | @Autowired 21 | private void setJwtProperties(JwtProperties jwtProperties) { 22 | JWTUtil.jwtProperties = jwtProperties; 23 | } 24 | public static String createToken(Map claims){ 25 | return Jwts.builder() 26 | .setClaims(claims) 27 | .signWith(SignatureAlgorithm.HS512,jwtProperties.getSecret()).compact(); 28 | } 29 | 30 | public static Map parseToken(String token){ 31 | return Jwts.parser().setSigningKey(jwtProperties.getSecret()).parseClaimsJws(token).getBody(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-im-server/src/main/java/com/yyh/xfs/im/config/ImConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.im.config; 2 | 3 | import com.yyh.xfs.common.redis.constant.BloomFilterMap; 4 | import com.yyh.xfs.common.redis.utils.BloomFilterUtils; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import javax.annotation.PostConstruct; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-02-25 12 | */ 13 | @Configuration 14 | public class ImConfig { 15 | private final BloomFilterUtils bloomFilterUtils; 16 | 17 | public ImConfig(BloomFilterUtils bloomFilterUtils) { 18 | this.bloomFilterUtils = bloomFilterUtils; 19 | } 20 | 21 | /** 22 | * 初始化布隆过滤器 23 | */ 24 | @PostConstruct 25 | public void initBloomFilter() { 26 | // 先判断有没有该布隆过滤器,没有则初始化 27 | long expectedInsertionsBloomFilter = bloomFilterUtils.getExpectedInsertionsBloomFilter(BloomFilterMap.ROCKETMQ_IDEMPOTENT_BLOOM_FILTER); 28 | if (expectedInsertionsBloomFilter > 0) { 29 | return; 30 | } 31 | bloomFilterUtils.initBloomFilter(BloomFilterMap.ROCKETMQ_IDEMPOTENT_BLOOM_FILTER, 100000, 0.01); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-search-api/src/main/java/com/yyh/xfs/search/domain/UserEsDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.springframework.data.annotation.Id; 7 | import org.springframework.data.elasticsearch.annotations.Document; 8 | import org.springframework.data.elasticsearch.annotations.Field; 9 | import org.springframework.data.elasticsearch.annotations.FieldType; 10 | 11 | /** 12 | * @author yyh 13 | * @date 2024-02-21 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Document(indexName = "user") 19 | public class UserEsDO { 20 | @Id 21 | @Field(type = FieldType.Long) 22 | private Long id; 23 | 24 | /** 25 | * 用户名 26 | */ 27 | @Field(type = FieldType.Text, analyzer = "ik_smart",searchAnalyzer = "ik_smart") 28 | private String nickname; 29 | 30 | /** 31 | * 用户头像 32 | */ 33 | @Field(type = FieldType.Text) 34 | private String avatarUrl; 35 | 36 | /** 37 | * 用户小番薯号 38 | */ 39 | @Field(type = FieldType.Text) 40 | private String uid; 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/controller/NotesCategoryController.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.controller; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import com.yyh.xfs.notes.domain.NotesCategoryDO; 5 | import com.yyh.xfs.notes.service.NotesCategoryService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @author yyh 15 | * @date 2024-02-23 16 | */ 17 | @RestController 18 | @RequestMapping("/notes/category") 19 | public class NotesCategoryController { 20 | private final NotesCategoryService notesCategoryService; 21 | 22 | public NotesCategoryController(NotesCategoryService notesCategoryService) { 23 | this.notesCategoryService = notesCategoryService; 24 | } 25 | 26 | @GetMapping("/getNotesCategoryList") 27 | public Result> getNotesCategory() { 28 | return notesCategoryService.getNotesCategory(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /xfs-common/common-mybatis/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | xfs-common 9 | 1.0-SNAPSHOT 10 | 11 | 12 | common-mybatis 13 | 14 | 15 | 8 16 | 8 17 | UTF-8 18 | 19 | 20 | 21 | 22 | mysql 23 | mysql-connector-java 24 | 25 | 26 | com.baomidou 27 | mybatis-plus-boot-starter 28 | 29 | 30 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 20 | 22 | 23 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-im-server/src/main/java/com/yyh/xfs/im/IMApplication.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.im; 2 | 3 | import com.yyh.xfs.common.web.config.FeignConfig; 4 | import com.yyh.xfs.im.server.IMServer; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | import org.springframework.cloud.openfeign.EnableFeignClients; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2023-12-24 15 | * @desc im启动类 16 | * 排除FeignConfig.class,因为websocket无法获取header,所以需要在参数中传递,不需要FeignConfig.class 17 | */ 18 | @SpringBootApplication(exclude = {FeignConfig.class}) 19 | @EnableFeignClients 20 | public class IMApplication implements CommandLineRunner { 21 | @Autowired 22 | private IMServer imServer; 23 | public static void main(String[] args) { 24 | SpringApplication.run(IMApplication.class, args); 25 | } 26 | /** 27 | * 项目启动后执行 28 | */ 29 | @Override 30 | public void run(String... args) { 31 | // 启动netty 32 | imServer.start(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/constant/RocketMQTopicConstant.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.constant; 2 | 3 | /** 4 | * @author yyh 5 | * @date 2024-02-25 6 | */ 7 | public class RocketMQTopicConstant { 8 | public static final String NOTES_DELETE_COMMENT_TOPIC = "notes-delete-comment-topic"; 9 | public static final String FIND_USER_TOPIC = "find-user-topic"; 10 | public static final String PRAISE_AND_COLLECT_REMIND_TOPIC = "notes-praiseAndCollect-remind-topic"; 11 | public static final String NOTES_REMIND_TARGET_TOPIC = "notes-remind-target-topic"; 12 | public static final String NOTES_REMOVE_REDIS_TOPIC = "notes-remove-redis-topic"; 13 | public static final String NOTES_ADD_ES_TOPIC = "notes-add-es-topic"; 14 | public static final String NOTES_DELETE_ES_TOPIC = "notes-delete-es-topic"; 15 | public static final String NOTES_UPDATE_ES_TOPIC = "notes-update-es-topic"; 16 | public static final String NOTES_UPDATE_COUNT_TOPIC = "notes-update-count-topic"; 17 | public static final String USER_ADD_ES_TOPIC = "user-add-es-topic"; 18 | public static final String USER_UPDATE_ES_TOPIC = "user-update-es-topic"; 19 | public static final String NOTES_ADD_TRANSACTION_TOPIC = "notes-add-transaction-topic"; 20 | } 21 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/service/impl/NotesCategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.yyh.xfs.common.domain.Result; 5 | import com.yyh.xfs.common.utils.ResultUtil; 6 | import com.yyh.xfs.notes.domain.NotesCategoryDO; 7 | import com.yyh.xfs.notes.mapper.NotesCategoryMapper; 8 | import com.yyh.xfs.notes.service.NotesCategoryService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * @author yyh 16 | * @date 2024-02-23 17 | */ 18 | @Service 19 | public class NotesCategoryServiceImpl implements NotesCategoryService { 20 | private final NotesCategoryMapper notesCategoryMapper; 21 | 22 | public NotesCategoryServiceImpl(NotesCategoryMapper notesCategoryMapper) { 23 | this.notesCategoryMapper = notesCategoryMapper; 24 | } 25 | 26 | @Override 27 | public Result> getNotesCategory() { 28 | List notesCategoryList = notesCategoryMapper.getNotesCategory(); 29 | return ResultUtil.successGet(notesCategoryList); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/myEnum/MessageTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.myEnum; 2 | 3 | import lombok.Getter; 4 | import lombok.ToString; 5 | 6 | /** 7 | * @author yyh 8 | * @date 2023-12-25 9 | */ 10 | @Getter 11 | @ToString 12 | public class MessageTypeEnum { 13 | /** 14 | * 0:连接信息 15 | * 1:心跳信息 16 | * 2:系统信息 17 | * 3:聊天信息 18 | * 4:新增关注信息 19 | * 5:服务器应答信息 20 | */ 21 | public static final Integer CONNECT_MESSAGE = 0; 22 | public static final Integer HEART_MESSAGE = 1; 23 | public static final Integer SYSTEM_MESSAGE = 2; 24 | public static final Integer CHAT_MESSAGE = 3; 25 | public static final Integer FOLLOW_MESSAGE = 4; 26 | public static final Integer SERVER_ANSWER_MESSAGE = 5; 27 | /** 28 | * 0:不是聊天信息 29 | * 1:文本信息 30 | * 2:图片信息 31 | * 3:文件信息 32 | */ 33 | public static final Integer NOT_CHAT_MESSAGE = 0; 34 | public static final Integer TEXT_MESSAGE = 1; 35 | public static final Integer IMAGE_MESSAGE = 2; 36 | public static final Integer FILE_MESSAGE = 3; 37 | /** 38 | * 0:好友消息 39 | * 1:陌生人消息 40 | */ 41 | public static final Integer FRIEND_MESSAGE = 0; 42 | public static final Integer STRANGER_MESSAGE = 1; 43 | } 44 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/consumer/RemoveCacheConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.consumer; 2 | 3 | import com.yyh.xfs.common.constant.RocketMQConsumerGroupConstant; 4 | import com.yyh.xfs.common.constant.RocketMQTopicConstant; 5 | import com.yyh.xfs.common.redis.utils.RedisCache; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; 8 | import org.apache.rocketmq.spring.core.RocketMQListener; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2024-02-24 15 | */ 16 | @Component 17 | @Slf4j 18 | @RocketMQMessageListener(topic = RocketMQTopicConstant.NOTES_REMOVE_REDIS_TOPIC, 19 | consumerGroup = RocketMQConsumerGroupConstant.NOTES_REMOVE_REDIS_CONSUMER_GROUP) 20 | public class RemoveCacheConsumer implements RocketMQListener { 21 | 22 | private final RedisCache redisCache; 23 | 24 | public RemoveCacheConsumer(RedisCache redisCache) { 25 | this.redisCache = redisCache; 26 | } 27 | 28 | @Override 29 | public void onMessage(String s) { 30 | log.info("remove cache: {}", s); 31 | redisCache.delAllPrefix(s); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /xfs-third-server/src/main/java/com/yyh/xfs/third/config/AliyunSms.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.third.config; 2 | 3 | import com.aliyun.dysmsapi20170525.Client; 4 | import com.aliyun.teaopenapi.models.Config; 5 | import com.yyh.xfs.common.myEnum.ExceptionMsgEnum; 6 | import com.yyh.xfs.common.web.exception.SystemException; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2023-12-12 15 | */ 16 | @Configuration 17 | @Slf4j 18 | public class AliyunSms { 19 | @Value("${aliyun.sms.accessKeyId}") 20 | private String accessKeyId; 21 | @Value("${aliyun.sms.accessKeySecret}") 22 | private String accessKeySecret; 23 | private static final String ENDPOINT = "dysmsapi.aliyuncs.com"; 24 | 25 | @Bean 26 | public Client smsClient() { 27 | Config config = new Config().setAccessKeyId(accessKeyId).setAccessKeySecret(accessKeySecret); 28 | config.endpoint = ENDPOINT; 29 | try { 30 | return new Client(config); 31 | } catch (Exception e) { 32 | throw new SystemException(ExceptionMsgEnum.ALIYUN_SMS_INIT_ERROR, e); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-user-server/src/main/java/com/yyh/xfs/user/mapper/UserAttentionMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.mapper; 2 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 3 | import com.yyh.xfs.user.domain.UserAttentionDO; 4 | import com.yyh.xfs.user.vo.UserRelationVO; 5 | import com.yyh.xfs.user.vo.ViewUserVO; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Select; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author yyh 13 | * @date 2023-12-30 14 | */ 15 | @Mapper 16 | public interface UserAttentionMapper extends BaseMapper { 17 | Boolean selectOneByUserIdAndAttentionIdIsExist(Long userId, Long attentionId); 18 | 19 | @Select("select count(*) from user_attention where user_id=#{userId}") 20 | Integer getCountById(Long userId); 21 | 22 | List selectAttentionList(Long userId, Integer offset, Integer pageSize); 23 | 24 | @Select("select * from user_attention where user_id=#{userId} and attention_id=#{targetUserId}") 25 | UserAttentionDO getExist(Long userId, Long targetUserId); 26 | 27 | /** 28 | * 获取用户关注的用户id 29 | * @param userId 用户id 30 | * @return 用户关注的用户id 31 | */ 32 | @Select("select attention_id from user_attention where user_id=#{userId}") 33 | List getAttentionUserId(Long userId); 34 | } 35 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/utils/JWTUtil.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.utils; 2 | 3 | import com.yyh.xfs.common.web.properties.JwtProperties; 4 | import io.jsonwebtoken.Jwts; 5 | import io.jsonwebtoken.SignatureAlgorithm; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2023-12-09 15 | */ 16 | @Configuration 17 | public class JWTUtil { 18 | 19 | private static JwtProperties jwtProperties; 20 | 21 | @Autowired 22 | private void setJwtProperties(JwtProperties jwtProperties) { 23 | JWTUtil.jwtProperties = jwtProperties; 24 | } 25 | public static String createToken(Map claims){ 26 | return Jwts.builder() 27 | .setClaims(claims) 28 | .signWith(SignatureAlgorithm.HS512,jwtProperties.getSecret()).compact(); 29 | } 30 | 31 | public static Map parseToken(String token){ 32 | return Jwts.parser().setSigningKey(jwtProperties.getSecret()).parseClaimsJws(token).getBody(); 33 | } 34 | 35 | public static Long getCurrentUserId(String token){ 36 | return (Long) parseToken(token).get("userId"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /xfs-auth/src/main/java/com/yyh/xfs/auth/utils/UserInfoUtil.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.auth.utils; 2 | import com.tencentyun.TLSSigAPIv2; 3 | import com.yyh.xfs.common.myEnum.ExceptionMsgEnum; 4 | import com.yyh.xfs.common.web.exception.BusinessException; 5 | import com.yyh.xfs.common.web.utils.JWTUtil; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import java.util.Map; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2023-10-01 15 | */ 16 | @Configuration 17 | public class UserInfoUtil { 18 | public static Long getUserId(HttpServletRequest request) { 19 | String token = null; 20 | try { 21 | token = request.getHeader("token"); 22 | } catch (Exception e) { 23 | throw new BusinessException(ExceptionMsgEnum.NOT_LOGIN, e); 24 | } 25 | if(token == null){ 26 | throw new BusinessException(ExceptionMsgEnum.NOT_LOGIN); 27 | } 28 | Long userId=null; 29 | try { 30 | Map map = JWTUtil.parseToken(token); 31 | userId = (Long) map.get("userId"); 32 | } catch (Exception e) { 33 | throw new BusinessException(ExceptionMsgEnum.TOKEN_INVALID, e); 34 | } 35 | return userId; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/constant/RocketMQConsumerGroupConstant.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.constant; 2 | 3 | /** 4 | * @author yyh 5 | * @date 2024-02-25 6 | */ 7 | public class RocketMQConsumerGroupConstant { 8 | public static final String NOTES_DELETE_COMMENT_CONSUMER_GROUP = "notes-delete-comment-consumer-group"; 9 | public static final String FIND_USER_CONSUMER_GROUP = "find-user-consumer-group"; 10 | public static final String PRAISE_AND_COLLECT_REMIND_CONSUMER_GROUP = "praise-and-collect-notification-consumer-group"; 11 | public static final String NOTES_REMIND_TARGET_CONSUMER_GROUP = "notes-remind-target-consumer-group"; 12 | public static final String NOTES_REMOVE_REDIS_CONSUMER_GROUP = "notes-remove-redis-consumer-group"; 13 | public static final String NOTES_ADD_ES_CONSUMER_GROUP = "notes-add-es-consumer-group"; 14 | public static final String NOTES_DELETE_ES_CONSUMER_GROUP = "notes-delete-es-consumer-group"; 15 | public static final String NOTES_UPDATE_ES_CONSUMER_GROUP = "notes-update-es-consumer-group"; 16 | public static final String NOTES_UPDATE_COUNT_CONSUMER_GROUP = "notes-update-count-consumer-group"; 17 | public static final String USER_ADD_ES_CONSUMER_GROUP = "user-add-es-consumer-group"; 18 | public static final String USER_UPDATE_ES_CONSUMER_GROUP = "user-update-es-consumer-group"; 19 | } 20 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/consumer/notes/NotesDeleteEsConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.consumer.notes; 2 | 3 | import com.yyh.xfs.common.constant.RocketMQConsumerGroupConstant; 4 | import com.yyh.xfs.common.constant.RocketMQTopicConstant; 5 | import com.yyh.xfs.search.service.NotesSearchService; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; 8 | import org.apache.rocketmq.spring.core.RocketMQListener; 9 | import org.springframework.stereotype.Component; 10 | 11 | /** 12 | * @author yyh 13 | * @date 2024-02-17 14 | */ 15 | @Component 16 | @Slf4j 17 | @RocketMQMessageListener(topic = RocketMQTopicConstant.NOTES_DELETE_ES_TOPIC, 18 | consumerGroup = RocketMQConsumerGroupConstant.NOTES_DELETE_ES_CONSUMER_GROUP) 19 | public class NotesDeleteEsConsumer implements RocketMQListener { 20 | 21 | private final NotesSearchService notesSearchService; 22 | 23 | public NotesDeleteEsConsumer(NotesSearchService notesSearchService) { 24 | this.notesSearchService = notesSearchService; 25 | } 26 | 27 | @Override 28 | public void onMessage(String s) { 29 | log.info("收到消息:{}", s); 30 | Long notesId = Long.valueOf(s); 31 | log.info("notesId:{}", notesId); 32 | notesSearchService.deleteNotes(notesId); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-im-api/src/main/java/com/yyh/xfs/im/vo/MessageVO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.im.vo; 2 | import lombok.*; 3 | 4 | import java.io.Serializable; 5 | 6 | /** 7 | * @author yyh 8 | * @date 2023-12-25 9 | * 消息前后端传输对象 10 | */ 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class MessageVO implements Serializable { 15 | private Integer id; 16 | /** 17 | * 发送者id 18 | */ 19 | private String from; 20 | /** 21 | * 发送者名称 22 | */ 23 | private String fromName; 24 | /** 25 | * 发送者头像 26 | */ 27 | private String fromAvatar; 28 | /** 29 | * 接收者id 30 | */ 31 | private String to; 32 | /** 33 | * 消息内容 34 | */ 35 | private String content; 36 | /** 37 | * 发送时间 38 | */ 39 | private Long time; 40 | /** 41 | * 0:连接信息 42 | * 1:心跳信息 43 | * 2:系统信息 44 | * 3:聊天信息 45 | * 4:新增关注信息 46 | * 5:服务器应答信息 47 | * 6:token鉴权信息 48 | * 7:@消息 49 | * 8:赞与收藏信息 50 | */ 51 | private Integer messageType; 52 | /** 53 | * 0:不是聊天信息 54 | * 1:文本信息 55 | * 2:图片信息 56 | * 3:文件信息 57 | * 4:语音信息 58 | */ 59 | private Integer chatType; 60 | /** 61 | * 0:好友消息 62 | * 1:陌生人消息 63 | */ 64 | private Integer friendType; 65 | /** 66 | * 语音时长,单位秒 67 | */ 68 | private Integer audioTime; 69 | } 70 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/mapper/NotesMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.yyh.xfs.notes.domain.NotesDO; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Select; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author yyh 12 | * @date 2024-01-19 13 | */ 14 | @Mapper 15 | public interface NotesMapper extends BaseMapper { 16 | 17 | List selectPageByTime(Integer offset, Integer pageSize); 18 | 19 | List selectPageByUserId(Integer offset, Integer pageSize, Long userId, Integer authority); 20 | 21 | List selectPageByUserIdAndLike(Integer offset, Integer pageSize, Long userId); 22 | 23 | List selectPageByUserIdAndCollect(Integer offset, Integer pageSize, Long userId); 24 | 25 | Integer getPraiseCountByUserId(Long userId); 26 | 27 | Integer getCollectCountByUserId(Long userId); 28 | 29 | List selectPageByAttentionUserId(Integer offset, Integer pageSize, List attentionUserId); 30 | 31 | List selectPageByCategoryIdByUpdateTime(Integer offset, Integer pageSize, Integer categoryId,Integer notesType); 32 | 33 | List selectPageByCategoryIdOrderByPraise(Integer offset, Integer pageSize, Integer categoryId,Integer notesType); 34 | } 35 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-im-server/src/main/java/com/yyh/xfs/im/feign/user/UserFeign.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.im.feign.user; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestHeader; 7 | import org.springframework.web.bind.annotation.RequestParam; 8 | 9 | /** 10 | * @author yyh 11 | * @date 2024-01-15 12 | */ 13 | @FeignClient("xfs-user") 14 | public interface UserFeign { 15 | /** 16 | * 查询用户是否被拉黑 17 | * 18 | * @param toId 被拉黑用户id 19 | * @param fromId 拉黑用户id 20 | * @param token token,由于websocket无法获取header,所以需要在参数中传递 21 | * @return 是否被拉黑 22 | */ 23 | @GetMapping(value = "/user/relation/isBlack") 24 | Result selectOneByUserIdAndBlackIdIsExist(@RequestParam("toId") Long toId, @RequestParam("fromId") Long fromId, @RequestHeader("token") String token); 25 | 26 | /** 27 | * 查询用户是否被关注 28 | * 29 | * @param toId 被关注用户id 30 | * @param fromId 关注用户id 31 | * @param token token,由于websocket无法获取header,所以需要在参数中传递 32 | * @return 是否被关注 33 | */ 34 | @GetMapping("/user/relation/isAttention") 35 | Result selectOneByUserIdAndAttentionIdIsExist(@RequestParam("toId") Long toId, @RequestParam("fromId") Long fromId, @RequestHeader("token") String token); 36 | } 37 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-user-server/src/main/resources/mapper/UserFansMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-comment-server/src/main/java/com/yyh/xfs/comment/consumer/NotesDeleteCommentConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.comment.consumer; 2 | 3 | import com.yyh.xfs.comment.service.CommentService; 4 | import com.yyh.xfs.common.constant.RocketMQConsumerGroupConstant; 5 | import com.yyh.xfs.common.constant.RocketMQTopicConstant; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; 8 | import org.apache.rocketmq.spring.core.RocketMQListener; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2024-02-17 15 | */ 16 | @Component 17 | @Slf4j 18 | @RocketMQMessageListener(topic = RocketMQTopicConstant.NOTES_DELETE_COMMENT_TOPIC, consumerGroup = RocketMQConsumerGroupConstant.NOTES_DELETE_COMMENT_CONSUMER_GROUP) 19 | public class NotesDeleteCommentConsumer implements RocketMQListener { 20 | 21 | private final CommentService commentService; 22 | 23 | public NotesDeleteCommentConsumer(CommentService commentService) { 24 | this.commentService = commentService; 25 | } 26 | 27 | @Override 28 | public void onMessage(String s) { 29 | log.info("收到消息:{}", s); 30 | Long notesId = Long.valueOf(s); 31 | log.info("notesId:{}", notesId); 32 | commentService.deleteCommentByNotesId(notesId); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/consumer/notes/NotesAddEsConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.consumer.notes; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.yyh.xfs.common.constant.RocketMQConsumerGroupConstant; 5 | import com.yyh.xfs.common.constant.RocketMQTopicConstant; 6 | import com.yyh.xfs.notes.domain.NotesDO; 7 | import com.yyh.xfs.search.service.NotesSearchService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; 10 | import org.apache.rocketmq.spring.core.RocketMQListener; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * @author yyh 15 | * @date 2024-01-24 16 | */ 17 | @Component 18 | @Slf4j 19 | @RocketMQMessageListener(topic = RocketMQTopicConstant.NOTES_ADD_ES_TOPIC, 20 | consumerGroup = RocketMQConsumerGroupConstant.NOTES_ADD_ES_CONSUMER_GROUP) 21 | public class NotesAddEsConsumer implements RocketMQListener { 22 | 23 | private final NotesSearchService notesSearchService; 24 | 25 | public NotesAddEsConsumer(NotesSearchService notesSearchService) { 26 | this.notesSearchService = notesSearchService; 27 | } 28 | 29 | @Override 30 | public void onMessage(String s) { 31 | log.info("收到消息:{}", s); 32 | NotesDO notesDO = JSON.parseObject(s, NotesDO.class); 33 | log.info("notesDO:{}", notesDO); 34 | notesSearchService.addNotes(notesDO); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/consumer/user/UserUpdateEsConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.consumer.user; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.yyh.xfs.common.constant.RocketMQConsumerGroupConstant; 5 | import com.yyh.xfs.common.constant.RocketMQTopicConstant; 6 | import com.yyh.xfs.search.domain.UserEsDO; 7 | import com.yyh.xfs.search.service.UserSearchService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; 10 | import org.apache.rocketmq.spring.core.RocketMQListener; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * @author yyh 15 | * @date 2024-02-21 16 | */ 17 | @Component 18 | @Slf4j 19 | @RocketMQMessageListener(topic = RocketMQTopicConstant.USER_UPDATE_ES_TOPIC, 20 | consumerGroup = RocketMQConsumerGroupConstant.USER_UPDATE_ES_CONSUMER_GROUP) 21 | public class UserUpdateEsConsumer implements RocketMQListener { 22 | private final UserSearchService userSearchService; 23 | 24 | public UserUpdateEsConsumer(UserSearchService userSearchService) { 25 | this.userSearchService = userSearchService; 26 | } 27 | 28 | @Override 29 | public void onMessage(String s) { 30 | log.info("收到消息:{}", s); 31 | UserEsDO userEsDO = JSON.parseObject(s, UserEsDO.class); 32 | log.info("转换后的对象:{}", userEsDO); 33 | userSearchService.updateUser(userEsDO); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.service.ApiInfo; 9 | import springfox.documentation.service.Contact; 10 | import springfox.documentation.spi.DocumentationType; 11 | import springfox.documentation.spring.web.plugins.Docket; 12 | 13 | /** 14 | * @author yyh 15 | * @date 2023-09-17 16 | */ 17 | @Configuration 18 | public class SwaggerConfig { 19 | @Bean 20 | public Docket createRestApi() { 21 | return new Docket(DocumentationType.SWAGGER_2) 22 | .useDefaultResponseMessages(false) 23 | .apiInfo(apiInfo()) 24 | .select() 25 | .apis(RequestHandlerSelectors.basePackage("com.yyh.xfs.*.controller")) 26 | .paths(PathSelectors.any()) 27 | .build(); 28 | 29 | } 30 | private ApiInfo apiInfo() { 31 | return new ApiInfoBuilder() 32 | .description("小番薯接口文档") 33 | .contact(new Contact("杨亚豪", "", "yahaoyang929@vip.qq.com")) 34 | .version("v1.0") 35 | .title("接口文档") 36 | .build(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/consumer/user/UserAddEsConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.consumer.user; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.yyh.xfs.common.constant.RocketMQConsumerGroupConstant; 5 | import com.yyh.xfs.common.constant.RocketMQTopicConstant; 6 | import com.yyh.xfs.search.domain.UserEsDO; 7 | import com.yyh.xfs.search.service.UserSearchService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; 10 | import org.apache.rocketmq.spring.core.RocketMQListener; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Component; 13 | 14 | /** 15 | * @author yyh 16 | * @date 2024-02-21 17 | */ 18 | @Component 19 | @Slf4j 20 | @RocketMQMessageListener(topic = RocketMQTopicConstant.USER_ADD_ES_TOPIC, 21 | consumerGroup = RocketMQConsumerGroupConstant.USER_ADD_ES_CONSUMER_GROUP) 22 | public class UserAddEsConsumer implements RocketMQListener { 23 | private final UserSearchService userSearchService; 24 | 25 | public UserAddEsConsumer(UserSearchService userSearchService) { 26 | this.userSearchService = userSearchService; 27 | } 28 | 29 | @Override 30 | public void onMessage(String s) { 31 | log.info("收到消息:{}", s); 32 | UserEsDO userEsDO = JSON.parseObject(s, UserEsDO.class); 33 | log.info("转换后的对象:{}", userEsDO); 34 | userSearchService.addUser(userEsDO); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/service/impl/ElasticSearchInitServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.service.impl; 2 | 3 | import com.yyh.xfs.common.myEnum.ExceptionMsgEnum; 4 | import com.yyh.xfs.common.web.exception.SystemException; 5 | import com.yyh.xfs.search.domain.NotesEsDO; 6 | import com.yyh.xfs.search.service.ElasticSearchInitService; 7 | import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; 8 | import org.springframework.stereotype.Service; 9 | 10 | /** 11 | * @author yyh 12 | * @date 2024-01-24 13 | */ 14 | @Service 15 | public class ElasticSearchInitServiceImpl implements ElasticSearchInitService { 16 | private final ElasticsearchRestTemplate elasticsearchRestTemplate; 17 | 18 | public ElasticSearchInitServiceImpl(ElasticsearchRestTemplate elasticsearchRestTemplate) { 19 | this.elasticsearchRestTemplate = elasticsearchRestTemplate; 20 | } 21 | 22 | @Override 23 | public void initElasticSearch() { 24 | // 判断索引是否存在 25 | try { 26 | if (!elasticsearchRestTemplate.indexOps(NotesEsDO.class).exists()) { 27 | // 创建索引 28 | elasticsearchRestTemplate.indexOps(NotesEsDO.class).create(); 29 | // 创建映射 30 | elasticsearchRestTemplate.indexOps(NotesEsDO.class).putMapping(); 31 | } 32 | } catch (Exception e) { 33 | throw new SystemException(ExceptionMsgEnum.ELASTICSEARCH_INIT_ERROR, e); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/consumer/notes/NotesUpdateEsConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.consumer.notes; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.yyh.xfs.common.constant.RocketMQConsumerGroupConstant; 5 | import com.yyh.xfs.common.constant.RocketMQTopicConstant; 6 | import com.yyh.xfs.notes.domain.NotesDO; 7 | import com.yyh.xfs.search.service.NotesSearchService; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; 10 | import org.apache.rocketmq.spring.core.RocketMQListener; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Component; 13 | 14 | /** 15 | * @author yyh 16 | * @date 2024-02-17 17 | */ 18 | @Component 19 | @Slf4j 20 | @RocketMQMessageListener(topic = RocketMQTopicConstant.NOTES_UPDATE_ES_TOPIC, 21 | consumerGroup = RocketMQConsumerGroupConstant.NOTES_UPDATE_ES_CONSUMER_GROUP) 22 | public class NotesUpdateEsConsumer implements RocketMQListener { 23 | 24 | private final NotesSearchService notesSearchService; 25 | 26 | public NotesUpdateEsConsumer(NotesSearchService notesSearchService) { 27 | this.notesSearchService = notesSearchService; 28 | } 29 | 30 | @Override 31 | public void onMessage(String s) { 32 | log.info("收到消息:{}", s); 33 | NotesDO notesDO = JSON.parseObject(s, NotesDO.class); 34 | log.info("notesDO:{}", notesDO); 35 | notesSearchService.updateNotes(notesDO); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-im-server/src/main/java/com/yyh/xfs/im/initialzer/IMServerInitialzer.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.im.initialzer; 2 | 3 | import com.yyh.xfs.im.handler.IMServerHandler; 4 | import io.netty.channel.ChannelInitializer; 5 | import io.netty.channel.ChannelPipeline; 6 | import io.netty.channel.socket.SocketChannel; 7 | import io.netty.handler.codec.http.HttpObjectAggregator; 8 | import io.netty.handler.codec.http.HttpServerCodec; 9 | import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler; 10 | import io.netty.handler.stream.ChunkedWriteHandler; 11 | import io.netty.handler.timeout.IdleStateHandler; 12 | import org.springframework.stereotype.Component; 13 | 14 | /** 15 | * @author yyh 16 | * @date 2023-12-24 17 | */ 18 | @Component 19 | public class IMServerInitialzer extends ChannelInitializer { 20 | private final IMServerHandler imServerHandler; 21 | 22 | public IMServerInitialzer(IMServerHandler imServerHandler) { 23 | this.imServerHandler = imServerHandler; 24 | } 25 | @Override 26 | protected void initChannel(SocketChannel socketChannel) throws Exception { 27 | ChannelPipeline pipeline = socketChannel.pipeline(); 28 | pipeline.addLast(new HttpServerCodec()) 29 | .addLast(new ChunkedWriteHandler()) 30 | .addLast(new HttpObjectAggregator(1024*64)) 31 | .addLast(new WebSocketServerProtocolHandler("/ws/xfs")) 32 | .addLast(new IdleStateHandler(5, 0, 0)) 33 | .addLast(imServerHandler); 34 | } 35 | } -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/utils/HtmlParseUtils.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.utils; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | /** 7 | * @author yyh 8 | * @date 2024-02-19 9 | */ 10 | public class HtmlParseUtils { 11 | 12 | /** 13 | * 将html转换为纯文本 14 | * 15 | * @param html html 16 | * @return 纯文本 17 | */ 18 | public static String htmlToText(String html) { 19 | // 移除样式、脚本、iframe标签及其内容 20 | String cleanedHtml = html.replaceAll("<(style|script|iframe)[^>]*?>[\\s\\S]+?", ""); 21 | // 提取图片标签中的alt属性内容 22 | Pattern imgPattern = Pattern.compile("]+alt=[\"']([^\"']+)[\"'][^>]*>"); 23 | String textWithAlt = getString(imgPattern, cleanedHtml); 24 | // 移除其他HTML标签 25 | String textWithoutTags = textWithAlt.replaceAll("<[^>]+?>", ""); 26 | // 将多个连续的空白字符替换为单个空格 27 | String textWithSingleSpace = textWithoutTags.replaceAll("\\s+", " ").trim(); 28 | // 移除多余的大于号 29 | return textWithSingleSpace.replaceAll(" >", ">"); 30 | } 31 | 32 | private static String getString(Pattern imgPattern, String cleanedHtml) { 33 | Matcher imgMatcher = imgPattern.matcher(cleanedHtml); 34 | StringBuffer resultBuffer = new StringBuffer(); 35 | while (imgMatcher.find()) { 36 | imgMatcher.appendReplacement(resultBuffer, " " + imgMatcher.group(1) + " "); 37 | } 38 | imgMatcher.appendTail(resultBuffer); 39 | return resultBuffer.toString(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/controller/UserSearchController.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.controller; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import com.yyh.xfs.common.myEnum.ExceptionMsgEnum; 5 | import com.yyh.xfs.common.web.exception.BusinessException; 6 | import com.yyh.xfs.search.domain.UserEsDO; 7 | import com.yyh.xfs.search.service.UserSearchService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * @author yyh 17 | * @date 2024-02-21 18 | */ 19 | @RestController 20 | @RequestMapping("/search/user") 21 | public class UserSearchController { 22 | private final UserSearchService userSearchService; 23 | 24 | public UserSearchController(UserSearchService userSearchService) { 25 | this.userSearchService = userSearchService; 26 | } 27 | 28 | @GetMapping("/getUser") 29 | public Result> getUser(String keyword, Integer page, Integer pageSize){ 30 | if (page == null || pageSize == null) { 31 | throw new BusinessException(ExceptionMsgEnum.PARAMETER_ERROR); 32 | } 33 | if (page < 1) { 34 | page = 1; 35 | } 36 | if (pageSize < 1) { 37 | pageSize = 10; 38 | } 39 | return userSearchService.getUser(keyword, page, pageSize); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /xfs-modules-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | xiaofanshu 9 | 1.0-SNAPSHOT 10 | 11 | 12 | xfs-modules-api 13 | pom 14 | 15 | xfs-user-api 16 | xfs-im-api 17 | xfs-notes-api 18 | xfs-search-api 19 | xfs-comment-api 20 | 21 | 22 | 23 | 8 24 | 8 25 | UTF-8 26 | 27 | 28 | 29 | 30 | org.example 31 | common-base 32 | 1.0-SNAPSHOT 33 | 34 | 35 | com.github.xiaoymin 36 | knife4j-openapi2-spring-boot-starter 37 | ${knife4j.version} 38 | 39 | 40 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/config/EsConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.core.annotation.AnnotationUtils; 5 | import org.springframework.data.elasticsearch.annotations.Document; 6 | import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; 7 | import org.springframework.data.elasticsearch.core.IndexOperations; 8 | import org.springframework.data.util.AnnotatedTypeScanner; 9 | 10 | import javax.annotation.PostConstruct; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2024-02-19 15 | */ 16 | @Configuration 17 | public class EsConfig { 18 | private final ElasticsearchRestTemplate elasticsearchRestTemplate; 19 | 20 | public EsConfig(ElasticsearchRestTemplate elasticsearchRestTemplate) { 21 | this.elasticsearchRestTemplate = elasticsearchRestTemplate; 22 | } 23 | 24 | @PostConstruct 25 | public void createIndex() { 26 | AnnotatedTypeScanner scanner = new AnnotatedTypeScanner(false, Document.class); 27 | for (Class clazz : scanner.findTypes("com.yyh.xfs.search.domain")) { 28 | Document doc = AnnotationUtils.findAnnotation(clazz, Document.class); 29 | assert doc != null; 30 | IndexOperations ops = elasticsearchRestTemplate.indexOps(clazz); 31 | if (!ops.exists()) { 32 | ops.create(); 33 | ops.refresh(); 34 | ops.putMapping(ops.createMapping()); 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/consumer/notes/NotesUpdateCountConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.consumer.notes; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.yyh.xfs.common.constant.RocketMQConsumerGroupConstant; 5 | import com.yyh.xfs.common.constant.RocketMQTopicConstant; 6 | import com.yyh.xfs.search.service.NotesSearchService; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; 9 | import org.apache.rocketmq.spring.core.RocketMQListener; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.util.Map; 13 | 14 | /** 15 | * @author yyh 16 | * @date 2024-02-19 17 | */ 18 | @Component 19 | @Slf4j 20 | @RocketMQMessageListener(topic = RocketMQTopicConstant.NOTES_UPDATE_COUNT_TOPIC, 21 | consumerGroup = RocketMQConsumerGroupConstant.NOTES_UPDATE_COUNT_CONSUMER_GROUP) 22 | public class NotesUpdateCountConsumer implements RocketMQListener { 23 | private final NotesSearchService notesSearchService; 24 | 25 | public NotesUpdateCountConsumer(NotesSearchService notesSearchService) { 26 | this.notesSearchService = notesSearchService; 27 | } 28 | 29 | @Override 30 | public void onMessage(String message) { 31 | log.info("notes-update-count-topic receive message:{}", message); 32 | Map map = JSON.parseObject(message, Map.class); 33 | log.info("notesId:{},notesLikeNum:{},type:{}", map.get("notesId"), map.get("notesLikeNum"), map.get("type")); 34 | notesSearchService.updateCount(map); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /xfs-common/common-redis/src/main/java/com/yyh/xfs/common/redis/config/RedissonConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.redis.config; 2 | 3 | import com.yyh.xfs.common.redis.properties.RedisProperties; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.redisson.Redisson; 6 | import org.redisson.api.RedissonClient; 7 | import org.redisson.config.Config; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2024-02-24 15 | */ 16 | @Slf4j 17 | @Configuration 18 | public class RedissonConfig { 19 | 20 | private static RedisProperties redisProperties; 21 | 22 | @Autowired 23 | private void setRedisProperties(RedisProperties redisProperties) { 24 | RedissonConfig.redisProperties = redisProperties; 25 | } 26 | 27 | @Bean 28 | public RedissonClient redissonClient() { 29 | RedissonClient redissonClient; 30 | Config config = new Config(); 31 | //starter依赖进来的redisson要以redis://开头,其他不用 32 | String url = "redis://"+ redisProperties.getHost() + ":" + redisProperties.getPort(); 33 | config.useSingleServer().setAddress(url) 34 | .setDatabase(redisProperties.getDatabase()); 35 | 36 | try { 37 | redissonClient = Redisson.create(config); 38 | return redissonClient; 39 | } catch (Exception e) { 40 | log.error("RedissonClient init redis url:[{}], Exception:", url, e); 41 | return null; 42 | } 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /xfs-modules-api/xfs-comment-api/src/main/java/com/yyh/xfs/comment/domain/CommentDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.comment.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.springframework.data.annotation.Id; 7 | import org.springframework.data.mongodb.core.mapping.Document; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | * @author yyh 13 | * @date 2024-02-05 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Document(value = "comment") 19 | public class CommentDO implements Serializable { 20 | 21 | @Id 22 | private String id; 23 | /** 24 | * 评论内容 25 | */ 26 | private String content; 27 | 28 | /** 29 | * 评论者id 30 | */ 31 | private Long commentUserId; 32 | 33 | /** 34 | * 评论者省份 35 | */ 36 | private String province; 37 | 38 | /** 39 | * 评论父级id,如果是一级评论则为0 40 | */ 41 | private String parentId; 42 | 43 | /** 44 | * 评论回复者id 45 | */ 46 | private Long replyUserId; 47 | 48 | /** 49 | * 评论回复者名称 50 | */ 51 | private String replyUserName; 52 | 53 | /** 54 | * 评论图片 55 | */ 56 | private String pictureUrl; 57 | 58 | /** 59 | * 评论点赞数 60 | */ 61 | private Integer commentLikeNum; 62 | 63 | /** 64 | * 评论所属笔记id 65 | */ 66 | private Long notesId; 67 | 68 | /** 69 | * 是否为置顶评论 70 | */ 71 | private Boolean isTop; 72 | 73 | /** 74 | * 是否为热门评论,前10条赞数最多的为热门评论,超过10条则按时间排序 75 | */ 76 | private Boolean isHot; 77 | /** 78 | * 评论时间 79 | */ 80 | private Long createTime; 81 | } 82 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-user-server/src/main/java/com/yyh/xfs/user/config/UserConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.user.config; 2 | 3 | import com.yyh.xfs.common.redis.constant.BloomFilterMap; 4 | import com.yyh.xfs.common.redis.utils.BloomFilterUtils; 5 | import com.yyh.xfs.user.mapper.UserMapper; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import javax.annotation.PostConstruct; 10 | import java.util.List; 11 | import java.util.stream.Collectors; 12 | 13 | /** 14 | * @author yyh 15 | * @date 2024-02-24 16 | */ 17 | @Configuration 18 | public class UserConfig { 19 | private final UserMapper userMapper; 20 | private final BloomFilterUtils bloomFilterUtils; 21 | 22 | public UserConfig(UserMapper userMapper, BloomFilterUtils bloomFilterUtils) { 23 | this.userMapper = userMapper; 24 | this.bloomFilterUtils = bloomFilterUtils; 25 | } 26 | 27 | /** 28 | * 初始化布隆过滤器 29 | */ 30 | @PostConstruct 31 | public void initBloomFilter() { 32 | List list = userMapper.selectList(null).stream().map(userDO -> String.valueOf(userDO.getId())).collect(Collectors.toList()); 33 | // 先判断有没有该布隆过滤器,没有则初始化 34 | long bloomFilterSize = bloomFilterUtils.getBloomFilterSize(BloomFilterMap.USER_ID_BLOOM_FILTER); 35 | if(bloomFilterSize==list.size()){ 36 | return; 37 | } 38 | bloomFilterUtils.initBloomFilter(BloomFilterMap.USER_ID_BLOOM_FILTER, list.isEmpty() ? 10000 : list.size() * 4L, 0.01); 39 | bloomFilterUtils.addAllBloomFilter(BloomFilterMap.USER_ID_BLOOM_FILTER, list); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /xfs-job-server/src/main/java/com/yyh/xfs/job/mapper/notes/NotesMapper.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.job.mapper.notes; 2 | 3 | import com.yyh.xfs.notes.domain.UserCollectNotesDO; 4 | import com.yyh.xfs.notes.domain.UserLikeNotesDO; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 笔记mapper 10 | * @author yyh 11 | * @date 2023-12-23 12 | */ 13 | public interface NotesMapper { 14 | /** 15 | * 更新笔记点赞数 16 | * @param notesId 笔记id 17 | * @param likeNum 点赞数 18 | */ 19 | boolean updateNotesLikeNum(Long notesId, Integer likeNum); 20 | 21 | /** 22 | * 更新笔记收藏数 23 | * @param notesId 笔记id 24 | * @param collectNum 收藏数 25 | */ 26 | boolean updateNotesCollectionNum(Long notesId, Integer collectNum); 27 | 28 | /** 29 | * 插入用户点赞笔记 30 | * @param userLikeNotesDO 用户点赞笔记 31 | */ 32 | boolean insertUserLikeNotes(UserLikeNotesDO userLikeNotesDO); 33 | 34 | /** 35 | * 删除用户点赞笔记 36 | * @param userLikeNotesDO 用户点赞笔记 37 | */ 38 | void deleteUserLikeNotes(UserLikeNotesDO userLikeNotesDO); 39 | 40 | /** 41 | * 插入用户收藏笔记 42 | * @param userCollectNotesDO 用户收藏笔记 43 | */ 44 | boolean insertUserCollectNotes(UserCollectNotesDO userCollectNotesDO); 45 | 46 | /** 47 | * 删除用户收藏笔记 48 | * @param userCollectNotesDO 用户收藏笔记 49 | */ 50 | void deleteUserCollectNotes(UserCollectNotesDO userCollectNotesDO); 51 | 52 | /** 53 | * 更新笔记浏览数 54 | * @param notesId 笔记id 55 | * @param viewNum 浏览数 56 | */ 57 | boolean updateNotesViewNum(Long notesId, Integer viewNum); 58 | 59 | /** 60 | * 获取所有笔记id 61 | */ 62 | List getAllNotesId(); 63 | } 64 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/config/NotesConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.config; 2 | 3 | import com.yyh.xfs.common.redis.constant.BloomFilterMap; 4 | import com.yyh.xfs.common.redis.utils.BloomFilterUtils; 5 | import com.yyh.xfs.notes.domain.NotesDO; 6 | import com.yyh.xfs.notes.mapper.NotesMapper; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | import javax.annotation.PostConstruct; 11 | import java.util.List; 12 | import java.util.stream.Collectors; 13 | 14 | /** 15 | * @author yyh 16 | * @date 2024-02-24 17 | */ 18 | @Configuration 19 | public class NotesConfig { 20 | 21 | private final BloomFilterUtils bloomFilterUtils; 22 | 23 | private final NotesMapper notesMapper; 24 | 25 | public NotesConfig(BloomFilterUtils bloomFilterUtils, NotesMapper notesMapper) { 26 | this.bloomFilterUtils = bloomFilterUtils; 27 | this.notesMapper = notesMapper; 28 | } 29 | 30 | /** 31 | * 初始化布隆过滤器 32 | */ 33 | @PostConstruct 34 | public void initBloomFilter() { 35 | List list = notesMapper.selectList(null).stream().map(notesDO -> String.valueOf(notesDO.getId())).collect(Collectors.toList()); 36 | // 先判断有没有该布隆过滤器,没有则初始化 37 | long bloomFilterSize = bloomFilterUtils.getBloomFilterSize(BloomFilterMap.NOTES_ID_BLOOM_FILTER); 38 | if(bloomFilterSize==list.size()){ 39 | return; 40 | } 41 | bloomFilterUtils.initBloomFilter(BloomFilterMap.NOTES_ID_BLOOM_FILTER, list.isEmpty() ? 10000 : list.size() * 4L, 0.01); 42 | bloomFilterUtils.addAllBloomFilter(BloomFilterMap.NOTES_ID_BLOOM_FILTER, list); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/exception/handler/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.exception.handler; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import com.yyh.xfs.common.web.exception.BusinessException; 5 | import com.yyh.xfs.common.web.exception.OnlyWarnException; 6 | import com.yyh.xfs.common.web.exception.SystemException; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.web.bind.annotation.ExceptionHandler; 9 | import org.springframework.web.bind.annotation.RestControllerAdvice; 10 | /** 11 | * @author yyh 12 | * @date 2023-12-15 13 | */ 14 | @Slf4j 15 | @RestControllerAdvice 16 | public class GlobalExceptionHandler { 17 | 18 | @ExceptionHandler(BusinessException.class) 19 | public Result handleAuthException(BusinessException businessException){ 20 | log.error("业务异常:{}",businessException.getExceptionMsgEnum()); 21 | return new Result<>( 22 | businessException.getExceptionMsgEnum().getCode(), 23 | businessException.getExceptionMsgEnum().getMsg(), 24 | null); 25 | } 26 | 27 | @ExceptionHandler(SystemException.class) 28 | public Result handleAuthException(SystemException systemException){ 29 | log.error("系统异常状态:{};系统异常:",systemException.getExceptionMsgEnum(),systemException); 30 | return new Result<>( 31 | systemException.getExceptionMsgEnum().getCode(), 32 | systemException.getExceptionMsgEnum().getMsg(), 33 | null); 34 | } 35 | @ExceptionHandler(OnlyWarnException.class) 36 | public void handleAuthException(OnlyWarnException onlyWarnException){ 37 | log.warn("警告异常:{};异常信息:",onlyWarnException.getExceptionMsgEnum(),onlyWarnException); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /xfs-common/common-redis/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | xfs-common 9 | 1.0-SNAPSHOT 10 | 11 | 12 | common-redis 13 | 14 | 15 | 8 16 | 8 17 | UTF-8 18 | 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-data-redis 24 | 25 | 26 | org.redisson 27 | redisson-spring-boot-starter 28 | 3.16.2 29 | 30 | 31 | com.fasterxml.jackson.core 32 | jackson-databind 33 | 34 | 35 | com.fasterxml.jackson.core 36 | jackson-annotations 37 | 38 | 39 | org.projectlombok 40 | lombok 41 | provided 42 | 43 | 44 | -------------------------------------------------------------------------------- /xfs-common/common-base/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | xfs-common 9 | 1.0-SNAPSHOT 10 | 11 | 12 | common-base 13 | 14 | 15 | 8 16 | 8 17 | UTF-8 18 | 19 | 20 | 21 | 22 | org.projectlombok 23 | lombok 24 | 25 | 26 | commons-codec 27 | commons-codec 28 | 29 | 30 | cn.hutool 31 | hutool-http 32 | 33 | 34 | com.alibaba 35 | fastjson 36 | 37 | 38 | com.fasterxml.jackson.core 39 | jackson-databind 40 | 41 | 42 | com.fasterxml.jackson.core 43 | jackson-annotations 44 | 45 | 46 | -------------------------------------------------------------------------------- /.idea/ProjectStorage.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 39 | 43 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-notes-server/src/main/java/com/yyh/xfs/notes/service/NotesService.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.yyh.xfs.common.domain.PageParam; 5 | import com.yyh.xfs.common.domain.Result; 6 | import com.yyh.xfs.notes.domain.NotesDO; 7 | import com.yyh.xfs.notes.vo.NotesPageVO; 8 | import com.yyh.xfs.notes.vo.NotesPublishVO; 9 | import com.yyh.xfs.notes.vo.NotesVO; 10 | 11 | import java.util.Map; 12 | 13 | /** 14 | * @author yyh 15 | * @date 2024-01-19 16 | */ 17 | public interface NotesService extends IService { 18 | Result addNotes(NotesPublishVO notesPublishVO); 19 | 20 | Result getLastNotesByPage(Integer page, Integer pageSize); 21 | 22 | Result initNotesLike(Long notesId); 23 | 24 | Result initNotesCollect(Long notesId); 25 | 26 | Result getNotesByUserId(Integer page, Integer pageSize, Integer authority, Integer type); 27 | 28 | Result getNotesByNotesId(Long notesId); 29 | 30 | Result praiseNotes(Long notesId, Long userId, Long targetUserId); 31 | 32 | Result collectNotes(Long notesId, Long userId, Long targetUserId); 33 | 34 | Result viewNotes(Long notesId); 35 | 36 | Result updateNotes(NotesPublishVO notesPublishVO); 37 | 38 | Result deleteNotes(Long notesId); 39 | 40 | Result changeNotesAuthority(Long notesId, Integer authority); 41 | 42 | Result> getAllNotesCountAndPraiseCountAndCollectCount(); 43 | 44 | Result getNotesByView(Integer page, Integer pageSize, Integer type, Long userId); 45 | 46 | Result getAttentionUserNotes(Integer page, Integer pageSize); 47 | 48 | Result getNotesByCategoryId(Integer page, Integer pageSize, Integer categoryId, Integer type,Integer notesType); 49 | } 50 | -------------------------------------------------------------------------------- /xfs-job-server/src/main/resources/mapper/notes/NotesMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | insert into user_like_notes(id, notes_id, user_id, create_time) 8 | values(#{id}, #{notesId}, #{userId}, #{createTime}) 9 | 10 | 11 | 12 | insert into user_collect_notes(id, notes_id, user_id, create_time) 13 | values(#{id}, #{notesId}, #{userId}, #{createTime}) 14 | 15 | 16 | 17 | update notes 18 | set notes_like_num = #{likeNum} 19 | where id = #{notesId} 20 | 21 | 22 | 23 | update notes 24 | set notes_collection_num = #{collectNum} 25 | where id = #{notesId} 26 | 27 | 28 | update notes 29 | set notes_view_num = #{viewNum} 30 | where id = #{notesId} 31 | 32 | 33 | 34 | delete from user_like_notes 35 | where notes_id = #{notesId} and user_id = #{userId} 36 | 37 | 38 | 39 | delete from user_collect_notes 40 | where notes_id = #{notesId} and user_id = #{userId} 41 | 42 | 45 | 46 | -------------------------------------------------------------------------------- /xiaofanshu-docker.md: -------------------------------------------------------------------------------- 1 | # 项目文件目录说明 2 | 3 | 本项目包含以下目录和文件。请根据文件结构将文件存放到相应位置。 4 | 5 | ## 目录结构 6 | 7 | ``` 8 | 9 | dir 10 | ├── config 11 | │ ├── broker.conf 12 | │ ├── elasticsearch.yml 13 | │ ├── init-message.js 14 | │ ├── init.sql 15 | │ ├── redis.conf 16 | │ └── run.sh 17 | ├── docker-compose-amd-xfs.yaml 18 | ├── docker-compose-arm-xfs.yaml 19 | ├── xiaofanshu-amd.dockerfile 20 | ├── xiaofanshu-arm.dockerfile 21 | └── docker-pre.sh 22 | 23 | ```` 24 | 25 | ## 文件说明 26 | 27 | - `config/` 28 | 配置文件目录,包含项目所需的各种配置文件: 29 | - `broker.conf`: Broker 配置文件 30 | - `elasticsearch.yml`: Elasticsearch 配置文件 31 | - `init-message.js`: 初始化消息脚本 32 | - `init.sql`: 初始化数据库 SQL 脚本 33 | - `redis.conf`: Redis 配置文件 34 | - `run.sh`: 启动脚本 35 | 36 | - `docker-compose-amd-xfs.yaml`: AMD 架构下的 Docker Compose 配置文件 37 | - `docker-compose-arm-xfs.yaml`: ARM 架构下的 Docker Compose 配置文件 38 | - `xiaofanshu-amd.dockerfile`: AMD 架构下的 Dockerfile 文件 39 | - `xiaofanshu-arm.dockerfile`: ARM 架构下的 Dockerfile 文件 40 | - `docker-pre.sh`: 用于执行预处理操作的 Shell 脚本,建议使用 `sudo` 权限运行。 41 | 42 | ## 使用说明 43 | 44 | ### 1. 执行预处理脚本 45 | 46 | 在开始使用 Docker Compose 配置之前,首先需要执行 `docker-pre.sh` 文件进行必要的预处理操作。 47 | 执行命令如下: 48 | 49 | ```bash 50 | sudo bash docker-pre.sh 51 | ```` 52 | 53 | ### 2. 选择架构并执行 Docker Compose 54 | 55 | 根据你的硬件架构,选择执行相应的 Docker Compose 配置文件: 56 | 57 | * 对于 **AMD 架构**,执行以下命令: 58 | 59 | ```bash 60 | docker-compose -f docker-compose-amd-xfs.yaml up 61 | ``` 62 | 63 | * 对于 **ARM 架构**,执行以下命令: 64 | 65 | ```bash 66 | docker-compose -f docker-compose-arm-xfs.yaml up 67 | ``` 68 | ### 3.修改配置 69 | 初始化elasticsearch密码 70 | ``` bash 71 | docker exec -it elasticsearch bash 72 | ./bin/elasticsearch-setup-passwords interactive 73 | ``` 74 | 75 | ## 注意事项 76 | 77 | * 确保在执行 `docker` 时,已经安装了 Docker 和 Docker Compose。 78 | * 选择合适的 Docker Compose 配置文件,确保它与你的硬件架构匹配。 79 | * 如果执行过程中遇到权限问题,请检查 `docker-pre.sh` 文件的权限,并确保有正确的执行权限。 80 | * 在构建 Docker 镜像时,请确保本地的 Docker 环境正常运行并且网络连接正常,以便从 Docker Hub 获取所需的基础镜像。 81 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-user-server/src/main/resources/mapper/UserAttentionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 24 | 40 | -------------------------------------------------------------------------------- /xfs-job-server/src/main/java/com/yyh/xfs/job/config/XxlJobConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.job.config; 2 | import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | /** 11 | * xxl-job config 12 | * 13 | * @author xuxueli 2017-04-28 14 | */ 15 | @Configuration 16 | @Slf4j 17 | public class XxlJobConfig { 18 | 19 | @Value("${xxl.job.admin.addresses}") 20 | private String adminAddresses; 21 | 22 | @Value("${xxl.job.accessToken}") 23 | private String accessToken; 24 | 25 | @Value("${xxl.job.executor.appname}") 26 | private String appname; 27 | 28 | @Value("${xxl.job.executor.address}") 29 | private String address; 30 | 31 | @Value("${xxl.job.executor.ip}") 32 | private String ip; 33 | 34 | @Value("${xxl.job.executor.port}") 35 | private int port; 36 | 37 | @Value("${xxl.job.executor.logpath}") 38 | private String logPath; 39 | 40 | @Value("${xxl.job.executor.logretentiondays}") 41 | private int logRetentionDays; 42 | 43 | 44 | @Bean 45 | public XxlJobSpringExecutor xxlJobExecutor() { 46 | log.info(">>>>>>>>>>> xxl-job config init."); 47 | XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); 48 | xxlJobSpringExecutor.setAdminAddresses(adminAddresses); 49 | xxlJobSpringExecutor.setAppname(appname); 50 | xxlJobSpringExecutor.setAddress(address); 51 | xxlJobSpringExecutor.setIp(ip); 52 | xxlJobSpringExecutor.setPort(port); 53 | xxlJobSpringExecutor.setAccessToken(accessToken); 54 | xxlJobSpringExecutor.setLogPath(logPath); 55 | xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); 56 | 57 | return xxlJobSpringExecutor; 58 | } 59 | } -------------------------------------------------------------------------------- /xfs-third-server/src/main/java/com/yyh/xfs/third/controller/UploadFileController.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.third.controller; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import com.yyh.xfs.common.web.aop.idempotent.Idempotent; 5 | import com.yyh.xfs.third.sevice.AliyunOssService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.PostMapping; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | import org.springframework.web.bind.annotation.RestController; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * @author yyh 17 | * @date 2023-12-21 18 | */ 19 | @RestController 20 | @RequestMapping("/third") 21 | public class UploadFileController { 22 | 23 | private final AliyunOssService aliyunOssService; 24 | 25 | public UploadFileController(AliyunOssService aliyunOssService) { 26 | this.aliyunOssService = aliyunOssService; 27 | } 28 | 29 | @PostMapping("/uploadImg") 30 | public Result uploadImg(@RequestParam("file") MultipartFile file) { 31 | return aliyunOssService.uploadImg(file); 32 | } 33 | 34 | @PostMapping("/uploadImgs") 35 | @Idempotent(value = "/third/uploadImgs", expireTime = 2000) 36 | public Result> uploadImgs(@RequestParam("file") MultipartFile[] file) { 37 | return aliyunOssService.uploadImgs(file); 38 | } 39 | 40 | @PostMapping("/uploadAudio") 41 | @Idempotent(value = "/third/uploadAudio", expireTime = 2000) 42 | public Result uploadAudio(@RequestParam("file") MultipartFile file) { 43 | return aliyunOssService.uploadAudio(file); 44 | } 45 | 46 | @PostMapping("/uploadVideo") 47 | @Idempotent(value = "/third/uploadVideo", expireTime = 2000) 48 | public Result uploadVideo(@RequestParam("file") MultipartFile file) { 49 | return aliyunOssService.uploadVideo(file); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /xfs-common/common-web/src/main/java/com/yyh/xfs/common/web/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.web.config; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.fasterxml.jackson.databind.module.SimpleModule; 5 | import com.fasterxml.jackson.databind.ser.std.DateSerializer; 6 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.http.converter.HttpMessageConverter; 9 | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; 10 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 11 | 12 | import java.text.SimpleDateFormat; 13 | import java.util.Date; 14 | import java.util.List; 15 | import java.util.TimeZone; 16 | 17 | /** 18 | * @author yyh 19 | * @date 2023-11-30 20 | */ 21 | @Configuration 22 | public class WebMvcConfig implements WebMvcConfigurer { 23 | 24 | /** 25 | * 解决前端Long类型精度丢失问题 26 | * @param converters 转换器 27 | */ 28 | @Override 29 | public void configureMessageConverters(List> converters){ 30 | MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); 31 | ObjectMapper objectMapper = new ObjectMapper(); 32 | SimpleModule simpleModule = new SimpleModule(); 33 | simpleModule.addSerializer(Long.class, ToStringSerializer.instance); 34 | simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); 35 | //将Data类型全部转换为yyyy-MM-dd HH:mm:ss格式的字符串 36 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 37 | simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC+8")); 38 | simpleModule.addSerializer(Date.class, new DateSerializer(false, simpleDateFormat)); 39 | objectMapper.registerModule(simpleModule); 40 | jackson2HttpMessageConverter.setObjectMapper(objectMapper); 41 | converters.add(0, jackson2HttpMessageConverter); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /xfs-job-server/src/main/java/com/yyh/xfs/job/config/NotesDataSourceConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.job.config; 2 | 3 | import com.yyh.xfs.job.mapper.notes.NotesMapper; 4 | import org.apache.ibatis.session.SqlSessionFactory; 5 | import org.mybatis.spring.SqlSessionFactoryBean; 6 | import org.mybatis.spring.SqlSessionTemplate; 7 | import org.mybatis.spring.annotation.MapperScan; 8 | import org.springframework.beans.factory.annotation.Qualifier; 9 | import org.springframework.boot.context.properties.ConfigurationProperties; 10 | import org.springframework.boot.jdbc.DataSourceBuilder; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; 14 | import org.springframework.core.io.support.ResourcePatternResolver; 15 | 16 | import javax.sql.DataSource; 17 | 18 | /** 19 | * @author yyh 20 | * @date 2024-02-09 21 | */ 22 | @Configuration 23 | @MapperScan(basePackages = "com.yyh.xfs.job.mapper.notes", sqlSessionFactoryRef = "notesSqlSessionFactory") 24 | public class NotesDataSourceConfig { 25 | //扫描指定前缀的key,使用其value 26 | @Bean(name = "notesDataSource") 27 | @ConfigurationProperties(prefix="spring.datasource.notes") 28 | public DataSource notesDataSource(){ 29 | return DataSourceBuilder.create().build(); 30 | } 31 | 32 | @Bean(name="notesSqlSessionFactory") 33 | public SqlSessionFactory notesSqlSessionFactory(@Qualifier("notesDataSource") DataSource dataSource) throws Exception{ 34 | SqlSessionFactoryBean ssfb = new SqlSessionFactoryBean(); 35 | ssfb.setDataSource(dataSource); 36 | // 设置 Mapper XML 文件的位置,可以使用通配符 37 | ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); 38 | ssfb.setMapperLocations(resolver.getResources("classpath:mapper/notes/*.xml")); 39 | return ssfb.getObject(); 40 | } 41 | 42 | @Bean(name="notesSqlSessionTemplate") 43 | public SqlSessionTemplate notesSqlSessionTemplate(@Qualifier("notesSqlSessionFactory") SqlSessionFactory sqlSessionFactory){ 44 | return new SqlSessionTemplate(sqlSessionFactory); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /xfs-job-server/src/main/java/com/yyh/xfs/job/config/UserDataSourceConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.job.config; 2 | 3 | import com.yyh.xfs.job.mapper.user.UserMapper; 4 | import org.apache.ibatis.session.SqlSessionFactory; 5 | import org.mybatis.spring.SqlSessionFactoryBean; 6 | import org.mybatis.spring.SqlSessionTemplate; 7 | import org.mybatis.spring.annotation.MapperScan; 8 | import org.springframework.beans.factory.annotation.Qualifier; 9 | import org.springframework.boot.context.properties.ConfigurationProperties; 10 | import org.springframework.boot.jdbc.DataSourceBuilder; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | import org.springframework.context.annotation.Primary; 14 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; 15 | import org.springframework.core.io.support.ResourcePatternResolver; 16 | 17 | import javax.sql.DataSource; 18 | 19 | /** 20 | * @author yyh 21 | * @date 2024-02-09 22 | */ 23 | @Configuration 24 | @MapperScan(basePackages = "com.yyh.xfs.job.mapper.user", sqlSessionFactoryRef = "userSqlSessionFactory") 25 | public class UserDataSourceConfig { 26 | //扫描指定前缀的key,使用其value 27 | @Bean(name = "userDataSource") 28 | @Primary 29 | @ConfigurationProperties(prefix="spring.datasource.user") 30 | public DataSource userDataSource(){ 31 | return DataSourceBuilder.create().build(); 32 | } 33 | 34 | @Bean(name="userSqlSessionFactory") 35 | @Primary 36 | public SqlSessionFactory userSqlSessionFactory(@Qualifier("userDataSource") DataSource dataSource) throws Exception{ 37 | SqlSessionFactoryBean ssfb = new SqlSessionFactoryBean(); 38 | ssfb.setDataSource(dataSource); 39 | // 设置 Mapper XML 文件的位置,可以使用通配符 40 | ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); 41 | ssfb.setMapperLocations(resolver.getResources("classpath:mapper/user/*.xml")); 42 | return ssfb.getObject(); 43 | } 44 | 45 | @Bean(name="userSqlSessionTemplate") 46 | @Primary 47 | public SqlSessionTemplate userSqlSessionTemplate(@Qualifier("userSqlSessionFactory") SqlSessionFactory sqlSessionFactory){ 48 | return new SqlSessionTemplate(sqlSessionFactory); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /xfs-common/common-web/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | xfs-common 9 | 1.0-SNAPSHOT 10 | 11 | 12 | common-web 13 | 14 | 15 | 8 16 | 8 17 | UTF-8 18 | 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-web 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-test 28 | 29 | 30 | com.github.xiaoymin 31 | knife4j-openapi2-spring-boot-starter 32 | ${knife4j.version} 33 | 34 | 35 | io.jsonwebtoken 36 | jjwt 37 | 38 | 39 | io.github.openfeign 40 | feign-core 41 | 42 | 43 | org.example 44 | common-base 45 | 1.0-SNAPSHOT 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-aop 50 | 51 | 52 | org.example 53 | common-redis 54 | 1.0-SNAPSHOT 55 | 56 | 57 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/controller/ElasticSearchInitController.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.controller; 2 | 3 | import com.yyh.xfs.common.domain.Result; 4 | import com.yyh.xfs.common.myEnum.ExceptionMsgEnum; 5 | import com.yyh.xfs.common.redis.constant.RedisConstant; 6 | import com.yyh.xfs.common.redis.utils.RedisCache; 7 | import com.yyh.xfs.common.redis.utils.RedisKey; 8 | import com.yyh.xfs.common.utils.ResultUtil; 9 | import com.yyh.xfs.common.web.exception.BusinessException; 10 | import com.yyh.xfs.search.service.ElasticSearchInitService; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.beans.factory.annotation.Value; 13 | import org.springframework.util.StringUtils; 14 | import org.springframework.web.bind.annotation.GetMapping; 15 | import org.springframework.web.bind.annotation.PathVariable; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | /** 20 | * @author yyh 21 | * @date 2024-01-24 22 | */ 23 | @RestController 24 | @RequestMapping("/search/init") 25 | public class ElasticSearchInitController { 26 | 27 | @Value("${spring.elasticsearch.init.key}") 28 | private String key; 29 | 30 | private final ElasticSearchInitService elasticSearchInitService; 31 | private final RedisCache redisCache; 32 | 33 | public ElasticSearchInitController(RedisCache redisCache, ElasticSearchInitService elasticSearchInitService) { 34 | this.redisCache = redisCache; 35 | this.elasticSearchInitService = elasticSearchInitService; 36 | } 37 | @GetMapping("/{key}/{type}") 38 | public Result initElasticSearch(@PathVariable String key, @PathVariable String type) { 39 | if (!StringUtils.hasText(key) || !this.key.equals(key) || !StringUtils.hasText(type)) { 40 | throw new BusinessException(ExceptionMsgEnum.PARAMETER_ERROR); 41 | } 42 | Boolean setnx = redisCache.setnx(RedisKey.build(RedisConstant.REDIS_KEY_ELASTICSEARCH_INIT, key + ":" + type)); 43 | if (!setnx) { 44 | throw new BusinessException(ExceptionMsgEnum.ELASTICSEARCH_INIT_ALREADY); 45 | } 46 | elasticSearchInitService.initElasticSearch(); 47 | return ResultUtil.successGet(null); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-user-server/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | id,uid,nickname, 31 | avatar_url,age,sex, 32 | area,self_introduction,birthday, 33 | home_page_background,occupation,phone_number, 34 | password,wx_open_id,qq_open_id, 35 | facebook_open_id,account_status,create__time, 36 | update_time 37 | 38 | 39 | -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/myEnum/ExceptionMsgEnum.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.myEnum; 2 | 3 | import com.yyh.xfs.common.constant.StatusCode; 4 | import lombok.Getter; 5 | import lombok.ToString; 6 | 7 | /** 8 | * @author yyh 9 | * @date 2023-12-11 10 | */ 11 | 12 | @Getter 13 | @ToString 14 | public enum ExceptionMsgEnum { 15 | /** 16 | * 业务异常 17 | */ 18 | NOT_LOGIN(StatusCode.NOT_LOGIN,"未登录"), 19 | TOKEN_EXPIRED(StatusCode.TOKEN_EXPIRED,"登录状态过期"), 20 | TOKEN_INVALID(StatusCode.TOKEN_INVALID,"登录状态无效"), 21 | ACCOUNT_OPERATION_ERROR(StatusCode.ACCOUNT_OPERATION_ERROR,"账号操作异常"), 22 | ACCOUNT_OTHER_LOGIN(StatusCode.ACCOUNT_OTHER_LOGIN,"账号在其他设备登录"), 23 | PASSWORD_ERROR(StatusCode.PASSWORD_ERROR,"密码错误"), 24 | SMS_CODE_ERROR(StatusCode.SMS_CODE_ERROR,"验证码错误"), 25 | PHONE_NUMBER_EXIST(StatusCode.PHONE_NUMBER_EXIST,"手机号已绑定"), 26 | PHONE_NUMBER_NOT_REGISTER(StatusCode.PHONE_NUMBER_NOT_REGISTER,"手机号未注册"), 27 | GET_GEOGRAPHIC_INFORMATION_ERROR(StatusCode.GET_GEOGRAPHIC_INFORMATION_ERROR,"获取地理信息失败"), 28 | LOGIN_TYPE_ERROR(StatusCode.LOGIN_TYPE_ERROR,"登录类型错误"), 29 | OPEN_ID_NULL(StatusCode.OPEN_ID_NULL,"账号openId为空"), 30 | ACCOUNT_EXCEPTION(StatusCode.ACCOUNT_EXCEPTION,"账号异常"), 31 | PARAMETER_ERROR(StatusCode.PARAMETER_ERROR,"参数错误"), 32 | FILE_SIZE_TOO_LARGE(StatusCode.FILE_SIZE_TOO_LARGE,"文件过大"), 33 | FILE_NOT_NULL(StatusCode.FILE_NOT_NULL,"文件不能为空"), 34 | ELASTICSEARCH_INIT_ALREADY(StatusCode.ELASTICSEARCH_INIT_ALREADY,"ElasticSearch已初始化"), 35 | SMS_CODE_SEND_FREQUENTLY(StatusCode.SMS_CODE_SEND_FREQUENTLY,"短信发送频繁,请稍后再试"), 36 | NO_PERMISSION(StatusCode.NO_PERMISSION,"无权限"), 37 | REPEAT_OPERATION(StatusCode.REPEAT_OPERATION,"操作太过频繁"), 38 | /** 39 | * 系统异常 40 | */ 41 | ALIYUN_SMS_SEND_ERROR(StatusCode.ALIYUN_SMS_SEND_ERROR,"短信发送失败"), 42 | ALIYUN_SMS_INIT_ERROR(StatusCode.ALIYUN_SMS_INIT_ERROR,"短信服务初始化异常"), 43 | ALIYUN_OSS_INIT_ERROR(StatusCode.ALIYUN_OSS_INIT_ERROR,"OSS服务初始化异常"), 44 | ELASTICSEARCH_INIT_ERROR(StatusCode.ELASTICSEARCH_INIT_ERROR,"ElasticSearch初始化异常"), 45 | REDIS_ERROR(StatusCode.REDIS_ERROR,"redis操作异常"), 46 | SERVER_ERROR(StatusCode.SERVER_ERROR,"服务器异常"), 47 | DB_ERROR(StatusCode.DB_ERROR,"数据库操作异常"); 48 | private Integer code; 49 | private String msg; 50 | 51 | ExceptionMsgEnum(Integer code, String msg) { 52 | this.code = code; 53 | this.msg = msg; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-im-server/src/main/java/com/yyh/xfs/im/consumer/PraiseAndCollectNotificationConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.im.consumer; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.yyh.xfs.common.constant.RocketMQConsumerGroupConstant; 5 | import com.yyh.xfs.common.constant.RocketMQTopicConstant; 6 | import com.yyh.xfs.common.redis.constant.BloomFilterMap; 7 | import com.yyh.xfs.common.redis.utils.BloomFilterUtils; 8 | import com.yyh.xfs.common.redis.utils.RedisCache; 9 | import com.yyh.xfs.im.handler.types.ChatHandler; 10 | import com.yyh.xfs.im.vo.MessageVO; 11 | import io.netty.channel.Channel; 12 | import lombok.extern.slf4j.Slf4j; 13 | import org.apache.rocketmq.common.message.MessageExt; 14 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; 15 | import org.apache.rocketmq.spring.core.RocketMQListener; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.stereotype.Component; 18 | 19 | import static com.yyh.xfs.im.handler.IMServerHandler.USER_CHANNEL_MAP; 20 | 21 | /** 22 | * @author yyh 23 | * @date 2024-02-21 24 | */ 25 | @Component 26 | @Slf4j 27 | @RocketMQMessageListener( 28 | topic = RocketMQTopicConstant.PRAISE_AND_COLLECT_REMIND_TOPIC, 29 | consumerGroup = RocketMQConsumerGroupConstant.PRAISE_AND_COLLECT_REMIND_CONSUMER_GROUP) 30 | public class PraiseAndCollectNotificationConsumer implements RocketMQListener { 31 | private final ChatHandler chatHandler; 32 | private final BloomFilterUtils bloomFilterUtils; 33 | 34 | public PraiseAndCollectNotificationConsumer(ChatHandler chatHandler, 35 | BloomFilterUtils bloomFilterUtils) { 36 | this.chatHandler = chatHandler; 37 | this.bloomFilterUtils = bloomFilterUtils; 38 | } 39 | @Override 40 | public void onMessage(MessageExt messageExt) { 41 | if (bloomFilterUtils.mightContainBloomFilter(BloomFilterMap.ROCKETMQ_IDEMPOTENT_BLOOM_FILTER, messageExt.getMsgId())) { 42 | log.info("消息已经消费过:{}", messageExt.getMsgId()); 43 | return; 44 | } 45 | String s = new String(messageExt.getBody()); 46 | log.info("收到消息:{}", s); 47 | MessageVO message = JSON.parseObject(s, MessageVO.class); 48 | Channel channel = USER_CHANNEL_MAP.get(message.getTo()); 49 | chatHandler.sendMessage(channel, message); 50 | bloomFilterUtils.addBloomFilter(BloomFilterMap.ROCKETMQ_IDEMPOTENT_BLOOM_FILTER, messageExt.getMsgId()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /xfs-modules-server/xfs-im-server/src/main/java/com/yyh/xfs/im/consumer/FindUserConsumer.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.im.consumer; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.yyh.xfs.common.constant.RocketMQConsumerGroupConstant; 5 | import com.yyh.xfs.common.constant.RocketMQTopicConstant; 6 | import com.yyh.xfs.common.redis.constant.BloomFilterMap; 7 | import com.yyh.xfs.common.redis.utils.BloomFilterUtils; 8 | import com.yyh.xfs.im.vo.MessageVO; 9 | import com.yyh.xfs.im.handler.IMServerHandler; 10 | import io.netty.channel.Channel; 11 | import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; 12 | import lombok.extern.slf4j.Slf4j; 13 | import org.apache.rocketmq.common.message.MessageExt; 14 | import org.apache.rocketmq.spring.annotation.MessageModel; 15 | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; 16 | import org.apache.rocketmq.spring.core.RocketMQListener; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.stereotype.Component; 19 | 20 | /** 21 | * @author yyh 22 | * @date 2023-12-25 23 | */ 24 | @Component 25 | @Slf4j 26 | @RocketMQMessageListener( 27 | topic = RocketMQTopicConstant.FIND_USER_TOPIC, 28 | consumerGroup = RocketMQConsumerGroupConstant.FIND_USER_CONSUMER_GROUP, 29 | messageModel = MessageModel.BROADCASTING) 30 | public class FindUserConsumer implements RocketMQListener{ 31 | 32 | private final BloomFilterUtils bloomFilterUtils; 33 | 34 | public FindUserConsumer(BloomFilterUtils bloomFilterUtils) { 35 | this.bloomFilterUtils = bloomFilterUtils; 36 | } 37 | 38 | @Override 39 | public void onMessage(MessageExt messageExt) { 40 | if (bloomFilterUtils.mightContainBloomFilter(BloomFilterMap.ROCKETMQ_IDEMPOTENT_BLOOM_FILTER, messageExt.getMsgId())) { 41 | log.info("消息已经消费过:{}", messageExt.getMsgId()); 42 | return; 43 | } 44 | String s = new String(messageExt.getBody()); 45 | log.info("收到消息:{}",s); 46 | MessageVO message = JSON.parseObject(s, MessageVO.class); 47 | String messageTo = message.getTo(); 48 | Channel channel = IMServerHandler.USER_CHANNEL_MAP.get(messageTo); 49 | if(channel!=null){ 50 | log.info("找到用户:{},发送消息:{}",messageTo,message); 51 | channel.writeAndFlush(new TextWebSocketFrame(JSON.toJSONString(message))); 52 | } 53 | bloomFilterUtils.addBloomFilter(BloomFilterMap.ROCKETMQ_IDEMPOTENT_BLOOM_FILTER, messageExt.getMsgId()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /xfs-common/common-redis/src/main/java/com/yyh/xfs/common/redis/config/CustomRedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.redis.config; 2 | 3 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 4 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 5 | import com.fasterxml.jackson.annotation.PropertyAccessor; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; 8 | import org.springframework.boot.autoconfigure.AutoConfigureBefore; 9 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 10 | import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | import org.springframework.data.redis.connection.RedisConnectionFactory; 14 | import org.springframework.data.redis.core.RedisTemplate; 15 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; 16 | import org.springframework.data.redis.serializer.RedisSerializer; 17 | import org.springframework.data.redis.serializer.StringRedisSerializer; 18 | 19 | import javax.annotation.Resource; 20 | 21 | /** 22 | * @author yyh 23 | * @date 2023-12-11 24 | */ 25 | @Configuration 26 | @AutoConfigureBefore(RedisAutoConfiguration.class) 27 | public class CustomRedisConfig { 28 | @Resource 29 | RedisConnectionFactory factory; 30 | @Bean 31 | @ConditionalOnMissingBean(name = "redisTemplate") 32 | public RedisTemplate redisTemplate() { 33 | RedisTemplate template = new RedisTemplate<>(); 34 | RedisSerializer redisSerializer = new StringRedisSerializer(); 35 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); 36 | ObjectMapper om = new ObjectMapper(); 37 | om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); 38 | om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance ,ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); 39 | jackson2JsonRedisSerializer.setObjectMapper(om); 40 | template.setConnectionFactory(factory); 41 | //key序列化方式 42 | template.setKeySerializer(redisSerializer); 43 | //value序列化 44 | template.setValueSerializer(jackson2JsonRedisSerializer); 45 | //value hashmap序列化 46 | template.setHashValueSerializer(jackson2JsonRedisSerializer); 47 | return template; 48 | } 49 | } -------------------------------------------------------------------------------- /xfs-modules-server/xfs-search-server/src/main/java/com/yyh/xfs/search/controller/NotesSearchController.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.controller; 2 | 3 | import com.yyh.xfs.common.domain.PageParam; 4 | import com.yyh.xfs.common.domain.Result; 5 | import com.yyh.xfs.common.myEnum.ExceptionMsgEnum; 6 | import com.yyh.xfs.common.web.exception.BusinessException; 7 | import com.yyh.xfs.notes.vo.NotesPageVO; 8 | import com.yyh.xfs.search.service.NotesSearchService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2024-01-24 15 | */ 16 | @RestController 17 | @RequestMapping("/search/notes") 18 | public class NotesSearchController { 19 | 20 | private final NotesSearchService notesSearchService; 21 | 22 | public NotesSearchController(NotesSearchService notesSearchService) { 23 | this.notesSearchService = notesSearchService; 24 | } 25 | 26 | @PostMapping("/getNotesNearBy") 27 | public Result getNotesNearBy(@RequestBody PageParam pageParam) { 28 | if (pageParam.getPage() == null || pageParam.getPageSize() == null) { 29 | throw new BusinessException(ExceptionMsgEnum.PARAMETER_ERROR); 30 | } 31 | if (pageParam.getLatitude() == null || pageParam.getLongitude() == null) { 32 | throw new BusinessException(ExceptionMsgEnum.GET_GEOGRAPHIC_INFORMATION_ERROR); 33 | } 34 | if (pageParam.getPage() < 1) { 35 | pageParam.setPage(1); 36 | } 37 | if (pageParam.getPageSize() < 1) { 38 | pageParam.setPageSize(10); 39 | } 40 | return notesSearchService.getNotesNearBy(pageParam); 41 | } 42 | 43 | @GetMapping("/getNotesByKeyword") 44 | public Result getNotesByKeyword(String keyword, Integer page, Integer pageSize,Integer notesType,Integer hot){ 45 | if (page == null || pageSize == null) { 46 | throw new BusinessException(ExceptionMsgEnum.PARAMETER_ERROR); 47 | } 48 | // 0:图片笔记,1:视频笔记,2:全部 49 | if (notesType == null||notesType < 0||notesType > 2) { 50 | notesType = 2; 51 | } 52 | // 0:最新,1:最热,2:全部 53 | if (hot == null||hot < 0||hot > 2) { 54 | hot = 2; 55 | } 56 | if (page < 1) { 57 | page = 1; 58 | } 59 | if (pageSize < 1) { 60 | pageSize = 10; 61 | } 62 | return notesSearchService.getNotesByKeyword(keyword, page, pageSize,notesType,hot); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-notes-api/src/main/java/com/yyh/xfs/notes/domain/NotesDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.notes.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.FieldFill; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import io.swagger.annotations.ApiModel; 8 | import lombok.Data; 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2024-01-18 15 | */ 16 | @Data 17 | @ApiModel(value = "笔记表") 18 | @TableName("notes") 19 | public class NotesDO implements Serializable { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | /** 24 | * 笔记id 25 | */ 26 | @TableId 27 | private Long id; 28 | 29 | /** 30 | * 笔记标题 31 | */ 32 | private String title; 33 | 34 | /** 35 | * 笔记内容 36 | */ 37 | private String content; 38 | 39 | /** 40 | * 所属用户id 41 | */ 42 | private Long belongUserId; 43 | 44 | /** 45 | * 所属分类 46 | */ 47 | private Integer belongCategory; 48 | 49 | /** 50 | * 笔记类型,0为图片笔记,1为视频笔记 51 | */ 52 | private Integer notesType; 53 | 54 | /** 55 | * 封面图片 56 | */ 57 | private String coverPicture; 58 | 59 | /** 60 | * 笔记资源,图片或视频,视频只能一个,图片最多9个,格式为json序列化数组后的字符串 61 | */ 62 | private String notesResources; 63 | 64 | /** 65 | * 赞数 66 | */ 67 | private Integer notesLikeNum; 68 | 69 | /** 70 | * 收藏数 71 | */ 72 | private Integer notesCollectionNum; 73 | 74 | /** 75 | * 评论数 76 | */ 77 | private Integer notesCommentNum; 78 | 79 | /** 80 | * 浏览数 81 | */ 82 | private Integer notesViewNum; 83 | 84 | /** 85 | * 展示的地点,可以为空 86 | */ 87 | private String address; 88 | 89 | /** 90 | * 纬度 91 | */ 92 | private Double latitude; 93 | 94 | /** 95 | * 经度 96 | */ 97 | private Double longitude; 98 | 99 | /** 100 | * 省份,中国显示省份,国外显示国家 101 | */ 102 | private String province; 103 | 104 | /** 105 | * 是否公开,0为公开,1为私密 106 | */ 107 | private Integer authority; 108 | 109 | /** 110 | * 创建时间 111 | */ 112 | @TableField(fill = FieldFill.INSERT) 113 | private Date createTime; 114 | 115 | /** 116 | * 更新时间 117 | */ 118 | @TableField(fill = FieldFill.INSERT_UPDATE) 119 | private Date updateTime; 120 | } 121 | -------------------------------------------------------------------------------- /.idea/dataSources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mysql.8 6 | true 7 | com.mysql.cj.jdbc.Driver 8 | jdbc:mysql://192.168.124.100:3306 9 | 10 | 11 | 12 | 13 | 14 | 15 | $ProjectFileDir$ 16 | 17 | 18 | mongo 19 | true 20 | com.dbschema.MongoJdbcDriver 21 | mongodb://192.168.242.157:27017/messagedb 22 | 23 | 24 | 25 | 26 | 27 | 28 | $ProjectFileDir$ 29 | 30 | 31 | redis 32 | true 33 | true 34 | $PROJECT_DIR$/xfs-modules-server/xfs-im-server/src/main/resources/application.yml 35 | jdbc.RedisDriver 36 | jdbc:redis://localhost:6379/0 37 | 38 | 39 | 40 | 41 | 42 | $ProjectFileDir$ 43 | 44 | 45 | -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/utils/ResultUtil.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.utils; 2 | 3 | import com.yyh.xfs.common.constant.StatusCode; 4 | import com.yyh.xfs.common.domain.Result; 5 | 6 | /** 7 | * @author yyh 8 | * @date 2023-12-09 9 | */ 10 | public class ResultUtil { 11 | public static final String SUCCESS = "success"; 12 | public static final String ERROR = "error"; 13 | 14 | public static Result successGet(T data) { 15 | return new Result<>(StatusCode.GET_SUCCESS, SUCCESS, data); 16 | } 17 | public static Result successGet(String msg, T data) { 18 | return new Result<>(StatusCode.GET_SUCCESS, msg, data); 19 | } 20 | public static Result successPost(T data) { 21 | return new Result<>(StatusCode.POST_SUCCESS, SUCCESS, data); 22 | } 23 | public static Result successPost(String msg, T data) { 24 | return new Result<>(StatusCode.POST_SUCCESS, msg, data); 25 | } 26 | 27 | public static Result successPut(T data) { 28 | return new Result<>(StatusCode.PUT_SUCCESS, SUCCESS, data); 29 | } 30 | public static Result successPut(String msg, T data) { 31 | return new Result<>(StatusCode.PUT_SUCCESS, msg, data); 32 | } 33 | public static Result successDelete(T data) { 34 | return new Result<>(StatusCode.DELETE_SUCCESS, SUCCESS, data); 35 | } 36 | public static Result successDelete(String msg, T data) { 37 | return new Result<>(StatusCode.DELETE_SUCCESS, msg, data); 38 | } 39 | public static Result errorGet(String msg){ 40 | return new Result<>(StatusCode.GET_ERROR, msg, null); 41 | } 42 | public static Result errorGet(T data) { 43 | return new Result<>(StatusCode.GET_ERROR, ERROR, data); 44 | } 45 | 46 | public static Result errorPost(String msg){ 47 | return new Result<>(StatusCode.POST_ERROR, msg, null); 48 | } 49 | public static Result errorPost(T data) { 50 | return new Result<>(StatusCode.POST_ERROR, ERROR, data); 51 | } 52 | 53 | public static Result errorPut(String msg){ 54 | return new Result<>(StatusCode.PUT_ERROR, msg, null); 55 | } 56 | public static Result errorPut(T data) { 57 | return new Result<>(StatusCode.PUT_ERROR, ERROR, data); 58 | } 59 | 60 | public static Result errorDelete(String msg){ 61 | return new Result<>(StatusCode.DELETE_ERROR, msg, null); 62 | } 63 | public static Result errorDelete(T data) { 64 | return new Result<>(StatusCode.DELETE_ERROR, ERROR, data); 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /xfs-job-server/src/main/resources/mapper/user/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | update user 31 | 32 | area = #{area}, 33 | avatar_url = #{avatarUrl}, 34 | home_page_background = #{homePageBackground}, 35 | nickname = #{nickname}, 36 | self_introduction = #{selfIntroduction}, 37 | sex = #{sex}, 38 | age = #{age}, 39 | birthday = #{birthday}, 40 | 41 | where id = #{id} 42 | 43 | 46 | 47 | -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/constant/StatusCode.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.constant; 2 | 3 | /** 4 | * @author yyh 5 | * @date 2023-12-09 6 | * @desc 状态码 7 | */ 8 | public class StatusCode { 9 | public static final Integer GET_SUCCESS = 20010; 10 | public static final Integer GET_ERROR = 20011; 11 | 12 | public static final Integer POST_SUCCESS = 20020; 13 | public static final Integer POST_ERROR = 20021; 14 | 15 | public static final Integer PUT_SUCCESS = 20030; 16 | public static final Integer PUT_ERROR = 20031; 17 | 18 | public static final Integer DELETE_SUCCESS = 20040; 19 | public static final Integer DELETE_ERROR = 20041; 20 | 21 | //未登录 22 | public static final Integer NOT_LOGIN = 40310; 23 | //token过期 24 | public static final Integer TOKEN_EXPIRED = 40320; 25 | //token无效 26 | public static final Integer TOKEN_INVALID = 40330; 27 | //密码错误 28 | public static final Integer PASSWORD_ERROR = 40340; 29 | //手机号已存在 30 | public static final Integer PHONE_NUMBER_EXIST = 10010; 31 | //手机号未注册 32 | public static final Integer PHONE_NUMBER_NOT_REGISTER = 10011; 33 | //短信验证码错误 34 | public static final Integer SMS_CODE_ERROR = 10020; 35 | //登录类型错误 36 | public static final Integer LOGIN_TYPE_ERROR = 10030; 37 | //第三方账号openId为空 38 | public static final Integer OPEN_ID_NULL = 10040; 39 | //短信发送频繁 40 | public static final Integer SMS_CODE_SEND_FREQUENTLY = 10050; 41 | //账号异常 42 | public static final Integer ACCOUNT_EXCEPTION = 10060; 43 | //账号在其他设备登录 44 | public static final Integer ACCOUNT_OTHER_LOGIN = 10061; 45 | //账号操作异常 46 | public static final Integer ACCOUNT_OPERATION_ERROR = 10062; 47 | //文件过大 48 | public static final Integer FILE_SIZE_TOO_LARGE = 10070; 49 | //ElasticSearch已初始化 50 | public static final Integer ELASTICSEARCH_INIT_ALREADY = 10080; 51 | // ElasticSearch初始化异常 52 | public static final Integer ELASTICSEARCH_INIT_ERROR = 10081; 53 | //获取地理信息失败 54 | public static final Integer GET_GEOGRAPHIC_INFORMATION_ERROR = 10090; 55 | //无权限 56 | public static final Integer NO_PERMISSION = 10100; 57 | //操作太过频繁 58 | public static final Integer REPEAT_OPERATION = 10110; 59 | //参数错误 60 | public static final Integer PARAMETER_ERROR = 40010; 61 | //服务器异常 62 | public static final Integer SERVER_ERROR = 50000; 63 | //数据库操作异常 64 | public static final Integer DB_ERROR = 50010; 65 | //aliyun短信服务初始化异常 66 | public static final Integer ALIYUN_SMS_INIT_ERROR = 50020; 67 | //aliyun短信服务异常 68 | public static final Integer ALIYUN_SMS_SEND_ERROR = 50021; 69 | //aliyun oss服务异常 70 | public static final Integer ALIYUN_OSS_INIT_ERROR = 50030; 71 | public static final Integer REDIS_ERROR = 50040; 72 | //文件不能为空 73 | public static final Integer FILE_NOT_NULL = 50050; 74 | } 75 | -------------------------------------------------------------------------------- /xfs-common/common-base/src/main/java/com/yyh/xfs/common/utils/CodeUtil.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.common.utils; 2 | 3 | import java.util.Random; 4 | import java.util.concurrent.ThreadLocalRandom; 5 | 6 | /** 7 | * @author yyh 8 | * @date 2023-12-12 9 | */ 10 | 11 | public class CodeUtil { 12 | 13 | /** 14 | * 生成6位随机数,用于短信验证码 15 | * 16 | * @return 6位随机数 17 | */ 18 | public static String createSmsCode() { 19 | // 使用线程安全的Random 20 | ThreadLocalRandom random = ThreadLocalRandom.current(); 21 | int code = random.nextInt(100000, 1000000); 22 | return String.valueOf(code); 23 | } 24 | 25 | /** 26 | * 生成用户uid,6-15位组成,首位不能为0,由数字,英文字母和下划线组成,没有强制要求,三种组合都可以 27 | * 暂时用手机号码后四位和当前时间戳的3-6位相加,再加3-6为替换掉当前时间戳的3-6位,只能有数字组成 28 | * 29 | * @param phoneNumber 手机号码 30 | * @return 用户uid 31 | */ 32 | public static String createUid(String phoneNumber) { 33 | long currentTimeMillis = System.currentTimeMillis(); 34 | String currentTimeMillisStr = String.valueOf(currentTimeMillis); 35 | int currentTimeMillisStrLength = currentTimeMillisStr.length(); 36 | //利用手机号码后四位与当前时间戳的3-6位相加,再加3-6为替换掉当前时间戳的3-6位 37 | String substring = currentTimeMillisStr.substring(2, 6); 38 | int i = Integer.parseInt(substring); 39 | int i1 = Integer.parseInt(phoneNumber.substring(7)); 40 | int i2 = i + i1; 41 | String i2Str = String.valueOf(i2); 42 | String substring1 = currentTimeMillisStr.substring(0, 2); 43 | String substring2 = currentTimeMillisStr.substring(6); 44 | return substring1 + i2Str + substring2; 45 | } 46 | 47 | /** 48 | * 生成用户昵称,8位随机数,由数字,英文字母组成,用户昵称是可以重复的,不需要唯一 49 | */ 50 | public static String createNickname() { 51 | String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 52 | ThreadLocalRandom random = ThreadLocalRandom.current(); 53 | StringBuilder sb = new StringBuilder(); 54 | for (int i = 0; i < 8; i++) { 55 | int number = random.nextInt(62); 56 | sb.append(str.charAt(number)); 57 | } 58 | return sb.toString(); 59 | } 60 | 61 | /** 62 | * 根据hash生成下标,size必须是2的幂 63 | * 64 | * @param object 对象 65 | * @param size 长度 必须是2的幂 66 | * @return 下标 67 | */ 68 | public static int hashIndex(Object object, int size) { 69 | // 判断size是否是2的幂 70 | if ((size & (size - 1)) != 0) { 71 | throw new IllegalArgumentException("size must be a power of 2"); 72 | } 73 | int h; 74 | int hash = (h = object.hashCode()) ^ (h >>> size); 75 | return hash & (size - 1); 76 | } 77 | 78 | /** 79 | * 根据hash生成下标,size必须是2的幂 80 | * 81 | * @param object 对象 82 | * @return 下标 83 | */ 84 | public static int hashIndex(Object object) { 85 | return hashIndex(object, 16); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /xfs-modules-api/xfs-search-api/src/main/java/com/yyh/xfs/search/domain/NotesEsDO.java: -------------------------------------------------------------------------------- 1 | package com.yyh.xfs.search.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.springframework.data.annotation.Id; 7 | import org.springframework.data.elasticsearch.annotations.*; 8 | import org.springframework.data.elasticsearch.core.geo.GeoPoint; 9 | 10 | import java.util.Date; 11 | 12 | /** 13 | * @author yyh 14 | * @date 2024-01-24 15 | */ 16 | @Data 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @Document(indexName = "notes") 20 | public class NotesEsDO { 21 | 22 | @Id 23 | @Field(type = FieldType.Long) 24 | private Long id; 25 | /** 26 | * 笔记标题 27 | */ 28 | @Field(type = FieldType.Text, analyzer = "ik_smart",searchAnalyzer = "ik_smart") 29 | private String title; 30 | 31 | /** 32 | * 笔记内容 33 | */ 34 | @Field(type = FieldType.Text, analyzer = "ik_smart",searchAnalyzer = "ik_smart") 35 | private String content; 36 | 37 | /** 38 | * 将笔记内容的html标签去掉后的纯文本内容,用于搜索 39 | */ 40 | @Field(type = FieldType.Text, analyzer = "ik_smart",searchAnalyzer = "ik_smart") 41 | private String textContent; 42 | 43 | /** 44 | * 所属用户id 45 | */ 46 | @Field(type = FieldType.Long) 47 | private Long belongUserId; 48 | 49 | /** 50 | * 所属分类 51 | */ 52 | @Field(type = FieldType.Integer) 53 | private Integer belongCategory; 54 | 55 | /** 56 | * 笔记类型,0为图片笔记,1为视频笔记 57 | */ 58 | @Field(type = FieldType.Integer) 59 | private Integer notesType; 60 | 61 | /** 62 | * 封面图片 63 | */ 64 | @Field(type = FieldType.Keyword) 65 | private String coverPicture; 66 | 67 | /** 68 | * 笔记资源,图片或视频,视频只能一个,图片最多9个,格式为json序列化数组后的字符串 69 | */ 70 | @Field(type = FieldType.Keyword) 71 | private String notesResources; 72 | 73 | /** 74 | * 赞数 75 | */ 76 | @Field(type = FieldType.Integer) 77 | private Integer notesLikeNum; 78 | 79 | /** 80 | * 收藏数 81 | */ 82 | @Field(type = FieldType.Integer) 83 | private Integer notesCollectionNum; 84 | 85 | /** 86 | * 评论数 87 | */ 88 | @Field(type = FieldType.Integer) 89 | private Integer notesCommentNum; 90 | 91 | /** 92 | * 展示的地点,可以为空 93 | */ 94 | @Field(type = FieldType.Text, analyzer = "ik_max_word",searchAnalyzer = "ik_max_word") 95 | private String address; 96 | 97 | @GeoPointField 98 | private GeoPoint geoPoint; 99 | /** 100 | * 是否公开,0为公开,1为私密 101 | */ 102 | @Field(type = FieldType.Integer) 103 | private Integer authority; 104 | 105 | /** 106 | * 创建时间 107 | */ 108 | @Field(type = FieldType.Long) 109 | private Long createTime; 110 | 111 | /** 112 | * 更新时间 113 | */ 114 | @Field(type = FieldType.Long) 115 | private Long updateTime; 116 | } 117 | --------------------------------------------------------------------------------