Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
weiwosuoai committed Jul 15, 2023
2 parents ab9d720 + 9628022 commit 1a7406a
Show file tree
Hide file tree
Showing 19 changed files with 204 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public interface ArticleCategoryRelDao {
List<ArticleCategoryRelDO> selectByArticleIds(List<Long> articleIds);

List<ArticleCategoryRelDO> selectByCategoryId(Long categoryId);

ArticleCategoryRelDO selectByArticleId(Long articleId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public interface ArticleTagRelDao {
List<ArticleTagRelDO> selectByArticleIds(List<Long> articleIds);

List<ArticleTagRelDO> selectByTagId(Long queryTagId);

List<ArticleTagRelDO> selectByArticleId(Long articleId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
public interface CategoryDao {
List<CategoryDO> selectAllCategory();

CategoryDO selectByCategoryId(Long categoryId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

public interface TagDao {
List<TagDO> selectAllTag();

List<TagDO> selectByTagIds(List<Long> tagIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ public List<ArticleCategoryRelDO> selectByCategoryId(Long categoryId) {
wrapper.lambda().in(ArticleCategoryRelDO::getCategoryId, categoryId);
return articleCategoryRelMapper.selectList(wrapper);
}

@Override
public ArticleCategoryRelDO selectByArticleId(Long articleId) {
QueryWrapper<ArticleCategoryRelDO> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(ArticleCategoryRelDO::getArticleId, articleId);
return articleCategoryRelMapper.selectOne(wrapper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ public List<ArticleTagRelDO> selectByTagId(Long queryTagId) {
wrapper.lambda().in(ArticleTagRelDO::getTagId, queryTagId);
return articleTagRelMapper.selectList(wrapper);
}

@Override
public List<ArticleTagRelDO> selectByArticleId(Long articleId) {
QueryWrapper<ArticleTagRelDO> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(ArticleTagRelDO::getArticleId, articleId);
return articleTagRelMapper.selectList(wrapper);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.quanxiaoha.weblog.web.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quanxiaoha.weblog.common.domain.mapper.CategoryMapper;
import com.quanxiaoha.weblog.common.domain.dos.CategoryDO;
import com.quanxiaoha.weblog.web.dao.CategoryDao;
Expand Down Expand Up @@ -27,4 +28,11 @@ public List<CategoryDO> selectAllCategory() {
return categoryMapper.selectList(null);
}

@Override
public CategoryDO selectByCategoryId(Long categoryId) {
QueryWrapper<CategoryDO> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(CategoryDO::getId, categoryId);
return categoryMapper.selectOne(wrapper);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.quanxiaoha.weblog.web.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quanxiaoha.weblog.common.domain.mapper.TagMapper;
import com.quanxiaoha.weblog.common.domain.dos.TagDO;
import com.quanxiaoha.weblog.web.dao.TagDao;
Expand All @@ -26,4 +27,11 @@ public class TagDaoImpl implements TagDao {
public List<TagDO> selectAllTag() {
return tagMapper.selectList(null);
}

@Override
public List<TagDO> selectByTagIds(List<Long> tagIds) {
QueryWrapper<TagDO> wrapper = new QueryWrapper<>();
wrapper.lambda().in(TagDO::getId, tagIds);
return tagMapper.selectList(wrapper);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.quanxiaoha.weblog.web.model.vo.article;

import com.quanxiaoha.weblog.web.model.vo.tag.QueryTagListRspVO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

/**
* @author: 犬小哈
Expand All @@ -21,6 +23,10 @@ public class QueryArticleDetailRspVO {
private String title;
private String content;
private Date updateTime;
private Long categoryId;
private String categoryName;
private Long readNum;
private List<QueryTagListRspVO> tags;
private QueryArticleLinkRspVO preArticle;
private QueryArticleLinkRspVO nextArticle;
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,24 @@ public Response queryArticleDetail(QueryArticleDetailReqVO queryArticleDetailReq
.title(articleDO.getTitle())
.updateTime(articleDO.getUpdateTime())
.content(MarkdownUtil.parse2Html(articleContentDO.getContent()))
.readNum(articleDO.getReadNum())
.build();

// 查询文章所属分类
ArticleCategoryRelDO articleCategoryRelDO = articleCategoryRelDao.selectByArticleId(articleId);
CategoryDO categoryDO = categoryDao.selectByCategoryId(articleCategoryRelDO.getCategoryId());
vo.setCategoryId(categoryDO.getId());
vo.setCategoryName(categoryDO.getName());

// 查询文章标签
List<ArticleTagRelDO> articleTagRelDOS = articleTagRelDao.selectByArticleId(articleId);
List<Long> tagIds = articleTagRelDOS.stream().map(p -> p.getTagId()).collect(Collectors.toList());
List<TagDO> tagDOS = tagDao.selectByTagIds(tagIds);

List<QueryTagListRspVO> queryTagListRspVOS = tagDOS.stream()
.map(p -> QueryTagListRspVO.builder().id(p.getId()).name(p.getName()).build()).collect(Collectors.toList());
vo.setTags(queryTagListRspVOS);

// 上一篇
ArticleDO preArticle = articleDao.selectPreArticle(articleId);
if (Objects.nonNull(preArticle)) {
Expand Down
18 changes: 18 additions & 0 deletions weblog-vue3/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions weblog-vue3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"md-editor-v3": "^3.0.1",
"moment": "^2.29.4",
"universal-cookie": "^4.0.4",
"v-viewer": "^3.0.11",
"vue": "^3.2.47",
"vue-router": "^4.1.6",
"vue3-highlightjs": "^1.0.5",
Expand Down
14 changes: 12 additions & 2 deletions weblog-vue3/src/layouts/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,21 @@
<ul class="py-2" aria-labelledby="user-menu-button">
<li>
<a @click="$router.push('/admin')"
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">进入后台</a>
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">
<svg class="inline w-3 h-3 mb-2px mr-1 text-gray-700 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14v4m-4 1h8M1 10h18M2 1h16a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1Z"/>
</svg>
进入后台
</a>
</li>
<li>
<a @click="logout"
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">退出登录</a>
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">
<svg class="inline w-3 h-3 mb-2px mr-1 text-gray-700 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8h11m0 0-4-4m4 4-4 4m-5 3H3a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h3"/>
</svg>
退出登录
</a>
</li>
</ul>
</div>
Expand Down
28 changes: 24 additions & 4 deletions weblog-vue3/src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { createApp } from 'vue'
// import ElementPlus from 'element-plus'
// import 'element-plus/dist/index.css'
import 'virtual:windi.css'

import '@/assets/main.css'
Expand All @@ -11,21 +9,43 @@ import store from './store'
import "@/permission"

import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
// 代码高亮
import VueHighlightJS from 'vue3-highlightjs'
import 'vue3-highlightjs/styles/monokai-sublime.css'


// 富文本图片预览
import "viewerjs/dist/viewer.css";
import Viewer from "v-viewer";

const app = createApp(App)

app.use(store)
app.use(router)
// app.use(ElementPlus, { locale: zhCn })

app.use(VueHighlightJS)

// 引入图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}

app.use(Viewer, {
defaultOptions: {
inline: false, // 默认值:false。启用内联模式。
button: true, // 在查看器的右上角显示按钮。
navbar: true, // 指定导航栏的可见性。
title: true, // 指定标题的可见性和内容。
toolbar: true, // 指定工具栏及其按钮的可见性和布局。
tooltip: true, // 放大或缩小时显示带有图像比率(百分比)的工具提示。
movable: true, // 启用以移动图像。
zoomable: true, // 启用以缩放图像
rotatable: true, // 启用以旋转图像
scalable: true, // 启用以缩放图像。
transition: true, // 为某些特殊元素启用CSS3转换。
fullscreen: true, // 启用以在播放时请求全屏。
keyboard: true, // 启用键盘支持。
// url: 'src', //默认值:'src'。定义获取原始图像URL以供查看的位置。
},
});

app.mount('#app')
2 changes: 1 addition & 1 deletion weblog-vue3/src/pages/admin/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- 右边栏 -->
<div class="col-span-6 px-3 md:col-span-2 sm:col-span-6">
<div class="login-container-right flex justify-center items-center flex-col">
<h2 class="font-bold text-3xl text-gray-800">欢迎回来</h2>
<h2 class="font-bold text-3xl text-gray-800 mt-5">欢迎回来</h2>
<div class="flex items-center justify-center my-5 text-gray-400 space-x-2">
<span class="h-[1px] w-16 bg-gray-200"></span>
<span>账号密码登录</span>
Expand Down
Loading

0 comments on commit 1a7406a

Please sign in to comment.