让用户ID抓包不泄露更安全

This commit is contained in:
limqhz
2022-05-09 23:09:37 +08:00
parent fe275a4df6
commit 1826e4bb9a
1378 changed files with 1486 additions and 91442 deletions

View File

@@ -1,7 +1,10 @@
package com.quinn.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.quinn.pojo.Blog;
import com.baomidou.mybatisplus.extension.service.IService;
import com.quinn.pojo.BlogWithUser;
import com.quinn.vo.MyPageParam;
import java.util.List;
@@ -17,4 +20,10 @@ public interface BlogService extends IService<Blog> {
List<Blog> getTopBlog();
List<BlogWithUser> getBlogWithUserOrderBySort(MyPageParam myPageParam);
List<BlogWithUser> getBlogWithUser(MyPageParam myPageParam);
List<BlogWithUser> getMyBlogs(String userId,MyPageParam myPageParam);
}

View File

@@ -1,16 +0,0 @@
package com.quinn.service;
import com.quinn.pojo.BlogStar;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author limqsh
* @since 2022-05-08
*/
public interface BlogStarService extends IService<BlogStar> {
}

View File

@@ -1,11 +1,15 @@
package com.quinn.service;
import com.quinn.common.Category;
import com.quinn.pojo.Comment;
import com.baomidou.mybatisplus.extension.service.IService;
import com.quinn.pojo.CommentWithUser;
import java.util.List;
/**
* <p>
* 服务类
* TODO 这里评论区早晚也要有分页
* </p>
*
* @author limqsh
@@ -13,4 +17,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface CommentService extends IService<Comment> {
List<CommentWithUser> getCommentList(String topicId, Category category);
}

View File

@@ -1,16 +0,0 @@
package com.quinn.service;
import com.quinn.pojo.Download;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author limqsh
* @since 2020-07-08
*/
public interface DownloadService extends IService<Download> {
}

View File

@@ -1,16 +0,0 @@
package com.quinn.service;
import com.quinn.pojo.QuestionCategory;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author limqsh
* @since 2020-06-28
*/
public interface QuestionCategoryService extends IService<QuestionCategory> {
}

View File

@@ -1,16 +0,0 @@
package com.quinn.service;
import com.quinn.pojo.Question;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author limqsh
* @since 2020-06-28
*/
public interface QuestionService extends IService<Question> {
}

View File

@@ -1,16 +0,0 @@
package com.quinn.service;
import com.quinn.pojo.SourceComment;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author limqsh
* @since 2022-05-03
*/
public interface SourceCommentService extends IService<SourceComment> {
}

View File

@@ -0,0 +1,28 @@
package com.quinn.service;
import com.quinn.common.Category;
import com.quinn.pojo.Star;
import com.baomidou.mybatisplus.extension.service.IService;
import com.quinn.pojo.StarWithTopic;
import com.quinn.vo.MyPageParam;
import com.quinn.vo.StarValue;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author limqsh
* @since 2022-05-08
*/
public interface StarService extends IService<Star> {
StarValue starTopic(String topicId, String userId, Category category);
StarValue isStar(String topicId, String userId, Category category);
List<StarWithTopic> listStars(String userId, MyPageParam myPageParam);
}

View File

@@ -1,14 +1,16 @@
package com.quinn.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quinn.pojo.Blog;
import com.quinn.mapper.BlogMapper;
import com.quinn.pojo.BlogWithUser;
import com.quinn.service.BlogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.quinn.vo.MyPageParam;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
@@ -36,4 +38,25 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements Bl
return topBlog;
}
@Override
public List<BlogWithUser> getBlogWithUserOrderBySort(MyPageParam myPageParam) {
int count = count(null);
myPageParam.setTotal(count);
return blogMapper.getBlogWithUserOrderBySort(myPageParam);
}
@Override
public List<BlogWithUser> getBlogWithUser(MyPageParam myPageParam) {
int count = count(null);
myPageParam.setTotal(count);
return blogMapper.getBlogWithUser(myPageParam);
}
@Override
public List<BlogWithUser> getMyBlogs(String userId, MyPageParam myPageParam) {
int count = count(new QueryWrapper<Blog>().eq("author_id",userId));
myPageParam.setTotal(count);
return blogMapper.getMyBlogs(userId,myPageParam);
}
}

View File

@@ -1,20 +0,0 @@
package com.quinn.service.impl;
import com.quinn.pojo.BlogStar;
import com.quinn.mapper.BlogStarMapper;
import com.quinn.service.BlogStarService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author limqsh
* @since 2022-05-08
*/
@Service
public class BlogStarServiceImpl extends ServiceImpl<BlogStarMapper, BlogStar> implements BlogStarService {
}

View File

@@ -1,11 +1,16 @@
package com.quinn.service.impl;
import com.quinn.common.Category;
import com.quinn.pojo.Comment;
import com.quinn.mapper.CommentMapper;
import com.quinn.pojo.CommentWithUser;
import com.quinn.service.CommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* <p>
* 服务实现类
@@ -17,4 +22,14 @@ import org.springframework.stereotype.Service;
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements CommentService {
@Resource
CommentMapper commentMapper;
@Override
public List<CommentWithUser> getCommentList(String topicId, Category category) {
if (Category.SOURCE.equals(category)){
return commentMapper.getSourceCommentList(topicId);
}
return commentMapper.getBlogCommentList(topicId);
}
}

View File

@@ -1,20 +0,0 @@
package com.quinn.service.impl;
import com.quinn.pojo.Download;
import com.quinn.mapper.DownloadMapper;
import com.quinn.service.DownloadService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author limqsh
* @since 2020-07-08
*/
@Service
public class DownloadServiceImpl extends ServiceImpl<DownloadMapper, Download> implements DownloadService {
}

View File

@@ -1,20 +0,0 @@
package com.quinn.service.impl;
import com.quinn.pojo.QuestionCategory;
import com.quinn.mapper.QuestionCategoryMapper;
import com.quinn.service.QuestionCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author limqsh
* @since 2020-06-28
*/
@Service
public class QuestionCategoryServiceImpl extends ServiceImpl<QuestionCategoryMapper, QuestionCategory> implements QuestionCategoryService {
}

View File

@@ -1,20 +0,0 @@
package com.quinn.service.impl;
import com.quinn.pojo.Question;
import com.quinn.mapper.QuestionMapper;
import com.quinn.service.QuestionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author limqsh
* @since 2020-06-28
*/
@Service
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> implements QuestionService {
}

View File

@@ -1,20 +0,0 @@
package com.quinn.service.impl;
import com.quinn.pojo.SourceComment;
import com.quinn.mapper.SourceCommentMapper;
import com.quinn.service.SourceCommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author limqsh
* @since 2022-05-03
*/
@Service
public class SourceCommentServiceImpl extends ServiceImpl<SourceCommentMapper, SourceComment> implements SourceCommentService {
}

View File

@@ -0,0 +1,80 @@
package com.quinn.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quinn.common.Category;
import com.quinn.pojo.Star;
import com.quinn.mapper.StarMapper;
import com.quinn.pojo.StarWithTopic;
import com.quinn.service.StarService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.quinn.utils.QuinnUtils;
import com.quinn.vo.MyPageParam;
import com.quinn.vo.StarValue;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author limqsh
* @since 2022-05-08
*/
@Service
public class StarServiceImpl extends ServiceImpl<StarMapper, Star> implements StarService {
@Resource
StarMapper starMapper;
@Override
public StarValue starTopic(String topicId, String userId, Category category) {
StarValue starValue = new StarValue();
starValue.setStar(false);
List<Star> list = list(new QueryWrapper<Star>()
.eq("user_id", userId)
.eq("topic_category",category.name())
.eq("topic_id", topicId));
if (!CollectionUtils.isEmpty(list)){
list.forEach(x->{
removeById(x);
});
starValue.setStar(false);
} else {
Star blogStar = new Star();
blogStar.setTopicId(topicId);
blogStar.setUserId(userId);
blogStar.setTopicCategory(category.name());
blogStar.setGmtCreate(QuinnUtils.getTime());
save(blogStar);
starValue.setStar(true);
}
return starValue;
}
@Override
public StarValue isStar(String topicId, String userId, Category category) {
StarValue starValue = new StarValue();
starValue.setStar(false);
if (!StringUtils.isEmpty(userId)){
List<Star> stars = list(new QueryWrapper<Star>()
.eq("topic_category",category.name())
.eq("user_id", userId).eq("topic_id",topicId));
if (!CollectionUtils.isEmpty(stars)){
starValue.setStar(true);
}
}
return starValue;
}
@Override
public List<StarWithTopic> listStars(String userId, MyPageParam myPageParam) {
int count = count(new QueryWrapper<Star>().eq("user_id",userId));
myPageParam.setTotal(count);
return starMapper.listStars(userId,myPageParam);
}
}