├── .gitignore ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── Dockerfile ├── README.assets └── FjuFfQtPAZwlzghcGvNv62Os5ifw.png ├── README.md ├── doc ├── Wanwu.jpg ├── image-20231020105126212.png ├── image-20231020105155593.png ├── image-20231020105215046.png ├── image-20231020105235862.png ├── image-20231020105305192.png └── swagger.png ├── mvnw ├── mvnw.cmd ├── pom.xml ├── sql ├── create_table.sql ├── create_table_api.sql ├── create_table_bi.sql ├── create_table_message.sql └── post_es_mapping.json ├── wanwu-code-api-common ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── cong │ └── wanwu │ └── api │ └── common │ ├── model │ ├── entity │ │ ├── InterfaceInfo.java │ │ └── UserInterfaceInfo.java │ └── enums │ │ └── InterfaceInfoStatusEnum.java │ └── service │ ├── InnerInterfaceInfoService.java │ ├── InnerUserInterfaceInfoService.java │ └── InnerUserService.java ├── wanwu-code-api ├── .gitignore ├── README.md ├── doc │ └── db.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── cong │ │ │ └── wanwu │ │ │ └── api │ │ │ ├── WanwuApiApplication.java │ │ │ ├── aop │ │ │ ├── LogInterceptor.java │ │ │ └── RequestInterceptor.java │ │ │ ├── common │ │ │ └── IdRequest.java │ │ │ ├── config │ │ │ ├── CorsConfig.java │ │ │ ├── Knife4jConfiguration.java │ │ │ └── MyBatisPlusConfig.java │ │ │ ├── controller │ │ │ ├── AnalysisController.java │ │ │ ├── InterfaceInfoController.java │ │ │ └── UserInterfaceInfoController.java │ │ │ ├── feign │ │ │ └── FeignUser.java │ │ │ ├── mapper │ │ │ ├── InterfaceInfoMapper.java │ │ │ └── UserInterfaceInfoMapper.java │ │ │ ├── model │ │ │ ├── dto │ │ │ │ ├── interfaceinfo │ │ │ │ │ ├── InterfaceInfoAddRequest.java │ │ │ │ │ ├── InterfaceInfoInvokeRequest.java │ │ │ │ │ ├── InterfaceInfoQueryRequest.java │ │ │ │ │ └── InterfaceInfoUpdateRequest.java │ │ │ │ └── userInterfaceInfo │ │ │ │ │ ├── UserInterfaceInfoAddRequest.java │ │ │ │ │ ├── UserInterfaceInfoQueryRequest.java │ │ │ │ │ └── UserInterfaceInfoUpdateRequest.java │ │ │ ├── enums │ │ │ │ └── InterfaceInfoStatusEnum.java │ │ │ └── vo │ │ │ │ └── InterfaceInfoVO.java │ │ │ └── service │ │ │ ├── InterfaceInfoService.java │ │ │ ├── UserInterfaceInfoService.java │ │ │ └── impl │ │ │ ├── InterfaceInfoServiceImpl.java │ │ │ ├── UserInterfaceInfoServiceImpl.java │ │ │ └── inner │ │ │ ├── InnerInterfaceInfoServiceImpl.java │ │ │ ├── InnerUserInterfaceInfoServiceImpl.java │ │ │ └── InnerUserServiceImpl.java │ └── resources │ │ ├── application-prod.yml │ │ ├── application.yml │ │ ├── banner.txt │ │ └── mapper │ │ ├── InterfaceInfoMapper.xml │ │ └── UserInterfaceInfoMapper.xml │ └── test │ └── java │ └── com │ └── cong │ └── wanwu │ └── api │ └── service │ └── UserInnerInterfaceInfoServiceTest.java ├── wanwu-code-bi ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── Dockerfile ├── README.md ├── doc │ └── swagger.png ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── cong │ │ │ └── wanwu │ │ │ └── bi │ │ │ ├── WanwuBIApplication.java │ │ │ ├── aop │ │ │ └── LogInterceptor.java │ │ │ ├── api │ │ │ └── OpenAiApi.java │ │ │ ├── bizmq │ │ │ ├── BiMessageConsumer.java │ │ │ ├── BiMessageProducer.java │ │ │ ├── BiMqConstant.java │ │ │ ├── MyMessageConsumer.java │ │ │ └── MyMessageProducer.java │ │ │ ├── config │ │ │ ├── CorsConfig.java │ │ │ ├── CosClientConfig.java │ │ │ ├── JsonConfig.java │ │ │ ├── Knife4jConfig.java │ │ │ ├── MyBatisPlusConfig.java │ │ │ ├── RedissonConfig.java │ │ │ ├── SaTokenConfigure.java │ │ │ ├── ThreadPoolExecutorConfig.java │ │ │ └── XfXhConfig.java │ │ │ ├── constant │ │ │ ├── CommonConstant.java │ │ │ └── FileConstant.java │ │ │ ├── controller │ │ │ ├── ChartController.java │ │ │ ├── DiseaseController.java │ │ │ └── QueueController.java │ │ │ ├── listener │ │ │ ├── XfXhWebSocketAsyncListener.java │ │ │ └── XfXhWebSocketListener.java │ │ │ ├── manager │ │ │ ├── AiManager.java │ │ │ ├── CosManager.java │ │ │ └── RedisLimiterManager.java │ │ │ ├── mapper │ │ │ ├── ChartMapper.java │ │ │ └── DiseaseMapper.java │ │ │ ├── model │ │ │ ├── dto │ │ │ │ ├── chart │ │ │ │ │ ├── ChartAddRequest.java │ │ │ │ │ ├── ChartEditRequest.java │ │ │ │ │ ├── ChartQueryRequest.java │ │ │ │ │ ├── ChartUpdateRequest.java │ │ │ │ │ ├── GenChartByAiRequest.java │ │ │ │ │ ├── XhAiMsgDTO.java │ │ │ │ │ ├── XhAiRequestDTO.java │ │ │ │ │ └── XhAiResponseDTO.java │ │ │ │ ├── disease │ │ │ │ │ ├── DiseaseAddRequest.java │ │ │ │ │ ├── DiseaseEditRequest.java │ │ │ │ │ ├── DiseaseQueryRequest.java │ │ │ │ │ ├── DiseaseUpdateRequest.java │ │ │ │ │ └── GenDiseaseByAiRequest.java │ │ │ │ └── file │ │ │ │ │ └── UploadFileRequest.java │ │ │ ├── entity │ │ │ │ ├── Chart.java │ │ │ │ └── Disease.java │ │ │ ├── enums │ │ │ │ ├── FileUploadBizEnum.java │ │ │ │ └── UserRoleEnum.java │ │ │ └── vo │ │ │ │ ├── BiDiseaseResponse.java │ │ │ │ └── BiResponse.java │ │ │ ├── service │ │ │ ├── ChartService.java │ │ │ ├── DiseaseService.java │ │ │ └── impl │ │ │ │ ├── ChartServiceImpl.java │ │ │ │ ├── DiseaseServiceImpl.java │ │ │ │ └── StpInterfaceImpl.java │ │ │ ├── utils │ │ │ ├── ExcelUtils.java │ │ │ ├── NetUtils.java │ │ │ ├── SpringContextUtils.java │ │ │ └── SqlUtils.java │ │ │ └── ws │ │ │ └── XfXhStreamClient.java │ └── resources │ │ ├── META-INF │ │ └── additional-spring-configuration-metadata.json │ │ ├── application-prod.yml │ │ ├── application-test.yml │ │ ├── application.yml │ │ ├── banner.txt │ │ ├── mapper │ │ ├── ChartMapper.xml │ │ └── DiseaseMapper.xml │ │ ├── test_excel.xlsx │ │ └── 网站数据.xlsx │ └── test │ └── java │ └── com │ └── cong │ └── wanwu │ └── bi │ ├── bizmq │ └── MyMessageProducerTest.java │ ├── manager │ ├── AIManagerTest.java │ ├── CosManagerTest.java │ └── RedisLimiterManagerTest.java │ └── utils │ └── EasyExcelTest.java ├── wanwu-code-common ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── cong │ └── wanwu │ └── common │ ├── annotation │ └── AuthCheck.java │ ├── common │ ├── BaseResponse.java │ ├── DeleteRequest.java │ ├── ErrorCode.java │ ├── PageRequest.java │ └── ResultUtils.java │ ├── constant │ ├── CommonConstant.java │ ├── RedisConstants.java │ ├── SystemConstants.java │ └── UserConstant.java │ ├── exception │ ├── BusinessException.java │ ├── GlobalExceptionHandler.java │ └── ThrowUtils.java │ ├── model │ ├── dto │ │ └── UserAccessKeyRequest.java │ ├── entity │ │ └── User.java │ ├── enums │ │ └── UserRoleEnum.java │ └── vo │ │ ├── request │ │ ├── CursorPageBaseReq.java │ │ └── PageBaseReq.java │ │ └── response │ │ ├── CursorPageBaseResp.java │ │ └── PageBaseResp.java │ └── utils │ ├── AssertUtil.java │ ├── BeanCopyUtils.java │ ├── CodeUtils.java │ ├── CursorUtils.java │ ├── FutureUtils.java │ ├── NetUtils.java │ ├── RedisUtils.java │ ├── SpElUtils.java │ ├── SpringContextUtils.java │ ├── SqlUtils.java │ └── discover │ ├── AbstractUrlTitleDiscover.java │ ├── CommonUrlTitleDiscover.java │ ├── PrioritizedUrlTitleDiscover.java │ ├── UrlTitleDiscover.java │ └── WxUrlTitleDiscover.java ├── wanwu-code-gateway ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── cong │ │ └── wanwu │ │ └── gateway │ │ ├── WanwuGatewayApplication.java │ │ ├── config │ │ ├── RequestLimitConfig.java │ │ └── SaTokenConfigure.java │ │ ├── filter │ │ └── CustomGlobalFilter.java │ │ └── service │ │ └── impl │ │ └── StpInterfaceImpl.java │ └── resources │ └── application.yml └── wanwu-code-usercenter ├── .gitignore ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── cong │ │ └── wanwu │ │ └── usercenter │ │ ├── SimpleCanalClientExample.java │ │ ├── WanwuUserCenterApplication.java │ │ ├── annotation │ │ ├── RedissonLock.java │ │ └── SecureInvokeConfigurer.java │ │ ├── aop │ │ ├── AuthInterceptor.java │ │ └── LogInterceptor.java │ │ ├── aspect │ │ └── RedissonLockAspect.java │ │ ├── common │ │ ├── AlgorithmUtils.java │ │ ├── event │ │ │ ├── ItemReceiveEvent.java │ │ │ ├── MessageMarkEvent.java │ │ │ ├── MessageSendEvent.java │ │ │ ├── UserOfflineEvent.java │ │ │ ├── UserOnlineEvent.java │ │ │ └── UserRegisterEvent.java │ │ ├── handler │ │ │ └── GlobalUncaughtExceptionHandler.java │ │ └── listener │ │ │ ├── MessageSendListener.java │ │ │ ├── UserOfflineListener.java │ │ │ ├── UserOnlineListener.java │ │ │ └── UserRegisterListener.java │ │ ├── config │ │ ├── CorsConfig.java │ │ ├── CosClientConfig.java │ │ ├── JsonConfig.java │ │ ├── Knife4jConfig.java │ │ ├── MinIoClientConfig.java │ │ ├── MyBatisPlusConfig.java │ │ ├── RedisTemplateConfig.java │ │ ├── RedissonConfig.java │ │ ├── SaTokenConfigure.java │ │ ├── ThreadPoolConfig.java │ │ └── WxOpenConfig.java │ │ ├── constant │ │ ├── FileConstant.java │ │ └── RedisKey.java │ │ ├── controller │ │ ├── ChatController.java │ │ ├── FileController.java │ │ ├── LoginController.java │ │ ├── NotificationController.java │ │ ├── OSSController.java │ │ ├── PictureController.java │ │ ├── PostController.java │ │ ├── PostFavourController.java │ │ ├── PostThumbController.java │ │ ├── SearchController.java │ │ ├── UserController.java │ │ ├── UserTagController.java │ │ └── WxMpController.java │ │ ├── datasource │ │ ├── CnBlogDataSource.java │ │ ├── CsdnDataSource.java │ │ ├── DataSource.java │ │ ├── PictureDataSource.java │ │ ├── PostDataSource.java │ │ └── UserDataSource.java │ │ ├── esdao │ │ └── PostEsDao.java │ │ ├── factory │ │ └── MyThreadFactory.java │ │ ├── job │ │ ├── cycle │ │ │ ├── IncSyncPostToEs.java │ │ │ └── IncSyncSendWxLoveMessage.java │ │ └── once │ │ │ ├── FetchInitPostList.java │ │ │ └── FullSyncPostToEs.java │ │ ├── manager │ │ ├── CosManager.java │ │ ├── DataSourceRegistry.java │ │ ├── MinIOManager.java │ │ └── SearchFacade.java │ │ ├── mapper │ │ ├── MessageMapper.java │ │ ├── PostFavourMapper.java │ │ ├── PostImagesMapper.java │ │ ├── PostMapper.java │ │ ├── PostThumbMapper.java │ │ ├── RoomFriendMapper.java │ │ ├── RoomGroupMapper.java │ │ ├── RoomMapper.java │ │ ├── UserAttentionMapper.java │ │ ├── UserMapper.java │ │ └── UserTagMapper.java │ │ ├── model │ │ ├── dto │ │ │ ├── chat │ │ │ │ ├── request │ │ │ │ │ ├── ChatMessageMarkReq.java │ │ │ │ │ ├── ChatMessagePageReq.java │ │ │ │ │ └── ChatMessageReq.java │ │ │ │ └── response │ │ │ │ │ ├── ChatMemberResp.java │ │ │ │ │ ├── ChatMemberStatisticResp.java │ │ │ │ │ ├── ChatMessageResp.java │ │ │ │ │ └── ChatRoomResp.java │ │ │ ├── file │ │ │ │ └── UploadFileRequest.java │ │ │ ├── picture │ │ │ │ └── PictureQueryRequest.java │ │ │ ├── post │ │ │ │ ├── PostAddRequest.java │ │ │ │ ├── PostEditRequest.java │ │ │ │ ├── PostEsDTO.java │ │ │ │ ├── PostImgRemoveRequest.java │ │ │ │ ├── PostPublishRequest.java │ │ │ │ ├── PostQueryRequest.java │ │ │ │ └── PostUpdateRequest.java │ │ │ ├── postfavour │ │ │ │ ├── PostFavourAddRequest.java │ │ │ │ └── PostFavourQueryRequest.java │ │ │ ├── postthumb │ │ │ │ └── PostThumbAddRequest.java │ │ │ ├── search │ │ │ │ └── SearchQueryRequest.java │ │ │ ├── user │ │ │ │ ├── UserAddRequest.java │ │ │ │ ├── UserLoginRequest.java │ │ │ │ ├── UserMpLoginRequest.java │ │ │ │ ├── UserQueryRequest.java │ │ │ │ ├── UserRegisterRequest.java │ │ │ │ ├── UserUpdateMyRequest.java │ │ │ │ └── UserUpdateRequest.java │ │ │ ├── userTag │ │ │ │ └── UserTagAddRequest.java │ │ │ └── ws │ │ │ │ └── WSChannelExtraDTO.java │ │ ├── entity │ │ │ ├── Picture.java │ │ │ ├── Post.java │ │ │ ├── PostFavour.java │ │ │ ├── PostImages.java │ │ │ ├── PostThumb.java │ │ │ ├── UserAttention.java │ │ │ ├── UserTag.java │ │ │ └── chat │ │ │ │ ├── Message.java │ │ │ │ ├── Room.java │ │ │ │ ├── RoomFriend.java │ │ │ │ └── RoomGroup.java │ │ ├── enums │ │ │ ├── FileUploadBizEnum.java │ │ │ ├── MessageTypeEnum.java │ │ │ ├── PostStatusTypeEnum.java │ │ │ ├── SearchTypeEnum.java │ │ │ ├── UserRoleEnum.java │ │ │ ├── chat │ │ │ │ ├── BlackTypeEnum.java │ │ │ │ ├── ChatActiveStatusEnum.java │ │ │ │ ├── ItemEnum.java │ │ │ │ ├── ItemTypeEnum.java │ │ │ │ ├── MessageMarkActTypeEnum.java │ │ │ │ ├── MessageMarkTypeEnum.java │ │ │ │ ├── MessageStatusEnum.java │ │ │ │ └── MessageTypeEnum.java │ │ │ └── ws │ │ │ │ ├── WSReqTypeEnum.java │ │ │ │ └── WSRespTypeEnum.java │ │ └── vo │ │ │ ├── CnBlogVo.java │ │ │ ├── CsdnBlogVo.java │ │ │ ├── LoginUserVO.java │ │ │ ├── NotificationCountVo.java │ │ │ ├── PostVO.java │ │ │ ├── QiNiuPolicyVo.java │ │ │ ├── SearchVO.java │ │ │ ├── TokenLoginUserVo.java │ │ │ ├── UserTagCategoryVo.java │ │ │ ├── UserTagVo.java │ │ │ ├── UserVO.java │ │ │ ├── WxLoveData.java │ │ │ ├── WxLoveMessage.java │ │ │ ├── message │ │ │ ├── ChatMessageVo.java │ │ │ ├── MessageExtra.java │ │ │ ├── MessageVo.java │ │ │ └── RoomFriendVo.java │ │ │ └── ws │ │ │ ├── request │ │ │ ├── WSAuthorize.java │ │ │ └── WSBaseReq.java │ │ │ └── response │ │ │ ├── WSBaseResp.java │ │ │ ├── WSBlack.java │ │ │ ├── WSLoginSuccess.java │ │ │ ├── WSLoginUrl.java │ │ │ ├── WSMessage.java │ │ │ ├── WSMsgMark.java │ │ │ └── WSOnlineOfflineNotify.java │ │ ├── service │ │ ├── ChatService.java │ │ ├── MessageService.java │ │ ├── NotificationService.java │ │ ├── PictureService.java │ │ ├── PostFavourService.java │ │ ├── PostImagesService.java │ │ ├── PostService.java │ │ ├── PostThumbService.java │ │ ├── RoomFriendService.java │ │ ├── RoomGroupService.java │ │ ├── RoomService.java │ │ ├── UserAttentionService.java │ │ ├── UserService.java │ │ ├── UserTagService.java │ │ ├── WebSocketService.java │ │ ├── adapter │ │ │ ├── MessageAdapter.java │ │ │ ├── RoomAdapter.java │ │ │ └── WSAdapter.java │ │ ├── cache │ │ │ └── UserCache.java │ │ └── impl │ │ │ ├── ChatServiceImpl.java │ │ │ ├── LockService.java │ │ │ ├── MessageServiceImpl.java │ │ │ ├── NotificationServiceImpl.java │ │ │ ├── PictureServiceImpl.java │ │ │ ├── PostFavourServiceImpl.java │ │ │ ├── PostImagesServiceImpl.java │ │ │ ├── PostServiceImpl.java │ │ │ ├── PostThumbServiceImpl.java │ │ │ ├── RoomFriendServiceImpl.java │ │ │ ├── RoomGroupServiceImpl.java │ │ │ ├── RoomServiceImpl.java │ │ │ ├── StpInterfaceImpl.java │ │ │ ├── UserAttentionServiceImpl.java │ │ │ ├── UserServiceImpl.java │ │ │ ├── UserTagServiceImpl.java │ │ │ └── WebSocketServiceImpl.java │ │ ├── websocket │ │ ├── HttpHeadersHandler.java │ │ ├── NettyUtil.java │ │ ├── NettyWebSocketServer.java │ │ └── NettyWebSocketServerHandler.java │ │ └── wxmp │ │ ├── WxMpConstant.java │ │ ├── WxMpMsgRouter.java │ │ └── handler │ │ ├── EventHandler.java │ │ ├── MessageHandler.java │ │ └── SubscribeHandler.java └── resources │ ├── META-INF │ └── additional-spring-configuration-metadata.json │ ├── application-prod.yml │ ├── application-test.yml │ ├── application.yml │ ├── banner.txt │ ├── mapper │ ├── MessageMapper.xml │ ├── PostFavourMapper.xml │ ├── PostImagesMapper.xml │ ├── PostMapper.xml │ ├── PostThumbMapper.xml │ ├── RoomFriendMapper.xml │ ├── RoomGroupMapper.xml │ ├── RoomMapper.xml │ ├── UserAttentionMapper.xml │ ├── UserMapper.xml │ └── UserTagMapper.xml │ └── test_excel.xlsx └── test └── java └── com └── cong └── wanwu ├── CrawlerTest.java ├── MainApplicationTests.java ├── esdao └── PostEsDaoTest.java ├── manager └── CosManagerTest.java ├── mapper ├── PostFavourMapperTest.java └── PostMapperTest.java ├── service ├── PostFavourServiceTest.java ├── PostServiceTest.java ├── PostThumbServiceTest.java └── UserServiceTest.java └── usercenter ├── common └── AlgorithmUtilsTest.java └── utils └── EasyExcelTest.java /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.8.1-jdk-8-slim as builder 2 | 3 | # Copy local code to the container image. 4 | WORKDIR /app 5 | COPY pom.xml . 6 | COPY wanwu-code-usercenter/src ./src 7 | 8 | # Build a release artifact. 9 | RUN mvn package -DskipTests 10 | 11 | # Run the web service on container startup. 12 | CMD ["java","-jar","/app/target/wanwu-code-backend-0.0.1-SNAPSHOT.jar","--spring.profiles.active=prod"] -------------------------------------------------------------------------------- /README.assets/FjuFfQtPAZwlzghcGvNv62Os5ifw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhccong/wanwu-code-backend/bb1fd28c65eac3f1f89fbb5a2b5625c1fd471ccc/README.assets/FjuFfQtPAZwlzghcGvNv62Os5ifw.png -------------------------------------------------------------------------------- /doc/Wanwu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhccong/wanwu-code-backend/bb1fd28c65eac3f1f89fbb5a2b5625c1fd471ccc/doc/Wanwu.jpg -------------------------------------------------------------------------------- /doc/image-20231020105126212.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhccong/wanwu-code-backend/bb1fd28c65eac3f1f89fbb5a2b5625c1fd471ccc/doc/image-20231020105126212.png -------------------------------------------------------------------------------- /doc/image-20231020105155593.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhccong/wanwu-code-backend/bb1fd28c65eac3f1f89fbb5a2b5625c1fd471ccc/doc/image-20231020105155593.png -------------------------------------------------------------------------------- /doc/image-20231020105215046.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhccong/wanwu-code-backend/bb1fd28c65eac3f1f89fbb5a2b5625c1fd471ccc/doc/image-20231020105215046.png -------------------------------------------------------------------------------- /doc/image-20231020105235862.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhccong/wanwu-code-backend/bb1fd28c65eac3f1f89fbb5a2b5625c1fd471ccc/doc/image-20231020105235862.png -------------------------------------------------------------------------------- /doc/image-20231020105305192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhccong/wanwu-code-backend/bb1fd28c65eac3f1f89fbb5a2b5625c1fd471ccc/doc/image-20231020105305192.png -------------------------------------------------------------------------------- /doc/swagger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhccong/wanwu-code-backend/bb1fd28c65eac3f1f89fbb5a2b5625c1fd471ccc/doc/swagger.png -------------------------------------------------------------------------------- /sql/post_es_mapping.json: -------------------------------------------------------------------------------- 1 | { 2 | "aliases": { 3 | "post": {} 4 | }, 5 | "mappings": { 6 | "properties": { 7 | "title": { 8 | "type": "text", 9 | "analyzer": "ik_max_word", 10 | "search_analyzer": "ik_smart", 11 | "fields": { 12 | "keyword": { 13 | "type": "keyword", 14 | "ignore_above": 256 15 | } 16 | } 17 | }, 18 | "synopsis": { 19 | "type": "text", 20 | "analyzer": "ik_max_word", 21 | "search_analyzer": "ik_smart", 22 | "fields": { 23 | "keyword": { 24 | "type": "keyword", 25 | "ignore_above": 256 26 | } 27 | } 28 | }, 29 | "content": { 30 | "type": "text", 31 | "analyzer": "ik_max_word", 32 | "search_analyzer": "ik_smart", 33 | "fields": { 34 | "keyword": { 35 | "type": "keyword", 36 | "ignore_above": 256 37 | } 38 | } 39 | }, 40 | "tags": { 41 | "type": "keyword" 42 | }, 43 | "userId": { 44 | "type": "keyword" 45 | }, 46 | "createTime": { 47 | "type": "date" 48 | }, 49 | "updateTime": { 50 | "type": "date" 51 | }, 52 | "isDelete": { 53 | "type": "keyword" 54 | } 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /wanwu-code-api-common/src/main/java/com/cong/wanwu/api/common/model/enums/InterfaceInfoStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.common.model.enums; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | 7 | /** 8 | * 接口信息状态枚举 9 | * 10 | * @author cong 11 | */ 12 | public enum InterfaceInfoStatusEnum { 13 | 14 | ONLINE("上线", 1), 15 | OFFLINE("关闭", 0 ); 16 | 17 | private final String text; 18 | 19 | private final int value; 20 | 21 | InterfaceInfoStatusEnum(String text, int value) { 22 | this.text = text; 23 | this.value = value; 24 | } 25 | 26 | /** 27 | * 获取值列表 28 | * 29 | * @return 30 | */ 31 | public static List getValues() { 32 | return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList()); 33 | } 34 | 35 | public int getValue() { 36 | return value; 37 | } 38 | 39 | public String getText() { 40 | return text; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /wanwu-code-api-common/src/main/java/com/cong/wanwu/api/common/service/InnerInterfaceInfoService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.common.service; 2 | 3 | 4 | import com.cong.wanwu.api.common.model.entity.InterfaceInfo; 5 | 6 | /** 7 | * @author 86188 8 | * @description 针对表【interface_info(接口信息表)】的数据库操作Service 9 | * @createDate 2022-10-30 17:11:45 10 | */ 11 | public interface InnerInterfaceInfoService { 12 | /** 13 | * 从数据库中查询模拟接口是否存在(请求路径、请求方法、请求参数) 14 | * @param path 路径 15 | * @param method 方法 16 | * @return {@link InterfaceInfo} 17 | */ 18 | InterfaceInfo getInterfaceInfo(String path,String method); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /wanwu-code-api-common/src/main/java/com/cong/wanwu/api/common/service/InnerUserInterfaceInfoService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.common.service; 2 | 3 | /** 4 | * @author 86188 5 | * @description 针对表【user_interface_info(用户调用接口关系)】的数据库操作Service 6 | * @createDate 2022-11-21 21:34:18 7 | */ 8 | public interface InnerUserInterfaceInfoService { 9 | 10 | 11 | 12 | /** 13 | * 调用计数 14 | * 15 | * @param interfaceInfoId 接口信息id 16 | * @param userId 用户id 17 | * @return Boolean 18 | */ 19 | Boolean invokeCount(Long interfaceInfoId,long userId); 20 | 21 | 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /wanwu-code-api-common/src/main/java/com/cong/wanwu/api/common/service/InnerUserService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.common.service; 2 | 3 | import com.cong.wanwu.common.model.entity.User; 4 | 5 | 6 | /** 7 | * 用户服务 8 | * 9 | * @author cong 10 | */ 11 | public interface InnerUserService { 12 | 13 | /** 14 | * 数据库中查是否已分配给用户秘钥(accessKey) 15 | * @param accessKey 16 | * @return 17 | */ 18 | User getInvokerUser(String accessKey); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /wanwu-code-api/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | ./src/main/resources/bootstrap.yml 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /wanwu-code-api/README.md: -------------------------------------------------------------------------------- 1 | # SpringBoot 项目初始模板 2 | 3 | > by [程序员鱼皮知识星球](https://cong.icu) 4 | 5 | Java SpringBoot 项目初始模板,整合了常用框架和示例代码,大家可以在此基础上快速开发自己的项目。 6 | 7 | ## 模板功能 8 | 9 | - Spring Boot 2.7.0(贼新) 10 | - Spring MVC 11 | - MySQL 驱动 12 | - MyBatis 13 | - MyBatis Plus 14 | - Spring Session Redis 分布式登录 15 | - Spring AOP 16 | - Apache Commons Lang3 工具类 17 | - Lombok 注解 18 | - Swagger + Knife4j 接口文档 19 | - Spring Boot 调试工具和项目处理器 20 | - 全局请求响应拦截器(记录日志) 21 | - 全局异常处理器 22 | - 自定义错误码 23 | - 封装通用响应类 24 | - 示例用户注册、登录、搜索功能 25 | - 示例单元测试类 26 | - 示例 SQL(用户表) 27 | 28 | 访问 localhost:7529/api/doc.html 就能在线调试接口了,不需要前端配合啦~ -------------------------------------------------------------------------------- /wanwu-code-api/doc/db.md: -------------------------------------------------------------------------------- 1 | # 数据库设计 2 | 3 | > 建表语句见 `sql/ddl.sql` 文件 4 | 5 | ## 用户信息表 6 | 7 | 8 | -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/WanwuApiApplication.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api; 2 | 3 | import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; 4 | import org.mybatis.spring.annotation.MapperScan; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 8 | import org.springframework.cloud.openfeign.EnableFeignClients; 9 | 10 | /** 11 | * @author liuhuaicong 12 | * @date 2023/10/12 13 | */ 14 | @SpringBootApplication 15 | @MapperScan("com.cong.wanwu.api.mapper") 16 | @EnableDubbo 17 | @EnableFeignClients 18 | @EnableDiscoveryClient 19 | public class WanwuApiApplication { 20 | 21 | public static void main(String[] args) { 22 | 23 | SpringApplication.run(WanwuApiApplication.class, args); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/common/IdRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.common; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * id请求 9 | * 10 | * @author cong 11 | */ 12 | @Data 13 | public class IdRequest implements Serializable { 14 | /** 15 | * id 16 | */ 17 | private Long id; 18 | 19 | private static final long serialVersionUID = 1L; 20 | } -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | //package com.cong.wanwu.api.config; 2 | // 3 | //import org.springframework.context.annotation.Configuration; 4 | //import org.springframework.web.servlet.config.annotation.CorsRegistry; 5 | //import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | // 7 | ///** 8 | // * 全局跨域配置 9 | // * 10 | // * @author cong 11 | // */ 12 | //@Configuration 13 | //public class CorsConfig implements WebMvcConfigurer { 14 | // 15 | // @Override 16 | // public void addCorsMappings(CorsRegistry registry) { 17 | // // 覆盖所有请求 18 | // registry.addMapping("/**") 19 | // // 允许发送 Cookie 20 | // .allowCredentials(true) 21 | // // 放行哪些域名(必须用 patterns,否则 * 会和 allowCredentials 冲突) 22 | // .allowedOriginPatterns("*") 23 | // .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") 24 | // .allowedHeaders("*") 25 | // .exposedHeaders("*"); 26 | // } 27 | //} 28 | -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/config/MyBatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 6 | import org.mybatis.spring.annotation.MapperScan; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | /** 11 | * MyBatis Plus 配置 12 | * 13 | * @author cong 14 | */ 15 | @Configuration 16 | @MapperScan("com.cong.wanwu.api.mapper") 17 | public class MyBatisPlusConfig { 18 | 19 | /** 20 | * 拦截器配置 21 | * 22 | * @return 23 | */ 24 | @Bean 25 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 26 | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); 27 | // 分页插件 28 | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); 29 | return interceptor; 30 | } 31 | } -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/controller/AnalysisController.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.controller; 2 | 3 | 4 | import com.cong.wanwu.api.mapper.UserInterfaceInfoMapper; 5 | import com.cong.wanwu.api.model.vo.InterfaceInfoVO; 6 | import com.cong.wanwu.common.common.BaseResponse; 7 | import com.cong.wanwu.common.common.ResultUtils; 8 | import lombok.extern.slf4j.Slf4j; 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 javax.annotation.Resource; 14 | import java.util.List; 15 | 16 | /** 17 | * 分析控制器 18 | * 19 | * @author 86188 20 | * @date 2023/01/27 21 | */ 22 | @RestController 23 | @RequestMapping("/analysis") 24 | @Slf4j 25 | public class AnalysisController { 26 | @Resource 27 | private UserInterfaceInfoMapper userInterfaceInfoMapper; 28 | @GetMapping("/top/interface/invoke") 29 | public BaseResponse> listTopInvokeInterfaceInfo(){ 30 | int limit = 3; 31 | List interfaceInfoVOList = userInterfaceInfoMapper.listTopInvokeInterfaceInfo(limit); 32 | return ResultUtils.success(interfaceInfoVOList); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/feign/FeignUser.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.feign; 2 | 3 | import com.cong.wanwu.common.common.BaseResponse; 4 | import com.cong.wanwu.common.model.dto.UserAccessKeyRequest; 5 | import com.cong.wanwu.common.model.entity.User; 6 | import org.springframework.cloud.openfeign.FeignClient; 7 | import org.springframework.web.bind.annotation.PostMapping; 8 | 9 | /** 10 | * @author liuhuaicong 11 | * @date 2023/10/12 12 | */ 13 | @FeignClient(value = "wanwu-code-usercenter",url = "https://qingxin.store/wanwu/wanwu-usercenter") 14 | public interface FeignUser { 15 | /** 16 | * 通过accessKey获取用户信息 17 | * @param userAccessKeyRequest 请求内容 18 | * @return {@link BaseResponse}<{@link User}> 19 | */ 20 | @PostMapping(value = "/api/user/getInvokerUser") 21 | BaseResponse getInvokerUser(UserAccessKeyRequest userAccessKeyRequest); 22 | } 23 | -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/mapper/InterfaceInfoMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.mapper; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import com.cong.wanwu.api.common.model.entity.InterfaceInfo; 6 | 7 | /** 8 | * @author 86188 9 | * @description 针对表【interface_info(接口信息表)】的数据库操作Mapper 10 | * @createDate 2022-10-30 17:11:45 11 | * @Entity com.cong.wanwu.api.model.entity.InterfaceInfo 12 | */ 13 | public interface InterfaceInfoMapper extends BaseMapper { 14 | 15 | } 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/mapper/UserInterfaceInfoMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.cong.wanwu.api.common.model.entity.UserInterfaceInfo; 5 | import com.cong.wanwu.api.model.vo.InterfaceInfoVO; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author 86188 12 | * @description 针对表【user_interface_info(用户调用接口关系)】的数据库操作Mapper 13 | * @createDate 2022-11-21 21:34:18 14 | * @Entity com.cong.wanwu.api.model.entity.UserInterfaceInfo 15 | */ 16 | public interface UserInterfaceInfoMapper extends BaseMapper { 17 | 18 | /** 19 | * 列表调用接口信息 20 | * 21 | * @param limit 限制 22 | * @return {@link List}<{@link InterfaceInfoVO}> 23 | */ 24 | List listTopInvokeInterfaceInfo(@Param("limit") int limit); 25 | } 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/model/dto/interfaceinfo/InterfaceInfoAddRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.model.dto.interfaceinfo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 创建请求 9 | 10 | * @author lhcong 11 | * @TableName InterfaceInfo 12 | */ 13 | @Data 14 | public class InterfaceInfoAddRequest implements Serializable { 15 | 16 | 17 | /** 18 | * 接口名称 19 | */ 20 | private String name; 21 | 22 | /** 23 | * 请求类型 24 | */ 25 | private String method; 26 | /** 27 | * 请求参数 28 | */ 29 | private String requestParams; 30 | 31 | /** 32 | * 描述 33 | */ 34 | private String description; 35 | 36 | /** 37 | * 接口地址 38 | */ 39 | private String url; 40 | 41 | /** 42 | * 请求头 43 | */ 44 | private String requestHeader; 45 | 46 | 47 | 48 | /** 49 | * 响应头 50 | */ 51 | private String responseHeader; 52 | 53 | 54 | 55 | private static final long serialVersionUID = 1L; 56 | } -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/model/dto/interfaceinfo/InterfaceInfoInvokeRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.model.dto.interfaceinfo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 用户模拟请求 9 | * 10 | * @author lhcong 11 | * @TableName InterfaceInfo 12 | */ 13 | @Data 14 | public class InterfaceInfoInvokeRequest implements Serializable { 15 | 16 | /** 17 | * 主键 18 | */ 19 | private Long id; 20 | 21 | 22 | /** 23 | * 用户请求参数 24 | */ 25 | private String userRequestParams; 26 | 27 | 28 | } -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/model/dto/interfaceinfo/InterfaceInfoQueryRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.model.dto.interfaceinfo; 2 | 3 | import com.cong.wanwu.common.common.PageRequest; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 查询请求 11 | * 12 | * 13 | * @author lhcong 14 | * @TableName InterfaceInfo 15 | */ 16 | @EqualsAndHashCode(callSuper = true) 17 | @Data 18 | public class InterfaceInfoQueryRequest extends PageRequest implements Serializable { 19 | 20 | /** 21 | * 主键 22 | */ 23 | private Long id; 24 | /** 25 | * 创建人 26 | */ 27 | private Long userId; 28 | 29 | /** 30 | * 接口名称 31 | */ 32 | private String name; 33 | 34 | /** 35 | * 请求类型 36 | */ 37 | private String method; 38 | 39 | /** 40 | * 描述 41 | */ 42 | private String description; 43 | 44 | /** 45 | * 接口地址 46 | */ 47 | private String url; 48 | 49 | /** 50 | * 请求头 51 | */ 52 | private String requestHeader; 53 | 54 | /** 55 | * 接口状态(0-关闭 1-开启) 56 | */ 57 | private Integer status; 58 | 59 | /** 60 | * 响应头 61 | */ 62 | private String responseHeader; 63 | 64 | 65 | } -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/model/dto/interfaceinfo/InterfaceInfoUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.model.dto.interfaceinfo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 更新请求 9 | * 10 | * @author lhcong 11 | * @TableName InterfaceInfo 12 | */ 13 | @Data 14 | public class InterfaceInfoUpdateRequest implements Serializable { 15 | 16 | /** 17 | * 主键 18 | */ 19 | private Long id; 20 | 21 | 22 | /** 23 | * 接口名称 24 | */ 25 | private String name; 26 | 27 | /** 28 | * 请求类型 29 | */ 30 | private String method; 31 | /** 32 | * 请求参数 33 | */ 34 | private String requestParams; 35 | 36 | /** 37 | * 描述 38 | */ 39 | private String description; 40 | 41 | /** 42 | * 接口地址 43 | */ 44 | private String url; 45 | 46 | /** 47 | * 请求头 48 | */ 49 | private String requestHeader; 50 | 51 | /** 52 | * 接口状态(0-关闭 1-开启) 53 | */ 54 | private Integer status; 55 | 56 | /** 57 | * 响应头 58 | */ 59 | private String responseHeader; 60 | } -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/model/dto/userInterfaceInfo/UserInterfaceInfoAddRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.model.dto.userInterfaceInfo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 创建请求 9 | 10 | * @author lhcong 11 | * @TableName InterfaceInfo 12 | */ 13 | @Data 14 | public class UserInterfaceInfoAddRequest implements Serializable { 15 | 16 | 17 | 18 | /** 19 | * 调用用户 20 | */ 21 | private Long userId; 22 | 23 | /** 24 | * 接口id 25 | */ 26 | private Long interfaceInfoId; 27 | 28 | /** 29 | * 总调用次数 30 | */ 31 | private Integer totalNum; 32 | 33 | /** 34 | * 剩余调用次数 35 | */ 36 | private Integer leftNum; 37 | 38 | } -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/model/dto/userInterfaceInfo/UserInterfaceInfoQueryRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.model.dto.userInterfaceInfo; 2 | 3 | import com.cong.wanwu.common.common.PageRequest; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 查询请求 11 | * 12 | * 13 | * @author lhcong 14 | * @TableName InterfaceInfo 15 | */ 16 | @EqualsAndHashCode(callSuper = true) 17 | @Data 18 | public class UserInterfaceInfoQueryRequest extends PageRequest implements Serializable { 19 | 20 | /** 21 | * 主键 22 | */ 23 | private Long id; 24 | 25 | /** 26 | * 调用用户 27 | */ 28 | private Long userId; 29 | 30 | /** 31 | * 接口id 32 | */ 33 | private Long interfaceInfoId; 34 | 35 | /** 36 | * 总调用次数 37 | */ 38 | private Integer totalNum; 39 | 40 | /** 41 | * 剩余调用次数 42 | */ 43 | private Integer leftNum; 44 | 45 | /** 46 | * 接口状态(0-正常 1-禁用) 47 | */ 48 | private Integer status; 49 | 50 | 51 | } -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/model/dto/userInterfaceInfo/UserInterfaceInfoUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.model.dto.userInterfaceInfo; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 更新请求 9 | * 10 | * @author lhcong 11 | * @TableName InterfaceInfo 12 | */ 13 | @Data 14 | public class UserInterfaceInfoUpdateRequest implements Serializable { 15 | 16 | /** 17 | * 主键 18 | */ 19 | private Long id; 20 | 21 | 22 | /** 23 | * 总调用次数 24 | */ 25 | private Integer totalNum; 26 | 27 | /** 28 | * 剩余调用次数 29 | */ 30 | private Integer leftNum; 31 | 32 | /** 33 | * 接口状态(0-正常 1-禁用) 34 | */ 35 | private Integer status; 36 | 37 | } -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/model/enums/InterfaceInfoStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.model.enums; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | 7 | /** 8 | * 接口信息状态枚举 9 | * 10 | * @author cong 11 | */ 12 | public enum InterfaceInfoStatusEnum { 13 | 14 | ONLINE("上线", 1), 15 | OFFLINE("关闭", 0 ); 16 | 17 | private final String text; 18 | 19 | private final int value; 20 | 21 | InterfaceInfoStatusEnum(String text, int value) { 22 | this.text = text; 23 | this.value = value; 24 | } 25 | 26 | /** 27 | * 获取值列表 28 | * 29 | * @return 30 | */ 31 | public static List getValues() { 32 | return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList()); 33 | } 34 | 35 | public int getValue() { 36 | return value; 37 | } 38 | 39 | public String getText() { 40 | return text; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/model/vo/InterfaceInfoVO.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.model.vo; 2 | 3 | 4 | import com.cong.wanwu.api.common.model.entity.InterfaceInfo; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | /** 9 | * 接口信息封装类 10 | * 11 | * @author cong 12 | * @TableName product 13 | */ 14 | @EqualsAndHashCode(callSuper = true) 15 | @Data 16 | public class InterfaceInfoVO extends InterfaceInfo { 17 | 18 | /** 19 | * 统计次数 20 | */ 21 | private Integer totalNum; 22 | 23 | private static final long serialVersionUID = 1L; 24 | } -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/service/InterfaceInfoService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.cong.wanwu.api.common.model.entity.InterfaceInfo; 5 | 6 | /** 7 | * @author 86188 8 | * @description 针对表【interface_info(接口信息表)】的数据库操作Service 9 | * @createDate 2022-10-30 17:11:45 10 | */ 11 | public interface InterfaceInfoService extends IService { 12 | 13 | 14 | /** 15 | * 有效接口信息 16 | * 17 | * @param interfaceInfo 接口信息 18 | * @param add 添加 19 | */ 20 | void validInterfaceInfo(InterfaceInfo interfaceInfo, boolean add); 21 | } 22 | -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/service/UserInterfaceInfoService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.cong.wanwu.api.common.model.entity.UserInterfaceInfo; 5 | 6 | /** 7 | * 用户接口信息服务 8 | * 9 | * @author 86188 10 | * @date 2023/01/13 11 | */ 12 | public interface UserInterfaceInfoService extends IService { 13 | /** 14 | * 有效用户界面信息 15 | * 16 | * @param userInterfaceInfo 用户界面信息 17 | * @param add 18 | */ 19 | void validUserInterfaceInfo(UserInterfaceInfo userInterfaceInfo, boolean add); 20 | 21 | /** 22 | * 调用计数 23 | * 24 | * @param interfaceInfoId 接口信息id 25 | * @param userId 用户id 26 | * @return Boolean 27 | */ 28 | Boolean invokeCount(Long interfaceInfoId,long userId); 29 | } 30 | -------------------------------------------------------------------------------- /wanwu-code-api/src/main/java/com/cong/wanwu/api/service/impl/inner/InnerUserInterfaceInfoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.service.impl.inner; 2 | 3 | 4 | import com.cong.wanwu.api.common.service.InnerUserInterfaceInfoService; 5 | import com.cong.wanwu.api.service.UserInterfaceInfoService; 6 | import org.apache.dubbo.config.annotation.DubboService; 7 | 8 | import javax.annotation.Resource; 9 | 10 | /** 11 | * 内部用户界面信息服务 12 | * 13 | * @author 86188 14 | * @date 2023/01/13 15 | */ 16 | @DubboService 17 | public class InnerUserInterfaceInfoServiceImpl implements InnerUserInterfaceInfoService { 18 | 19 | @Resource 20 | private UserInterfaceInfoService userInterfaceInfoService; 21 | 22 | @Override 23 | public Boolean invokeCount(Long interfaceInfoId, long userId) { 24 | return userInterfaceInfoService.invokeCount(interfaceInfoId,userId); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /wanwu-code-api/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | #spring: 2 | # datasource: 3 | # driver-class-name: com.mysql.cj.jdbc.Driver 4 | # url: jdbc:mysql://localhost:3306/congapi 5 | # username: root 6 | # password: 123456 -------------------------------------------------------------------------------- /wanwu-code-api/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | 我的项目 by 程序员鱼皮 https://github.com/licong -------------------------------------------------------------------------------- /wanwu-code-api/src/test/java/com/cong/wanwu/api/service/UserInnerInterfaceInfoServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.api.service; 2 | 3 | import org.junit.Assert; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | 7 | import javax.annotation.Resource; 8 | 9 | @SpringBootTest 10 | public class UserInnerInterfaceInfoServiceTest { 11 | 12 | @Resource 13 | private UserInterfaceInfoService userInterfaceInfoService; 14 | 15 | @Test 16 | public void invokeCount() { 17 | Boolean aBoolean = userInterfaceInfoService.invokeCount(1L, 1L); 18 | Assert.assertTrue(aBoolean); 19 | } 20 | } -------------------------------------------------------------------------------- /wanwu-code-bi/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /wanwu-code-bi/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.8.1-jdk-8-slim as builder 2 | 3 | # Copy local code to the container image. 4 | WORKDIR /app 5 | COPY pom.xml . 6 | COPY src ./src 7 | 8 | # Build a release artifact. 9 | RUN mvn package -DskipTests 10 | 11 | # Run the web service on container startup. 12 | CMD ["java","-jar","/app/target/wanwu-code-bi-0.0.1-SNAPSHOT.jar","--spring.profiles.active=prod"] -------------------------------------------------------------------------------- /wanwu-code-bi/doc/swagger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhccong/wanwu-code-backend/bb1fd28c65eac3f1f89fbb5a2b5625c1fd471ccc/wanwu-code-bi/doc/swagger.png -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/api/OpenAiApi.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.api; 2 | 3 | /** 4 | * 开放ai api 5 | * 6 | * @author 86188 7 | * @date 2023/05/19 8 | */ 9 | public class OpenAiApi { 10 | /** 11 | * AI 对话(需要自己创建请求响应对象) 12 | * 13 | * @param request 14 | * @param openAiApiKey 15 | * @return 16 | */ 17 | // public CreateChatCompletionResponse createChatCompletion(CreateChatCompletionRequest request, String openAiApiKey) { 18 | // if (StringUtils.isBlank(openAiApiKey)) { 19 | // throw new BusinessException(ErrorCode.PARAMS_ERROR, "未传 openAiApiKey"); 20 | // } 21 | // 22 | // String url = "https://api.openai.com/v1/chat/completions"; 23 | // String json = JSONUtil.toJsonStr(request); 24 | // String result = HttpRequest.post(url) 25 | // .header("Authorization", "Bearer " + openAiApiKey) 26 | // .body(json) 27 | // .execute() 28 | // .body(); 29 | // return JSONUtil.toBean(result, CreateChatCompletionResponse.class); 30 | // } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/bizmq/BiMessageProducer.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.bizmq; 2 | 3 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 4 | import org.springframework.stereotype.Component; 5 | 6 | import javax.annotation.Resource; 7 | 8 | /** 9 | * 消息发送 10 | * 11 | * @author 86188 12 | * @date 2023/06/23 13 | */ 14 | @Component 15 | public class BiMessageProducer { 16 | @Resource 17 | private RabbitTemplate rabbitTemplate; 18 | 19 | /** 20 | * 发送消息 21 | * @param message 22 | */ 23 | public void sendMessage(String message){ 24 | rabbitTemplate.convertAndSend(BiMqConstant.BI_EXCHANGE_NAME,BiMqConstant.BI_ROUTING_KEY,message); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/bizmq/BiMqConstant.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.bizmq; 2 | 3 | /** 4 | * bi mq常数 5 | * 6 | * @author 86188 7 | * @date 2023/06/23 8 | */ 9 | public interface BiMqConstant { 10 | String BI_EXCHANGE_NAME = "bi_exchange"; 11 | String BI_QUEUE_NAME = "bi_queue"; 12 | String BI_ROUTING_KEY = "bi_routingKey"; 13 | } 14 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/bizmq/MyMessageConsumer.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.bizmq; 2 | 3 | import com.rabbitmq.client.AMQP; 4 | import com.rabbitmq.client.Channel; 5 | import lombok.SneakyThrows; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.amqp.rabbit.annotation.RabbitListener; 8 | import org.springframework.amqp.rabbit.annotation.RabbitListeners; 9 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 10 | import org.springframework.amqp.support.AmqpHeaders; 11 | import org.springframework.messaging.handler.annotation.Header; 12 | import org.springframework.stereotype.Component; 13 | 14 | import javax.annotation.Resource; 15 | 16 | /** 17 | * 信息消费 18 | * 19 | * @author 86188 20 | * @date 2023/06/23 21 | */ 22 | @Component 23 | @Slf4j 24 | public class MyMessageConsumer { 25 | @Resource 26 | private RabbitTemplate rabbitTemplate; 27 | 28 | /** 29 | * 指定监听的消息队列和确认机制 30 | * @param message 31 | * @param channel 32 | * @param deliveryTags 33 | */ 34 | @RabbitListener(queues = {"code-queue"},ackMode = "MANUAL") 35 | @SneakyThrows 36 | public void receiveMessage(String message, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTags){ 37 | log.info("收到消息啦->{}",message); 38 | channel.basicAck(deliveryTags,false); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/bizmq/MyMessageProducer.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.bizmq; 2 | 3 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 4 | import org.springframework.stereotype.Component; 5 | 6 | import javax.annotation.Resource; 7 | 8 | /** 9 | * 消息发送 10 | * 11 | * @author 86188 12 | * @date 2023/06/23 13 | */ 14 | @Component 15 | public class MyMessageProducer { 16 | @Resource 17 | private RabbitTemplate rabbitTemplate; 18 | 19 | public void sendMessage(String exchange,String routingKey,String message){ 20 | rabbitTemplate.convertAndSend(exchange,routingKey,message); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | //package com.cong.wanwu.bi.config; 2 | // 3 | //import org.springframework.context.annotation.Configuration; 4 | //import org.springframework.web.servlet.config.annotation.CorsRegistry; 5 | //import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | // 7 | ///** 8 | // * 全局跨域配置 9 | // * 10 | // * @author 程序员鱼皮 11 | // * @from 编程导航知识星球 12 | // */ 13 | //@Configuration 14 | //public class CorsConfig implements WebMvcConfigurer { 15 | // @Override 16 | // public void addCorsMappings(CorsRegistry registry) { 17 | // registry.addMapping("/**") // 所有接口 18 | // .allowCredentials(true) // 是否发送 Cookie 19 | // .allowedOriginPatterns("*") // 支持域 20 | // .allowedMethods("GET", "POST", "PUT", "DELETE") // 支持方法 21 | // .allowedHeaders("*") 22 | // .exposedHeaders("*"); 23 | // } 24 | //} 25 | // 26 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/config/JsonConfig.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.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.ToStringSerializer; 6 | import org.springframework.boot.jackson.JsonComponent; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; 9 | 10 | /** 11 | * Spring MVC Json 配置 12 | * 13 | * @author 程序员鱼皮 14 | * @from 编程导航知识星球 15 | */ 16 | @JsonComponent 17 | public class JsonConfig { 18 | 19 | /** 20 | * 添加 Long 转 json 精度丢失的配置 21 | */ 22 | @Bean 23 | public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { 24 | ObjectMapper objectMapper = builder.createXmlMapper(false).build(); 25 | SimpleModule module = new SimpleModule(); 26 | module.addSerializer(Long.class, ToStringSerializer.instance); 27 | module.addSerializer(Long.TYPE, ToStringSerializer.instance); 28 | objectMapper.registerModule(module); 29 | return objectMapper; 30 | } 31 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/config/MyBatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 6 | import org.mybatis.spring.annotation.MapperScan; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | /** 11 | * MyBatis Plus 配置 12 | * 13 | * @author https://github.com/liyupi 14 | */ 15 | @Configuration 16 | @MapperScan("com.cong.wanwu.bi.mapper") 17 | public class MyBatisPlusConfig { 18 | 19 | /** 20 | * 拦截器配置 21 | * 22 | * @return 23 | */ 24 | @Bean 25 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 26 | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); 27 | // 分页插件 28 | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); 29 | return interceptor; 30 | } 31 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/config/RedissonConfig.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.config; 2 | 3 | import lombok.Data; 4 | import org.redisson.Redisson; 5 | import org.redisson.api.RedissonClient; 6 | import org.redisson.client.RedisClient; 7 | import org.redisson.config.Config; 8 | import org.springframework.boot.context.properties.ConfigurationProperties; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | /** 13 | * redisson配置 14 | * 15 | * @author 86188 16 | * @date 2023/05/26 17 | */ 18 | @Configuration 19 | @Data 20 | @ConfigurationProperties(prefix = "spring.redis") 21 | public class RedissonConfig { 22 | private Integer database; 23 | 24 | private String host; 25 | 26 | private Integer port; 27 | 28 | private String password; 29 | @Bean 30 | public RedissonClient redissonClient(){ 31 | Config config = new Config(); 32 | config.useSingleServer() 33 | .setAddress("redis://"+host+":"+port) 34 | .setDatabase(database) 35 | .setPassword(password); 36 | RedissonClient redissonClient = Redisson.create(config); 37 | return redissonClient; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/config/SaTokenConfigure.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.config; 2 | 3 | import cn.dev33.satoken.interceptor.SaInterceptor; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | /** 9 | * @author liuhuaicong 10 | */ 11 | @Configuration 12 | public class SaTokenConfigure implements WebMvcConfigurer { 13 | // 注册 Sa-Token 拦截器,打开注解式鉴权功能 14 | @Override 15 | public void addInterceptors(InterceptorRegistry registry) { 16 | // 注册 Sa-Token 拦截器,打开注解式鉴权功能 17 | registry.addInterceptor(new SaInterceptor()).addPathPatterns("/**"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/config/XfXhConfig.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.config; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | 8 | /** 9 | * 星火配置 10 | * 11 | * @author 86188 12 | * @date 2023/10/22 13 | */ 14 | @Configuration 15 | @ConfigurationProperties(prefix = "xfxh") 16 | @Data 17 | public class XfXhConfig { 18 | /** 19 | * 服务引擎使用 讯飞星火认知大模型V2.0,如果使用 V1.5 需要将 hostUrl 修改为 https://spark-api.xf-yun.com/v1.1/chat 20 | */ 21 | private String hostUrl; 22 | /** 23 | * 发送请求时指定的访问领域,如果是 V1.5版本 设置为 general,如果是 V2版本 设置为 generalv2 24 | */ 25 | private String domain; 26 | /** 27 | * 核采样阈值。用于决定结果随机性,取值越高随机性越强即相同的问题得到的不同答案的可能性越高。取值 [0,1] 28 | */ 29 | private Float temperature; 30 | /** 31 | * 模型回答的tokens的最大长度,V1.5取值为[1,4096],V2.0取值为[1,8192]。 32 | */ 33 | private Integer maxTokens; 34 | /** 35 | * 大模型回复问题的最大响应时长,单位 s 36 | */ 37 | private Integer maxResponseTime; 38 | /** 39 | * 用于权限验证,从服务接口认证信息中获取 40 | */ 41 | private String appId; 42 | /** 43 | * 用于权限验证,从服务接口认证信息中获取 44 | */ 45 | private String apiKey; 46 | /** 47 | * 用于权限验证,从服务接口认证信息中获取 48 | */ 49 | private String apiSecret; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/constant/CommonConstant.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.constant; 2 | 3 | /** 4 | * 通用常量 5 | * 6 | * @author 程序员鱼皮 7 | * @from 编程导航知识星球 8 | */ 9 | public interface CommonConstant { 10 | 11 | /** 12 | * 升序 13 | */ 14 | String SORT_ORDER_ASC = "ascend"; 15 | 16 | /** 17 | * 降序 18 | */ 19 | String SORT_ORDER_DESC = " descend"; 20 | /** 21 | * bi模型id 22 | */ 23 | long BI_MODEL_ID = 1659171950288818178L; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/constant/FileConstant.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.constant; 2 | 3 | /** 4 | * 文件常量 5 | * 6 | * @author 程序员鱼皮 7 | * @from 编程导航知识星球 8 | */ 9 | public interface FileConstant { 10 | 11 | /** 12 | * COS 访问地址 13 | * todo 需替换配置 14 | */ 15 | String COS_HOST = "https://yupi.icu"; 16 | } 17 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/manager/RedisLimiterManager.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.manager; 2 | 3 | import com.cong.wanwu.common.exception.BusinessException; 4 | import org.redisson.api.RRateLimiter; 5 | import org.redisson.api.RateIntervalUnit; 6 | import org.redisson.api.RateType; 7 | import org.redisson.api.RedissonClient; 8 | import org.springframework.stereotype.Service; 9 | import com.cong.wanwu.common.common.ErrorCode; 10 | import javax.annotation.Resource; 11 | 12 | /** 13 | * 提供RedisLimiter限流基础服务 14 | * 15 | * @author 86188 16 | * @date 2023/05/26 17 | */ 18 | @Service 19 | public class RedisLimiterManager { 20 | 21 | @Resource 22 | private RedissonClient redissonClient; 23 | 24 | /** 25 | * 限流操作 26 | * @param key 区分不同的限流器,比如不同的用户id应该分别统计 27 | */ 28 | public void doRateLimit(String key){ 29 | //创建一个限流器,每秒最多访问2次 30 | RRateLimiter rateLimiter = redissonClient.getRateLimiter(key); 31 | rateLimiter.trySetRate(RateType.OVERALL,2,1, RateIntervalUnit.SECONDS); 32 | //每当操作来了后,请求一个令牌 33 | boolean canOp = rateLimiter.tryAcquire(1); 34 | if (!canOp){ 35 | throw new BusinessException(ErrorCode.TOO_MANY_REQUEST); 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/mapper/ChartMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.mapper; 2 | 3 | import com.cong.wanwu.bi.model.entity.Chart; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | * @author 86188 8 | * @description 针对表【chart(图表信息)】的数据库操作Mapper 9 | * @createDate 2023-04-29 09:57:48 10 | * @Entity com.cong.wanwu.bi.model.entity.Chart 11 | */ 12 | public interface ChartMapper extends BaseMapper { 13 | 14 | } 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/mapper/DiseaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.mapper; 2 | 3 | import com.cong.wanwu.bi.model.entity.Disease; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | * @author 86188 8 | * @description 针对表【disease(病症信息表)】的数据库操作Mapper 9 | * @createDate 2023-06-01 16:20:46 10 | * @Entity com.cong.wanwu.bi.model.entity.Disease 11 | */ 12 | public interface DiseaseMapper extends BaseMapper { 13 | 14 | } 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/dto/chart/ChartAddRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.dto.chart; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableField; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 创建请求 10 | * 11 | * @author 程序员鱼皮 12 | * @from 编程导航知识星球 13 | */ 14 | @Data 15 | public class ChartAddRequest implements Serializable { 16 | 17 | 18 | 19 | /** 20 | * 分析目标 21 | */ 22 | private String goal; 23 | /** 24 | * 图标名称 25 | */ 26 | private String name; 27 | 28 | /** 29 | * 图表数据 30 | */ 31 | private String chartData; 32 | 33 | /** 34 | * 图表类型 35 | */ 36 | private String chartType; 37 | 38 | @TableField(exist = false) 39 | private static final long serialVersionUID = 1L; 40 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/dto/chart/ChartEditRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.dto.chart; 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.TableLogic; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | import java.util.List; 12 | 13 | /** 14 | * 编辑请求 15 | * 16 | * @author 程序员鱼皮 17 | * @from 编程导航知识星球 18 | */ 19 | @Data 20 | public class ChartEditRequest implements Serializable { 21 | 22 | /** 23 | * id 24 | */ 25 | private Long id; 26 | 27 | /** 28 | * 图标名称 29 | */ 30 | private String name; 31 | 32 | /** 33 | * 分析目标 34 | */ 35 | private String goal; 36 | 37 | /** 38 | * 图表数据 39 | */ 40 | private String chartData; 41 | 42 | /** 43 | * 图表类型 44 | */ 45 | private String chartType; 46 | 47 | 48 | 49 | @TableField(exist = false) 50 | private static final long serialVersionUID = 1L; 51 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/dto/chart/ChartQueryRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.dto.chart; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableField; 4 | import com.cong.wanwu.common.common.PageRequest; 5 | import lombok.Data; 6 | import lombok.EqualsAndHashCode; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 查询请求 12 | * 13 | * @author 程序员鱼皮 14 | * @from 编程导航知识星球 15 | */ 16 | @EqualsAndHashCode(callSuper = true) 17 | @Data 18 | public class ChartQueryRequest extends PageRequest implements Serializable { 19 | 20 | /** 21 | * id 22 | */ 23 | 24 | private Long id; 25 | /** 26 | * 图标名称 27 | */ 28 | private String name; 29 | /** 30 | * 创建用户 31 | */ 32 | 33 | private Long userId; 34 | 35 | /** 36 | * 分析目标 37 | */ 38 | private String goal; 39 | 40 | 41 | /** 42 | * 图表类型 43 | */ 44 | private String chartType; 45 | 46 | 47 | 48 | @TableField(exist = false) 49 | private static final long serialVersionUID = 1L; 50 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/dto/chart/ChartUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.dto.chart; 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.TableLogic; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | import java.util.Date; 11 | import java.util.List; 12 | 13 | /** 14 | * 更新请求 15 | * 16 | * @author 程序员鱼皮 17 | * @from 编程导航知识星球 18 | */ 19 | @Data 20 | public class ChartUpdateRequest implements Serializable { 21 | 22 | /** 23 | * id 24 | */ 25 | @TableId(type = IdType.ASSIGN_ID) 26 | private Long id; 27 | /** 28 | * 图标名称 29 | */ 30 | private String name; 31 | 32 | /** 33 | * 分析目标 34 | */ 35 | private String goal; 36 | 37 | /** 38 | * 图表数据 39 | */ 40 | private String chartData; 41 | 42 | /** 43 | * 图表类型 44 | */ 45 | private String chartType; 46 | 47 | 48 | 49 | @TableField(exist = false) 50 | private static final long serialVersionUID = 1L; 51 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/dto/chart/GenChartByAiRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.dto.chart; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 文件上传请求 9 | * 10 | * @author 程序员鱼皮 11 | * @from 编程导航知识星球 12 | */ 13 | @Data 14 | public class GenChartByAiRequest implements Serializable { 15 | /** 16 | * 图标名称 17 | */ 18 | private String name; 19 | 20 | /** 21 | * 目标 22 | */ 23 | private String goal; 24 | 25 | /** 26 | * 图表类型 27 | */ 28 | private String chartType; 29 | 30 | private static final long serialVersionUID = 1L; 31 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/dto/chart/XhAiMsgDTO.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.dto.chart; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * 消息对象 10 | * 11 | * @author 86188 12 | * @date 2023/10/22 13 | */ 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @JsonInclude(JsonInclude.Include.NON_NULL) 18 | public class XhAiMsgDTO { 19 | /** 20 | * 角色 21 | */ 22 | private String role; 23 | /** 24 | * 消息内容 25 | */ 26 | private String content; 27 | /** 28 | * 响应结果字段:结果序号,取值为[0,10]; 当前为保留字段,开发者可忽略 29 | */ 30 | private Integer index; 31 | 32 | public static final String ROLE_USER = "user"; 33 | public static final String ROLE_ASSISTANT = "assistant"; 34 | 35 | public static XhAiMsgDTO createUserMsg(String content) { 36 | return new XhAiMsgDTO(ROLE_USER, content, null); 37 | } 38 | 39 | public static XhAiMsgDTO createAssistantMsg(String content) { 40 | return new XhAiMsgDTO(ROLE_ASSISTANT, content, null); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/dto/disease/DiseaseAddRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.dto.disease; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import lombok.Data; 7 | 8 | import java.io.Serializable; 9 | import java.util.Date; 10 | 11 | /** 12 | * 创建请求 13 | * 14 | * @author 程序员鱼皮 15 | * @from 编程导航知识星球 16 | */ 17 | @Data 18 | public class DiseaseAddRequest implements Serializable { 19 | 20 | /** 21 | * 用户性别 22 | */ 23 | private Integer sex; 24 | 25 | /** 26 | * 所属科 27 | */ 28 | private String diseaseType; 29 | 30 | /** 31 | * 用户描述病症 32 | */ 33 | private String userDesc; 34 | 35 | 36 | 37 | @TableField(exist = false) 38 | private static final long serialVersionUID = 1L; 39 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/dto/disease/DiseaseEditRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.dto.disease; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import lombok.Data; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 编辑请求 12 | * 13 | * @author 程序员鱼皮 14 | * @from 编程导航知识星球 15 | */ 16 | @Data 17 | public class DiseaseEditRequest implements Serializable { 18 | 19 | /** 20 | * id 21 | */ 22 | @TableId(type = IdType.AUTO) 23 | private Long id; 24 | 25 | /** 26 | * 用户确诊症状 27 | */ 28 | private String name; 29 | 30 | /** 31 | * 用户性别 32 | */ 33 | private Integer sex; 34 | 35 | /** 36 | * 所属科 37 | */ 38 | private String diseaseType; 39 | 40 | /** 41 | * 用户描述病症 42 | */ 43 | private String userDesc; 44 | 45 | /** 46 | * 生成的治疗计划 47 | */ 48 | private String genResult; 49 | 50 | 51 | 52 | @TableField(exist = false) 53 | private static final long serialVersionUID = 1L; 54 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/dto/disease/DiseaseQueryRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.dto.disease; 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.cong.wanwu.common.common.PageRequest; 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | 10 | import java.io.Serializable; 11 | 12 | /** 13 | * 查询请求 14 | * 15 | * @author 程序员鱼皮 16 | * @from 编程导航知识星球 17 | */ 18 | @EqualsAndHashCode(callSuper = true) 19 | @Data 20 | public class DiseaseQueryRequest extends PageRequest implements Serializable { 21 | 22 | /** 23 | * id 24 | */ 25 | @TableId(type = IdType.AUTO) 26 | private Long id; 27 | 28 | /** 29 | * 创建用户 30 | */ 31 | private Long userId; 32 | 33 | /** 34 | * 用户确诊症状 35 | */ 36 | private String name; 37 | 38 | /** 39 | * 用户性别 40 | */ 41 | private Integer sex; 42 | 43 | /** 44 | * 所属科 45 | */ 46 | private String diseaseType; 47 | 48 | /** 49 | * 用户描述病症 50 | */ 51 | private String userDesc; 52 | 53 | 54 | @TableField(exist = false) 55 | private static final long serialVersionUID = 1L; 56 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/dto/disease/DiseaseUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.dto.disease; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import lombok.Data; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 更新请求 12 | * 13 | * @author 程序员鱼皮 14 | * @from 编程导航知识星球 15 | */ 16 | @Data 17 | public class DiseaseUpdateRequest implements Serializable { 18 | 19 | /** 20 | * id 21 | */ 22 | @TableId(type = IdType.AUTO) 23 | private Long id; 24 | 25 | 26 | /** 27 | * 用户确诊症状 28 | */ 29 | private String name; 30 | 31 | /** 32 | * 用户性别 33 | */ 34 | private Integer sex; 35 | 36 | /** 37 | * 所属科 38 | */ 39 | private String diseaseType; 40 | 41 | /** 42 | * 用户描述病症 43 | */ 44 | private String userDesc; 45 | 46 | /** 47 | * 生成的治疗计划 48 | */ 49 | private String genResult; 50 | 51 | @TableField(exist = false) 52 | private static final long serialVersionUID = 1L; 53 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/dto/disease/GenDiseaseByAiRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.dto.disease; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 文件上传请求 9 | * 10 | * @author 程序员鱼皮 11 | * @from 编程导航知识星球 12 | */ 13 | @Data 14 | public class GenDiseaseByAiRequest implements Serializable { 15 | 16 | 17 | /** 18 | * 用户性别 19 | */ 20 | private Integer sex; 21 | 22 | /** 23 | * 所属科 24 | */ 25 | private String diseaseType; 26 | 27 | /** 28 | * 用户描述病症 29 | */ 30 | private String userDesc; 31 | 32 | 33 | private static final long serialVersionUID = 1L; 34 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/dto/file/UploadFileRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.dto.file; 2 | 3 | import java.io.Serializable; 4 | import lombok.Data; 5 | 6 | /** 7 | * 文件上传请求 8 | * 9 | * @author 程序员鱼皮 10 | * @from 编程导航知识星球 11 | */ 12 | @Data 13 | public class UploadFileRequest implements Serializable { 14 | 15 | /** 16 | * 业务 17 | */ 18 | private String biz; 19 | 20 | private static final long serialVersionUID = 1L; 21 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/vo/BiDiseaseResponse.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * bi医生响应 7 | * 8 | * @author 86188 9 | * @date 2023/05/19 10 | */ 11 | @Data 12 | public class BiDiseaseResponse { 13 | private String name; 14 | private String genResult; 15 | } 16 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/model/vo/BiResponse.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.model.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * bi响应 7 | * 8 | * @author 86188 9 | * @date 2023/05/19 10 | */ 11 | @Data 12 | public class BiResponse { 13 | private String genChart; 14 | private String genResult; 15 | 16 | private Long chartId; 17 | } 18 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/service/ChartService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.service; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.cong.wanwu.bi.model.dto.chart.ChartQueryRequest; 5 | import com.cong.wanwu.bi.model.entity.Chart; 6 | import com.baomidou.mybatisplus.extension.service.IService; 7 | 8 | /** 9 | * @author 86188 10 | * @description 针对表【chart(图表信息)】的数据库操作Service 11 | * @createDate 2023-04-29 09:57:48 12 | */ 13 | public interface ChartService extends IService { 14 | 15 | QueryWrapper getQueryWrapper(ChartQueryRequest chartQueryRequest); 16 | void handleChartUpdateError(long chartId,String execMessage); 17 | } 18 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/service/DiseaseService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.service; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.cong.wanwu.bi.model.dto.disease.DiseaseQueryRequest; 5 | import com.cong.wanwu.bi.model.entity.Disease; 6 | import com.baomidou.mybatisplus.extension.service.IService; 7 | 8 | /** 9 | * @author 86188 10 | * @description 针对表【disease(病症信息表)】的数据库操作Service 11 | * @createDate 2023-06-01 16:20:46 12 | */ 13 | public interface DiseaseService extends IService { 14 | 15 | /** 16 | * 得到查询包装 17 | * 18 | * @param diseaseQueryRequest 疾病查询请求 19 | * @return {@link Object} 20 | */ 21 | QueryWrapper getQueryWrapper(DiseaseQueryRequest diseaseQueryRequest); 22 | } 23 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/java/com/cong/wanwu/bi/utils/SqlUtils.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.utils; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | /** 6 | * SQL 工具 7 | * 8 | * @author 程序员鱼皮 9 | * @from 编程导航知识星球 10 | */ 11 | public class SqlUtils { 12 | 13 | /** 14 | * 校验排序字段是否合法(防止 SQL 注入) 15 | * 16 | * @param sortField 17 | * @return 18 | */ 19 | public static boolean validSortField(String sortField) { 20 | if (StringUtils.isBlank(sortField)) { 21 | return false; 22 | } 23 | return !StringUtils.containsAny(sortField, "=", "(", ")", " "); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/resources/META-INF/additional-spring-configuration-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": [ 3 | { 4 | "name": "cos.client.accessKey", 5 | "type": "java.lang.String", 6 | "description": "Description for cos.client.accessKey." 7 | }, 8 | { 9 | "name": "cos.client.secretKey", 10 | "type": "java.lang.String", 11 | "description": "Description for cos.client.secretKey." 12 | }, 13 | { 14 | "name": "cos.client.region", 15 | "type": "java.lang.String", 16 | "description": "Description for cos.client.region." 17 | }, 18 | { 19 | "name": "cos.client.bucket", 20 | "type": "java.lang.String", 21 | "description": "Description for cos.client.bucket." 22 | }, 23 | { 24 | "name": "wx.open.appId", 25 | "type": "java.lang.String", 26 | "description": "Description for wx.open.appId." 27 | }, 28 | { 29 | "name": "wx.open.appSecret", 30 | "type": "java.lang.String", 31 | "description": "Description for wx.open.appSecret." 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8101 3 | spring: 4 | # 数据库配置 5 | # todo 需替换配置 6 | datasource: 7 | driver-class-name: com.mysql.cj.jdbc.Driver 8 | url: jdbc:mysql://localhost:3306/my_db 9 | username: root 10 | password: 123456 11 | # Redis 配置 12 | # todo 需替换配置 13 | redis: 14 | database: 1 15 | host: localhost 16 | port: 6379 17 | timeout: 5000 18 | password: 123456 19 | # Elasticsearch 配置 20 | # todo 需替换配置 21 | elasticsearch: 22 | uris: http://localhost:9200 23 | username: root 24 | password: 123456 25 | mybatis-plus: 26 | configuration: 27 | # 生产环境关闭日志 28 | log-impl: '' -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/resources/application-test.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8101 3 | spring: 4 | # 数据库配置 5 | # todo 需替换配置 6 | datasource: 7 | driver-class-name: com.mysql.cj.jdbc.Driver 8 | url: jdbc:mysql://localhost:3306/my_db 9 | username: root 10 | password: 123456 11 | # Redis 配置 12 | # todo 需替换配置 13 | redis: 14 | database: 1 15 | host: localhost 16 | port: 6379 17 | timeout: 5000 18 | password: 123456 19 | # Elasticsearch 配置 20 | # todo 需替换配置 21 | elasticsearch: 22 | uris: http://localhost:9200 23 | username: root 24 | password: 123456 -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | by 程序员鱼皮:https://github.com/liyupi 2 | 可能是最好的编程学习圈子:https://yupi.icu 3 | -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/resources/test_excel.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhccong/wanwu-code-backend/bb1fd28c65eac3f1f89fbb5a2b5625c1fd471ccc/wanwu-code-bi/src/main/resources/test_excel.xlsx -------------------------------------------------------------------------------- /wanwu-code-bi/src/main/resources/网站数据.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhccong/wanwu-code-backend/bb1fd28c65eac3f1f89fbb5a2b5625c1fd471ccc/wanwu-code-bi/src/main/resources/网站数据.xlsx -------------------------------------------------------------------------------- /wanwu-code-bi/src/test/java/com/cong/wanwu/bi/bizmq/MyMessageProducerTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.bizmq; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | import javax.annotation.Resource; 7 | 8 | @SpringBootTest 9 | class MyMessageProducerTest { 10 | @Resource 11 | private MyMessageProducer myMessageProducer; 12 | 13 | @Test 14 | void sendMessage() { 15 | myMessageProducer.sendMessage("code-exchange","my_routingKey","你好聪"); 16 | } 17 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/test/java/com/cong/wanwu/bi/manager/AIManagerTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.manager; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | import javax.annotation.Resource; 7 | 8 | /** 9 | * AI 操作测试 10 | * 11 | * @author 程序员鱼皮 12 | * @from 编程导航知识星球 13 | */ 14 | @SpringBootTest 15 | class AIManagerTest { 16 | 17 | @Resource 18 | private AiManager aiManager; 19 | 20 | @Test 21 | void putObject() { 22 | String message = aiManager.doChat(1659171950288818178L,"分析需求:\n" + 23 | "分析网站用户的增长情况\n"+ 24 | "原始数据:\n"+ 25 | "日期,用户数\n" + 26 | "1号,10\n" + 27 | "2号,20\n" + 28 | "3号,30\n"); 29 | System.out.println("message = " + message); 30 | } 31 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/test/java/com/cong/wanwu/bi/manager/CosManagerTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.manager; 2 | 3 | import javax.annotation.Resource; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | 7 | /** 8 | * Cos 操作测试 9 | * 10 | * @author 程序员鱼皮 11 | * @from 编程导航知识星球 12 | */ 13 | @SpringBootTest 14 | class CosManagerTest { 15 | 16 | @Resource 17 | private CosManager cosManager; 18 | 19 | @Test 20 | void putObject() { 21 | cosManager.putObject("test", "test.json"); 22 | } 23 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/test/java/com/cong/wanwu/bi/manager/RedisLimiterManagerTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.manager; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | import javax.annotation.Resource; 7 | 8 | @SpringBootTest 9 | class RedisLimiterManagerTest { 10 | @Resource 11 | private RedisLimiterManager redisLimiterManager; 12 | 13 | @Test 14 | void doRateLimit() { 15 | String userId = "1"; 16 | for (int i = 0; i < 3; i++) { 17 | redisLimiterManager.doRateLimit(userId); 18 | System.out.println("成功"); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /wanwu-code-bi/src/test/java/com/cong/wanwu/bi/utils/EasyExcelTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.bi.utils; 2 | 3 | import com.alibaba.excel.EasyExcel; 4 | import com.alibaba.excel.support.ExcelTypeEnum; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.util.ResourceUtils; 8 | 9 | import java.io.File; 10 | import java.io.FileNotFoundException; 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | /** 15 | * EasyExcel 测试 16 | * 17 | * @author 程序员鱼皮 18 | * @from 编程导航知识星球 19 | */ 20 | @SpringBootTest 21 | public class EasyExcelTest { 22 | 23 | @Test 24 | public void doImport() throws FileNotFoundException { 25 | File file = ResourceUtils.getFile("classpath:test_excel.xlsx"); 26 | List> list = EasyExcel.read(file) 27 | .excelType(ExcelTypeEnum.XLSX) 28 | .sheet() 29 | .headRowNumber(0) 30 | .doReadSync(); 31 | System.out.println(list); 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /wanwu-code-common/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/annotation/AuthCheck.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 权限校验 10 | * 11 | * @author 聪 12 | * 13 | */ 14 | @Target(ElementType.METHOD) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | public @interface AuthCheck { 17 | 18 | /** 19 | * 必须有某个角色 20 | * 21 | * @return 22 | */ 23 | String mustRole() default ""; 24 | 25 | } 26 | 27 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/common/BaseResponse.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.common; 2 | 3 | import java.io.Serializable; 4 | 5 | import com.cong.wanwu.common.common.ErrorCode; 6 | import lombok.Data; 7 | 8 | /** 9 | * 通用返回类 10 | * 11 | * @param 12 | * @author 聪 13 | * 14 | */ 15 | @Data 16 | public class BaseResponse implements Serializable { 17 | 18 | private int code; 19 | 20 | private T data; 21 | 22 | private String message; 23 | 24 | public BaseResponse(int code, T data, String message) { 25 | this.code = code; 26 | this.data = data; 27 | this.message = message; 28 | } 29 | 30 | public BaseResponse(int code, T data) { 31 | this(code, data, ""); 32 | } 33 | 34 | public BaseResponse(ErrorCode errorCode) { 35 | this(errorCode.getCode(), null, errorCode.getMessage()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/common/DeleteRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.common; 2 | 3 | import java.io.Serializable; 4 | import lombok.Data; 5 | 6 | /** 7 | * 删除请求 8 | * 9 | * @author 聪 10 | * 11 | */ 12 | @Data 13 | public class DeleteRequest implements Serializable { 14 | 15 | /** 16 | * id 17 | */ 18 | private Long id; 19 | 20 | private static final long serialVersionUID = 1L; 21 | } -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/common/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.common; 2 | 3 | /** 4 | * 自定义错误码 5 | * 6 | * @author 聪 7 | * 8 | */ 9 | public enum ErrorCode { 10 | 11 | SUCCESS(0, "ok"), 12 | PARAMS_ERROR(40000, "请求参数错误"), 13 | NOT_LOGIN_ERROR(40100, "未登录"), 14 | NO_AUTH_ERROR(40101, "无权限"), 15 | NOT_FOUND_ERROR(40400, "请求数据不存在"), 16 | FORBIDDEN_ERROR(40300, "禁止访问"), 17 | SYSTEM_ERROR(50000, "系统内部异常"), 18 | OPERATION_ERROR(50001, "操作失败"), 19 | TOO_MANY_REQUEST(50003, "请求过多"), 20 | LOCK_LIMIT(50004, "锁超时"); 21 | 22 | /** 23 | * 状态码 24 | */ 25 | private final int code; 26 | 27 | /** 28 | * 信息 29 | */ 30 | private final String message; 31 | 32 | ErrorCode(int code, String message) { 33 | this.code = code; 34 | this.message = message; 35 | } 36 | 37 | public int getCode() { 38 | return code; 39 | } 40 | 41 | public String getMessage() { 42 | return message; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/common/PageRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.common; 2 | 3 | import com.cong.wanwu.common.constant.CommonConstant; 4 | import lombok.Data; 5 | 6 | /** 7 | * 分页请求 8 | * 9 | * @author 聪 10 | * 11 | */ 12 | @Data 13 | public class PageRequest { 14 | 15 | /** 16 | * 当前页号 17 | */ 18 | private long current = 1; 19 | 20 | /** 21 | * 页面大小 22 | */ 23 | private long pageSize = 10; 24 | 25 | /** 26 | * 排序字段 27 | */ 28 | private String sortField; 29 | 30 | /** 31 | * 排序顺序(默认升序) 32 | */ 33 | private String sortOrder = CommonConstant.SORT_ORDER_ASC; 34 | } 35 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/common/ResultUtils.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.common; 2 | 3 | import com.cong.wanwu.common.common.BaseResponse; 4 | import com.cong.wanwu.common.common.ErrorCode; 5 | 6 | /** 7 | * 返回工具类 8 | * 9 | * @author 聪 10 | * 11 | */ 12 | public class ResultUtils { 13 | 14 | /** 15 | * 成功 16 | * 17 | * @param data 18 | * @param 19 | * @return 20 | */ 21 | public static BaseResponse success(T data) { 22 | return new BaseResponse<>(0, data, "ok"); 23 | } 24 | 25 | /** 26 | * 失败 27 | * 28 | * @param errorCode 29 | * @return 30 | */ 31 | public static BaseResponse error(ErrorCode errorCode) { 32 | return new BaseResponse<>(errorCode); 33 | } 34 | 35 | /** 36 | * 失败 37 | * 38 | * @param code 39 | * @param message 40 | * @return 41 | */ 42 | public static BaseResponse error(int code, String message) { 43 | return new BaseResponse(code, null, message); 44 | } 45 | 46 | /** 47 | * 失败 48 | * 49 | * @param errorCode 50 | * @return 51 | */ 52 | public static BaseResponse error(ErrorCode errorCode, String message) { 53 | return new BaseResponse(errorCode.getCode(), null, message); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/constant/CommonConstant.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.constant; 2 | 3 | /** 4 | * 通用常量 5 | * 6 | * @author 聪 7 | * 8 | */ 9 | public interface CommonConstant { 10 | 11 | /** 12 | * 升序 13 | */ 14 | String SORT_ORDER_ASC = "ascend"; 15 | 16 | /** 17 | * 降序 18 | */ 19 | String SORT_ORDER_DESC = " descend"; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/constant/RedisConstants.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.constant; 2 | 3 | /** 4 | * Redis 5 | * @author liuhuaicong 6 | * @date 2023/09/14 7 | */ 8 | public interface RedisConstants { 9 | /** 10 | * 通知 11 | */ 12 | public static final String NOTIFICATION_PREFIX = "notification:uid:"; 13 | //点赞 14 | public static final String LIKE_NOTIFICATION_SUFFIX = ":like"; 15 | //评论 16 | public static final String COMMENT_NOTIFICATION_SUFFIX = ":comment"; 17 | //消息 18 | public static final String MSG_NOTIFICATION_SUFFIX = ":msg"; 19 | //系统通知 20 | public static final String NOTICE_NOTIFICATION_SUFFIX = ":notice"; 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/constant/UserConstant.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.constant; 2 | 3 | /** 4 | * 用户常量 5 | * 6 | * @author 聪 7 | * 8 | */ 9 | public interface UserConstant { 10 | 11 | 12 | // region 权限 13 | 14 | /** 15 | * 默认角色 16 | */ 17 | String DEFAULT_ROLE = "user"; 18 | 19 | /** 20 | * 管理员角色 21 | */ 22 | String ADMIN_ROLE = "admin"; 23 | 24 | /** 25 | * 被封号 26 | */ 27 | String BAN_ROLE = "ban"; 28 | 29 | String USER_AVATAR_DEFALUT = "https://img2.baidu.com/it/u=4108448286,3962911507&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1695315600&t=233bc64b6cbdda14303d0466841added"; 30 | String NICK_NAME_PREFIX = "WanWuCode_"; 31 | 32 | // endregion 33 | } 34 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.exception; 2 | 3 | import com.cong.wanwu.common.common.ErrorCode; 4 | 5 | /** 6 | * 自定义异常类 7 | * 8 | * @author 聪 9 | * 10 | */ 11 | public class BusinessException extends RuntimeException { 12 | 13 | /** 14 | * 错误码 15 | */ 16 | private final int code; 17 | 18 | public BusinessException(int code, String message) { 19 | super(message); 20 | this.code = code; 21 | } 22 | 23 | public BusinessException(ErrorCode errorCode) { 24 | super(errorCode.getMessage()); 25 | this.code = errorCode.getCode(); 26 | } 27 | 28 | public BusinessException(ErrorCode errorCode, String message) { 29 | super(message); 30 | this.code = errorCode.getCode(); 31 | } 32 | 33 | public int getCode() { 34 | return code; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.exception; 2 | 3 | import com.cong.wanwu.common.common.BaseResponse; 4 | import com.cong.wanwu.common.common.ErrorCode; 5 | import com.cong.wanwu.common.common.ResultUtils; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.bind.annotation.RestControllerAdvice; 9 | 10 | /** 11 | * 全局异常处理器 12 | * 13 | * @author 聪 14 | * 15 | */ 16 | @RestControllerAdvice 17 | @Slf4j 18 | public class GlobalExceptionHandler { 19 | 20 | @ExceptionHandler(BusinessException.class) 21 | public BaseResponse businessExceptionHandler(BusinessException e) { 22 | log.error("BusinessException", e); 23 | return ResultUtils.error(e.getCode(), e.getMessage()); 24 | } 25 | 26 | @ExceptionHandler(RuntimeException.class) 27 | public BaseResponse runtimeExceptionHandler(RuntimeException e) { 28 | log.error("RuntimeException", e); 29 | return ResultUtils.error(ErrorCode.SYSTEM_ERROR, "系统错误"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/exception/ThrowUtils.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.exception; 2 | 3 | import com.cong.wanwu.common.common.ErrorCode; 4 | 5 | /** 6 | * 抛异常工具类 7 | * 8 | * @author 聪 9 | * 10 | */ 11 | public class ThrowUtils { 12 | 13 | /** 14 | * 条件成立则抛异常 15 | * 16 | * @param condition 17 | * @param runtimeException 18 | */ 19 | public static void throwIf(boolean condition, RuntimeException runtimeException) { 20 | if (condition) { 21 | throw runtimeException; 22 | } 23 | } 24 | 25 | /** 26 | * 条件成立则抛异常 27 | * 28 | * @param condition 29 | * @param errorCode 30 | */ 31 | public static void throwIf(boolean condition, ErrorCode errorCode) { 32 | throwIf(condition, new BusinessException(errorCode)); 33 | } 34 | 35 | /** 36 | * 条件成立则抛异常 37 | * 38 | * @param condition 39 | * @param errorCode 40 | * @param message 41 | */ 42 | public static void throwIf(boolean condition, ErrorCode errorCode, String message) { 43 | throwIf(condition, new BusinessException(errorCode, message)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/model/dto/UserAccessKeyRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.model.dto; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author liuhuaicong 8 | * @date 2023/10/12 9 | */ 10 | @Data 11 | @Builder 12 | public class UserAccessKeyRequest { 13 | /** 14 | * accessKey 15 | */ 16 | private String accessKey; 17 | /** 18 | * 加密判断标识 19 | */ 20 | private String salt; 21 | } 22 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/model/vo/request/CursorPageBaseReq.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.model.vo.request; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import com.fasterxml.jackson.annotation.JsonIgnore; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | import org.apache.commons.lang3.StringUtils; 11 | 12 | 13 | /** 14 | * @author abin 15 | * @since 2023-03-19 16 | */ 17 | @Data 18 | @ApiModel("游标翻页请求") 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | public class CursorPageBaseReq { 22 | 23 | @ApiModelProperty("页面大小") 24 | private Integer pageSize = 10; 25 | 26 | @ApiModelProperty("游标(初始为null,后续请求附带上次翻页的游标)") 27 | private String cursor; 28 | 29 | public Page plusPage() { 30 | return new Page(1, this.pageSize); 31 | } 32 | 33 | @JsonIgnore 34 | public Boolean isFirstPage() { 35 | return StringUtils.isEmpty(cursor); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/model/vo/request/PageBaseReq.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.model.vo.request; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | 8 | 9 | /** 10 | * @author abin 11 | * @since 2023-03-19 12 | */ 13 | @Data 14 | @ApiModel("基础翻页请求") 15 | public class PageBaseReq { 16 | 17 | @ApiModelProperty("页面大小") 18 | private Integer pageSize = 10; 19 | 20 | @ApiModelProperty("页面索引(从1开始)") 21 | private Integer pageNo = 1; 22 | 23 | /** 24 | * 获取mybatisPlus的page 25 | * 26 | * @return 27 | */ 28 | public Page plusPage() { 29 | return new Page(pageNo, pageSize); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/utils/CodeUtils.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.utils; 2 | 3 | import java.util.Random; 4 | 5 | /** 6 | * 代码跑龙套 7 | * 8 | * @author 86188 9 | * @date 2023/04/25 10 | */ 11 | public class CodeUtils { 12 | public static int generateRandomNumber() { 13 | // 创建 Random 对象 14 | Random random = new Random(); 15 | // 生成一个六位随机数(范围从 100000 到 999999) 16 | int randomNumber = random.nextInt(900000) + 100000; 17 | return randomNumber; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/utils/SqlUtils.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.utils; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | /** 6 | * SQL 工具 7 | * 8 | * @author 聪 9 | * 10 | */ 11 | public class SqlUtils { 12 | 13 | /** 14 | * 校验排序字段是否合法(防止 SQL 注入) 15 | * 16 | * @param sortField 17 | * @return 18 | */ 19 | public static boolean validSortField(String sortField) { 20 | if (StringUtils.isBlank(sortField)) { 21 | return false; 22 | } 23 | return !StringUtils.containsAny(sortField, "=", "(", ")", " "); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/utils/discover/CommonUrlTitleDiscover.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.utils.discover; 2 | 3 | import org.jsoup.nodes.Document; 4 | 5 | /** 6 | * Description: 通用的标题解析类 7 | * Author: abin 8 | * Date: 2023-05-27 9 | */ 10 | public class CommonUrlTitleDiscover extends AbstractUrlTitleDiscover { 11 | @Override 12 | public String getDocTitle(Document document) { 13 | return document.title(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/utils/discover/PrioritizedUrlTitleDiscover.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.utils.discover; 2 | 3 | import cn.hutool.core.util.StrUtil; 4 | import org.jsoup.nodes.Document; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Description: 具有优先级的title查询器 11 | * Author: abin 12 | * Date: 2023-05-27 13 | */ 14 | public class PrioritizedUrlTitleDiscover extends AbstractUrlTitleDiscover { 15 | 16 | private final List urlTitleDiscovers = new ArrayList<>(2); 17 | 18 | public PrioritizedUrlTitleDiscover() { 19 | urlTitleDiscovers.add(new CommonUrlTitleDiscover()); 20 | urlTitleDiscovers.add(new WxUrlTitleDiscover()); 21 | } 22 | 23 | @Override 24 | public String getDocTitle(Document document) { 25 | for (UrlTitleDiscover urlTitleDiscover : urlTitleDiscovers) { 26 | String urlTitle = urlTitleDiscover.getDocTitle(document); 27 | if (StrUtil.isNotBlank(urlTitle)) { 28 | return urlTitle; 29 | } 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /wanwu-code-common/src/main/java/com/cong/wanwu/common/utils/discover/WxUrlTitleDiscover.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.common.utils.discover; 2 | 3 | import org.jsoup.nodes.Document; 4 | 5 | /** 6 | * Description: 针对微信公众号文章的标题获取类 7 | * Author: abin 8 | * Date: 2023-05-27 9 | */ 10 | public class WxUrlTitleDiscover extends AbstractUrlTitleDiscover { 11 | @Override 12 | public String getDocTitle(Document document) { 13 | return document.getElementsByAttributeValue("property", "og:title").attr("content"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /wanwu-code-gateway/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | ./src/main/resources/bootstrap.yml 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /wanwu-code-gateway/src/main/java/com/cong/wanwu/gateway/WanwuGatewayApplication.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.gateway; 2 | 3 | 4 | import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; 9 | import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; 10 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 11 | 12 | 13 | /** 14 | * @author liuhuaicong 15 | * @date 2023/10/09 16 | */ 17 | @SpringBootApplication(exclude = { 18 | DataSourceAutoConfiguration.class, 19 | DataSourceTransactionManagerAutoConfiguration.class, 20 | HibernateJpaAutoConfiguration.class 21 | }) 22 | @EnableDiscoveryClient 23 | @EnableDubbo 24 | public class WanwuGatewayApplication { 25 | public static void main(String[] args) { 26 | SpringApplication.run(WanwuGatewayApplication.class, args); 27 | } 28 | 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /wanwu-code-gateway/src/main/java/com/cong/wanwu/gateway/config/RequestLimitConfig.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.gateway.config; 2 | 3 | import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.context.annotation.Primary; 7 | import reactor.core.publisher.Mono; 8 | 9 | import java.util.Objects; 10 | 11 | /** 12 | * 请求限流配置类 13 | * @author lhc 14 | * @date 2022-10-03 13:44 15 | */ 16 | @Configuration 17 | public class RequestLimitConfig { 18 | /** 19 | * 针对某一个接口 ip来限流 /doLogin 每一个ip 10s访问3次 @Primary //主要的 20 | * @return 21 | */ 22 | @Bean 23 | @Primary 24 | public KeyResolver ipKeyResolver(){ 25 | return exchange -> Mono.just(Objects.requireNonNull(exchange.getRequest().getHeaders().getHost()).getHostString()); 26 | } 27 | 28 | /** 29 | * 针对路径限制 /doLogin 30 | * @return 31 | */ 32 | @Bean 33 | public KeyResolver apiKeyResolver(){ 34 | return exchange -> Mono.just(exchange.getRequest().getPath().value()); 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /wanwu-code-gateway/src/main/java/com/cong/wanwu/gateway/config/SaTokenConfigure.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.gateway.config; 2 | 3 | import cn.dev33.satoken.interceptor.SaInterceptor; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | /** 9 | * @author liuhuaicong 10 | */ 11 | @Configuration 12 | public class SaTokenConfigure implements WebMvcConfigurer { 13 | // 注册 Sa-Token 拦截器,打开注解式鉴权功能 14 | @Override 15 | public void addInterceptors(InterceptorRegistry registry) { 16 | // 注册 Sa-Token 拦截器,打开注解式鉴权功能 17 | registry.addInterceptor(new SaInterceptor()).addPathPatterns("/**"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | ./src/main/resources/bootstrap.yml 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/WanwuUserCenterApplication.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 8 | import org.springframework.scheduling.annotation.EnableScheduling; 9 | 10 | /** 11 | * 主类(项目启动入口) 12 | * 13 | * @author liuhuaicong 14 | */ 15 | // todo 如需开启 Redis,须移除 exclude 中的内容 16 | //@SpringBootApplication(exclude = {RedisAutoConfiguration.class}) 17 | @SpringBootApplication(scanBasePackages = {"com.cong.wanwu"}) 18 | @MapperScan("com.cong.wanwu.usercenter.mapper") 19 | @EnableScheduling 20 | @EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true) 21 | @EnableDiscoveryClient 22 | public class WanwuUserCenterApplication { 23 | 24 | public static void main(String[] args) { 25 | SpringApplication.run(WanwuUserCenterApplication.class, args); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/annotation/RedissonLock.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | import java.util.concurrent.TimeUnit; 8 | 9 | /** 10 | * 分布式锁注解 11 | */ 12 | @Retention(RetentionPolicy.RUNTIME)//运行时生效 13 | @Target(ElementType.METHOD)//作用在方法上 14 | public @interface RedissonLock { 15 | /** 16 | * key的前缀,默认取方法全限定名,除非我们在不同方法上对同一个资源做分布式锁,就自己指定 17 | * 18 | * @return key的前缀 19 | */ 20 | String prefixKey() default ""; 21 | 22 | /** 23 | * springEl 表达式 24 | * 25 | * @return 表达式 26 | */ 27 | String key(); 28 | 29 | /** 30 | * 等待锁的时间,默认-1,不等待直接失败,redisson默认也是-1 31 | * 32 | * @return 单位秒 33 | */ 34 | int waitTime() default -1; 35 | 36 | /** 37 | * 等待锁的时间单位,默认毫秒 38 | * 39 | * @return 单位 40 | */ 41 | TimeUnit unit() default TimeUnit.MILLISECONDS; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/annotation/SecureInvokeConfigurer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2021 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.cong.wanwu.usercenter.annotation; 18 | 19 | import org.springframework.lang.Nullable; 20 | 21 | import java.util.concurrent.Executor; 22 | 23 | public interface SecureInvokeConfigurer { 24 | 25 | /** 26 | * 返回一个线程池 27 | */ 28 | @Nullable 29 | default Executor getSecureInvokeExecutor() { 30 | return null; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/common/event/ItemReceiveEvent.java: -------------------------------------------------------------------------------- 1 | //package com.cong.wanwu.usercenter.common.event; 2 | // 3 | //import com.abin.mallchat.common.user.domain.entity.UserBackpack; 4 | //import lombok.Getter; 5 | //import org.springframework.context.ApplicationEvent; 6 | // 7 | //@Getter 8 | //public class ItemReceiveEvent extends ApplicationEvent { 9 | // private UserBackpack userBackpack; 10 | // 11 | // public ItemReceiveEvent(Object source, UserBackpack userBackpack) { 12 | // super(source); 13 | // this.userBackpack = userBackpack; 14 | // } 15 | // 16 | //} 17 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/common/event/MessageMarkEvent.java: -------------------------------------------------------------------------------- 1 | //package com.cong.wanwu.usercenter.common.event; 2 | // 3 | //import com.abin.mallchat.common.chat.domain.dto.ChatMessageMarkDTO; 4 | //import lombok.Getter; 5 | //import org.springframework.context.ApplicationEvent; 6 | // 7 | //@Getter 8 | //public class MessageMarkEvent extends ApplicationEvent { 9 | // private ChatMessageMarkDTO dto; 10 | // 11 | // public MessageMarkEvent(Object source, ChatMessageMarkDTO dto) { 12 | // super(source); 13 | // this.dto = dto; 14 | // } 15 | //} 16 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/common/event/MessageSendEvent.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.common.event; 2 | 3 | import lombok.Getter; 4 | import org.springframework.context.ApplicationEvent; 5 | 6 | @Getter 7 | public class MessageSendEvent extends ApplicationEvent { 8 | private Long msgId; 9 | 10 | public MessageSendEvent(Object source, Long msgId) { 11 | super(source); 12 | this.msgId = msgId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/common/event/UserOfflineEvent.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.common.event; 2 | 3 | import com.cong.wanwu.common.model.entity.User; 4 | import lombok.Getter; 5 | import org.springframework.context.ApplicationEvent; 6 | 7 | @Getter 8 | public class UserOfflineEvent extends ApplicationEvent { 9 | private User user; 10 | 11 | public UserOfflineEvent(Object source, User user) { 12 | super(source); 13 | this.user = user; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/common/event/UserOnlineEvent.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.common.event; 2 | 3 | import com.cong.wanwu.common.model.entity.User; 4 | import lombok.Getter; 5 | import org.springframework.context.ApplicationEvent; 6 | 7 | /** 8 | * 用户在线活动 9 | * 10 | * @author liuhuaicong 11 | * @date 2023/10/31 12 | */ 13 | @Getter 14 | public class UserOnlineEvent extends ApplicationEvent { 15 | private final User user; 16 | 17 | public UserOnlineEvent(Object source, User user) { 18 | super(source); 19 | this.user = user; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/common/event/UserRegisterEvent.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.common.event; 2 | 3 | import com.cong.wanwu.common.model.entity.User; 4 | import lombok.Getter; 5 | import org.springframework.context.ApplicationEvent; 6 | 7 | @Getter 8 | public class UserRegisterEvent extends ApplicationEvent { 9 | private User user; 10 | 11 | public UserRegisterEvent(Object source, User user) { 12 | super(source); 13 | this.user = user; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/common/handler/GlobalUncaughtExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.common.handler; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | /** 6 | * 全局未捕获异常处理程序 7 | * 8 | * @author liuhuaicong 9 | * @date 2023/10/31 10 | */ 11 | @Slf4j 12 | public class GlobalUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { 13 | 14 | /** 15 | * 实例 16 | */ 17 | private static final GlobalUncaughtExceptionHandler instance = new GlobalUncaughtExceptionHandler(); 18 | 19 | private GlobalUncaughtExceptionHandler() { 20 | } 21 | 22 | @Override 23 | public void uncaughtException(Thread t, Throwable e) { 24 | log.error("Exception in thread {} ", t.getName(), e); 25 | } 26 | 27 | public static GlobalUncaughtExceptionHandler getInstance() { 28 | return instance; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | //package com.cong.wanwu.usercenter.config; 2 | // 3 | //import org.springframework.context.annotation.Configuration; 4 | //import org.springframework.web.servlet.config.annotation.CorsRegistry; 5 | //import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | // 7 | ///** 8 | // * 全局跨域配置 9 | // * 10 | // * @author 聪 11 | // * 12 | // */ 13 | //@Configuration 14 | //public class CorsConfig implements WebMvcConfigurer { 15 | // 16 | // @Override 17 | // public void addCorsMappings(CorsRegistry registry) { 18 | // // 覆盖所有请求 19 | // registry.addMapping("/**") 20 | // // 允许发送 Cookie 21 | // .allowCredentials(true) 22 | // // 放行哪些域名(必须用 patterns,否则 * 会和 allowCredentials 冲突) 23 | // .allowedOriginPatterns("*") 24 | // .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") 25 | // .allowedHeaders("*") 26 | // .exposedHeaders("*"); 27 | // } 28 | //} 29 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/config/JsonConfig.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.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.ToStringSerializer; 6 | import org.springframework.boot.jackson.JsonComponent; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; 9 | 10 | /** 11 | * Spring MVC Json 配置 12 | * 13 | * @author 聪 14 | * 15 | */ 16 | @JsonComponent 17 | public class JsonConfig { 18 | 19 | /** 20 | * 添加 Long 转 json 精度丢失的配置 21 | */ 22 | @Bean 23 | public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { 24 | ObjectMapper objectMapper = builder.createXmlMapper(false).build(); 25 | SimpleModule module = new SimpleModule(); 26 | module.addSerializer(Long.class, ToStringSerializer.instance); 27 | module.addSerializer(Long.TYPE, ToStringSerializer.instance); 28 | objectMapper.registerModule(module); 29 | return objectMapper; 30 | } 31 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/config/MinIoClientConfig.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.config; 2 | 3 | import io.minio.MinioClient; 4 | import lombok.Data; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.boot.context.properties.ConfigurationProperties; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | 11 | /** 12 | * @author liuhuaicong 13 | * @date 2023/10/18 14 | */ 15 | @Data 16 | @Configuration 17 | @ConfigurationProperties(prefix = "minio") 18 | public class MinIoClientConfig { 19 | 20 | /** 21 | * 访问密钥 22 | */ 23 | private String accessKey; 24 | 25 | /** 26 | * 密钥 27 | */ 28 | private String secretKey; 29 | 30 | /** 31 | * 访问api Url 32 | */ 33 | private String endpoint; 34 | 35 | /** 36 | * 捅名称 37 | */ 38 | private String bucketName; 39 | 40 | /** 41 | * 创建MinIo客户端 42 | * 43 | * @return 44 | */ 45 | @Bean 46 | public MinioClient minioClient() { 47 | 48 | return MinioClient.builder() 49 | .endpoint(endpoint) 50 | .credentials(accessKey, secretKey) 51 | .build(); 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/config/MyBatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 6 | import org.mybatis.spring.annotation.MapperScan; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | /** 11 | * MyBatis Plus 配置 12 | * 13 | * @author https://github.com/licong 14 | */ 15 | @Configuration 16 | @MapperScan("com.cong.wanwu.usercenter.mapper") 17 | public class MyBatisPlusConfig { 18 | 19 | /** 20 | * 拦截器配置 21 | * 22 | * @return 23 | */ 24 | @Bean 25 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 26 | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); 27 | // 分页插件 28 | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); 29 | return interceptor; 30 | } 31 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/config/RedissonConfig.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.config; 2 | 3 | import lombok.Data; 4 | import org.redisson.Redisson; 5 | import org.redisson.api.RedissonClient; 6 | import org.redisson.config.Config; 7 | import org.springframework.boot.context.properties.ConfigurationProperties; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | /** 12 | * redisson配置 13 | * 14 | * @author 86188 15 | * @date 2023/05/26 16 | */ 17 | @Configuration 18 | @Data 19 | @ConfigurationProperties(prefix = "spring.redis") 20 | public class RedissonConfig { 21 | private Integer database; 22 | 23 | private String host; 24 | 25 | private Integer port; 26 | 27 | private String password; 28 | @Bean 29 | public RedissonClient redissonClient(){ 30 | Config config = new Config(); 31 | config.useSingleServer() 32 | .setAddress("redis://"+host+":"+port) 33 | .setDatabase(database) 34 | .setPassword(password); 35 | RedissonClient redissonClient = Redisson.create(config); 36 | return redissonClient; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/config/SaTokenConfigure.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.config; 2 | 3 | import cn.dev33.satoken.interceptor.SaInterceptor; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | /** 9 | * @author liuhuaicong 10 | */ 11 | @Configuration 12 | public class SaTokenConfigure implements WebMvcConfigurer { 13 | // 注册 Sa-Token 拦截器,打开注解式鉴权功能 14 | @Override 15 | public void addInterceptors(InterceptorRegistry registry) { 16 | // 注册 Sa-Token 拦截器,打开注解式鉴权功能 17 | registry.addInterceptor(new SaInterceptor()).addPathPatterns("/**"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/constant/FileConstant.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.constant; 2 | 3 | /** 4 | * 文件常量 5 | * 6 | * @author 聪 7 | * 8 | */ 9 | public interface FileConstant { 10 | 11 | /** 12 | * COS 访问地址 13 | * todo 需替换配置 14 | */ 15 | String COS_HOST = "https://cong.icu"; 16 | } 17 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/constant/RedisKey.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.constant; 2 | 3 | /** 4 | * Redis 密钥 5 | * 6 | * @author liuhuaicong 7 | * @date 2023/10/31 8 | */ 9 | public class RedisKey { 10 | private static final String BASE_KEY = "wanwu:"; 11 | 12 | /** 13 | * 在线用户列表 14 | */ 15 | public static final String ONLINE_UID_ZET = "online"; 16 | 17 | /** 18 | * 离线用户列表 19 | */ 20 | public static final String OFFLINE_UID_ZET = "offline"; 21 | 22 | /** 23 | * 用户信息 24 | */ 25 | public static final String USER_INFO_STRING = "userInfo:uid_%d"; 26 | 27 | /** 28 | * 用户token存放 29 | */ 30 | public static final String USER_TOKEN_STRING = "userToken:uid_%d"; 31 | 32 | public static String getKey(String key, Object... objects) { 33 | return BASE_KEY + String.format(key, objects); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/datasource/DataSource.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.datasource; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | 5 | /** 6 | * 数据源接口(新接入数据源必须实现 ) 7 | * 8 | * @author 86188 9 | * @date 2023/03/20 10 | */ 11 | public interface DataSource { 12 | /** 13 | * 做搜索 14 | * 15 | * @param searchText 搜索文本 16 | * @param pageNum 页面num 17 | * @param pageSize 页面大小 18 | * @return {@link Page}<{@link T}> 19 | */ 20 | Page doSearch(String searchText, long pageNum, long pageSize); 21 | } 22 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/datasource/UserDataSource.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.datasource; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import com.cong.wanwu.usercenter.model.dto.user.UserQueryRequest; 5 | import com.cong.wanwu.usercenter.model.vo.UserVO; 6 | import com.cong.wanwu.usercenter.service.UserService; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.stereotype.Service; 9 | 10 | import javax.annotation.Resource; 11 | 12 | /** 13 | * 用户服务实现 14 | * 15 | * @author 聪 16 | * 17 | */ 18 | @Service 19 | @Slf4j 20 | public class UserDataSource implements DataSource { 21 | @Resource 22 | private UserService userService; 23 | 24 | 25 | 26 | 27 | @Override 28 | public Page doSearch(String searchText, long pageNum, long pageSize) { 29 | UserQueryRequest userQueryRequest = new UserQueryRequest(); 30 | userQueryRequest.setUserName(searchText); 31 | userQueryRequest.setCurrent(pageNum); 32 | userQueryRequest.setPageSize(pageSize); 33 | Page userVOPage = userService.listUserVOByPage(userQueryRequest); 34 | return userVOPage; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/esdao/PostEsDao.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.esdao; 2 | 3 | import com.cong.wanwu.usercenter.model.dto.post.PostEsDTO; 4 | import java.util.List; 5 | 6 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 7 | 8 | /** 9 | * 帖子 ES 操作 10 | * 11 | * @author 聪 12 | * 13 | */ 14 | public interface PostEsDao extends ElasticsearchRepository { 15 | 16 | /** 17 | * 根据用户id查找 18 | * 19 | * @param userId 用户id 20 | * @return {@link List}<{@link PostEsDTO}> 21 | */ 22 | List findByUserId(Long userId); 23 | 24 | /** 25 | * 根据title查找 26 | * 27 | * @param title 标题 28 | * @return {@link List}<{@link PostEsDTO}> 29 | */ 30 | List findByTitle(String title); 31 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/factory/MyThreadFactory.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.factory; 2 | 3 | import com.cong.wanwu.usercenter.common.handler.GlobalUncaughtExceptionHandler; 4 | import lombok.AllArgsConstructor; 5 | import lombok.extern.slf4j.Slf4j; 6 | 7 | import java.util.concurrent.ThreadFactory; 8 | 9 | @Slf4j 10 | @AllArgsConstructor 11 | public class MyThreadFactory implements ThreadFactory { 12 | 13 | private final ThreadFactory factory; 14 | 15 | @Override 16 | public Thread newThread(Runnable r) { 17 | Thread thread = factory.newThread(r); 18 | thread.setUncaughtExceptionHandler(GlobalUncaughtExceptionHandler.getInstance()); 19 | return thread; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/mapper/MessageMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.mapper; 2 | 3 | import com.cong.wanwu.usercenter.model.entity.chat.Message; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | * @author liuhuaicong 8 | * @description 针对表【message(消息表)】的数据库操作Mapper 9 | * @createDate 2023-10-31 10:35:04 10 | * @Entity com.cong.wanwu.usercenter.model.entity.chat.Message 11 | */ 12 | public interface MessageMapper extends BaseMapper { 13 | 14 | } 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/mapper/PostFavourMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.Wrapper; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import com.baomidou.mybatisplus.core.toolkit.Constants; 7 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 8 | import com.cong.wanwu.usercenter.model.entity.Post; 9 | import com.cong.wanwu.usercenter.model.entity.PostFavour; 10 | import org.apache.ibatis.annotations.Param; 11 | 12 | /** 13 | * 帖子收藏数据库操作 14 | * 15 | * @author 聪 16 | * 17 | */ 18 | public interface PostFavourMapper extends BaseMapper { 19 | 20 | /** 21 | * 分页查询收藏帖子列表 22 | * 23 | * @param page 24 | * @param queryWrapper 25 | * @param favourUserId 26 | * @return 27 | */ 28 | Page listFavourPostByPage(IPage page, @Param(Constants.WRAPPER) Wrapper queryWrapper, 29 | long favourUserId); 30 | 31 | } 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/mapper/PostImagesMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.cong.wanwu.usercenter.model.entity.PostImages; 5 | 6 | /** 7 | * @author liuhuaicong 8 | * @description 针对表【post_images(帖子图片表)】的数据库操作Mapper 9 | * @createDate 2023-09-14 10:57:28 10 | * @Entity generator.domain.PostImages 11 | */ 12 | public interface PostImagesMapper extends BaseMapper { 13 | 14 | } 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/mapper/PostMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.cong.wanwu.usercenter.model.entity.Post; 5 | import java.util.Date; 6 | import java.util.List; 7 | 8 | /** 9 | * 帖子数据库操作 10 | * 11 | * @author 聪 12 | * 13 | */ 14 | public interface PostMapper extends BaseMapper { 15 | 16 | /** 17 | * 查询帖子列表(包括已被删除的数据) 18 | */ 19 | List listPostWithDelete(Date minUpdateTime); 20 | 21 | } 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/mapper/PostThumbMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.mapper; 2 | 3 | import com.cong.wanwu.usercenter.model.entity.PostThumb; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | * 帖子点赞数据库操作 8 | * 9 | * @author 聪 10 | * 11 | */ 12 | public interface PostThumbMapper extends BaseMapper { 13 | 14 | } 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/mapper/RoomFriendMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.mapper; 2 | 3 | import com.cong.wanwu.usercenter.model.entity.chat.RoomFriend; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | * @author liuhuaicong 8 | * @description 针对表【room_friend(单聊房间表)】的数据库操作Mapper 9 | * @createDate 2023-10-31 10:35:04 10 | * @Entity com.cong.wanwu.usercenter.model.entity.chat.RoomFriend 11 | */ 12 | public interface RoomFriendMapper extends BaseMapper { 13 | 14 | } 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/mapper/RoomGroupMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.mapper; 2 | 3 | import com.cong.wanwu.usercenter.model.entity.chat.RoomGroup; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | * @author liuhuaicong 8 | * @description 针对表【room_group(群聊房间表)】的数据库操作Mapper 9 | * @createDate 2023-10-31 10:35:04 10 | * @Entity com.cong.wanwu.usercenter.model.entity.chat.RoomGroup 11 | */ 12 | public interface RoomGroupMapper extends BaseMapper { 13 | 14 | } 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/mapper/RoomMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.mapper; 2 | 3 | import com.cong.wanwu.usercenter.model.entity.chat.Room; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | * @author liuhuaicong 8 | * @description 针对表【room(房间表)】的数据库操作Mapper 9 | * @createDate 2023-10-31 10:35:04 10 | * @Entity com.cong.wanwu.usercenter.model.entity.chat.Room 11 | */ 12 | public interface RoomMapper extends BaseMapper { 13 | 14 | } 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/mapper/UserAttentionMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.mapper; 2 | 3 | import com.cong.wanwu.usercenter.model.entity.UserAttention; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | * @author liuhuaicong 8 | * @description 针对表【user_attention( 用户关注表)】的数据库操作Mapper 9 | * @createDate 2023-09-08 16:41:55 10 | * @Entity com.cong.wanwu.model.entity.UserAttention 11 | */ 12 | public interface UserAttentionMapper extends BaseMapper { 13 | 14 | } 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.cong.wanwu.common.model.entity.User; 5 | 6 | /** 7 | * 用户数据库操作 8 | * 9 | * @author 聪 10 | * 11 | */ 12 | public interface UserMapper extends BaseMapper { 13 | 14 | } 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/mapper/UserTagMapper.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.mapper; 2 | 3 | import com.cong.wanwu.usercenter.model.entity.UserTag; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | 6 | /** 7 | * @author liuhuaicong 8 | * @description 针对表【user_tag】的数据库操作Mapper 9 | * @createDate 2023-09-08 16:41:55 10 | * @Entity com.cong.wanwu.model.entity.UserTag 11 | */ 12 | public interface UserTagMapper extends BaseMapper { 13 | 14 | } 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/chat/request/ChatMessageMarkReq.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.chat.request; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import javax.validation.constraints.NotNull; 10 | 11 | /** 12 | * 聊天消息标记请求 13 | * Description: 消息标记请求 14 | * Date: 2023-03-29 15 | * 16 | * @author liuhuaicong 17 | * @date 2023/10/31 18 | */ 19 | @Data 20 | @Builder 21 | @AllArgsConstructor 22 | @NoArgsConstructor 23 | public class ChatMessageMarkReq { 24 | @NotNull 25 | @ApiModelProperty("消息id") 26 | private Long msgId; 27 | 28 | @NotNull 29 | @ApiModelProperty("标记类型 1点赞 2举报") 30 | private Integer markType; 31 | 32 | @NotNull 33 | @ApiModelProperty("动作类型 1确认 2取消") 34 | private Integer actType; 35 | } 36 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/chat/request/ChatMessagePageReq.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.chat.request; 2 | 3 | import com.cong.wanwu.common.model.vo.request.CursorPageBaseReq; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Builder; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | import javax.validation.constraints.NotNull; 11 | 12 | /** 13 | * 聊天消息页面请求 14 | * Description: 消息列表请求 15 | * @author liuhuaicong 16 | * @date 2023/10/31 17 | */ 18 | @Data 19 | @Builder 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | public class ChatMessagePageReq extends CursorPageBaseReq { 23 | @NotNull 24 | @ApiModelProperty("会话id") 25 | private Long roomId; 26 | } 27 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/chat/request/ChatMessageReq.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.chat.request; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | import org.hibernate.validator.constraints.Length; 9 | 10 | import javax.validation.constraints.NotNull; 11 | 12 | 13 | /** 14 | * 聊天消息请求 15 | * Description: 消息发送请求体 16 | * 17 | * @author liuhuaicong 18 | * @date 2023/10/31 19 | */ 20 | @Data 21 | @Builder 22 | @AllArgsConstructor 23 | @NoArgsConstructor 24 | public class ChatMessageReq { 25 | 26 | @NotNull 27 | @Length(max = 10000, message = "消息内容过长,服务器扛不住啊,兄dei") 28 | @ApiModelProperty("消息内容") 29 | private String content; 30 | 31 | @NotNull 32 | @ApiModelProperty("会话id") 33 | private Long roomId; 34 | 35 | @ApiModelProperty("回复的消息id,如果没有别传就好") 36 | private Long replyMsgId; 37 | } 38 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/chat/response/ChatMemberResp.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.chat.response; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * Description: 群成员列表的成员信息 13 | * Author: abin 14 | * Date: 2023-03-23 15 | */ 16 | @Data 17 | @Builder 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | public class ChatMemberResp { 21 | @ApiModelProperty("uid") 22 | private Long uid; 23 | @ApiModelProperty("用户名称") 24 | private String name; 25 | @ApiModelProperty("头像") 26 | private String avatar; 27 | 28 | @ApiModelProperty("在线状态 1在线 2离线") 29 | private Integer activeStatus; 30 | @ApiModelProperty("最后一次上下线时间") 31 | private Date lastOptTime; 32 | } 33 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/chat/response/ChatMemberStatisticResp.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.chat.response; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | /** 10 | * Description: 群成员统计信息 11 | * Author: abin 12 | * Date: 2023-03-23 13 | */ 14 | @Data 15 | @Builder 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class ChatMemberStatisticResp { 19 | 20 | @ApiModelProperty("在线人数") 21 | private Long onlineNum;//在线人数 22 | @ApiModelProperty("总人数") 23 | @Deprecated 24 | private Long totalNum;//总人数 25 | } 26 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/chat/response/ChatRoomResp.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.chat.response; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * Description: 群成员列表的成员信息 13 | * Author: abin 14 | * Date: 2023-03-23 15 | */ 16 | @Data 17 | @Builder 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | public class ChatRoomResp { 21 | @ApiModelProperty("会话id") 22 | private Long id; 23 | @ApiModelProperty("会话名称") 24 | private String name; 25 | @ApiModelProperty("会话类型 1大群聊 2沸点") 26 | private Integer type; 27 | @ApiModelProperty("房间最后活跃时间") 28 | private Date lastActiveTime; 29 | } 30 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/file/UploadFileRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.file; 2 | 3 | import java.io.Serializable; 4 | import lombok.Data; 5 | 6 | /** 7 | * 文件上传请求 8 | * 9 | * @author 聪 10 | * 11 | */ 12 | @Data 13 | public class UploadFileRequest implements Serializable { 14 | 15 | /** 16 | * 业务 17 | */ 18 | private String biz; 19 | 20 | private static final long serialVersionUID = 1L; 21 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/picture/PictureQueryRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.picture; 2 | 3 | import com.cong.wanwu.common.common.PageRequest; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 查询请求 11 | * 12 | * @author 聪 13 | * 14 | */ 15 | @EqualsAndHashCode(callSuper = true) 16 | @Data 17 | public class PictureQueryRequest extends PageRequest implements Serializable { 18 | 19 | 20 | /** 21 | * 搜索词 22 | */ 23 | private String searchText; 24 | 25 | 26 | 27 | private static final long serialVersionUID = 1L; 28 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/post/PostAddRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.post; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | import lombok.Data; 6 | 7 | /** 8 | * 创建请求 9 | * 10 | * @author 聪 11 | * 12 | */ 13 | @Data 14 | public class PostAddRequest implements Serializable { 15 | 16 | /** 17 | * 标题 18 | */ 19 | private String title; 20 | /** 21 | * 描述 22 | */ 23 | private String synopsis; 24 | 25 | /** 26 | * 图片缩略图 27 | */ 28 | private List imgList; 29 | 30 | /** 31 | * 内容 32 | */ 33 | private String content; 34 | 35 | /** 36 | * 标签列表 37 | */ 38 | private List tags; 39 | 40 | private static final long serialVersionUID = 1L; 41 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/post/PostEditRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.post; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | import lombok.Data; 6 | 7 | /** 8 | * 编辑请求 9 | * 10 | * @author 聪 11 | * 12 | */ 13 | @Data 14 | public class PostEditRequest implements Serializable { 15 | 16 | /** 17 | * id 18 | */ 19 | private Long id; 20 | 21 | /** 22 | * 标题 23 | */ 24 | private String title; 25 | /** 26 | * 图片缩略图 27 | */ 28 | private List imgList; 29 | /** 30 | * 描述 31 | */ 32 | private String synopsis; 33 | 34 | /** 35 | * 内容 36 | */ 37 | private String content; 38 | 39 | /** 40 | * 标签列表 41 | */ 42 | private List tags; 43 | 44 | private static final long serialVersionUID = 1L; 45 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/post/PostImgRemoveRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.post; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 贴子附件图片移除 9 | * @author liuhuaicong 10 | */ 11 | @Data 12 | public class PostImgRemoveRequest implements Serializable { 13 | private Long postId; 14 | private String imgUrl; 15 | private static final long serialVersionUID = 1L; 16 | } 17 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/post/PostPublishRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.post; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 贴子发布 9 | * @author liuhuaicong 10 | */ 11 | @Data 12 | public class PostPublishRequest implements Serializable { 13 | private Long postId; 14 | private static final long serialVersionUID = 1L; 15 | } 16 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/post/PostUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.post; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | import lombok.Data; 6 | 7 | /** 8 | * 更新请求 9 | * 10 | */ 11 | @Data 12 | public class PostUpdateRequest implements Serializable { 13 | 14 | /** 15 | * id 16 | */ 17 | private Long id; 18 | /** 19 | * 描述 20 | */ 21 | private String synopsis; 22 | /** 23 | * 图片缩略图 24 | */ 25 | private List imgList; 26 | 27 | /** 28 | * 标题 29 | */ 30 | private String title; 31 | 32 | /** 33 | * 内容 34 | */ 35 | private String content; 36 | 37 | /** 38 | * 标签列表 39 | */ 40 | private List tags; 41 | 42 | private static final long serialVersionUID = 1L; 43 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/postfavour/PostFavourAddRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.postfavour; 2 | 3 | import java.io.Serializable; 4 | import lombok.Data; 5 | 6 | /** 7 | * 帖子收藏 / 取消收藏请求 8 | * 9 | * @author 聪 10 | * 11 | */ 12 | @Data 13 | public class PostFavourAddRequest implements Serializable { 14 | 15 | /** 16 | * 帖子 id 17 | */ 18 | private Long postId; 19 | 20 | private static final long serialVersionUID = 1L; 21 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/postfavour/PostFavourQueryRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.postfavour; 2 | 3 | import com.cong.wanwu.common.common.PageRequest; 4 | import com.cong.wanwu.usercenter.model.dto.post.PostQueryRequest; 5 | import java.io.Serializable; 6 | 7 | import lombok.Data; 8 | import lombok.EqualsAndHashCode; 9 | 10 | /** 11 | * 帖子收藏查询请求 12 | * 13 | * @author 聪 14 | * 15 | */ 16 | @Data 17 | @EqualsAndHashCode(callSuper = true) 18 | public class PostFavourQueryRequest extends PageRequest implements Serializable { 19 | 20 | /** 21 | * 帖子查询请求 22 | */ 23 | private PostQueryRequest postQueryRequest; 24 | 25 | /** 26 | * 用户 id 27 | */ 28 | private Long userId; 29 | 30 | private static final long serialVersionUID = 1L; 31 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/postthumb/PostThumbAddRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.postthumb; 2 | 3 | import java.io.Serializable; 4 | import lombok.Data; 5 | 6 | /** 7 | * 帖子点赞请求 8 | * 9 | * @author 聪 10 | * 11 | */ 12 | @Data 13 | public class PostThumbAddRequest implements Serializable { 14 | 15 | /** 16 | * 帖子 id 17 | */ 18 | private Long postId; 19 | 20 | private static final long serialVersionUID = 1L; 21 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/search/SearchQueryRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.search; 2 | 3 | import com.cong.wanwu.common.common.PageRequest; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 查询请求 11 | * 12 | * @author 聪 13 | * 14 | */ 15 | @EqualsAndHashCode(callSuper = true) 16 | @Data 17 | public class SearchQueryRequest extends PageRequest implements Serializable { 18 | 19 | 20 | /** 21 | * 搜索词 22 | */ 23 | private String searchText; 24 | 25 | /** 26 | * 类型 27 | */ 28 | private String type; 29 | 30 | 31 | private static final long serialVersionUID = 1L; 32 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/user/UserAddRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.user; 2 | 3 | import java.io.Serializable; 4 | import lombok.Data; 5 | 6 | /** 7 | * 用户创建请求 8 | * 9 | * @author 聪 10 | * 11 | */ 12 | @Data 13 | public class UserAddRequest implements Serializable { 14 | 15 | /** 16 | * 用户昵称 17 | */ 18 | private String userName; 19 | 20 | /** 21 | * 用户标签 22 | */ 23 | private String tags; 24 | 25 | /** 26 | * 账号 27 | */ 28 | private String userAccount; 29 | 30 | /** 31 | * 用户头像 32 | */ 33 | private String userAvatar; 34 | 35 | /** 36 | * 用户角色: user, admin 37 | */ 38 | private String userRole; 39 | 40 | private static final long serialVersionUID = 1L; 41 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/user/UserLoginRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.user; 2 | 3 | import java.io.Serializable; 4 | import lombok.Data; 5 | 6 | /** 7 | * 用户登录请求 8 | * 9 | * @author 聪 10 | * 11 | */ 12 | @Data 13 | public class UserLoginRequest implements Serializable { 14 | 15 | private static final long serialVersionUID = 3191241716373120793L; 16 | 17 | private String userAccount; 18 | 19 | private String userPassword; 20 | } 21 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/user/UserMpLoginRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.user; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 用户登录请求 9 | * 10 | * @author 聪 11 | * 12 | */ 13 | @Data 14 | public class UserMpLoginRequest implements Serializable { 15 | 16 | private static final long serialVersionUID = 3191241716373120793L; 17 | 18 | private String mpCode; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/user/UserQueryRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.user; 2 | 3 | import com.cong.wanwu.common.common.PageRequest; 4 | import java.io.Serializable; 5 | 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | 9 | /** 10 | * 用户查询请求 11 | * 12 | * @author 聪 13 | * 14 | */ 15 | @EqualsAndHashCode(callSuper = true) 16 | @Data 17 | public class UserQueryRequest extends PageRequest implements Serializable { 18 | /** 19 | * id 20 | */ 21 | private Long id; 22 | /** 23 | * 用户标签 24 | */ 25 | private String tags; 26 | 27 | /** 28 | * 开放平台id 29 | */ 30 | private String unionId; 31 | 32 | /** 33 | * 公众号openId 34 | */ 35 | private String mpOpenId; 36 | 37 | /** 38 | * 用户昵称 39 | */ 40 | private String userName; 41 | 42 | /** 43 | * 简介 44 | */ 45 | private String userProfile; 46 | 47 | /** 48 | * 用户角色:user/admin/ban 49 | */ 50 | private String userRole; 51 | 52 | private static final long serialVersionUID = 1L; 53 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/user/UserRegisterRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.user; 2 | 3 | import java.io.Serializable; 4 | import lombok.Data; 5 | 6 | /** 7 | * 用户注册请求体 8 | * 9 | */ 10 | @Data 11 | public class UserRegisterRequest implements Serializable { 12 | 13 | private static final long serialVersionUID = 3191241716373120793L; 14 | 15 | private String userAccount; 16 | 17 | private String userPassword; 18 | 19 | private String checkPassword; 20 | } 21 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/user/UserUpdateMyRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.user; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import lombok.Data; 7 | 8 | /** 9 | * 用户更新个人信息请求 10 | * 11 | * @author 聪 12 | * 13 | */ 14 | @Data 15 | public class UserUpdateMyRequest implements Serializable { 16 | 17 | /** 18 | * 用户昵称 19 | */ 20 | private String userName; 21 | 22 | /** 23 | * 用户头像 24 | */ 25 | private String userAvatar; 26 | 27 | /** 28 | * 简介 29 | */ 30 | private String userProfile; 31 | 32 | /** 33 | * 用户标签 34 | */ 35 | private List tags; 36 | 37 | private static final long serialVersionUID = 1L; 38 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/user/UserUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.user; 2 | 3 | import java.io.Serializable; 4 | import lombok.Data; 5 | 6 | /** 7 | * 用户更新请求 8 | * 9 | * @author 聪 10 | * 11 | */ 12 | @Data 13 | public class UserUpdateRequest implements Serializable { 14 | /** 15 | * id 16 | */ 17 | private Long id; 18 | 19 | /** 20 | * 用户昵称 21 | */ 22 | private String userName; 23 | 24 | /** 25 | * 用户头像 26 | */ 27 | private String userAvatar; 28 | 29 | /** 30 | * 简介 31 | */ 32 | private String userProfile; 33 | /** 34 | * 用户标签 35 | */ 36 | private String tags; 37 | 38 | /** 39 | * 用户角色:user/admin/ban 40 | */ 41 | private String userRole; 42 | 43 | private static final long serialVersionUID = 1L; 44 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/userTag/UserTagAddRequest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.userTag; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author liuhuaicong 7 | * @date 2023/09/08 8 | */ 9 | @Data 10 | public class UserTagAddRequest { 11 | /** 12 | *父级id 13 | */ 14 | private Long parentId; 15 | /** 16 | *名称 17 | */ 18 | private String name; 19 | } 20 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/dto/ws/WSChannelExtraDTO.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.dto.ws; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * WSSchannel 额外 DTO 10 | * Description: 记录和前端连接的一些映射信息 11 | * Author: abin 12 | * Date: 2023-03-21 13 | * 14 | * @author liuhuaicong 15 | * @date 2023/10/27 16 | */ 17 | @Data 18 | @Builder 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | public class WSChannelExtraDTO { 22 | /** 23 | * 前端如果登录了,记录uid 24 | */ 25 | private Long uid; 26 | } 27 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/entity/Picture.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 图片 9 | * 10 | * @author 86188 11 | * @date 2023/03/13 12 | */ 13 | @Data 14 | public class Picture implements Serializable { 15 | 16 | /** 17 | * 标题 18 | */ 19 | private String title; 20 | 21 | /** 22 | * url地址 23 | */ 24 | private String url; 25 | private static final long serialVersionUID = 1L; 26 | } 27 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/entity/PostFavour.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.entity; 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 java.io.Serializable; 8 | import java.util.Date; 9 | import lombok.Data; 10 | 11 | /** 12 | * 帖子收藏 13 | * 14 | * @author 聪 15 | * 16 | **/ 17 | @TableName(value = "post_favour") 18 | @Data 19 | public class PostFavour implements Serializable { 20 | 21 | /** 22 | * id 23 | */ 24 | @TableId(type = IdType.AUTO) 25 | private Long id; 26 | 27 | /** 28 | * 帖子 id 29 | */ 30 | private Long postId; 31 | 32 | /** 33 | * 创建用户 id 34 | */ 35 | private Long userId; 36 | 37 | /** 38 | * 创建时间 39 | */ 40 | private Date createTime; 41 | 42 | /** 43 | * 更新时间 44 | */ 45 | private Date updateTime; 46 | 47 | @TableField(exist = false) 48 | private static final long serialVersionUID = 1L; 49 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/entity/PostImages.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.entity; 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 java.io.Serializable; 8 | import java.util.Date; 9 | import lombok.Data; 10 | 11 | /** 12 | * 帖子图片表 13 | * @TableName post_images 14 | */ 15 | @TableName(value ="post_images") 16 | @Data 17 | public class PostImages implements Serializable { 18 | /** 19 | * id 20 | */ 21 | @TableId(type = IdType.AUTO) 22 | private Long id; 23 | 24 | /** 25 | * 图片地址 26 | */ 27 | private String imgUrl; 28 | 29 | /** 30 | * 帖子id 31 | */ 32 | private Long postId; 33 | 34 | /** 35 | * 创建用户 id 36 | */ 37 | private Long userId; 38 | 39 | /** 40 | * 创建时间 41 | */ 42 | private Date createTime; 43 | 44 | /** 45 | * 更新时间 46 | */ 47 | private Date updateTime; 48 | 49 | /** 50 | * 是否删除 51 | */ 52 | private Integer isDelete; 53 | 54 | @TableField(exist = false) 55 | private static final long serialVersionUID = 1L; 56 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/entity/PostThumb.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.entity; 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 java.io.Serializable; 8 | import java.util.Date; 9 | import lombok.Data; 10 | 11 | /** 12 | * 帖子点赞 13 | * 14 | * @author 聪 15 | * 16 | */ 17 | @TableName(value = "post_thumb") 18 | @Data 19 | public class PostThumb implements Serializable { 20 | 21 | /** 22 | * id 23 | */ 24 | @TableId(type = IdType.AUTO) 25 | private Long id; 26 | 27 | /** 28 | * 帖子 id 29 | */ 30 | private Long postId; 31 | 32 | /** 33 | * 创建用户 id 34 | */ 35 | private Long userId; 36 | 37 | /** 38 | * 创建时间 39 | */ 40 | private Date createTime; 41 | 42 | /** 43 | * 更新时间 44 | */ 45 | private Date updateTime; 46 | 47 | @TableField(exist = false) 48 | private static final long serialVersionUID = 1L; 49 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/entity/UserAttention.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.entity; 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 java.io.Serializable; 8 | import java.util.Date; 9 | import lombok.Data; 10 | 11 | /** 12 | * 用户关注表 13 | * @TableName user_attention 14 | */ 15 | @TableName(value ="user_attention") 16 | @Data 17 | public class UserAttention implements Serializable { 18 | /** 19 | * id 20 | */ 21 | @TableId(type = IdType.AUTO) 22 | private Long id; 23 | 24 | /** 25 | * 关注人id(点击关注那个人ID) 26 | */ 27 | private Long userId; 28 | 29 | /** 30 | * 被关注人id(被关注的那个人) 31 | */ 32 | private Long followedUserId; 33 | 34 | /** 35 | * 创建时间 36 | */ 37 | private Date createTime; 38 | 39 | /** 40 | * 更新时间 41 | */ 42 | private Date updateTime; 43 | 44 | @TableField(exist = false) 45 | private static final long serialVersionUID = 1L; 46 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/entity/UserTag.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.entity; 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 java.io.Serializable; 8 | import java.util.Date; 9 | import lombok.Data; 10 | 11 | /** 12 | * 13 | * @TableName user_tag 14 | */ 15 | @TableName(value ="user_tag") 16 | @Data 17 | public class UserTag implements Serializable { 18 | /** 19 | * 主键 20 | */ 21 | @TableId(type = IdType.AUTO) 22 | private Long id; 23 | 24 | /** 25 | * 类别id 26 | */ 27 | private Long parentId; 28 | 29 | /** 30 | * 标签名 31 | */ 32 | private String name; 33 | 34 | /** 35 | * 颜色 36 | */ 37 | private String color; 38 | 39 | /** 40 | * 创建用户 41 | */ 42 | private Long createdBy; 43 | 44 | /** 45 | * 创建时间 46 | */ 47 | private Date createTime; 48 | 49 | /** 50 | * 更新时间 51 | */ 52 | private Date updateTime; 53 | 54 | /** 55 | * 是否删除 56 | */ 57 | private Integer isDelete; 58 | 59 | @TableField(exist = false) 60 | private static final long serialVersionUID = 1L; 61 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/enums/chat/BlackTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.enums.chat; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | /** 7 | * 黑色类型枚举 8 | * Description: 物品枚举 9 | * Date: 2023-03-19 10 | * 11 | * @author liuhuaicong 12 | * @date 2023/10/31 13 | */ 14 | @AllArgsConstructor 15 | @Getter 16 | public enum BlackTypeEnum { 17 | IP(1), 18 | UID(2), 19 | ; 20 | 21 | private final Integer type; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/enums/chat/ChatActiveStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.enums.chat; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | import java.util.Arrays; 7 | import java.util.Map; 8 | import java.util.function.Function; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * 聊天活动状态枚举 13 | * Description: ws前端请求类型枚举 14 | * @author liuhuaicong 15 | * @date 2023/10/31 16 | */ 17 | @AllArgsConstructor 18 | @Getter 19 | public enum ChatActiveStatusEnum { 20 | ONLINE(1, "在线"), 21 | OFFLINE(2, "离线"), 22 | ; 23 | 24 | private final Integer status; 25 | private final String desc; 26 | 27 | private static Map cache; 28 | 29 | static { 30 | cache = Arrays.stream(ChatActiveStatusEnum.values()).collect(Collectors.toMap(ChatActiveStatusEnum::getStatus, Function.identity())); 31 | } 32 | 33 | public static ChatActiveStatusEnum of(Integer type) { 34 | return cache.get(type); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/enums/chat/ItemEnum.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.enums.chat; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | import java.util.Arrays; 7 | import java.util.Map; 8 | import java.util.function.Function; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * 项枚举 13 | * Description: 物品枚举 14 | * @author liuhuaicong 15 | * @date 2023/10/31 16 | */ 17 | @AllArgsConstructor 18 | @Getter 19 | public enum ItemEnum { 20 | MODIFY_NAME_CARD(1L, ItemTypeEnum.MODIFY_NAME_CARD, "改名卡"), 21 | LIKE_BADGE(2L, ItemTypeEnum.BADGE, "爆赞徽章"), 22 | REG_TOP10_BADGE(3L, ItemTypeEnum.BADGE, "前十注册徽章"), 23 | REG_TOP100_BADGE(4L, ItemTypeEnum.BADGE, "前100注册徽章"), 24 | ; 25 | 26 | private final Long id; 27 | private final ItemTypeEnum typeEnum; 28 | private final String desc; 29 | 30 | private static Map cache; 31 | 32 | static { 33 | cache = Arrays.stream(ItemEnum.values()).collect(Collectors.toMap(ItemEnum::getId, Function.identity())); 34 | } 35 | 36 | public static ItemEnum of(Integer type) { 37 | return cache.get(type); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/enums/chat/ItemTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.enums.chat; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | import java.util.Arrays; 7 | import java.util.Map; 8 | import java.util.function.Function; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * 项目类型枚举 13 | * Description: 物品枚举 14 | * @author liuhuaicong 15 | * @date 2023/10/31 16 | */ 17 | @AllArgsConstructor 18 | @Getter 19 | public enum ItemTypeEnum { 20 | MODIFY_NAME_CARD(1, "改名卡"), 21 | BADGE(2, "徽章"), 22 | ; 23 | 24 | private final Integer type; 25 | private final String desc; 26 | 27 | private static Map cache; 28 | 29 | static { 30 | cache = Arrays.stream(ItemTypeEnum.values()).collect(Collectors.toMap(ItemTypeEnum::getType, Function.identity())); 31 | } 32 | 33 | public static ItemTypeEnum of(Integer type) { 34 | return cache.get(type); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/enums/chat/MessageMarkActTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.enums.chat; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | import java.util.Arrays; 7 | import java.util.Map; 8 | import java.util.function.Function; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * Description: 消息标记动作类型 13 | * Author: abin 14 | * Date: 2023-03-19 15 | */ 16 | @AllArgsConstructor 17 | @Getter 18 | public enum MessageMarkActTypeEnum { 19 | MARK(1, "确认标记"), 20 | UN_MARK(2, "取消标记"), 21 | ; 22 | 23 | private final Integer type; 24 | private final String desc; 25 | 26 | private static Map cache; 27 | 28 | static { 29 | cache = Arrays.stream(MessageMarkActTypeEnum.values()).collect(Collectors.toMap(MessageMarkActTypeEnum::getType, Function.identity())); 30 | } 31 | 32 | public static MessageMarkActTypeEnum of(Integer type) { 33 | return cache.get(type); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/enums/chat/MessageMarkTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.enums.chat; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | import java.util.Arrays; 7 | import java.util.Map; 8 | import java.util.function.Function; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * Description: 消息标记类型 13 | * Author: abin 14 | * Date: 2023-03-19 15 | */ 16 | @AllArgsConstructor 17 | @Getter 18 | public enum MessageMarkTypeEnum { 19 | LIKE(1, "点赞", 10, MessageTypeEnum.LIKE), 20 | DISLIKE(2, "点踩", 5, MessageTypeEnum.DISLIKE), 21 | ; 22 | 23 | private final Integer type; 24 | private final String desc; 25 | private final Integer riseNum;//需要多少个标记升级 26 | private final MessageTypeEnum riseEnum;//消息升级成什么类型的消息 27 | 28 | private static Map cache; 29 | 30 | static { 31 | cache = Arrays.stream(MessageMarkTypeEnum.values()).collect(Collectors.toMap(MessageMarkTypeEnum::getType, Function.identity())); 32 | } 33 | 34 | public static MessageMarkTypeEnum of(Integer type) { 35 | return cache.get(type); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/enums/chat/MessageStatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.enums.chat; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | import java.util.Arrays; 7 | import java.util.Map; 8 | import java.util.function.Function; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * Description: 消息状态 13 | * Author: abin 14 | * Date: 2023-03-19 15 | */ 16 | @AllArgsConstructor 17 | @Getter 18 | public enum MessageStatusEnum { 19 | NORMAL(0, "正常"), 20 | DELETE(1, "删除"), 21 | ; 22 | 23 | private final Integer status; 24 | private final String desc; 25 | 26 | private static Map cache; 27 | 28 | static { 29 | cache = Arrays.stream(MessageStatusEnum.values()).collect(Collectors.toMap(MessageStatusEnum::getStatus, Function.identity())); 30 | } 31 | 32 | public static MessageStatusEnum of(Integer type) { 33 | return cache.get(type); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/enums/chat/MessageTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.enums.chat; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | import java.util.Arrays; 7 | import java.util.Map; 8 | import java.util.function.Function; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * Description: 消息状态 13 | * Author: abin 14 | * Date: 2023-03-19 15 | */ 16 | @AllArgsConstructor 17 | @Getter 18 | public enum MessageTypeEnum { 19 | GROUP(1, "群聊"), 20 | PRIVATE(2, "私聊"), 21 | NORMAL(3, "正常"), 22 | LIKE(4, "爆赞"), 23 | DISLIKE(5, "危险发言"), 24 | ; 25 | 26 | private final Integer type; 27 | private final String desc; 28 | 29 | private static Map cache; 30 | 31 | static { 32 | cache = Arrays.stream(MessageTypeEnum.values()).collect(Collectors.toMap(MessageTypeEnum::getType, Function.identity())); 33 | } 34 | 35 | public static MessageTypeEnum of(Integer type) { 36 | return cache.get(type); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/enums/ws/WSReqTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.enums.ws; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | import java.util.Arrays; 7 | import java.util.Map; 8 | import java.util.function.Function; 9 | import java.util.stream.Collectors; 10 | 11 | /** 12 | * Description: ws前端请求类型枚举 13 | * Author: abin 14 | * Date: 2023-03-19 15 | */ 16 | @AllArgsConstructor 17 | @Getter 18 | public enum WSReqTypeEnum { 19 | LOGIN(1, "请求登录二维码"), 20 | HEARTBEAT(2, "心跳包"), 21 | AUTHORIZE(3, "登录认证"), 22 | WANWU_LOGIN(4, "wanwu登录"), 23 | CHAT(5, "发送消息"), 24 | ; 25 | 26 | private final Integer type; 27 | private final String desc; 28 | 29 | private static Map cache; 30 | 31 | static { 32 | cache = Arrays.stream(WSReqTypeEnum.values()).collect(Collectors.toMap(WSReqTypeEnum::getType, Function.identity())); 33 | } 34 | 35 | public static WSReqTypeEnum of(Integer type) { 36 | return cache.get(type); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/CnBlogVo.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 博客园VO 7 | * 8 | * @author liuhuaicong 9 | * @date 2023/10/19 10 | */ 11 | @Data 12 | public class CnBlogVo { 13 | 14 | /** 15 | * 标题 16 | */ 17 | private String title; 18 | 19 | /** 20 | * 文章网址 21 | */ 22 | private String articleUrl; 23 | 24 | /** 25 | * 总结 26 | */ 27 | private String summary; 28 | 29 | /** 30 | * 观看次数 31 | */ 32 | private String viewCount; 33 | 34 | /** 35 | * 喜欢计数 36 | */ 37 | private String likeCount; 38 | 39 | /** 40 | * 评论计数 41 | */ 42 | private String commentCount; 43 | 44 | /** 45 | * 作者 46 | */ 47 | private String author; 48 | 49 | /** 50 | * 作者网址 51 | */ 52 | private String authorUrl; 53 | 54 | /** 55 | * 创建时间 56 | */ 57 | private String createdTime; 58 | } 59 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/CsdnBlogVo.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * CSDN 博客 VO 9 | * 10 | * @author liuhuaicong 11 | * @date 2023/10/19 12 | */ 13 | @Data 14 | public class CsdnBlogVo { 15 | /** 16 | * 标题 17 | */ 18 | private String title; 19 | /** 20 | * 文章网址 21 | */ 22 | private String articleUrl; 23 | /** 24 | * 总结 25 | */ 26 | private String summary; 27 | /** 28 | * 观看次数 29 | */ 30 | private String viewCount; 31 | /** 32 | * 喜欢计数 33 | */ 34 | private String likeCount; 35 | /** 36 | * 评论计数 37 | */ 38 | private String commentCount; 39 | /** 40 | * 作者 41 | */ 42 | private String author; 43 | /** 44 | * 作者网址 45 | */ 46 | private String authorUrl; 47 | /** 48 | * 创建时间 49 | */ 50 | private String createdTime; 51 | /** 52 | * 图片列表 53 | */ 54 | private List picList; 55 | } 56 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/NotificationCountVo.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | /** 7 | * 消息通知数量 8 | * @author liuhuaicong 9 | * @date 2023/09/14 10 | */ 11 | @Data 12 | @AllArgsConstructor 13 | public class NotificationCountVo { 14 | private Integer likeCount; 15 | private Integer commentCount; 16 | private Integer msgCount; 17 | private Integer noticeCount; 18 | } 19 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/QiNiuPolicyVo.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 七牛云签名任认证 7 | * @author liuhuaicong 8 | * @date 2023/09/11 9 | */ 10 | @Data 11 | public class QiNiuPolicyVo { 12 | 13 | /** 14 | *凭证 15 | */ 16 | String token; 17 | 18 | /** 19 | *存入外链默认域名,用于拼接完整的资源外链路径 20 | */ 21 | String domain; 22 | 23 | /** 24 | * 存放文件夹 25 | */ 26 | String dir; 27 | } 28 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/SearchVO.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import com.cong.wanwu.usercenter.model.entity.Picture; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | import java.util.List; 9 | 10 | /** 11 | * 帖子视图 12 | * 13 | */ 14 | @Data 15 | public class SearchVO implements Serializable { 16 | 17 | 18 | private Page pageData; 19 | } 20 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/TokenLoginUserVo.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo; 2 | 3 | import cn.dev33.satoken.stp.SaTokenInfo; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 使用Token登录 11 | * @author liuhuaicong 12 | * @date 2023/09/11 13 | */ 14 | @EqualsAndHashCode(callSuper = true) 15 | @Data 16 | public class TokenLoginUserVo extends LoginUserVO implements Serializable { 17 | 18 | private static final long serialVersionUID = 2405172041950251807L; 19 | 20 | /** 21 | *token的信息 22 | */ 23 | private transient SaTokenInfo saTokenInfo; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/UserTagCategoryVo.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo; 2 | 3 | import com.cong.wanwu.usercenter.model.entity.UserTag; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author liuhuaicong 10 | * @date 2023/09/08 11 | */ 12 | @Data 13 | public class UserTagCategoryVo { 14 | private Long id; 15 | 16 | private String name; 17 | 18 | private List tags; 19 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/UserTagVo.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author liuhuaicong 7 | * @date 2023/09/08 8 | */ 9 | @Data 10 | public class UserTagVo { 11 | private Long id; 12 | private Long parentId; 13 | /** 14 | *名称 15 | */ 16 | private String name; 17 | /** 18 | *颜色 19 | */ 20 | private String color; 21 | } 22 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/WxLoveData.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * WX爱情数据 7 | * 8 | * @author liuhuaicong 9 | * @date 2023/10/23 10 | */ 11 | @Data 12 | public class WxLoveData{ 13 | /** 14 | * 值 15 | */ 16 | String value; 17 | 18 | /** 19 | * 颜色 20 | */ 21 | String color; 22 | } 23 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/WxLoveMessage.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | /** 9 | * WX爱心留言 10 | * 11 | * @author liuhuaicong 12 | * @date 2023/10/23 13 | */ 14 | @Data 15 | public class WxLoveMessage { 16 | /** 17 | * 模板标识 18 | */ 19 | String template_id; 20 | 21 | /** 22 | * 用户 23 | */ 24 | String touser; 25 | 26 | /** 27 | * 网址 28 | */ 29 | String url; 30 | 31 | /** 32 | * 数据 33 | */ 34 | Map data = new HashMap<>(); 35 | } 36 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/message/ChatMessageVo.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo.message; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 聊天消息VO 7 | * 8 | * @author liuhuaicong 9 | * @date 2023/10/31 10 | */ 11 | @Data 12 | public class ChatMessageVo { 13 | private Integer type; 14 | private String content; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/message/MessageExtra.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo.message; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.io.Serializable; 9 | import java.util.Map; 10 | 11 | /** 12 | * Description: 消息扩展属性 13 | * Author: abin 14 | * Date: 2023-05-28 15 | */ 16 | @Data 17 | @Builder 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | public class MessageExtra implements Serializable { 21 | private static final long serialVersionUID = 1L; 22 | //注册时的ip 23 | private Map urlTitleMap; 24 | } 25 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/message/MessageVo.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo.message; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 消息 VO 9 | * 10 | * @author liuhuaicong 11 | * @date 2023/10/31 12 | */ 13 | @Data 14 | public class MessageVo { 15 | private String avatar; 16 | 17 | /** 18 | * 会话表id 19 | */ 20 | private Long roomId; 21 | 22 | /** 23 | * 消息发送者uid 24 | */ 25 | private Long fromUid; 26 | 27 | /** 28 | * 消息内容 29 | */ 30 | private String content; 31 | 32 | 33 | 34 | /** 35 | * 与回复的消息间隔多少条 36 | */ 37 | private Integer gapCount; 38 | 39 | 40 | /** 41 | * 扩展信息 42 | */ 43 | private String extra; 44 | 45 | /** 46 | * 创建时间 47 | */ 48 | private Date createTime; 49 | } 50 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/message/RoomFriendVo.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo.message; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Date; 6 | 7 | /** 8 | * 室友VO 9 | * 10 | * @author liuhuaicong 11 | * @date 2023/11/01 12 | */ 13 | @Data 14 | public class RoomFriendVo { 15 | 16 | private Long id; 17 | private Long roomId; 18 | private Long fromUid; 19 | private String fromUsername; 20 | private String avatar; 21 | 22 | private Integer unread; 23 | private String lastMessage; 24 | private Date updateTime; 25 | } 26 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/ws/request/WSAuthorize.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo.ws.request; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * wsauthorize 10 | * Description: 11 | * Author: abin 12 | * Date: 2023-03-19 13 | * 14 | * @author liuhuaicong 15 | * @date 2023/10/27 16 | */ 17 | @Data 18 | @Builder 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | public class WSAuthorize { 22 | private String token; 23 | } 24 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/ws/request/WSBaseReq.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo.ws.request; 2 | 3 | import com.cong.wanwu.usercenter.model.enums.ws.WSReqTypeEnum; 4 | import lombok.Data; 5 | 6 | /** 7 | * Description: websocket前端请求体 8 | * Date: 2023-03-19 9 | */ 10 | @Data 11 | public class WSBaseReq { 12 | /** 13 | * 请求类型 1.请求登录二维码,2心跳检测 14 | * 15 | * @see WSReqTypeEnum 16 | */ 17 | private Integer type; 18 | 19 | /** 20 | * 接收的用户id 21 | */ 22 | private Long uid; 23 | 24 | /** 25 | * 每个请求包具体的数据,类型不同结果不同 26 | */ 27 | private String data; 28 | } 29 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/ws/response/WSBaseResp.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo.ws.response; 2 | 3 | import com.cong.wanwu.usercenter.model.enums.ws.WSReqTypeEnum; 4 | import lombok.Data; 5 | 6 | /** 7 | * Description: ws的基本返回信息体 8 | * Author: abin 9 | * Date: 2023-03-19 10 | */ 11 | @Data 12 | public class WSBaseResp { 13 | /** 14 | * ws推送给前端的消息 15 | * 16 | * @see WSReqTypeEnum 17 | */ 18 | private Integer type; 19 | private T data; 20 | } 21 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/ws/response/WSBlack.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo.ws.response; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * Description: 10 | * Author: abin 11 | * Date: 2023-03-19 12 | */ 13 | @Data 14 | @Builder 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | public class WSBlack { 18 | private Long uid; 19 | } 20 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/ws/response/WSLoginSuccess.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo.ws.response; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * WSLOGIN 成功 10 | * Description: 11 | * Author: abin 12 | * Date: 2023-03-19 13 | * 14 | * @author liuhuaicong 15 | * @date 2023/10/27 16 | */ 17 | @Data 18 | @Builder 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | public class WSLoginSuccess { 22 | private Long uid; 23 | private String avatar; 24 | private String token; 25 | private String name; 26 | } 27 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/ws/response/WSLoginUrl.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo.ws.response; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | /** 9 | * WSLOGIN URL 10 | * Description: 11 | * Author: abin 12 | * Date: 2023-03-19 13 | * 14 | * @author liuhuaicong 15 | * @date 2023/10/27 16 | */ 17 | @Data 18 | @Builder 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | public class WSLoginUrl { 22 | private String loginUrl; 23 | } 24 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/ws/response/WSMessage.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo.ws.response; 2 | 3 | import com.cong.wanwu.usercenter.model.dto.chat.response.ChatMessageResp; 4 | import lombok.Data; 5 | 6 | /** 7 | * WSMmessage(WS消息) 8 | * Description: 用户消息推送 9 | * Author: abin 10 | * Date: 2023-03-19 11 | * 12 | * @author liuhuaicong 13 | * @date 2023/10/27 14 | */ 15 | @Data 16 | public class WSMessage extends ChatMessageResp { 17 | } 18 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/model/vo/ws/response/WSOnlineOfflineNotify.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.model.vo.ws.response; 2 | 3 | 4 | import com.cong.wanwu.usercenter.model.dto.chat.response.ChatMemberResp; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Builder; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * Description:用户上下线变动的推送类 15 | * Author: abin 16 | * Date: 2023-03-19 17 | */ 18 | @Data 19 | @Builder 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | public class WSOnlineOfflineNotify { 23 | private List changeList = new ArrayList<>();//新的上下线用户 24 | private Long onlineNum;//在线人数 25 | @Deprecated 26 | private Long totalNum;//总人数 27 | 28 | } 29 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/MessageService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service; 2 | 3 | import com.cong.wanwu.common.model.vo.request.CursorPageBaseReq; 4 | import com.cong.wanwu.common.model.vo.response.CursorPageBaseResp; 5 | import com.cong.wanwu.usercenter.model.entity.chat.Message; 6 | import com.baomidou.mybatisplus.extension.service.IService; 7 | 8 | /** 9 | * @author liuhuaicong 10 | * @description 针对表【message(消息表)】的数据库操作Service 11 | * @createDate 2023-10-31 10:35:04 12 | */ 13 | public interface MessageService extends IService { 14 | 15 | /** 16 | * 获取间隙计数 17 | * 18 | * @param roomId 房间 ID 19 | * @param fromId 从 ID 20 | * @param toId 到 ID 21 | * @return {@link Integer} 22 | */ 23 | Integer getGapCount(Long roomId, Long fromId, Long toId); 24 | 25 | /** 26 | * 更新间隔计数 27 | * 28 | * @param id 编号 29 | * @param gapCount 间隙计数 30 | */ 31 | void updateGapCount(Long id, Integer gapCount); 32 | 33 | /** 34 | * 获取光标页面 35 | * 36 | * @param roomId 房间 ID 37 | * @param request 请求 38 | * @return {@link CursorPageBaseResp}<{@link Message}> 39 | */ 40 | CursorPageBaseResp getCursorPage(Long roomId, CursorPageBaseReq request); 41 | } 42 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/NotificationService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import com.cong.wanwu.usercenter.model.vo.NotificationCountVo; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | 8 | /** 9 | * @author liuhuaicong 10 | * @description 针对表【notification】的数据库操作Service 11 | * @createDate 2023-05-18 16:36:19 12 | * @date 2023/09/14 13 | */ 14 | public interface NotificationService { 15 | 16 | /** 17 | * 获取信息数量 18 | * @return {@link NotificationCountVo} 19 | */ 20 | NotificationCountVo count(); 21 | 22 | /** 23 | * 清除指定消息 24 | * @param type 25 | */ 26 | void clearNotification(String type); 27 | 28 | // Page listLikeNotificationByPage(NotificationQueryRequest notificationQueryRequest); 29 | // 30 | // 31 | // Page listCommentNotificationByPage(NotificationQueryRequest notificationQueryRequest); 32 | } 33 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/PictureService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import com.cong.wanwu.usercenter.model.entity.Picture; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 图片服务 10 | * 11 | * @author 聪 12 | * 13 | */ 14 | public interface PictureService { 15 | 16 | 17 | /** 18 | * 搜索图片 19 | * 20 | * @param searchText 搜索文本 21 | * @param pageNum 页面num 22 | * @param pageSize 页面大小 23 | * @return {@link List}<{@link Picture}> 24 | */ 25 | Page searchPicture(String searchText,long pageNum,long pageSize); 26 | } 27 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/PostImagesService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.cong.wanwu.usercenter.model.entity.PostImages; 5 | 6 | /** 7 | * @author liuhuaicong 8 | * @description 针对表【post_images(帖子图片表)】的数据库操作Service 9 | * @createDate 2023-09-14 10:57:28 10 | */ 11 | public interface PostImagesService extends IService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/PostThumbService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service; 2 | 3 | import com.cong.wanwu.usercenter.model.entity.PostThumb; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.cong.wanwu.common.model.entity.User; 6 | 7 | /** 8 | * 帖子点赞服务 9 | * 10 | * @author 聪 11 | * 12 | */ 13 | public interface PostThumbService extends IService { 14 | 15 | /** 16 | * 点赞 17 | * 18 | * @param postId 19 | * @param loginUser 20 | * @return 21 | */ 22 | int doPostThumb(long postId, User loginUser); 23 | 24 | /** 25 | * 帖子点赞(内部服务) 26 | * 27 | * @param userId 28 | * @param postId 29 | * @return 30 | */ 31 | int doPostThumbInner(long userId, long postId); 32 | } 33 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/RoomFriendService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service; 2 | 3 | import com.cong.wanwu.common.model.vo.request.CursorPageBaseReq; 4 | import com.cong.wanwu.common.model.vo.response.CursorPageBaseResp; 5 | import com.cong.wanwu.usercenter.model.entity.chat.RoomFriend; 6 | import com.baomidou.mybatisplus.extension.service.IService; 7 | 8 | /** 9 | * @author liuhuaicong 10 | * @description 针对表【room_friend(单聊房间表)】的数据库操作Service 11 | * @createDate 2023-10-31 10:35:04 12 | */ 13 | public interface RoomFriendService extends IService { 14 | 15 | /** 16 | * 获取光标页面 17 | * 18 | * @param request 请求 19 | * @param uid uid 20 | * @return {@link CursorPageBaseResp}<{@link RoomFriend}> 21 | */ 22 | CursorPageBaseResp getCursorPage(CursorPageBaseReq request,Long uid); 23 | } 24 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/RoomGroupService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service; 2 | 3 | import com.cong.wanwu.usercenter.model.entity.chat.RoomGroup; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | * @author liuhuaicong 8 | * @description 针对表【room_group(群聊房间表)】的数据库操作Service 9 | * @createDate 2023-10-31 10:35:04 10 | */ 11 | public interface RoomGroupService extends IService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/RoomService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service; 2 | 3 | import com.cong.wanwu.common.model.vo.request.CursorPageBaseReq; 4 | import com.cong.wanwu.common.model.vo.response.CursorPageBaseResp; 5 | import com.cong.wanwu.usercenter.model.entity.chat.Message; 6 | import com.cong.wanwu.usercenter.model.entity.chat.Room; 7 | import com.baomidou.mybatisplus.extension.service.IService; 8 | 9 | /** 10 | * @author liuhuaicong 11 | * @description 针对表【room(房间表)】的数据库操作Service 12 | * @createDate 2023-10-31 10:35:04 13 | */ 14 | public interface RoomService extends IService { 15 | /** 16 | * 获取光标页面 17 | * 18 | * @param request 请求 19 | * @return {@link CursorPageBaseResp}<{@link Message}> 20 | */ 21 | CursorPageBaseResp getCursorPage(CursorPageBaseReq request); 22 | } 23 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/UserAttentionService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service; 2 | 3 | import com.cong.wanwu.usercenter.model.entity.UserAttention; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | 6 | /** 7 | * @author liuhuaicong 8 | * @description 针对表【user_attention( 用户关注表)】的数据库操作Service 9 | * @createDate 2023-09-08 16:41:55 10 | */ 11 | public interface UserAttentionService extends IService { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/UserTagService.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service; 2 | 3 | import com.cong.wanwu.usercenter.model.dto.userTag.UserTagAddRequest; 4 | import com.cong.wanwu.usercenter.model.entity.UserTag; 5 | import com.baomidou.mybatisplus.extension.service.IService; 6 | import com.cong.wanwu.usercenter.model.vo.UserTagCategoryVo; 7 | import com.cong.wanwu.usercenter.model.vo.UserTagVo; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | import java.util.List; 11 | 12 | /** 13 | * @author liuhuaicong 14 | * @description 针对表【user_tag】的数据库操作Service 15 | * @createDate 2023-09-08 16:41:55 16 | */ 17 | public interface UserTagService extends IService { 18 | 19 | /** 20 | * 获取所有标签 21 | * @return {@link List}<{@link UserTagCategoryVo}> 22 | */ 23 | List getAllTags(); 24 | 25 | /** 26 | * 增加标签 27 | * @param userTagAddRequest 28 | 29 | * @return {@link UserTagVo} 30 | */ 31 | UserTagVo addTag(UserTagAddRequest userTagAddRequest); 32 | 33 | /** 34 | * 获取tagsVo列表 35 | * @param tagIdsList tagsId 36 | * @return {@link List}<{@link UserTagVo}> 37 | */ 38 | List getUserTagsVo(List tagIdsList); 39 | } 40 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/adapter/RoomAdapter.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service.adapter; 2 | 3 | import cn.hutool.core.bean.BeanUtil; 4 | import com.cong.wanwu.usercenter.model.dto.chat.request.ChatMessageReq; 5 | import com.cong.wanwu.usercenter.model.dto.chat.response.ChatRoomResp; 6 | import com.cong.wanwu.usercenter.model.entity.chat.Room; 7 | import com.cong.wanwu.usercenter.model.entity.chat.RoomGroup; 8 | 9 | 10 | import java.util.List; 11 | import java.util.Map; 12 | import java.util.stream.Collectors; 13 | 14 | /** 15 | * 房间适配器 16 | * Description: 消息适配器 17 | * Author: abin 18 | * Date: 2023-03-26 19 | * 20 | * @author liuhuaicong 21 | * @date 2023/11/01 22 | */ 23 | public class RoomAdapter { 24 | 25 | 26 | public static List buildResp(List list) { 27 | return list.stream() 28 | .map(a -> { 29 | ChatRoomResp resp = new ChatRoomResp(); 30 | BeanUtil.copyProperties(a, resp); 31 | resp.setLastActiveTime(a.getActiveTime()); 32 | return resp; 33 | }).collect(Collectors.toList()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/impl/PostImagesServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.cong.wanwu.usercenter.mapper.PostImagesMapper; 5 | import com.cong.wanwu.usercenter.model.entity.PostImages; 6 | import com.cong.wanwu.usercenter.service.PostImagesService; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author liuhuaicong 11 | * @description 针对表【post_images(帖子图片表)】的数据库操作Service实现 12 | * @createDate 2023-09-14 10:57:28 13 | */ 14 | @Service 15 | public class PostImagesServiceImpl extends ServiceImpl 16 | implements PostImagesService { 17 | 18 | } 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/impl/RoomFriendServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.cong.wanwu.common.model.vo.request.CursorPageBaseReq; 5 | import com.cong.wanwu.common.model.vo.response.CursorPageBaseResp; 6 | import com.cong.wanwu.common.utils.CursorUtils; 7 | import com.cong.wanwu.usercenter.model.entity.chat.Room; 8 | import com.cong.wanwu.usercenter.model.entity.chat.RoomFriend; 9 | import com.cong.wanwu.usercenter.service.RoomFriendService; 10 | import com.cong.wanwu.usercenter.mapper.RoomFriendMapper; 11 | import org.springframework.stereotype.Service; 12 | 13 | /** 14 | * @author liuhuaicong 15 | * @description 针对表【room_friend(单聊房间表)】的数据库操作Service实现 16 | * @createDate 2023-10-31 10:35:04 17 | */ 18 | @Service 19 | public class RoomFriendServiceImpl extends ServiceImpl 20 | implements RoomFriendService{ 21 | 22 | @Override 23 | public CursorPageBaseResp getCursorPage(CursorPageBaseReq request,Long uid) { 24 | return CursorUtils.getCursorPageByMysql(this, request, wrapper -> { 25 | wrapper.eq(RoomFriend::getUid1,uid).or().eq(RoomFriend::getUid2,uid); 26 | }, RoomFriend::getId); 27 | } 28 | } 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/impl/RoomGroupServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.cong.wanwu.usercenter.model.entity.chat.RoomGroup; 5 | import com.cong.wanwu.usercenter.service.RoomGroupService; 6 | import com.cong.wanwu.usercenter.mapper.RoomGroupMapper; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author liuhuaicong 11 | * @description 针对表【room_group(群聊房间表)】的数据库操作Service实现 12 | * @createDate 2023-10-31 10:35:04 13 | */ 14 | @Service 15 | public class RoomGroupServiceImpl extends ServiceImpl 16 | implements RoomGroupService{ 17 | 18 | } 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/impl/RoomServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.cong.wanwu.common.model.vo.request.CursorPageBaseReq; 5 | import com.cong.wanwu.common.model.vo.response.CursorPageBaseResp; 6 | import com.cong.wanwu.common.utils.CursorUtils; 7 | import com.cong.wanwu.usercenter.model.entity.chat.Message; 8 | import com.cong.wanwu.usercenter.model.entity.chat.Room; 9 | import com.cong.wanwu.usercenter.model.enums.chat.MessageStatusEnum; 10 | import com.cong.wanwu.usercenter.service.RoomService; 11 | import com.cong.wanwu.usercenter.mapper.RoomMapper; 12 | import org.springframework.stereotype.Service; 13 | 14 | /** 15 | * @author liuhuaicong 16 | * @description 针对表【room(房间表)】的数据库操作Service实现 17 | * @createDate 2023-10-31 10:35:04 18 | */ 19 | @Service 20 | public class RoomServiceImpl extends ServiceImpl 21 | implements RoomService{ 22 | 23 | @Override 24 | public CursorPageBaseResp getCursorPage(CursorPageBaseReq request) { 25 | return CursorUtils.getCursorPageByMysql(this, request, wrapper -> { 26 | }, Room::getId); 27 | } 28 | } 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/service/impl/UserAttentionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.service.impl; 2 | 3 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 4 | import com.cong.wanwu.usercenter.model.entity.UserAttention; 5 | import com.cong.wanwu.usercenter.service.UserAttentionService; 6 | import com.cong.wanwu.usercenter.mapper.UserAttentionMapper; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author liuhuaicong 11 | * @description 针对表【user_attention( 用户关注表)】的数据库操作Service实现 12 | * @createDate 2023-09-08 16:41:55 13 | */ 14 | @Service 15 | public class UserAttentionServiceImpl extends ServiceImpl 16 | implements UserAttentionService{ 17 | 18 | } 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/websocket/NettyUtil.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.websocket; 2 | 3 | import io.netty.channel.Channel; 4 | import io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker; 5 | import io.netty.util.Attribute; 6 | import io.netty.util.AttributeKey; 7 | 8 | /** 9 | * Description: netty工具类 10 | * @author liuhuaicong 11 | * @date 2023/10/27 12 | */ 13 | 14 | public class NettyUtil { 15 | 16 | public static AttributeKey TOKEN = AttributeKey.valueOf("token"); 17 | public static AttributeKey IP = AttributeKey.valueOf("ip"); 18 | public static AttributeKey UID = AttributeKey.valueOf("uid"); 19 | public static AttributeKey HANDSHAKER_ATTR_KEY = AttributeKey.valueOf(WebSocketServerHandshaker.class, "HANDSHAKER"); 20 | 21 | public static void setAttr(Channel channel, AttributeKey attributeKey, T data) { 22 | Attribute attr = channel.attr(attributeKey); 23 | attr.set(data); 24 | } 25 | 26 | public static T getAttr(Channel channel, AttributeKey ip) { 27 | return channel.attr(ip).get(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/wxmp/WxMpConstant.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.wxmp; 2 | 3 | /** 4 | * 微信公众号相关常量 5 | * 6 | **/ 7 | public class WxMpConstant { 8 | 9 | /** 10 | * 点击菜单 key 11 | */ 12 | public static final String CLICK_MENU_KEY = "CLICK_MENU_KEY"; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/wxmp/handler/EventHandler.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.wxmp.handler; 2 | 3 | import java.util.Map; 4 | import me.chanjar.weixin.common.error.WxErrorException; 5 | import me.chanjar.weixin.common.session.WxSessionManager; 6 | import me.chanjar.weixin.mp.api.WxMpMessageHandler; 7 | import me.chanjar.weixin.mp.api.WxMpService; 8 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 9 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 10 | import org.springframework.stereotype.Component; 11 | 12 | /** 13 | * 事件处理器 14 | * 15 | 16 | **/ 17 | @Component 18 | public class EventHandler implements WxMpMessageHandler { 19 | 20 | @Override 21 | public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map map, WxMpService wxMpService, 22 | WxSessionManager wxSessionManager) throws WxErrorException { 23 | final String content = "您点击了菜单"; 24 | // 调用接口,返回验证码 25 | return WxMpXmlOutMessage.TEXT().content(content) 26 | .fromUser(wxMpXmlMessage.getToUser()) 27 | .toUser(wxMpXmlMessage.getFromUser()) 28 | .build(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/java/com/cong/wanwu/usercenter/wxmp/handler/SubscribeHandler.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.wxmp.handler; 2 | 3 | import java.util.Map; 4 | 5 | import me.chanjar.weixin.common.error.WxErrorException; 6 | import me.chanjar.weixin.common.session.WxSessionManager; 7 | import me.chanjar.weixin.mp.api.WxMpMessageHandler; 8 | import me.chanjar.weixin.mp.api.WxMpService; 9 | import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; 10 | import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; 11 | import org.springframework.stereotype.Component; 12 | 13 | /** 14 | * 关注处理器 15 | * 16 | 17 | **/ 18 | @Component 19 | public class SubscribeHandler implements WxMpMessageHandler { 20 | 21 | @Override 22 | public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map map, 23 | WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException { 24 | String openId = wxMpXmlMessage.getFromUser(); 25 | final String content = "感谢关注,可以发送 “验证码” 来获取登录信息噢"; 26 | // 调用接口,返回验证码 27 | return WxMpXmlOutMessage.TEXT().content(content) 28 | .fromUser(wxMpXmlMessage.getToUser()) 29 | .toUser(openId) 30 | .build(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/META-INF/additional-spring-configuration-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": [ 3 | { 4 | "name": "cos.client.accessKey", 5 | "type": "java.lang.String", 6 | "description": "Description for cos.client.accessKey." 7 | }, 8 | { 9 | "name": "cos.client.secretKey", 10 | "type": "java.lang.String", 11 | "description": "Description for cos.client.secretKey." 12 | }, 13 | { 14 | "name": "cos.client.region", 15 | "type": "java.lang.String", 16 | "description": "Description for cos.client.region." 17 | }, 18 | { 19 | "name": "cos.client.bucket", 20 | "type": "java.lang.String", 21 | "description": "Description for cos.client.bucket." 22 | }, 23 | { 24 | "name": "wx.open.appId", 25 | "type": "java.lang.String", 26 | "description": "Description for wx.open.appId." 27 | }, 28 | { 29 | "name": "wx.open.appSecret", 30 | "type": "java.lang.String", 31 | "description": "Description for wx.open.appSecret." 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/application-prod.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8101 3 | spring: 4 | # 数据库配置 5 | # todo 需替换配置 6 | datasource: 7 | driver-class-name: com.mysql.cj.jdbc.Driver 8 | url: jdbc:mysql://localhost:3306/my_db 9 | username: root 10 | password: 123456 11 | # Redis 配置 12 | # todo 需替换配置 13 | redis: 14 | database: 1 15 | host: localhost 16 | port: 6379 17 | timeout: 5000 18 | password: 123456 19 | # Elasticsearch 配置 20 | # todo 需替换配置 21 | elasticsearch: 22 | uris: http://localhost:9200 23 | username: root 24 | password: 123456 25 | mybatis-plus: 26 | configuration: 27 | # 生产环境关闭日志 28 | log-impl: '' -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/application-test.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8101 3 | spring: 4 | # 数据库配置 5 | # todo 需替换配置 6 | datasource: 7 | driver-class-name: com.mysql.cj.jdbc.Driver 8 | url: jdbc:mysql://localhost:3306/my_db 9 | username: root 10 | password: 123456 11 | # Redis 配置 12 | # todo 需替换配置 13 | redis: 14 | database: 1 15 | host: localhost 16 | port: 6379 17 | timeout: 5000 18 | password: 123456 19 | # Elasticsearch 配置 20 | # todo 需替换配置 21 | elasticsearch: 22 | uris: http://localhost:9200 23 | username: root 24 | password: 123456 -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | by 程序员鱼皮:https://github.com/licong 2 | 可能是最好的编程学习圈子:https://cong.icu 3 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/mapper/PostFavourMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id,postId,userId, 17 | createTime,updateTime 18 | 19 | 20 | 27 | 28 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/mapper/PostImagesMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | id,imgUrl,postId, 19 | userId,createTime,updateTime, 20 | isDelete 21 | 22 | 23 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/mapper/PostThumbMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id,postId, 17 | userId,createTime,updateTime 18 | 19 | 20 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/mapper/RoomFriendMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | id,roomId,uid1, 20 | uid2,roomKey,status, 21 | createTime,updateTime 22 | 23 | 24 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/mapper/RoomGroupMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | id,roomId,name, 20 | avatar,extJson,deleteStatus, 21 | createTime,updateTime 22 | 23 | 24 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/mapper/RoomMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | id,type,hotFlag, 20 | activeTime,lastMsgId,extJson, 21 | createTime,updateTime 22 | 23 | 24 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/mapper/UserAttentionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | id,userId,followedUserId, 17 | createTime,updateTime 18 | 19 | 20 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/mapper/UserTagMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | id,parentId,name, 20 | color,createdBy,createTime, 21 | updateTime,isDelete 22 | 23 | 24 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/main/resources/test_excel.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhccong/wanwu-code-backend/bb1fd28c65eac3f1f89fbb5a2b5625c1fd471ccc/wanwu-code-usercenter/src/main/resources/test_excel.xlsx -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/test/java/com/cong/wanwu/MainApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu; 2 | 3 | import com.cong.wanwu.usercenter.config.WxOpenConfig; 4 | import javax.annotation.Resource; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | 8 | /** 9 | * 主类测试 10 | * 11 | * @author 聪 12 | * 13 | */ 14 | @SpringBootTest 15 | class MainApplicationTests { 16 | 17 | @Resource 18 | private WxOpenConfig wxOpenConfig; 19 | 20 | @Test 21 | void contextLoads() { 22 | System.out.println(wxOpenConfig); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/test/java/com/cong/wanwu/manager/CosManagerTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.manager; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import com.cong.wanwu.usercenter.manager.CosManager; 6 | import org.junit.jupiter.api.Test; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | 9 | /** 10 | * Cos 操作测试 11 | * 12 | * @author 聪 13 | * 14 | */ 15 | @SpringBootTest 16 | class CosManagerTest { 17 | 18 | @Resource 19 | private CosManager cosManager; 20 | 21 | @Test 22 | void putObject() { 23 | cosManager.putObject("test", "test.json"); 24 | } 25 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/test/java/com/cong/wanwu/mapper/PostFavourMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import com.baomidou.mybatisplus.core.metadata.IPage; 5 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 6 | import com.cong.wanwu.usercenter.mapper.PostFavourMapper; 7 | import com.cong.wanwu.usercenter.model.entity.Post; 8 | import javax.annotation.Resource; 9 | import org.junit.jupiter.api.Assertions; 10 | import org.junit.jupiter.api.Test; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | 13 | /** 14 | * 帖子收藏数据库操作测试 15 | * 16 | * @author 聪 17 | * 18 | */ 19 | @SpringBootTest 20 | class PostFavourMapperTest { 21 | 22 | @Resource 23 | private PostFavourMapper postFavourMapper; 24 | 25 | @Test 26 | void listUserFavourPostByPage() { 27 | IPage page = new Page<>(2, 1); 28 | QueryWrapper queryWrapper = new QueryWrapper<>(); 29 | queryWrapper.eq("id", 1); 30 | queryWrapper.like("content", "a"); 31 | IPage result = postFavourMapper.listFavourPostByPage(page, queryWrapper, 1); 32 | Assertions.assertNotNull(result); 33 | } 34 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/test/java/com/cong/wanwu/mapper/PostMapperTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.mapper; 2 | 3 | import com.cong.wanwu.usercenter.mapper.PostMapper; 4 | import com.cong.wanwu.usercenter.model.entity.Post; 5 | import java.util.Date; 6 | import java.util.List; 7 | import javax.annotation.Resource; 8 | import org.junit.jupiter.api.Assertions; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | 12 | /** 13 | * 帖子数据库操作测试 14 | * 15 | * @author 聪 16 | * 17 | */ 18 | @SpringBootTest 19 | class PostMapperTest { 20 | 21 | @Resource 22 | private PostMapper postMapper; 23 | 24 | @Test 25 | void listPostWithDelete() { 26 | List postList = postMapper.listPostWithDelete(new Date()); 27 | Assertions.assertNotNull(postList); 28 | } 29 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/test/java/com/cong/wanwu/service/PostServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.service; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import com.cong.wanwu.usercenter.model.dto.post.PostQueryRequest; 5 | import com.cong.wanwu.usercenter.model.entity.Post; 6 | import javax.annotation.Resource; 7 | 8 | import com.cong.wanwu.usercenter.service.PostService; 9 | import org.junit.jupiter.api.Assertions; 10 | import org.junit.jupiter.api.Test; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | 13 | /** 14 | * 帖子服务测试 15 | * 16 | * @author 聪 17 | * 18 | */ 19 | @SpringBootTest 20 | class PostServiceTest { 21 | 22 | @Resource 23 | private PostService postService; 24 | 25 | @Test 26 | void searchFromEs() { 27 | PostQueryRequest postQueryRequest = new PostQueryRequest(); 28 | postQueryRequest.setUserId(1L); 29 | Page postPage = postService.searchFromEs(postQueryRequest); 30 | Assertions.assertNotNull(postPage); 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/test/java/com/cong/wanwu/service/PostThumbServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.service; 2 | 3 | import com.cong.wanwu.common.model.entity.User; 4 | import javax.annotation.Resource; 5 | 6 | import com.cong.wanwu.usercenter.service.PostThumbService; 7 | import org.junit.jupiter.api.Assertions; 8 | import org.junit.jupiter.api.BeforeAll; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | 12 | /** 13 | * 帖子点赞服务测试 14 | * 15 | * @author 聪 16 | * 17 | */ 18 | @SpringBootTest 19 | class PostThumbServiceTest { 20 | 21 | @Resource 22 | private PostThumbService postThumbService; 23 | 24 | private static final User loginUser = new User(); 25 | 26 | @BeforeAll 27 | static void setUp() { 28 | loginUser.setId(1L); 29 | } 30 | 31 | @Test 32 | void doPostThumb() { 33 | int i = postThumbService.doPostThumb(1L, loginUser); 34 | Assertions.assertTrue(i >= 0); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/test/java/com/cong/wanwu/service/UserServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.service; 2 | 3 | import javax.annotation.Resource; 4 | 5 | import com.cong.wanwu.usercenter.service.UserService; 6 | import org.junit.jupiter.api.Assertions; 7 | import org.junit.jupiter.api.Test; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | 10 | /** 11 | * 用户服务测试 12 | * 13 | * @author 聪 14 | * 15 | */ 16 | @SpringBootTest 17 | public class UserServiceTest { 18 | 19 | @Resource 20 | private UserService userService; 21 | 22 | @Test 23 | void userRegister() { 24 | String userAccount = "cong"; 25 | String userPassword = ""; 26 | String checkPassword = "123456"; 27 | try { 28 | long result = userService.userRegister(userAccount, userPassword, checkPassword); 29 | Assertions.assertEquals(-1, result); 30 | userAccount = "yu"; 31 | result = userService.userRegister(userAccount, userPassword, checkPassword); 32 | Assertions.assertEquals(-1, result); 33 | } catch (Exception e) { 34 | 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/test/java/com/cong/wanwu/usercenter/common/AlgorithmUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.common; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import java.util.Arrays; 6 | import java.util.List; 7 | 8 | import static org.junit.jupiter.api.Assertions.*; 9 | 10 | class AlgorithmUtilsTest { 11 | 12 | @Test 13 | void minDistance() { 14 | List TagList1 = Arrays.asList("Java", "大一", "男"); 15 | List TagList2 = Arrays.asList("Java", "大一", "女"); 16 | List TagList3 = Arrays.asList("Python", "大二", "男"); 17 | 18 | int i = AlgorithmUtils.minDistance(TagList1, TagList2); 19 | int i1 = AlgorithmUtils.minDistance(TagList1, TagList3); 20 | 21 | System.out.println(i); 22 | System.out.println(i1); 23 | } 24 | } -------------------------------------------------------------------------------- /wanwu-code-usercenter/src/test/java/com/cong/wanwu/usercenter/utils/EasyExcelTest.java: -------------------------------------------------------------------------------- 1 | package com.cong.wanwu.usercenter.utils; 2 | 3 | import com.alibaba.excel.EasyExcel; 4 | import com.alibaba.excel.support.ExcelTypeEnum; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.util.ResourceUtils; 8 | 9 | import java.io.File; 10 | import java.io.FileNotFoundException; 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | /** 15 | * EasyExcel 测试 16 | * 17 | * @author 聪 18 | * 19 | */ 20 | @SpringBootTest 21 | public class EasyExcelTest { 22 | 23 | @Test 24 | public void doImport() throws FileNotFoundException { 25 | File file = ResourceUtils.getFile("classpath:test_excel.xlsx"); 26 | List> list = EasyExcel.read(file) 27 | .excelType(ExcelTypeEnum.XLSX) 28 | .sheet() 29 | .headRowNumber(0) 30 | .doReadSync(); 31 | System.out.println(list); 32 | } 33 | 34 | } --------------------------------------------------------------------------------