forked from iVMiku/guidance-backend
Compare commits
3 Commits
312bccf7aa
...
6d902b8eee
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d902b8eee | |||
|
|
ddd0faf296 | ||
|
|
b755ecfeef |
@@ -24,7 +24,18 @@
|
||||
<!-- <artifactId>springfox-boot-starter</artifactId>-->
|
||||
<!-- <version>3.0.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.7</version>
|
||||
</dependency>
|
||||
<!-- 集成redis依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
@@ -69,10 +80,30 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.mybatis</groupId>-->
|
||||
<!-- <artifactId>mybatis</artifactId>-->
|
||||
<!-- <version>3.5.6</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.baomidou</groupId>-->
|
||||
<!-- <artifactId>mybatis-plus-spring-boot3-starter</artifactId>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>org.mybatis</groupId>-->
|
||||
<!-- <artifactId>mybatis</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.mybatis</groupId>-->
|
||||
<!-- <artifactId>mybatis</artifactId>-->
|
||||
<!-- <version>3.5.6</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ivmiku.tutorial.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
// 定义一个Bean,名称为"redisTemplate",返回类型为RedisTemplate<String, Object>
|
||||
@Bean(name = "redisTemplate")
|
||||
public RedisTemplate<String, Object> getRedisTemplate(RedisConnectionFactory factory) {
|
||||
// 创建一个新的RedisTemplate实例,用于操作Redis
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
|
||||
// 设置RedisTemplate使用的连接工厂,以便它能够连接到Redis服务器
|
||||
redisTemplate.setConnectionFactory(factory);
|
||||
|
||||
// 创建一个StringRedisSerializer实例,用于序列化Redis的key为字符串
|
||||
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
|
||||
|
||||
// 创建一个ObjectMapper实例,用于处理JSON的序列化和反序列化
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
// 设置ObjectMapper的属性访问级别,以便能够序列化对象的所有属性
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
|
||||
// 启用默认的类型信息,以便在反序列化时能够知道对象的实际类型
|
||||
// 注意:这里使用了新的方法替换了过期的enableDefaultTyping方法
|
||||
// 方法过期,改为下面代码
|
||||
// objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance,
|
||||
ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||
|
||||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(objectMapper, Object.class);
|
||||
|
||||
|
||||
// 设置RedisTemplate的key序列化器为stringRedisSerializer
|
||||
redisTemplate.setKeySerializer(stringRedisSerializer); // key的序列化类型
|
||||
// 设置RedisTemplate的value序列化器为jackson2JsonRedisSerializer
|
||||
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); // value的序列化类型
|
||||
|
||||
// 设置RedisTemplate的hash key序列化器为stringRedisSerializer
|
||||
redisTemplate.setHashKeySerializer(stringRedisSerializer); // key的序列化类型
|
||||
// 设置RedisTemplate的hash value序列化器为jackson2JsonRedisSerializer
|
||||
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); // value的序列化类型
|
||||
|
||||
// 调用RedisTemplate的afterPropertiesSet方法,该方法会执行一些初始化操作,比如检查序列化器是否设置等
|
||||
redisTemplate.afterPropertiesSet();
|
||||
|
||||
// 返回配置好的RedisTemplate实例
|
||||
return redisTemplate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.ivmiku.tutorial.config;
|
||||
|
||||
import cn.dev33.satoken.interceptor.SaAnnotationInterceptor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class SaTokenConfig implements WebMvcConfigurer {
|
||||
// 注册Sa-Token的注解拦截器,打开注解式鉴权功能
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 注册注解拦截器,并排除不需要注解鉴权的接口地址 (与登录拦截器无关)
|
||||
registry.addInterceptor(new SaAnnotationInterceptor())
|
||||
.addPathPatterns("/**");
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package com.ivmiku.tutorial.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ivmiku.tutorial.entity.Comment;
|
||||
import com.ivmiku.tutorial.entity.Pages;
|
||||
import com.ivmiku.tutorial.response.Result;
|
||||
import com.ivmiku.tutorial.service.CommentService;
|
||||
import com.ivmiku.tutorial.service.FileService;
|
||||
@@ -204,9 +206,11 @@ public class CommentController {
|
||||
*/
|
||||
@GetMapping("/post/{postId}")
|
||||
@Operation(summary = "获取帖子下的所有评论")
|
||||
public Result getPostComments(@PathVariable("postId") Long postId) {
|
||||
public Result getPostComments(@PathVariable("postId") Long postId, @RequestBody Pages pages) {
|
||||
logger.info("获取帖子ID:{}的评论列表", postId);
|
||||
List<Comment> comments = commentService.getPostComments(postId);
|
||||
logger.info("获取pageSize:{}", pages.getPageSize());
|
||||
System.out.println("aaaaaa" + pages.getPageSize());
|
||||
PageInfo<Comment> comments = commentService.getPostComments(postId, pages.getPageNum(), pages.getPageSize());
|
||||
return Result.ok(comments);
|
||||
}
|
||||
|
||||
@@ -218,9 +222,9 @@ public class CommentController {
|
||||
*/
|
||||
@GetMapping("/replies/{commentId}")
|
||||
@Operation(summary = "获取评论下的所有回复")
|
||||
public Result getCommentReplies(@PathVariable Long commentId) {
|
||||
public Result getCommentReplies(@PathVariable Long commentId, @RequestBody Pages pages) {
|
||||
logger.info("获取评论ID:{}的回复列表", commentId);
|
||||
List<Comment> replies = commentService.getCommentReplies(commentId);
|
||||
PageInfo<Comment> replies = commentService.getCommentReplies(commentId, pages.getPageNum(), pages.getPageSize());
|
||||
return Result.ok(replies);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.ivmiku.tutorial.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ivmiku.tutorial.entity.Pages;
|
||||
import com.ivmiku.tutorial.entity.Post;
|
||||
import com.ivmiku.tutorial.response.Result;
|
||||
import com.ivmiku.tutorial.service.FileService;
|
||||
@@ -36,7 +38,9 @@ public class PostController {
|
||||
@RequestParam("content") String content,
|
||||
@RequestParam("communityId") Long communityId,
|
||||
@RequestParam("imageFiles") MultipartFile[] imageFiles,
|
||||
@RequestParam("videoFile") MultipartFile videoFile) {
|
||||
@RequestParam("videoFile") MultipartFile videoFile,
|
||||
@RequestParam("isPublic") Integer isPublic,
|
||||
@RequestParam("location") String location) {
|
||||
String userId = StpUtil.getLoginIdAsString();
|
||||
logger.info("用户ID:{}开始创建帖子", userId);
|
||||
|
||||
@@ -45,6 +49,8 @@ public class PostController {
|
||||
post.setTitle(title);
|
||||
post.setContent(content);
|
||||
post.setCommunityId(communityId);
|
||||
post.setIsPublic(isPublic);
|
||||
post.setLocation(location);
|
||||
try {
|
||||
// 上传视频
|
||||
if (videoFile != null && !videoFile.isEmpty()) {
|
||||
@@ -107,10 +113,10 @@ public class PostController {
|
||||
* @return 当前用户帖子列表
|
||||
*/
|
||||
@GetMapping("/getPostList")
|
||||
public Result getPostList() {
|
||||
public Result getPostList(@RequestBody Pages pages) {
|
||||
logger.info("开始获取帖子列表");
|
||||
String userId = StpUtil.getLoginIdAsString(); // 获取当前登录用户的ID
|
||||
List<Post> posts = postService.getPostList(userId);
|
||||
PageInfo<Post> posts = postService.getPostList(userId, pages.getPageNum(), pages.getPageSize());
|
||||
return Result.ok(posts); // 调用服务层获取帖子列表
|
||||
}
|
||||
|
||||
@@ -119,9 +125,9 @@ public class PostController {
|
||||
* @return 当前用户帖子列表
|
||||
*/
|
||||
@GetMapping("/getCommunityPostList{communityId}")
|
||||
public Result getCommunityPostList(@PathVariable("communityId") Long communityId) {
|
||||
public Result getCommunityPostList(@PathVariable("communityId") Long communityId, @RequestBody Pages pages) {
|
||||
logger.info("开始获取帖子列表");
|
||||
List<Post> posts = postService.getCommunityPostList(communityId);
|
||||
PageInfo<Post> posts = postService.getCommunityPostList(communityId, pages.getPageNum(), pages.getPageSize());
|
||||
return Result.ok(posts); // 调用服务层获取帖子列表
|
||||
}
|
||||
|
||||
@@ -130,8 +136,8 @@ public class PostController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/official")
|
||||
public List<Post> getOfficialPosts() {
|
||||
return postService.getOfficialPosts();
|
||||
public PageInfo<Post> getOfficialPosts(@RequestBody Pages pages) {
|
||||
return postService.getOfficialPosts(pages.getPageNum(), pages.getPageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +145,16 @@ public class PostController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/nonOfficial")
|
||||
public List<Post> getNonOfficialPosts() {
|
||||
return postService.getNonOfficialPosts();
|
||||
public PageInfo<Post> getNonOfficialPosts(@RequestBody Pages pages) {
|
||||
return postService.getNonOfficialPosts(pages.getPageNum(), pages.getPageSize());
|
||||
}
|
||||
|
||||
@PutMapping("/changePublic")
|
||||
public Result changePublic(@RequestParam Long postId, @RequestParam Integer isPublic) {
|
||||
String userId = StpUtil.getLoginIdAsString(); // 获取当前登录用户的ID
|
||||
logger.info("用户ID:{}开始修改帖子ID:{}的公开状态", userId, postId);
|
||||
postService.changePublic(postId, isPublic); // 调用服务层修改帖子公开状态
|
||||
logger.info("用户ID:{}的帖子ID:{}修改成功", userId, postId);
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,17 @@ public class Post implements Serializable {
|
||||
|
||||
private String content;
|
||||
|
||||
private String videoUrl; // 新增字段,存储视频URL
|
||||
private String videoUrl; // 存储视频URL
|
||||
|
||||
private String imageUrls; // 新增字段,存储图片URL(多个URL用分号分隔)
|
||||
private String imageUrls; // 存储图片URL(多个URL用分号分隔)
|
||||
|
||||
private Integer isDeleted;
|
||||
|
||||
private Integer isOfficial; // 新增字段,标记是否为官方创建的帖子
|
||||
private Integer isOfficial; // 标记是否为官方创建的帖子
|
||||
|
||||
private Integer isPublic; // 标记帖子是否公开 0非公开 1公开
|
||||
|
||||
private String location; // 存储帖子位置信息
|
||||
|
||||
private Date createdAt;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ivmiku.tutorial.service;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ivmiku.tutorial.entity.Comment;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@@ -49,10 +50,9 @@ public interface CommentService extends IService<Comment> {
|
||||
|
||||
void deleteComment(Long commentId, String userId);
|
||||
|
||||
List<Comment> getPostComments(Long postId);
|
||||
|
||||
List<Comment> getCommentReplies(Long commentId);
|
||||
PageInfo<Comment> getPostComments(Long postId, int pageNum, int pageSize);
|
||||
|
||||
PageInfo<Comment> getCommentReplies(Long commentId, int pageNum, int pageSize);
|
||||
|
||||
/**
|
||||
* 回复评论。
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ivmiku.tutorial.service;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ivmiku.tutorial.entity.Post;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@@ -11,11 +12,13 @@ public interface PostService extends IService<Post> {
|
||||
void updatePost(Long postId, String userId, Post post);
|
||||
void deletePost(Long postId, String userId);
|
||||
|
||||
List<Post> getPostList(String userId);
|
||||
PageInfo<Post> getPostList(String userId, int pageNum, int pageSize);
|
||||
|
||||
List<Post> getCommunityPostList(Long communityId);
|
||||
PageInfo<Post> getCommunityPostList(Long communityId, int pageNum, int pageSize);
|
||||
|
||||
List<Post> getOfficialPosts(); // 新增获取官方帖子的方法
|
||||
PageInfo<Post> getOfficialPosts(int pageNum, int pageSize);
|
||||
|
||||
List<Post> getNonOfficialPosts(); // 新增获取非官方帖子的方法
|
||||
PageInfo<Post> getNonOfficialPosts(int pageNum, int pageSize);
|
||||
|
||||
void changePublic(Long postId, Integer isPublic);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.ivmiku.tutorial.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ivmiku.tutorial.entity.Comment;
|
||||
import com.ivmiku.tutorial.mapper.CommentMapper;
|
||||
import com.ivmiku.tutorial.service.CommentService;
|
||||
@@ -11,7 +13,6 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
@@ -102,19 +103,28 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
|
||||
* @return List<Comment> 返回评论列表
|
||||
*/
|
||||
@Override
|
||||
public List<Comment> getPostComments(Long postId) {
|
||||
logger.info("开始获取帖子ID:{}的评论列表", postId);
|
||||
public PageInfo<Comment> getPostComments(Long postId, int pageNum, int pageSize) {
|
||||
logger.info("开始获取帖子ID:{}的评论列表,第{}页,每页{}条", postId, pageNum, pageSize);
|
||||
|
||||
// 设置分页参数
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
|
||||
// 查询评论
|
||||
LambdaQueryWrapper<Comment> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Comment::getPostId, postId).eq(Comment::getIsDeleted, 0);
|
||||
List<Comment> comments = commentMapper.selectList(wrapper);
|
||||
|
||||
if (comments != null) {
|
||||
logger.info("获取帖子ID:{}的评论列表成功", postId);
|
||||
} else {
|
||||
logger.warn("帖子ID:{}的评论列表为空", postId);
|
||||
}
|
||||
return comments;
|
||||
|
||||
// 使用 PageInfo 包装结果
|
||||
return new PageInfo<>(comments);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取评论下的所有回复。
|
||||
*
|
||||
@@ -122,17 +132,25 @@ public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> impl
|
||||
* @return List<Comment> 返回回复列表
|
||||
*/
|
||||
@Override
|
||||
public List<Comment> getCommentReplies(Long commentId) {
|
||||
logger.info("开始获取评论ID:{}的回复列表", commentId);
|
||||
public PageInfo<Comment> getCommentReplies(Long commentId, int pageNum, int pageSize) {
|
||||
logger.info("开始获取评论ID:{}的回复列表,第{}页,每页{}条", commentId, pageNum, pageSize);
|
||||
|
||||
// 设置分页参数
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
|
||||
// 查询回复
|
||||
LambdaQueryWrapper<Comment> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Comment::getParentCommentId, commentId).eq(Comment::getIsDeleted, 0);
|
||||
List<Comment> replies = commentMapper.selectList(wrapper);
|
||||
|
||||
if (replies != null) {
|
||||
logger.info("获取评论ID:{}的回复列表成功", commentId);
|
||||
} else {
|
||||
logger.warn("评论ID:{}的回复列表为空", commentId);
|
||||
}
|
||||
return replies;
|
||||
|
||||
// 使用 PageInfo 包装结果
|
||||
return new PageInfo<>(replies);
|
||||
}
|
||||
/**
|
||||
* 回复评论。
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ivmiku.tutorial.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ivmiku.tutorial.entity.Post;
|
||||
import com.ivmiku.tutorial.mapper.PostMapper;
|
||||
import com.ivmiku.tutorial.service.PostService;
|
||||
@@ -10,7 +12,6 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,7 +36,14 @@ public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements Po
|
||||
@Override
|
||||
public Post getPostById(Long postId) {
|
||||
logger.info("开始根据ID获取帖子详情,帖子ID:{}", postId);
|
||||
return getById(postId);
|
||||
LambdaQueryWrapper<Post> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Post::getIsPublic, 1);
|
||||
Post post = postMapper.selectById(wrapper);
|
||||
if (post == null) {
|
||||
logger.warn("帖子ID:{}不存在", postId);
|
||||
return null;
|
||||
}
|
||||
return post;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,38 +70,91 @@ public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements Po
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Post> getPostList(String userId) {
|
||||
logger.info("用户ID:{}开始获取帖子列表", userId);
|
||||
public PageInfo<Post> getPostList(String userId, int pageNum, int pageSize) {
|
||||
logger.info("用户ID:{}开始获取帖子列表,第{}页,每页{}条", userId, pageNum, pageSize);
|
||||
|
||||
// 设置分页参数
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
|
||||
LambdaQueryWrapper<Post> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Post::getUserOpenid, userId);
|
||||
wrapper.eq(Post::getIsDeleted, 0);
|
||||
wrapper.eq(Post::getIsPublic, 1);
|
||||
|
||||
List<Post> posts = postMapper.selectList(wrapper);
|
||||
return posts;
|
||||
|
||||
// 使用PageInfo封装分页结果
|
||||
PageInfo<Post> pageInfo = new PageInfo<>(posts);
|
||||
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Post> getCommunityPostList(Long communityId) {
|
||||
logger.info("开始获取社区ID:{}的帖子列表", communityId);
|
||||
public PageInfo<Post> getCommunityPostList(Long communityId, int pageNum, int pageSize) {
|
||||
logger.info("开始获取社区ID:{}的帖子列表,第{}页,每页{}条", communityId, pageNum, pageSize);
|
||||
|
||||
// 设置分页参数
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
|
||||
LambdaQueryWrapper<Post> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Post::getCommunityId, communityId);
|
||||
wrapper.eq(Post::getIsDeleted, 0);
|
||||
wrapper.eq(Post::getIsPublic, 1);
|
||||
|
||||
List<Post> posts = postMapper.selectList(wrapper);
|
||||
return posts;
|
||||
|
||||
// 使用PageInfo封装分页结果
|
||||
PageInfo<Post> pageInfo = new PageInfo<>(posts);
|
||||
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Post> getOfficialPosts() {
|
||||
logger.info("开始获取所有官方创建的帖子");
|
||||
public PageInfo<Post> getOfficialPosts(int pageNum, int pageSize) {
|
||||
logger.info("开始获取所有官方创建的帖子,第{}页,每页{}条", pageNum, pageSize);
|
||||
|
||||
// 设置分页参数
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
|
||||
LambdaQueryWrapper<Post> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Post::getIsOfficial, 1);
|
||||
wrapper.eq(Post::getIsDeleted, 0);
|
||||
wrapper.eq(Post::getIsPublic, 1);
|
||||
|
||||
List<Post> posts = postMapper.selectList(wrapper);
|
||||
return posts;
|
||||
|
||||
// 使用PageInfo封装分页结果
|
||||
PageInfo<Post> pageInfo = new PageInfo<>(posts);
|
||||
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Post> getNonOfficialPosts() {
|
||||
logger.info("开始获取所有非官方创建的帖子");
|
||||
public PageInfo<Post> getNonOfficialPosts(int pageNum, int pageSize) {
|
||||
logger.info("开始获取所有非官方创建的帖子,第{}页,每页{}条", pageNum, pageSize);
|
||||
|
||||
// 设置分页参数
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
|
||||
LambdaQueryWrapper<Post> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Post::getIsOfficial, 0);
|
||||
wrapper.eq(Post::getIsDeleted, 0);
|
||||
wrapper.eq(Post::getIsPublic, 1);
|
||||
|
||||
List<Post> posts = postMapper.selectList(wrapper);
|
||||
return posts;
|
||||
|
||||
// 使用PageInfo封装分页结果
|
||||
PageInfo<Post> pageInfo = new PageInfo<>(posts);
|
||||
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changePublic(Long postId, Integer isPublic) {
|
||||
LambdaQueryWrapper<Post> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Post::getPostId, postId);
|
||||
Post post = postMapper.selectById(postId);
|
||||
post.setIsPublic(isPublic);
|
||||
postMapper.update(post, wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,528 @@
|
||||
package com.ivmiku.tutorial.util;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @className: RedisUtil
|
||||
* @description:
|
||||
* @author: sh.Liu
|
||||
* @date: 2022-03-09 14:07
|
||||
*/
|
||||
@Component
|
||||
public class RedisUtil {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
/**
|
||||
* 给一个指定的 key 值附加过期时间
|
||||
*
|
||||
* @param key
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public boolean expire(String key, long time) {
|
||||
return redisTemplate.expire(key, time, TimeUnit.SECONDS);
|
||||
}
|
||||
/**
|
||||
* 根据key 获取过期时间
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public long getTime(String key) {
|
||||
return redisTemplate.getExpire(key, TimeUnit.SECONDS);
|
||||
}
|
||||
/**
|
||||
* 根据key 获取过期时间
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public boolean hasKey(String key) {
|
||||
return redisTemplate.hasKey(key);
|
||||
}
|
||||
/**
|
||||
* 移除指定key 的过期时间
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public boolean persist(String key) {
|
||||
return redisTemplate.boundValueOps(key).persist();
|
||||
}
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - String类型 - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
/**
|
||||
* 根据key获取值
|
||||
*
|
||||
* @param key 键
|
||||
* @return 值
|
||||
*/
|
||||
public Object get(String key) {
|
||||
return key == null ? null : redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将值放入缓存
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return true成功 false 失败
|
||||
*/
|
||||
public void set(String key, String value) {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将值放入缓存并设置时间
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param time 时间(秒) -1为无期限
|
||||
* @return true成功 false 失败
|
||||
*/
|
||||
public void set(String key, String value, long time) {
|
||||
if (time > 0) {
|
||||
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
|
||||
} else {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加 key (重复的键会覆盖)
|
||||
*
|
||||
* @param keyAndValue
|
||||
*/
|
||||
public void batchSet(Map<String, String> keyAndValue) {
|
||||
redisTemplate.opsForValue().multiSet(keyAndValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量添加 key-value 只有在键不存在时,才添加
|
||||
* map 中只要有一个key存在,则全部不添加
|
||||
*
|
||||
* @param keyAndValue
|
||||
*/
|
||||
public void batchSetIfAbsent(Map<String, String> keyAndValue) {
|
||||
redisTemplate.opsForValue().multiSetIfAbsent(keyAndValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对一个 key-value 的值进行加减操作,
|
||||
* 如果该 key 不存在 将创建一个key 并赋值该 number
|
||||
* 如果 key 存在,但 value 不是长整型 ,将报错
|
||||
*
|
||||
* @param key
|
||||
* @param number
|
||||
*/
|
||||
public Long increment(String key, long number) {
|
||||
return redisTemplate.opsForValue().increment(key, number);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对一个 key-value 的值进行加减操作,
|
||||
* 如果该 key 不存在 将创建一个key 并赋值该 number
|
||||
* 如果 key 存在,但 value 不是 纯数字 ,将报错
|
||||
*
|
||||
* @param key
|
||||
* @param number
|
||||
*/
|
||||
public Double increment(String key, double number) {
|
||||
return redisTemplate.opsForValue().increment(key, number);
|
||||
}
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - set类型 - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
/**
|
||||
* 将数据放入set缓存
|
||||
*
|
||||
* @param key 键
|
||||
* @return
|
||||
*/
|
||||
public void sSet(String key, String value) {
|
||||
redisTemplate.opsForSet().add(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取变量中的值
|
||||
*
|
||||
* @param key 键
|
||||
* @return
|
||||
*/
|
||||
public Set<Object> members(String key) {
|
||||
return redisTemplate.opsForSet().members(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机获取变量中指定个数的元素
|
||||
*
|
||||
* @param key 键
|
||||
* @param count 值
|
||||
* @return
|
||||
*/
|
||||
public void randomMembers(String key, long count) {
|
||||
redisTemplate.opsForSet().randomMembers(key, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机获取变量中的元素
|
||||
*
|
||||
* @param key 键
|
||||
* @return
|
||||
*/
|
||||
public Object randomMember(String key) {
|
||||
return redisTemplate.opsForSet().randomMember(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹出变量中的元素
|
||||
*
|
||||
* @param key 键
|
||||
* @return
|
||||
*/
|
||||
public Object pop(String key) {
|
||||
return redisTemplate.opsForSet().pop("setValue");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取变量中值的长度
|
||||
*
|
||||
* @param key 键
|
||||
* @return
|
||||
*/
|
||||
public long size(String key) {
|
||||
return redisTemplate.opsForSet().size(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据value从一个set中查询,是否存在
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return true 存在 false不存在
|
||||
*/
|
||||
public boolean sHasKey(String key, Object value) {
|
||||
return redisTemplate.opsForSet().isMember(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查给定的元素是否在变量中。
|
||||
*
|
||||
* @param key 键
|
||||
* @param obj 元素对象
|
||||
* @return
|
||||
*/
|
||||
public boolean isMember(String key, Object obj) {
|
||||
return redisTemplate.opsForSet().isMember(key, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转移变量的元素值到目的变量。
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 元素对象
|
||||
* @param destKey 元素对象
|
||||
* @return
|
||||
*/
|
||||
public boolean move(String key, String value, String destKey) {
|
||||
return redisTemplate.opsForSet().move(key, value, destKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量移除set缓存中元素
|
||||
*
|
||||
* @param key 键
|
||||
* @param values 值
|
||||
* @return
|
||||
*/
|
||||
public void remove(String key, Object... values) {
|
||||
redisTemplate.opsForSet().remove(key, values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过给定的key求2个set变量的差值
|
||||
*
|
||||
* @param key 键
|
||||
* @param destKey 键
|
||||
* @return
|
||||
*/
|
||||
public Set<Set> difference(String key, String destKey) {
|
||||
return redisTemplate.opsForSet().difference(key, destKey);
|
||||
}
|
||||
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - hash类型 - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
/**
|
||||
* 加入缓存
|
||||
*
|
||||
* @param key 键
|
||||
* @param map 键
|
||||
* @return
|
||||
*/
|
||||
public void add(String key, Map<String, String> map) {
|
||||
redisTemplate.opsForHash().putAll(key, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 key 下的 所有 hashkey 和 value
|
||||
*
|
||||
* @param key 键
|
||||
* @return
|
||||
*/
|
||||
public Map<Object, Object> getHashEntries(String key) {
|
||||
return redisTemplate.opsForHash().entries(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证指定 key 下 有没有指定的 hashkey
|
||||
*
|
||||
* @param key
|
||||
* @param hashKey
|
||||
* @return
|
||||
*/
|
||||
public boolean hashKey(String key, String hashKey) {
|
||||
return redisTemplate.opsForHash().hasKey(key, hashKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定key的值string
|
||||
*
|
||||
* @param key 键
|
||||
* @param key2 键
|
||||
* @return
|
||||
*/
|
||||
public String getMapString(String key, String key2) {
|
||||
return redisTemplate.opsForHash().get("map1", "key1").toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定的值Int
|
||||
*
|
||||
* @param key 键
|
||||
* @param key2 键
|
||||
* @return
|
||||
*/
|
||||
public Integer getMapInt(String key, String key2) {
|
||||
return (Integer) redisTemplate.opsForHash().get("map1", "key1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹出元素并删除
|
||||
*
|
||||
* @param key 键
|
||||
* @return
|
||||
*/
|
||||
public String popValue(String key) {
|
||||
return redisTemplate.opsForSet().pop(key).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定 hash 的 HashKey
|
||||
*
|
||||
* @param key
|
||||
* @param hashKeys
|
||||
* @return 删除成功的 数量
|
||||
*/
|
||||
public Long delete(String key, String... hashKeys) {
|
||||
return redisTemplate.opsForHash().delete(key, hashKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给指定 hash 的 hashkey 做增减操作
|
||||
*
|
||||
* @param key
|
||||
* @param hashKey
|
||||
* @param number
|
||||
* @return
|
||||
*/
|
||||
public Long increment(String key, String hashKey, long number) {
|
||||
return redisTemplate.opsForHash().increment(key, hashKey, number);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给指定 hash 的 hashkey 做增减操作
|
||||
*
|
||||
* @param key
|
||||
* @param hashKey
|
||||
* @param number
|
||||
* @return
|
||||
*/
|
||||
public Double increment(String key, String hashKey, Double number) {
|
||||
return redisTemplate.opsForHash().increment(key, hashKey, number);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 key 下的 所有 hashkey 字段
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Set<Object> hashKeys(String key) {
|
||||
return redisTemplate.opsForHash().keys(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定 hash 下面的 键值对 数量
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Long hashSize(String key) {
|
||||
return redisTemplate.opsForHash().size(key);
|
||||
}
|
||||
|
||||
//- - - - - - - - - - - - - - - - - - - - - list类型 - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
/**
|
||||
* 在变量左边添加元素值
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public void leftPush(String key, Object value) {
|
||||
redisTemplate.opsForList().leftPush(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取集合指定位置的值。
|
||||
*
|
||||
* @param key
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
public Object index(String key, long index) {
|
||||
return redisTemplate.opsForList().index("list", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定区间的值。
|
||||
*
|
||||
* @param key
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
public List<Object> range(String key, long start, long end) {
|
||||
return redisTemplate.opsForList().range(key, start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* 把最后一个参数值放到指定集合的第一个出现中间参数的前面,
|
||||
* 如果中间参数值存在的话。
|
||||
*
|
||||
* @param key
|
||||
* @param pivot
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public void leftPush(String key, String pivot, String value) {
|
||||
redisTemplate.opsForList().leftPush(key, pivot, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向左边批量添加参数元素。
|
||||
*
|
||||
* @param key
|
||||
* @param values
|
||||
* @return
|
||||
*/
|
||||
public void leftPushAll(String key, String... values) {
|
||||
// redisTemplate.opsForList().leftPushAll(key,"w","x","y");
|
||||
redisTemplate.opsForList().leftPushAll(key, values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向集合最右边添加元素。
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public void leftPushAll(String key, String value) {
|
||||
redisTemplate.opsForList().rightPush(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向左边批量添加参数元素。
|
||||
*
|
||||
* @param key
|
||||
* @param values
|
||||
* @return
|
||||
*/
|
||||
public void rightPushAll(String key, String... values) {
|
||||
//redisTemplate.opsForList().leftPushAll(key,"w","x","y");
|
||||
redisTemplate.opsForList().rightPushAll(key, values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向已存在的集合中添加元素。
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public void rightPushIfPresent(String key, Object value) {
|
||||
redisTemplate.opsForList().rightPushIfPresent(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向已存在的集合中添加元素。
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public long listLength(String key) {
|
||||
return redisTemplate.opsForList().size(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除集合中的左边第一个元素。
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public void leftPop(String key) {
|
||||
redisTemplate.opsForList().leftPop(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除集合中左边的元素在等待的时间里,如果超过等待的时间仍没有元素则退出。
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public void leftPop(String key, long timeout, TimeUnit unit) {
|
||||
redisTemplate.opsForList().leftPop(key, timeout, unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除集合中右边的元素。
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public void rightPop(String key) {
|
||||
redisTemplate.opsForList().rightPop(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除集合中右边的元素在等待的时间里,如果超过等待的时间仍没有元素则退出。
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public void rightPop(String key, long timeout, TimeUnit unit) {
|
||||
redisTemplate.opsForList().rightPop(key, timeout, unit);
|
||||
}
|
||||
}
|
||||
@@ -10,18 +10,20 @@
|
||||
<result property="communityId" column="community_id" jdbcType="BIGINT"/>
|
||||
<result property="title" column="title" jdbcType="VARCHAR"/>
|
||||
<result property="content" column="content" jdbcType="VARCHAR"/>
|
||||
<result property="videoUrl" column="video_url" jdbcType="VARCHAR"/> <!-- 新增字段 -->
|
||||
<result property="imageUrls" column="image_urls" jdbcType="VARCHAR"/> <!-- 新增字段 -->
|
||||
<result property="videoUrl" column="video_url" jdbcType="VARCHAR"/>
|
||||
<result property="imageUrls" column="image_urls" jdbcType="VARCHAR"/>
|
||||
<result property="isDeleted" column="is_deleted" jdbcType="TINYINT"/>
|
||||
<result property="isOfficial" column="is_official" jdbcType="TINYINT"/> <!-- 新增字段 -->
|
||||
<result property="isOfficial" column="is_official" jdbcType="TINYINT"/>
|
||||
<result property="isPublic" column="is_public" jdbcType="TINYINT"/>
|
||||
<result property="location" column="location" jdbcType="VARCHAR"/>
|
||||
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
|
||||
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
post_id, user_openid, community_id, title, content,
|
||||
video_url, image_urls, <!-- 新增字段 -->
|
||||
is_deleted, is_official, created_at, updated_at
|
||||
video_url, image_urls,
|
||||
is_deleted, is_official, is_public, location, created_at, updated_at
|
||||
</sql>
|
||||
|
||||
<!-- 查询指定帖子的所有评论 -->
|
||||
@@ -36,12 +38,12 @@
|
||||
<insert id="insertPost" parameterType="com.ivmiku.tutorial.entity.Post">
|
||||
INSERT INTO post (
|
||||
post_id, user_openid, community_id, title, content,
|
||||
video_url, image_urls, <!-- 新增字段 -->
|
||||
is_deleted, is_official, created_at, updated_at
|
||||
video_url, image_urls,
|
||||
is_deleted, is_official, is_public, location, created_at, updated_at
|
||||
) VALUES (
|
||||
#{postId}, #{userOpenid}, #{communityId}, #{title}, #{content},
|
||||
#{videoUrl}, #{imageUrls}, <!-- 新增字段 -->
|
||||
#{isDeleted}, #{isOfficial}, #{createdAt}, #{updatedAt}
|
||||
#{videoUrl}, #{imageUrls},
|
||||
#{isDeleted}, #{isOfficial}, #{is_public}, #{location}, #{createdAt}, #{updatedAt}
|
||||
)
|
||||
</insert>
|
||||
|
||||
@@ -53,10 +55,12 @@
|
||||
community_id = #{communityId},
|
||||
title = #{title},
|
||||
content = #{content},
|
||||
video_url = #{videoUrl}, <!-- 新增字段 -->
|
||||
image_urls = #{imageUrls}, <!-- 新增字段 -->
|
||||
video_url = #{videoUrl},
|
||||
image_urls = #{imageUrls},
|
||||
is_deleted = #{isDeleted},
|
||||
is_official = #{isOfficial},
|
||||
is_public = #{is_public},
|
||||
location = #{location},
|
||||
created_at = #{createdAt},
|
||||
updated_at = #{updatedAt}
|
||||
WHERE post_id = #{postId}
|
||||
@@ -72,9 +76,9 @@
|
||||
|
||||
<select id="getTagPostList" resultType="com.ivmiku.tutorial.entity.Post">
|
||||
SELECT p.post_id, p.user_openid, p.community_id, p.title, p.content,
|
||||
p.is_deleted, p.is_official, p.created_at, p.updated_at
|
||||
p.is_deleted, p.is_official, p.is_public, p.location, p.created_at, p.updated_at
|
||||
FROM post p, posttag pt, tag t
|
||||
WHERE p.post_id = pt.post_id AND pt.tag_id = t.tag_id AND t.tag_id = #{tagId} AND p.is_deleted = 0
|
||||
WHERE p.post_id = pt.post_id AND pt.tag_id = t.tag_id AND t.tag_id = #{tagId} AND p.is_deleted = 0 AND p.is_public = 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
12
pom.xml
12
pom.xml
@@ -25,7 +25,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<hutool.version>5.8.22</hutool.version>
|
||||
<lombok.version>1.18.30</lombok.version>
|
||||
<mybatis.springboot.version>3.5.6</mybatis.springboot.version>
|
||||
<!-- <mybatis.springboot.version>3.5.6</mybatis.springboot.version>-->
|
||||
<mysql.version>8.0.28</mysql.version>
|
||||
<mapper.version>4.2.3</mapper.version>
|
||||
<fastjson2.version>2.0.40</fastjson2.version>
|
||||
@@ -110,11 +110,11 @@
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!--SpringBoot集成mybatis-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis.springboot.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.baomidou</groupId>-->
|
||||
<!-- <artifactId>mybatis-plus-spring-boot3-starter</artifactId>-->
|
||||
<!-- <version>${mybatis.springboot.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
|
||||
<!-- <dependency>-->
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
|
||||
Reference in New Issue
Block a user