Fixbug 私密日志取消被推荐、私密日志取消被搜索
This commit is contained in:
@@ -16,6 +16,8 @@ docker run -p 8088:8088 -d monitor/centos:latest
|
|||||||
|
|
||||||
docker run --network host -p 8088:8088 -d monitor/centos:latest
|
docker run --network host -p 8088:8088 -d monitor/centos:latest
|
||||||
|
|
||||||
|
docker run --network host -e TZ=Asia/Shanghai -p 8088:8088 -d monitor/centos:latest
|
||||||
|
|
||||||
docker run -it monitor/centos:latest /bin/bash
|
docker run -it monitor/centos:latest /bin/bash
|
||||||
|
|
||||||
docker inspect & docker info
|
docker inspect & docker info
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -125,12 +126,12 @@ public class BlogController extends BaseModelController{
|
|||||||
// 阅读文章
|
// 阅读文章
|
||||||
@GetMapping("/blog/read/{bid}")
|
@GetMapping("/blog/read/{bid}")
|
||||||
public String read(HttpServletRequest request, @PathVariable("bid") String bid, Model model){
|
public String read(HttpServletRequest request, @PathVariable("bid") String bid, Model model){
|
||||||
Blog blog = blogService.getOne(new QueryWrapper<Blog>().eq("bid", bid));
|
String loginUserId = getLoginUserId(request);
|
||||||
String sessionId = getSessionId(request);
|
String sessionId = getSessionId(request);
|
||||||
blogService.addRecord(blog,sessionId);
|
BlogWithUser readBlog = blogService.getReadBlog(bid, sessionId, loginUserId);
|
||||||
model.addAttribute("blog",blog);
|
model.addAttribute("blog",readBlog);
|
||||||
|
|
||||||
StarValue starValue = starService.isStar(bid, getLoginUserId(request), Category.BLOG);
|
StarValue starValue = starService.isStar(bid, loginUserId, Category.BLOG);
|
||||||
model.addAttribute("starValue",starValue);
|
model.addAttribute("starValue",starValue);
|
||||||
|
|
||||||
List<CommentWithUser> commentList = commentService.getCommentList(bid, Category.BLOG);
|
List<CommentWithUser> commentList = commentService.getCommentList(bid, Category.BLOG);
|
||||||
|
|||||||
@@ -24,4 +24,6 @@ public interface BlogMapper extends BaseMapper<Blog> {
|
|||||||
List<BlogWithUser> getBlogWithUserOrderBySort(String userId,MyPageParam myPageParam);
|
List<BlogWithUser> getBlogWithUserOrderBySort(String userId,MyPageParam myPageParam);
|
||||||
|
|
||||||
List<BlogWithUser> getMyBlogs(String userId,MyPageParam myPageParam);
|
List<BlogWithUser> getMyBlogs(String userId,MyPageParam myPageParam);
|
||||||
|
|
||||||
|
BlogWithUser getReadBlog(String bid, String userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<select id="getTopBlog" resultType="com.quinn.pojo.Blog">
|
<select id="getTopBlog" resultType="com.quinn.pojo.Blog">
|
||||||
select bid,title,(star + views) as views from
|
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
|
(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
|
from qn_blog where sort = 0 and category_id = '2') t
|
||||||
order by (views + star) desc limit 7
|
order by (views + star) desc limit 7
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -34,4 +34,14 @@
|
|||||||
limit #{myPageParam.pageNum},#{myPageParam.size}
|
limit #{myPageParam.pageNum},#{myPageParam.size}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getReadBlog" resultType="com.quinn.pojo.BlogWithUser">
|
||||||
|
select a.id,a.bid,a.title,a.sort,a.views,a.content,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
|
||||||
|
and (case when a.category_id = '1' then a.author_id = #{userId} else 1 end)
|
||||||
|
and a.bid = #{bid}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -9,8 +9,9 @@
|
|||||||
or a.content_json like CONCAT('%',#{findWhat},'%')
|
or a.content_json like CONCAT('%',#{findWhat},'%')
|
||||||
union all
|
union all
|
||||||
select 1 from qn_blog b
|
select 1 from qn_blog b
|
||||||
where b.title like CONCAT('%',#{findWhat},'%')
|
where (b.title like CONCAT('%',#{findWhat},'%')
|
||||||
or b.content_json like CONCAT('%',#{findWhat},'%')
|
or b.content_json like CONCAT('%',#{findWhat},'%'))
|
||||||
|
and b.category_id = '2'
|
||||||
) t
|
) t
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -24,5 +24,6 @@ public interface BlogService extends IService<Blog> {
|
|||||||
|
|
||||||
List<BlogWithUser> getMyBlogs(String userId,MyPageParam myPageParam);
|
List<BlogWithUser> getMyBlogs(String userId,MyPageParam myPageParam);
|
||||||
|
|
||||||
void addRecord(Blog blog, String sessionId);
|
BlogWithUser getReadBlog(String bid,String sessionId,String userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,14 +56,23 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements Bl
|
|||||||
return blogMapper.getMyBlogs(userId,myPageParam);
|
return blogMapper.getMyBlogs(userId,myPageParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void addRecord(BlogWithUser blogRead, String sessionId) {
|
||||||
public void addRecord(Blog blog, String sessionId) {
|
String value = redisUtils.get(sessionId + blogRead.getBid());
|
||||||
String value = redisUtils.get(sessionId + blog.getBid());
|
Blog blog = new Blog();
|
||||||
|
blog.setBid(blogRead.getBid());
|
||||||
if (!QuinnConstant.SESSION_VIEW_KEY.equals(value)){
|
if (!QuinnConstant.SESSION_VIEW_KEY.equals(value)){
|
||||||
blog.setViews(blog.getViews()+1);
|
blog.setViews(blogRead.getViews()+1);
|
||||||
redisUtils.set(sessionId + blog.getBid(),QuinnConstant.SESSION_VIEW_KEY,QuinnConstant.SESSION_TIME_OUT);
|
redisUtils.set(sessionId + blog.getBid(),QuinnConstant.SESSION_VIEW_KEY,QuinnConstant.SESSION_TIME_OUT);
|
||||||
updateById(blog);
|
updateById(blog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlogWithUser getReadBlog(String bid, String sessionId, String userId) {
|
||||||
|
BlogWithUser blog = blogMapper.getReadBlog(bid,userId);
|
||||||
|
if (blog!=null){
|
||||||
|
addRecord(blog,sessionId);
|
||||||
|
}
|
||||||
|
return blog;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,14 +32,31 @@
|
|||||||
</small>
|
</small>
|
||||||
</h2>
|
</h2>
|
||||||
<p class="blog-post-meta">
|
<p class="blog-post-meta">
|
||||||
<span th:text="${#dates.format(blog.getGmtUpdate(),'yyyy-MM-dd HH:mm:ss')}"></span>
|
<span>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clock-fill" viewBox="0 0 16 16">
|
||||||
|
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71V3.5z"/>
|
||||||
|
</svg>
|
||||||
|
[[${#dates.format(blog.getGmtUpdate(),'yyyy-MM-dd')}]]
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-person-fill" viewBox="0 0 16 16">
|
||||||
|
<path d="M12 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zm-1 7a3 3 0 1 1-6 0 3 3 0 0 1 6 0zm-3 4c2.623 0 4.146.826 5 1.755V14a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-1.245C3.854 11.825 5.377 11 8 11z"/>
|
||||||
|
</svg>
|
||||||
|
[[${blog.getUsername()}]]
|
||||||
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<svg class="bi bi-eye-fill" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
<svg class="bi bi-eye-fill" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M10.5 8a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z"/>
|
<path d="M10.5 8a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z"/>
|
||||||
<path fill-rule="evenodd" d="M0 8s3-5.5 8-5.5S16 8 16 8s-3 5.5-8 5.5S0 8 0 8zm8 3.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z"/>
|
<path fill-rule="evenodd" d="M0 8s3-5.5 8-5.5S16 8 16 8s-3 5.5-8 5.5S0 8 0 8zm8 3.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z"/>
|
||||||
</svg>
|
</svg>
|
||||||
[[${blog.getViews()}]]
|
[[${blog.getViews()}]]
|
||||||
</span>
|
</span>
|
||||||
|
<span>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bookmark-star-fill" viewBox="0 0 16 16">
|
||||||
|
<path fill-rule="evenodd" d="M2 15.5V2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v13.5a.5.5 0 0 1-.74.439L8 13.069l-5.26 2.87A.5.5 0 0 1 2 15.5zM8.16 4.1a.178.178 0 0 0-.32 0l-.634 1.285a.178.178 0 0 1-.134.098l-1.42.206a.178.178 0 0 0-.098.303L6.58 6.993c.042.041.061.1.051.158L6.39 8.565a.178.178 0 0 0 .258.187l1.27-.668a.178.178 0 0 1 .165 0l1.27.668a.178.178 0 0 0 .257-.187L9.368 7.15a.178.178 0 0 1 .05-.158l1.028-1.001a.178.178 0 0 0-.098-.303l-1.42-.206a.178.178 0 0 1-.134-.098L8.16 4.1z"/>
|
||||||
|
</svg>
|
||||||
|
[[${blog.getStar()}]]
|
||||||
|
</span>
|
||||||
<!-- 自己写的文章可以编辑和删除 -->
|
<!-- 自己写的文章可以编辑和删除 -->
|
||||||
<a th:if="@{${session.loginUser} ? ${session.loginUser.getUid()==blog.getAuthorId()} : false}"
|
<a th:if="@{${session.loginUser} ? ${session.loginUser.getUid()==blog.getAuthorId()} : false}"
|
||||||
class="float-right text-decoration-none" style="color: red"
|
class="float-right text-decoration-none" style="color: red"
|
||||||
|
|||||||
Reference in New Issue
Block a user