让用户ID抓包不泄露更安全
This commit is contained in:
@@ -2,6 +2,8 @@ package com.quinn.mapper;
|
||||
|
||||
import com.quinn.pojo.Blog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.quinn.pojo.BlogWithUser;
|
||||
import com.quinn.vo.MyPageParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,4 +18,10 @@ import java.util.List;
|
||||
public interface BlogMapper extends BaseMapper<Blog> {
|
||||
|
||||
List<Blog> getTopBlog();
|
||||
|
||||
List<BlogWithUser> getBlogWithUserOrderBySort(MyPageParam myPageParam);
|
||||
|
||||
List<BlogWithUser> getBlogWithUser(MyPageParam myPageParam);
|
||||
|
||||
List<BlogWithUser> getMyBlogs(String userId,MyPageParam myPageParam);
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.quinn.mapper;
|
||||
|
||||
import com.quinn.pojo.BlogStar;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2022-05-08
|
||||
*/
|
||||
public interface BlogStarMapper extends BaseMapper<BlogStar> {
|
||||
|
||||
}
|
||||
@@ -2,6 +2,9 @@ package com.quinn.mapper;
|
||||
|
||||
import com.quinn.pojo.Comment;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.quinn.pojo.CommentWithUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -13,4 +16,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface CommentMapper extends BaseMapper<Comment> {
|
||||
|
||||
List<CommentWithUser> getSourceCommentList(String topicId);
|
||||
|
||||
List<CommentWithUser> getBlogCommentList(String topicId);
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.quinn.mapper;
|
||||
|
||||
import com.quinn.pojo.Download;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2020-07-08
|
||||
*/
|
||||
@Repository
|
||||
public interface DownloadMapper extends BaseMapper<Download> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.quinn.mapper;
|
||||
|
||||
import com.quinn.pojo.QuestionCategory;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2020-06-28
|
||||
*/
|
||||
public interface QuestionCategoryMapper extends BaseMapper<QuestionCategory> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.quinn.mapper;
|
||||
|
||||
import com.quinn.pojo.Question;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2020-06-28
|
||||
*/
|
||||
public interface QuestionMapper extends BaseMapper<Question> {
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.quinn.mapper;
|
||||
|
||||
import com.quinn.pojo.SourceComment;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2022-05-03
|
||||
*/
|
||||
public interface SourceCommentMapper extends BaseMapper<SourceComment> {
|
||||
|
||||
}
|
||||
22
src/main/java/com/quinn/mapper/StarMapper.java
Normal file
22
src/main/java/com/quinn/mapper/StarMapper.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.quinn.mapper;
|
||||
|
||||
import com.quinn.pojo.Star;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.quinn.pojo.StarWithTopic;
|
||||
import com.quinn.vo.MyPageParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author limqsh
|
||||
* @since 2022-05-08
|
||||
*/
|
||||
public interface StarMapper extends BaseMapper<Star> {
|
||||
|
||||
List<StarWithTopic> listStars(String userId, MyPageParam myPageParam);
|
||||
|
||||
}
|
||||
@@ -3,8 +3,36 @@
|
||||
<mapper namespace="com.quinn.mapper.BlogMapper">
|
||||
|
||||
<select id="getTopBlog" resultType="com.quinn.pojo.Blog">
|
||||
select bid,title,(star + views) as views from qn_blog where sort = 0
|
||||
order by (star + views) desc limit 5;
|
||||
select bid,title,(star + views) as views from
|
||||
(select bid,title,(select count(1) from qn_star where topic_id = bid and topic_category = 'BLOG') as star,views
|
||||
from qn_blog where sort = 0) t
|
||||
order by (views + star) desc limit 7
|
||||
</select>
|
||||
|
||||
<select id="getBlogWithUserOrderBySort" parameterType="com.quinn.vo.MyPageParam" resultType="com.quinn.pojo.BlogWithUser">
|
||||
select a.id,a.bid,a.title,a.sort,a.views,a.author_id,a.category_id,a.category_name,a.gmt_create,a.gmt_update
|
||||
,b.username,b.avatar,
|
||||
(select count(1) from qn_star c where c.topic_id = a.bid and c.topic_category = 'BLOG') as star
|
||||
from qn_blog a,qn_user b
|
||||
where a.author_id = b.uid order by a.sort desc,a.gmt_create desc
|
||||
limit #{pageNum},#{size}
|
||||
</select>
|
||||
|
||||
<select id="getBlogWithUser" parameterType="com.quinn.vo.MyPageParam" resultType="com.quinn.pojo.BlogWithUser">
|
||||
select a.id,a.bid,a.title,a.sort,a.views,a.author_id,a.category_id,a.category_name,a.gmt_create,a.gmt_update
|
||||
,b.username,b.avatar,
|
||||
(select count(1) from qn_star c where c.topic_id = a.bid and c.topic_category = 'BLOG') as star
|
||||
from qn_blog a,qn_user b
|
||||
where a.author_id = b.uid order by a.gmt_create desc
|
||||
limit #{pageNum},#{size}
|
||||
</select>
|
||||
|
||||
<select id="getMyBlogs" resultType="com.quinn.pojo.BlogWithUser">
|
||||
select a.id,a.bid,a.title,a.sort,a.views,a.author_id,a.category_id,a.category_name,a.gmt_create,a.gmt_update,
|
||||
(select count(1) from qn_star c where c.topic_id = a.bid and c.topic_category = 'BLOG') as star
|
||||
from qn_blog a
|
||||
where a.author_id = #{userId} order by a.gmt_create desc
|
||||
limit #{myPageParam.pageNum},#{myPageParam.size}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -2,4 +2,20 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.quinn.mapper.CommentMapper">
|
||||
|
||||
<select id="getSourceCommentList" resultType="com.quinn.pojo.CommentWithUser">
|
||||
select a.*,b.username,b.avatar from qn_comment a,qn_user b
|
||||
where a.user_id = b.uid and a.topic_category = 'SOURCE'
|
||||
and a.topic_id = #{topicId}
|
||||
order by a.gmt_create desc
|
||||
limit 100
|
||||
</select>
|
||||
|
||||
<select id="getBlogCommentList" resultType="com.quinn.pojo.CommentWithUser">
|
||||
select a.*,b.username,b.avatar from qn_comment a,qn_user b
|
||||
where a.user_id = b.uid and a.topic_category = 'BLOG'
|
||||
and a.topic_id = #{topicId}
|
||||
order by a.gmt_create desc
|
||||
limit 100
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.quinn.mapper.SourceCommentMapper">
|
||||
|
||||
</mapper>
|
||||
21
src/main/java/com/quinn/mapper/xml/StarMapper.xml
Normal file
21
src/main/java/com/quinn/mapper/xml/StarMapper.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.quinn.mapper.StarMapper">
|
||||
|
||||
<select id="listStars" resultType="com.quinn.pojo.StarWithTopic">
|
||||
select * from
|
||||
(
|
||||
select a.*,b.title as topicName from qn_star a,qn_blog b
|
||||
where a.topic_id = b.bid
|
||||
and a.topic_category = 'BLOG'
|
||||
and a.user_id = #{userId}
|
||||
union all
|
||||
select a.*,c.source_name as topicName from qn_star a,qn_source c
|
||||
where a.topic_id = c.sid
|
||||
and a.topic_category = 'SOURCE'
|
||||
and a.user_id = #{userId}) t
|
||||
order by t.gmt_create desc
|
||||
limit #{myPageParam.pageNum},#{myPageParam.size}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user