diff --git a/珞珈岛-项目相关文件/luojia-island/pom.xml b/珞珈岛-项目相关文件/luojia-island/pom.xml
index ff51003..ae2d286 100644
--- a/珞珈岛-项目相关文件/luojia-island/pom.xml
+++ b/珞珈岛-项目相关文件/luojia-island/pom.xml
@@ -120,6 +120,12 @@
2.8.8
+
+
+ org.springframework.boot
+ spring-boot-starter-data-elasticsearch
+
+
diff --git a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/captcha/controller/CaptchaController.java b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/captcha/controller/CaptchaController.java
deleted file mode 100644
index 27befe0..0000000
--- a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/captcha/controller/CaptchaController.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.luojia_channel.modules.captcha.controller;
-
-import com.luojia_channel.common.domain.Result;
-import com.luojia_channel.modules.captcha.utils.CaptchaUtils;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import jakarta.servlet.http.Cookie;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.http.HttpSession;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.web.bind.annotation.*;
-
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-
-
-@RestController
-@RequestMapping("/user")
-@Tag(name = "图形验证码", description = "图形验证码相关接口")
-public class CaptchaController {
-
- @Autowired
- private RedisTemplate redisTemplate;
-
- /**
- * 生成验证码图片
- * @param request
- * @param res
- * @throws IOException
- */
- @GetMapping("/captcha")
- @Operation(
- summary = "生成验证码图片"
- )
- public void generateCaptcha(HttpServletRequest request,
- HttpServletResponse res) throws IOException {
-
- CaptchaUtils captcha = new CaptchaUtils();
- BufferedImage image = captcha.getImage();
- String text = captcha.getText();
-
- String captchaKey = UUID.randomUUID().toString();
- redisTemplate.opsForValue().set("captcha:" + captchaKey, text, 60, TimeUnit.SECONDS);
-
- Cookie cookie = new Cookie("captchaKey", captchaKey);
- cookie.setPath("/");
- res.addCookie(cookie);
-
- CaptchaUtils.output(image,res.getOutputStream());
- }
-
- /**
- * 验证验证码
- * @param session
- * @param params
- * @return
- */
- @PostMapping("/verify-captcha")
- public Result verifyCaptcha(@RequestBody Map params, @CookieValue(value = "captchaKey", required = false) String captchaKey, HttpSession session) {
- String captcha = params.get("captcha");
-
- if (captchaKey == null) {
- return Result.fail(500, "验证码已失效,请重新获取");
- }
-
- String redisKey = "captcha:" + captchaKey;
- String correctCaptcha = redisTemplate.opsForValue().get(redisKey);
- if (correctCaptcha == null) {
- return Result.fail(500, "验证码已过期,请重新获取");
- }
-
- if (captcha.equalsIgnoreCase(correctCaptcha)) {
- redisTemplate.delete(redisKey);
- return Result.success();
- } else {
- return Result.fail(500, "图形验证码错误");
- }
- }
-}
diff --git a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/post/service/impl/CommentServiceImpl.java b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/post/service/impl/CommentServiceImpl.java
index de6dc45..1248d1b 100644
--- a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/post/service/impl/CommentServiceImpl.java
+++ b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/post/service/impl/CommentServiceImpl.java
@@ -150,6 +150,7 @@ public class CommentServiceImpl extends ServiceImpl impl
.build();
notificationProducer.sendMessage(notificationMessage);
}
+ redisUtil.delete("post:detail:" + comment.getPostId());
return comment.getId();
}
diff --git a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/post/service/impl/PostServiceImpl.java b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/post/service/impl/PostServiceImpl.java
index fb7bebc..5d514c9 100644
--- a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/post/service/impl/PostServiceImpl.java
+++ b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/post/service/impl/PostServiceImpl.java
@@ -104,7 +104,7 @@ public class PostServiceImpl extends ServiceImpl implements Po
if(!updateById(post)){
throw new PostException("更新帖子失败");
}
- // redisUtil.delete("post:detail:" + postSaveDTO.getId());
+ redisUtil.delete("post:detail:" + postSaveDTO.getId());
// redisUtil.delete("post:of:user:" + UserContext.getUserId());
}
@@ -284,17 +284,18 @@ public class PostServiceImpl extends ServiceImpl implements Po
//没点赞
if(!isLikedPost(id)){
//数据库点赞记录加一
- boolean success = update().setSql("liked = liked + 1").eq("id",id).update();
+ boolean success = update().setSql("like_count = like_count + 1").eq("id",id).update();
if(success){
redisTemplate.opsForSet().add(likeBlogKey, userId, System.currentTimeMillis());
}
}else{
//数据库点赞记录减一
- boolean success = update().setSql("liked = liked - 1").eq("id",id).update();
+ boolean success = update().setSql("like_count = like_count - 1").eq("id",id).update();
if(success){
redisTemplate.opsForSet().remove(likeBlogKey, userId);
}
}
+ redisUtil.delete("post:detail:" + id);
}
}
diff --git a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/controller/SearchController.java b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/controller/SearchController.java
new file mode 100644
index 0000000..2342efd
--- /dev/null
+++ b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/controller/SearchController.java
@@ -0,0 +1,4 @@
+package com.luojia_channel.modules.search.controller;
+
+public class SearchController {
+}
diff --git a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/entity/EsPost.java b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/entity/EsPost.java
new file mode 100644
index 0000000..4f41b6a
--- /dev/null
+++ b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/entity/EsPost.java
@@ -0,0 +1,36 @@
+package com.luojia_channel.modules.search.entity;
+
+
+import lombok.Data;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.elasticsearch.annotations.Document;
+import org.springframework.data.elasticsearch.annotations.Field;
+import org.springframework.data.elasticsearch.annotations.FieldType;
+
+import java.time.LocalDateTime;
+
+
+@Data
+@Document(indexName = "post_index")
+public class EsPost {
+ @Id
+ private Long id;
+
+ @Field(type = FieldType.Text, analyzer = "ik_max_word")
+ private String title;
+
+ private String image;
+
+ @Field(type = FieldType.Text, analyzer = "ik_max_word")
+ private String content;
+
+ private Integer status;
+ private Integer likeCount;
+ private Integer commentCount;
+ private Integer favoriteCount;
+ private Integer viewCount;
+ private Long userId;
+ private Long categoryId;
+
+ private LocalDateTime createTime;
+}
diff --git a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/entity/EsUser.java b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/entity/EsUser.java
new file mode 100644
index 0000000..ecb0df7
--- /dev/null
+++ b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/entity/EsUser.java
@@ -0,0 +1,30 @@
+package com.luojia_channel.modules.search.entity;
+
+import lombok.Data;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.elasticsearch.annotations.Document;
+import org.springframework.data.elasticsearch.annotations.Field;
+import org.springframework.data.elasticsearch.annotations.FieldType;
+
+
+@Data
+@Document(indexName = "user_index")
+public class EsUser {
+ @Id
+ private Long id;
+
+ @Field(type = FieldType.Text, analyzer = "ik_max_word")
+ private String username;
+
+ @Field(type = FieldType.Keyword)
+ private String studentId;
+
+ private String avatar;
+ private Integer gender;
+
+
+ private Integer integral;
+
+ @Field(type = FieldType.Keyword)
+ private String college;
+}
diff --git a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/service/SearchService.java b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/service/SearchService.java
new file mode 100644
index 0000000..dd15b7a
--- /dev/null
+++ b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/service/SearchService.java
@@ -0,0 +1,4 @@
+package com.luojia_channel.modules.search.service;
+
+public class SearchService {
+}
diff --git a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/task/DataSyncTask.java b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/task/DataSyncTask.java
new file mode 100644
index 0000000..8b57020
--- /dev/null
+++ b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/search/task/DataSyncTask.java
@@ -0,0 +1,4 @@
+package com.luojia_channel.modules.search.task;
+
+public class DataSyncTask {
+}
diff --git a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/user/controller/UserLoginController.java b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/user/controller/UserLoginController.java
index 03ff900..057fadf 100644
--- a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/user/controller/UserLoginController.java
+++ b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/user/controller/UserLoginController.java
@@ -2,6 +2,8 @@ package com.luojia_channel.modules.user.controller;
import com.luojia_channel.common.domain.Result;
import com.luojia_channel.common.domain.UserDTO;
+import com.luojia_channel.common.utils.RedisUtil;
+import com.luojia_channel.modules.user.utils.CaptchaUtils;
import com.luojia_channel.modules.user.dto.UserLoginDTO;
import com.luojia_channel.modules.user.dto.UserRegisterDTO;
import com.luojia_channel.modules.user.service.UserLoginService;
@@ -12,16 +14,26 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpSession;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
@Tag(name = "用户管理", description = "用户登陆注册相关接口")
public class UserLoginController {
private final UserLoginService userLoginService;
+ private final RedisUtil redisUtil;
@PostMapping("/login")
@Operation(
summary = "用户登录",
@@ -67,4 +79,59 @@ public class UserLoginController {
return Result.success("hello");
}
+
+ /**
+ * 生成验证码图片
+ * @param request
+ * @param res
+ * @throws IOException
+ */
+ @GetMapping("/captcha")
+ @Operation(
+ summary = "生成验证码图片"
+ )
+ public void generateCaptcha(HttpServletRequest request,
+ HttpServletResponse res) throws IOException {
+
+ CaptchaUtils captcha = new CaptchaUtils();
+ BufferedImage image = captcha.getImage();
+ String text = captcha.getText();
+
+ String captchaKey = UUID.randomUUID().toString();
+ redisUtil.set("captcha:" + captchaKey, text, 60, TimeUnit.SECONDS);
+
+ Cookie cookie = new Cookie("captchaKey", captchaKey);
+ cookie.setPath("/");
+ res.addCookie(cookie);
+
+ CaptchaUtils.output(image,res.getOutputStream());
+ }
+
+ /**
+ * 验证验证码
+ * @param session
+ * @param params
+ * @return
+ */
+ @PostMapping("/verify-captcha")
+ public Result verifyCaptcha(@RequestBody Map params, @CookieValue(value = "captchaKey", required = false) String captchaKey, HttpSession session) {
+ String captcha = params.get("captcha");
+
+ if (captchaKey == null) {
+ return Result.fail(500, "验证码已失效,请重新获取");
+ }
+
+ String redisKey = "captcha:" + captchaKey;
+ String correctCaptcha = redisUtil.get(redisKey, String.class);
+ if (correctCaptcha == null) {
+ return Result.fail(500, "验证码已过期,请重新获取");
+ }
+
+ if (captcha.equalsIgnoreCase(correctCaptcha)) {
+ redisUtil.delete(redisKey);
+ return Result.success();
+ } else {
+ return Result.fail(500, "图形验证码错误");
+ }
+ }
}
diff --git a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/captcha/utils/CaptchaUtils.java b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/user/utils/CaptchaUtils.java
similarity index 98%
rename from 珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/captcha/utils/CaptchaUtils.java
rename to 珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/user/utils/CaptchaUtils.java
index d476111..28c2140 100644
--- a/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/captcha/utils/CaptchaUtils.java
+++ b/珞珈岛-项目相关文件/luojia-island/service/src/main/java/com/luojia_channel/modules/user/utils/CaptchaUtils.java
@@ -1,4 +1,4 @@
-package com.luojia_channel.modules.captcha.utils;
+package com.luojia_channel.modules.user.utils;
import javax.imageio.ImageIO;
import java.awt.*;
diff --git a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/captcha/controller/CaptchaController.class b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/captcha/controller/CaptchaController.class
deleted file mode 100644
index 8ed3d69..0000000
Binary files a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/captcha/controller/CaptchaController.class and /dev/null differ
diff --git a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/post/service/impl/CommentServiceImpl.class b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/post/service/impl/CommentServiceImpl.class
index d3c7681..85a784e 100644
Binary files a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/post/service/impl/CommentServiceImpl.class and b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/post/service/impl/CommentServiceImpl.class differ
diff --git a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/post/service/impl/PostServiceImpl.class b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/post/service/impl/PostServiceImpl.class
index 5cfc0b7..966fdee 100644
Binary files a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/post/service/impl/PostServiceImpl.class and b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/post/service/impl/PostServiceImpl.class differ
diff --git a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/controller/SearchController.class b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/controller/SearchController.class
new file mode 100644
index 0000000..25b7283
Binary files /dev/null and b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/controller/SearchController.class differ
diff --git a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/entity/EsPost.class b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/entity/EsPost.class
new file mode 100644
index 0000000..1e51dd4
Binary files /dev/null and b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/entity/EsPost.class differ
diff --git a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/entity/EsUser.class b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/entity/EsUser.class
new file mode 100644
index 0000000..bc5cd6b
Binary files /dev/null and b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/entity/EsUser.class differ
diff --git a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/service/SearchService.class b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/service/SearchService.class
new file mode 100644
index 0000000..c4d393b
Binary files /dev/null and b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/service/SearchService.class differ
diff --git a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/task/DataSyncTask.class b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/task/DataSyncTask.class
new file mode 100644
index 0000000..897a168
Binary files /dev/null and b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/search/task/DataSyncTask.class differ
diff --git a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/user/controller/UserLoginController.class b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/user/controller/UserLoginController.class
index 32e1a26..809a24b 100644
Binary files a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/user/controller/UserLoginController.class and b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/user/controller/UserLoginController.class differ
diff --git a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/captcha/utils/CaptchaUtils.class b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/user/utils/CaptchaUtils.class
similarity index 71%
rename from 珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/captcha/utils/CaptchaUtils.class
rename to 珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/user/utils/CaptchaUtils.class
index a3f8bdf..d0ad118 100644
Binary files a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/captcha/utils/CaptchaUtils.class and b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/user/utils/CaptchaUtils.class differ
diff --git a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/user/utils/ValidateUserUtil.class b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/user/utils/ValidateUserUtil.class
index 3414faa..b956abb 100644
Binary files a/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/user/utils/ValidateUserUtil.class and b/珞珈岛-项目相关文件/luojia-island/service/target/classes/com/luojia_channel/modules/user/utils/ValidateUserUtil.class differ