feat: 完成子文章的操作

This commit is contained in:
陈淳
2023-03-12 19:49:08 +08:00
parent 1eac218910
commit 8e56667760
40 changed files with 569 additions and 337 deletions

View File

@@ -0,0 +1,41 @@
import myaxios from '@/utils/request'
export function getList(data){
return myaxios({
url: '/article',
method: 'get',
params:data
})
};
export function get(id){
return myaxios({
url: `/article/${id}`,
method: 'get'
})
};
export function add(data){
return myaxios({
url: `/article`,
method: 'post',
data:data
})
};
export function update(id,data){
return myaxios({
url: `/article/${id}`,
method: 'put',
data:data
})
};
export function del(ids){
return myaxios({
url: `/article/${ids}`,
method: 'delete'
})
};
export function all(discussId)
{
return myaxios({
url: `/article/all/discuss-id/${discussId}`,
method: 'get'
})
}

View File

@@ -26,3 +26,9 @@ export function update(id,data){
data:data data:data
}) })
}; };
export function del(ids){
return myaxios({
url: `/discuss/${ids}`,
method: 'delete'
})
};

View File

@@ -0,0 +1,42 @@
<template>
<el-tree
:data="props.data"
:props="defaultProps"
@node-click="handleNodeClick"
:expand-on-click-node="false"
node-key="id"
>
<template #default="{ node, data }">
<span class="custom-tree-node">
<span>{{ node.label }}</span>
<span>
<a style="color: #f56c6c; margin-left: 8px" @click="$emit('remove',node, data)"
> 删除 </a>
</span>
</span>
</template>
</el-tree>
</template>
<script setup>
const props = defineProps(['data'])
//数据定义
//子文章数据
// const articleData =ref([]);
//树形子文章选项
const defaultProps = {
children: "children",
label: "name",
};
// //子文章初始化
// const loadArticleData=async()=>
// {
// articleData.value= await articleall(route.params.discussId);
// }
//点击事件
const handleNodeClick = (data) => {
console.log(data);
};
</script>

View File

@@ -16,9 +16,9 @@ background-color:#F0F2F5;
} }
.content-main{ .content-main{
/* max-width:1200px; */
margin: 0 auto; margin: 0 auto;
display: flex; display: flex;
justify-content: center; justify-content: center;
min-height: 1150px;
} }
</style> </style>

View File

@@ -33,7 +33,7 @@ const router = createRouter({
//artTypediscuss主题、article文章 //artTypediscuss主题、article文章
//operTypecreate创建、update更新 //operTypecreate创建、update更新
name:'editArt', name:'editArt',
path:'/editArt/:artType/:operType/:id', path:'/editArt',
component:()=>import('../views/EditArticle.vue') component:()=>import('../views/EditArticle.vue')
} }
] ]

View File

@@ -1,320 +1,332 @@
<template> <template>
<div style="width: 90%;min-width: 1200px;"> <div style="width: 90%; min-width: 1200px">
<!-- <div style="width: 1200px;"> --> <!-- <div style="width: 1200px;"> -->
<el-row :gutter="20" class="top-div"> <el-row :gutter="20" class="top-div">
<el-col :span="5">
<el-col :span="5"> <el-row class="art-info-left">
<el-row class="art-info-left"> <el-col :span="24">
<InfoCard header="主题信息" text="展开" hideDivider="true">
<el-col :span="24"> <template #content>
<InfoCard header="主题信息" text="展开" hideDivider="true"> <el-button style="width: 100%; margin-bottom: 0.8rem"
<template #content> >首页</el-button
<el-button style="width: 100%;margin-bottom: 0.8rem;">首页</el-button> >
<el-tree :data="data" @node-click="handleNodeClick" /> <el-button
</template> @click="addArticle(0)"
</InfoCard> type="primary"
</el-col> style="width: 100%; margin-bottom: 0.8rem; margin-left: 0"
<el-col :span="24"> >添加子文章</el-button
<InfoCard :items=items header="推荐好友" text="更多"> >
<template #item="temp"> <!--目录在这里 -->
<AvatarInfo /> <TreeArticleInfo :data="articleData" @remove="delArticle" />
</template> </template>
</InfoCard> </InfoCard>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<InfoCard :items=items header="推荐好友" text="更多"> <InfoCard :items="items" header="推荐好友" text="更多">
<template #item="temp"> <template #item="temp">
<AvatarInfo /> <AvatarInfo />
</template> </template>
</InfoCard> </InfoCard>
</el-col> </el-col>
<el-col :span="24">
<InfoCard :items="items" header="推荐好友" text="更多">
</el-row> <template #item="temp">
<AvatarInfo />
</el-col> </template>
</InfoCard>
<el-col :span="14"> </el-col>
<el-row class="left-div">
<el-col :span="24">
<AvatarInfo :size="50" :showWatching="true" :time="'2023-03-08 21:09:02'"></AvatarInfo>
<el-divider />
<h2>{{discuss.title}}</h2>
<ArticleContentInfo :code="discuss.content"></ArticleContentInfo>
<el-divider class="tab-divider" />
<el-space :size="10" :spacer="spacer">
<el-button icon="Pointer" text>
4</el-button>
<el-button icon="Star" text>
0</el-button>
<el-button icon="Share" text>
分享</el-button>
<el-button icon="Operation" text>
操作</el-button>
</el-space>
</el-col>
<el-col :span="24" class="comment">
文章评论
</el-col>
</el-row>
</el-col>
<el-col :span="5">
<el-row class="right-div">
<el-col :span="24">
<InfoCard class="art-info-right" header="文章信息" text="更多" hideDivider="true">
<template #content>
<div>
<ul class="art-info-ul">
<li>
<RouterLink :to='`/editArt/discuss/update/${route.params.discussId}`'> <el-button type="primary" size="default" >编辑</el-button></RouterLink>
</li>
<li>
分类 <span>文章</span>
</li>
标签 <el-tag type="success">文章</el-tag>
<el-tag type="info">资源</el-tag>
</ul>
</div>
</template>
</InfoCard>
</el-col>
<el-col :span="24">
<InfoCard class="art-info-right" header="目录" hideDivider="true">
<template #content>
<div>
<ul class="art-info-ul">
<li v-for="(item,i) in catalogueData" :key="i">
<el-button style="width: 100%;justify-content: left" type="primary" text>{{ `${i+1} ${item}` }}</el-button>
</li>
</ul>
</div>
</template>
</InfoCard>
</el-col>
<el-col :span="24">
<InfoCard :items=items header="推荐好友" text="更多">
<template #item="temp">
<AvatarInfo />
</template>
</InfoCard>
</el-col>
<el-col :span="24">
<InfoCard :items=items header="推荐好友" text="更多">
<template #item="temp">
<AvatarInfo />
</template>
</InfoCard>
</el-col>
</el-row>
</el-col>
</el-row> </el-row>
</div> </el-col>
<el-col :span="14">
<el-row class="left-div">
<el-col :span="24">
<AvatarInfo
:size="50"
:showWatching="true"
:time="'2023-03-08 21:09:02'"
></AvatarInfo>
<el-divider />
<h2>{{ discuss.title }}</h2>
<ArticleContentInfo :code="discuss.content"></ArticleContentInfo>
<el-divider class="tab-divider" />
<el-space :size="10" :spacer="spacer">
<el-button icon="Pointer" text> 4</el-button>
<el-button icon="Star" text> 0</el-button>
<el-button icon="Share" text> 分享</el-button>
<el-button icon="Operation" text> 操作</el-button>
</el-space>
</el-col>
<el-col :span="24" class="comment"> 文章评论 </el-col>
</el-row>
</el-col>
<el-col :span="5">
<el-row class="right-div">
<el-col :span="24">
<InfoCard
class="art-info-right"
header="文章信息"
text="更多"
hideDivider="true"
>
<template #content>
<div>
<ul class="art-info-ul">
<li>
<el-button
type="primary"
size="default"
@click="updateHander(route.params.discussId)"
>编辑</el-button
>
<el-button
style="margin-left: 1rem"
type="danger"
@click="delHander(route.params.discussId)"
>删除</el-button
>
</li>
<li>分类 <span>文章</span></li>
标签
<el-tag type="success">文章</el-tag>
<el-tag type="info">资源</el-tag>
</ul>
</div>
</template>
</InfoCard>
</el-col>
<el-col :span="24">
<InfoCard class="art-info-right" header="目录" hideDivider="true">
<template #content>
<div>
<ul class="art-info-ul">
<li v-for="(item, i) in catalogueData" :key="i">
<el-button
style="width: 100%; justify-content: left"
type="primary"
text
>{{ `${i + 1} ${item}` }}</el-button
>
</li>
</ul>
</div>
</template>
</InfoCard>
</el-col>
<el-col :span="24">
<InfoCard :items="items" header="推荐好友" text="更多">
<template #item="temp">
<AvatarInfo />
</template>
</InfoCard>
</el-col>
<el-col :span="24">
<InfoCard :items="items" header="推荐好友" text="更多">
<template #item="temp">
<AvatarInfo />
</template>
</InfoCard>
</el-col>
</el-row>
</el-col>
</el-row>
</div>
</template> </template>
<script setup> <script setup>
import { h, ref ,onMounted } from 'vue' import { h, ref, onMounted } from "vue";
import AvatarInfo from '@/components/AvatarInfo.vue' import AvatarInfo from "@/components/AvatarInfo.vue";
import InfoCard from '@/components/InfoCard.vue'; import InfoCard from "@/components/InfoCard.vue";
import ArticleContentInfo from '@/components/ArticleContentInfo.vue' import ArticleContentInfo from "@/components/ArticleContentInfo.vue";
import { useRoute } from 'vue-router'
import {get as discussGet} from '@/apis/discussApi.js'; import TreeArticleInfo from "@/components/TreeArticleInfo.vue";
import { useRoute, useRouter } from "vue-router";
import { get as discussGet, del as discussDel } from "@/apis/discussApi.js";
import {all as articleall,del as articleDel} from "@/apis/articleApi.js";
//数据定义 //数据定义
const route=useRoute() const route = useRoute();
const spacer = h(ElDivider, { direction: 'vertical' }) const router = useRouter();
const items = [{ user: "用户1" }, { user: "用户2" }, { user: "用户3" }] const spacer = h(ElDivider, { direction: "vertical" });
const handleNodeClick = (data) => { const items = [{ user: "用户1" }, { user: "用户2" }, { user: "用户3" }];
console.log(data)
}
const data = [ //子文章数据
{ const articleData =ref([]);
label: 'HTML',
children: [
{
label: 'Level two 1-1',
children: [
{
label: 'Level three 1-1-1',
},
],
},
],
},
{
label: 'HTML5',
children: [
{
label: 'Level two 2-1',
children: [
{
label: 'Level three 2-1-1',
},
],
},
{
label: 'Level two 2-2',
children: [
{
label: 'Level three 2-2-1',
},
],
},
],
},
{
label: 'XHTML',
children: [
{
label: 'Level two 3-1',
children: [
{
label: 'Level three 3-1-1',
},
],
},
{
label: 'Level two 3-2',
children: [
{
label: 'Level three 3-2-1',
},
],
},
],
},
{
label: 'Xcss',
},
{
label: 'CSS3',
},
{
label: 'Bootstrap 5',
},
{
label: 'Tcp/ip',
}
]
//主题内容 //主题内容
const discuss=ref({}); const discuss = ref({});
//目录数据 //目录数据
const catalogueData=ref([]); const catalogueData = ref([]);
//子文章初始化
const loadArticleData=async()=>
{
articleData.value= await articleall(route.params.discussId);
}
//主题初始化 //主题初始化
const loadDiscuss=async()=>{ const loadDiscuss = async () => {
discuss.value= await discussGet(route.params.discussId); discuss.value = await discussGet(route.params.discussId);
//加载目录 //加载目录
var reg = /(#{1,6})\s(.*)/g; var reg = /(#{1,6})\s(.*)/g;
var myArray =discuss.value.content.match(reg); var myArray = discuss.value.content.match(reg);
if(myArray!=null) if (myArray != null) {
{ catalogueData.value = myArray.map((x) => {
catalogueData.value= myArray.map(x=>{ return x.replace(/#/g,"").replace(/\s/g,'')}) return x.replace(/#/g, "").replace(/\s/g, "");
} });
}
};
//添加树型子文章
const addArticle = (parentArticleId) => {
//跳转路由
var routerPer = {
path: "/editArt",
query: {
operType: "create",
artType: "article",
discussId: route.params.discussId,
parentArticleId: parentArticleId,
},
};
router.push(routerPer);
};
//删除主题
const delHander = async (ids) => {
ElMessageBox.confirm(`确定是否删除编号[${ids}]的主题吗?`, "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "warning",
}).then(async () => {
const response = await discussDel(ids);
//删除成功后,跳转到主页
router.push("/index");
ElMessage({
type: "success",
message: "删除成功",
});
});
};
//更新操作
const updateHander = (discussId) => {
//跳转路由
var routerPer = {
path: "/editArt",
query: {
operType: "update",
artType: "discuss",
discussId: discussId,
},
};
router.push(routerPer);
};
//删除子文章
const delArticle=( node,data)=>{
ElMessageBox.confirm(`确定是否删除编号[${data.id}]的子文章吗?`, "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "warning",
}).then(async () => {
await articleDel(data.id);
await loadArticleData();
ElMessage({
type: "success",
message: "删除成功",
});
});
} }
onMounted(async () => {
await loadDiscuss();
onMounted(async()=>{ await loadArticleData();
await loadDiscuss(); });
})
</script> </script>
<style scoped > <style scoped >
.comment .comment {
{ height: 40rem;
height:40rem;
} }
.art-info-left .el-col { .art-info-left .el-col {
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.art-info-ul span { .art-info-ul span {
margin-left: 1rem; margin-left: 1rem;
} }
.art-info-ul .el-tag { .art-info-ul .el-tag {
margin-left: 1rem; margin-left: 1rem;
} }
.art-info-ul { .art-info-ul {
padding: 0; padding: 0;
margin: 0; margin: 0;
} }
li { li {
list-style: none; list-style: none;
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
.art-info-right { .art-info-right {
height: 100%; height: 100%;
} }
.left-div .el-col { .left-div .el-col {
background-color: #FFFFFF; background-color: #ffffff;
min-height: 12rem; min-height: 12rem;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.right-div .el-col { .right-div .el-col {
background-color: #FFFFFF; background-color: #ffffff;
min-height: 10rem; min-height: 10rem;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.left-top-div .el-col { .left-top-div .el-col {
min-height: 2rem; min-height: 2rem;
background-color: #FAFAFA; background-color: #fafafa;
margin-bottom: 1rem; margin-bottom: 1rem;
margin-left: 10px; margin-left: 10px;
} }
.top-div { .top-div {
padding-top: 1rem; padding-top: 1rem;
} }
.left-top-div { .left-top-div {
font-size: small; font-size: small;
text-align: center; text-align: center;
line-height: 2rem; line-height: 2rem;
} }
h2 { h2 {
margin-bottom: .5em; margin-bottom: 0.5em;
color: rgba(0, 0, 0, .85); color: rgba(0, 0, 0, 0.85);
font-weight: 600; font-weight: 600;
font-size: 30px; font-size: 30px;
line-height: 1.35; line-height: 1.35;
} }
.left-div .el-col { .left-div .el-col {
padding: 1.4rem 1.4rem 0.5rem 1.4rem; padding: 1.4rem 1.4rem 0.5rem 1.4rem;
} }
.el-space { .el-space {
display: flex; display: flex;
vertical-align: top; vertical-align: top;
justify-content: space-evenly; justify-content: space-evenly;
} }
.tab-divider { .tab-divider {
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
</style> </style>

View File

@@ -104,7 +104,13 @@ const loadDiscussList=async()=>{
//进入添加主题页面 //进入添加主题页面
const enterEditArticle=()=>{ const enterEditArticle=()=>{
router.push(`/editArt/discuss/create/${route.params.plateId}`) //跳转路由
var routerPer= { path: '/editArt', query: {
operType: 'create',
artType:'discuss',
plateId:route.params.plateId,
}}
router.push(routerPer);
} }
</script> </script>
<style scoped> <style scoped>

View File

@@ -1,111 +1,194 @@
<template> <template>
<div style="width: 100%;"> <div style="width: 100%">
<div class="body-div"> <div class="body-div">
<el-form label-width="120px" :model="discuss" label-position="left" :rules="rules" ref="ruleFormRef"> <el-form
label-width="120px"
:model="editForm"
label-position="left"
:rules="rules"
ref="ruleFormRef"
>
<el-form-item label="分类:"> <el-form-item label="分类:">
<el-radio-group v-model="radio"> <el-radio-group v-model="radio">
<el-radio-button label="1">文章</el-radio-button> <el-radio-button label="discuss">主题</el-radio-button>
<el-radio-button label="2">主题</el-radio-button> <el-radio-button label="article">文章</el-radio-button>
<el-radio-button label="3">板块</el-radio-button> <el-radio-button label="plate">板块</el-radio-button>
<el-radio-button label="4">其他</el-radio-button> <el-radio-button label="orther">其他</el-radio-button>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item
v-if="route.query.artType == 'article'"
label="名称:"
prop="name"
>
<el-input placeholder="请输入" v-model="editForm.name" />
</el-form-item>
<el-form-item label="标题:" prop="title"> <el-form-item label="标题:" prop="title">
<el-input placeholder="请输入" v-model="discuss.title" /> <el-input placeholder="请输入" v-model="editForm.title" />
</el-form-item> </el-form-item>
<el-form-item label="描述:" prop="introduction"> <el-form-item label="描述:" prop="introduction">
<el-input placeholder="请输入" v-model="discuss.introduction" /> <el-input placeholder="请输入" v-model="editForm.introduction" />
</el-form-item> </el-form-item>
<el-form-item label="内容:" prop="content"> <el-form-item label="内容:" prop="content">
{{ discuss.content + "[111]" }} {{ editForm.content + "*" }}
<MavonEdit height="30rem" v-model="discuss.content" :codeStyle="codeStyle" /> <MavonEdit
height="30rem"
v-model="editForm.content"
:codeStyle="codeStyle"
/>
</el-form-item> </el-form-item>
<el-form-item label="封面:"> <el-form-item label="封面:">
<el-input placeholder="请输入" /> <el-input placeholder="请输入" />
</el-form-item> </el-form-item>
<el-form-item label="标签:" prop="types"> <el-form-item label="标签:" prop="types">
<el-input placeholder="请输入" v-model="discuss.types" /> <el-input placeholder="请输入" v-model="editForm.types" />
</el-form-item> </el-form-item>
<el-form-item> <el-button @click="submit(ruleFormRef)" class="submit-btn" <el-form-item>
type="primary">提交</el-button></el-form-item> <el-button
@click="submit(ruleFormRef)"
class="submit-btn"
type="primary"
>提交</el-button
></el-form-item
>
</el-form> </el-form>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import MavonEdit from '@/components/MavonEdit.vue' import MavonEdit from "@/components/MavonEdit.vue";
import { ref, reactive,onMounted } from 'vue'; import { ref, reactive, onMounted } from "vue";
import { useRoute } from 'vue-router' import { useRoute, useRouter } from "vue-router";
import { add as discussAdd, update as discussUpdate,get as discussGet } from '@/apis/discussApi.js' import {
add as discussAdd,
update as discussUpdate,
get as discussGet,
} from "@/apis/discussApi.js";
import {
add as acticleAdd,
update as acticleUpdate,
get as acticleGet,
} from "@/apis/articleApi.js";
//数据定义 //数据定义
const route = useRoute() const route = useRoute();
const radio = ref(1) const router = useRouter();
const codeStyle = "atom-one-dark" const radio = ref(route.query.artType);
//需要添加的主题信息 const codeStyle = "atom-one-dark";
const discuss = reactive({
//整个页面上的表单
const editForm = reactive({
title: "", title: "",
types: "", types: "",
introduction: "", introduction: "",
content: "", content: "",
plateId: route.params.id name: ""
}); });
//组装主题内容: 需要更新主题信息
const discuss = {
};
//组装文章内容:需要添加的文章信息
const article = {
};
//定义效验规则 //定义效验规则
const ruleFormRef = ref(null) const ruleFormRef = ref(null);
const rules = reactive({ const rules = reactive({
title: [ title: [
{ required: true, message: '请输入标题', trigger: 'blur' }, { required: true, message: "请输入标题", trigger: "blur" },
{ min: 3, max: 20, message: '长度 3 到 20', trigger: 'blur' }, { min: 3, max: 20, message: "长度 3 到 20", trigger: "blur" },
], ],
content: [
}) { required: true, message: "请输入内容", trigger: "blur" },
{ min: 10, max: 4000, message: "长度 10 到4000", trigger: "blur" },
],
});
//提交按钮,需要区分操作类型 //提交按钮,需要区分操作类型
const submit = async (formEl) => { const submit = async (formEl) => {
if (!formEl) return if (!formEl) return;
await formEl.validate(async (valid, fields) => { await formEl.validate(async (valid, fields) => {
if (valid) { if (valid) {
//创建 //dicuss主题处理
if (route.params.operType == 'create') { if (route.query.artType == "discuss") {
await discussAdd(discuss)
}
//更新 discuss.title=editForm.title;
else if (route.params.operType == 'update') { discuss.types= editForm.types;
await discussUpdate(route.params.id, discuss) discuss.introduction= editForm.introduction;
discuss.content= editForm.content;
discuss.plateId= discuss.plateId??route.query.plateId
//主题创建
if (route.query.operType == "create") {
await discussAdd(discuss);
}
//主题更新
else if (route.query.operType == "update") {
await discussUpdate(route.query.discussId, discuss);
}
} }
ruleFormRef.value.resetFields(); //artcle文章处理
discuss.plateId = route.params.id; else if (route.query.artType == "article") {
//组装文章内容:需要添加的文章信息
article. content= editForm.content;
article.name= editForm.name;
article.discussId=route.query.discussId;
//文章创建
if (route.query.operType == "create") {
await acticleAdd(article);
}
//文章更新
else if (route.query.operType == "update") {
await articleUpdate(route.query.articleId, article);
}
}
//添加成功后跳转到该页面
var routerPer = { path: `/discuss/${discuss.plateId}` };
router.push(routerPer);
// ruleFormRef.value.resetFields();
// discuss.plateId = route.query.plateId;
} }
}) });
};
} onMounted(async () => {
onMounted(async()=>{
//如果是更新操作,需要先查询 //如果是更新操作,需要先查询
if (route.params.operType == 'update') { if (route.query.operType == "update") {
await loadDiscuss();
}
})
//加载主题
const loadDiscuss=async()=>{
const response= await discussGet(route.params.id);
discuss.content= response.content;
discuss.title= response.title;
discuss.types= response.types;
discuss.introduction= response.introduction;
}
// const clear = (source) => {
// const keys = Object.keys(source);
// let obj = {};
// keys.forEach((item) => {
// obj[item] = "";
// });
// Object.assign(source, obj);
// };
//更新主题
if (route.query.artType == "discuss") {
await loadDiscuss();
//更新文章
} else if (route.query.artType == "acticle") {
await loadActicle();
}
}
});
//加载主题
const loadDiscuss = async () => {
const response = await discussGet(route.query.discussId);
editForm.content = response.content;
editForm.title = response.title;
editForm.types = response.types;
editForm.introduction = response.introduction;
discuss.plateId=response.plateId;
};
//加载文章
const loadActicle = async () => {
const response = await acticleGet(route.query.acticleId);
editForm.content = response.content;
editForm.name = response.name;
// editForm.discussId = response.discussId;
};
</script> </script>
<style scoped> <style scoped>
.submit-btn { .submit-btn {

View File

@@ -94,16 +94,20 @@ import BottomInfo from '@/components/BottomInfo.vue'
import {getList} from '@/apis/plateApi.js' import {getList} from '@/apis/plateApi.js'
import {getList as discussGetList} from '@/apis/discussApi.js' import {getList as discussGetList} from '@/apis/discussApi.js'
import { onMounted, ref } from 'vue' import { onMounted, ref ,reactive} from 'vue'
var plateList=ref([]); var plateList=ref([]);
var discussList=ref([]); var discussList=ref([]);
const items=[{user:"用户1"},{user:"用户2"},{user:"用户3"}] const items=[{user:"用户1"},{user:"用户2"},{user:"用户3"}]
//主题查询参数
const query=reactive({
pageNum:1,
pageSize:10,
});
onMounted(async()=>{ onMounted(async()=>{
const response= await getList(); const response= await getList();
plateList.value= response.items; plateList.value= response.items;
const discussReponse=await discussGetList(); const discussReponse=await discussGetList(query);
discussList.value= discussReponse.items; discussList.value= discussReponse.items;
}); });

View File

@@ -101,7 +101,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.FileManager",
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.MultiTenancy", "src\framework\Yi.Framework.MultiTenancy\Yi.Framework.MultiTenancy.csproj", "{590B1EC0-CDA9-4937-BE07-FBB04437D21F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.MultiTenancy", "src\framework\Yi.Framework.MultiTenancy\Yi.Framework.MultiTenancy.csproj", "{590B1EC0-CDA9-4937-BE07-FBB04437D21F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.DictionaryManager", "Yi.Framework.DictionaryManager\Yi.Framework.DictionaryManager.csproj", "{8941B30D-698B-477A-8737-43E7B4A8695A}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.DictionaryManager", "src\module\Yi.Framework.DictionaryManager\Yi.Framework.DictionaryManager.csproj", "{8941B30D-698B-477A-8737-43E7B4A8695A}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@@ -13,6 +13,8 @@ using Yi.Framework.Core.Configuration;
using Yi.Framework.Core.Model; using Yi.Framework.Core.Model;
using Yi.Framework.Core.Sqlsugar.Const; using Yi.Framework.Core.Sqlsugar.Const;
using Yi.Framework.Core.Sqlsugar.Options; using Yi.Framework.Core.Sqlsugar.Options;
using Yi.Framework.Data.Auditing;
using Yi.Framework.Data.Entities;
using DbType = SqlSugar.DbType; using DbType = SqlSugar.DbType;
namespace Yi.Framework.Core.Sqlsugar.Extensions namespace Yi.Framework.Core.Sqlsugar.Extensions
@@ -93,15 +95,46 @@ namespace Yi.Framework.Core.Sqlsugar.Extensions
} }
db.Aop.DataExecuting = (oldValue, entityInfo) => db.Aop.DataExecuting = (oldValue, entityInfo) =>
{ {
//这里将进行审计日志
switch (entityInfo.OperationType) switch (entityInfo.OperationType)
{ {
case DataFilterType.InsertByObject:
break;
case DataFilterType.UpdateByObject: case DataFilterType.UpdateByObject:
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModificationTime)))
{
entityInfo.SetValue(DateTime.Now);
}
//if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModifierId)))
//{
// if (_currentUser != null)
// {
// entityInfo.SetValue(_currentUser.Id);
// }
//}
break;
case DataFilterType.InsertByObject:
if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreationTime)))
{
entityInfo.SetValue(DateTime.Now);
}
//if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreatorId)))
//{
// if (_currentUser != null)
// {
// entityInfo.SetValue(_currentUser.Id);
// }
//}
//插入时需要租户id,先预留
if (entityInfo.PropertyName.Equals(nameof(IMultiTenant.TenantId)))
{
//if (this.CurrentTenant is not null)
//{
// entityInfo.SetValue(this.CurrentTenant.Id);
//}
}
break; break;
} }
}; };
db.Aop.OnLogExecuting = (s, p) => db.Aop.OnLogExecuting = (s, p) =>
{ {

View File

@@ -7,8 +7,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\src\framework\Yi.Framework.Data\Yi.Framework.Data.csproj" /> <ProjectReference Include="..\..\framework\Yi.Framework.Data\Yi.Framework.Data.csproj" />
<ProjectReference Include="..\src\framework\Yi.Framework.Ddd\Yi.Framework.Ddd.csproj" /> <ProjectReference Include="..\..\framework\Yi.Framework.Ddd\Yi.Framework.Ddd.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -14,7 +14,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
public string Title { get; set; } public string Title { get; set; }
public string Types { get; set; } public string Types { get; set; }
public string? Introduction { get; set; } public string? Introduction { get; set; }
public DateTime? CreateTime { get; set; } public DateTime? CreateTime { get; set; } = DateTime.Now;
public string Content { get; set; } public string Content { get; set; }
public string? Color { get; set; } public string? Color { get; set; }

View File

@@ -20,5 +20,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
public int SeeNum { get; set; } public int SeeNum { get; set; }
public string Content { get; set; } public string Content { get; set; }
public string? Color { get; set; } public string? Color { get; set; }
public long PlateId { get; set; }
} }
} }

View File

@@ -20,5 +20,7 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos
public int SeeNum { get; set; } public int SeeNum { get; set; }
public string Content { get; set; } public string Content { get; set; }
public string? Color { get; set; } public string? Color { get; set; }
public long PlateId { get; set; }
} }
} }

View File

@@ -11,7 +11,6 @@ namespace Yi.BBS.Application.Contracts.Forum.Dtos.Discuss
public string Title { get; set; } public string Title { get; set; }
public string Types { get; set; } public string Types { get; set; }
public string? Introduction { get; set; } public string? Introduction { get; set; }
public DateTime? CreateTime { get; set; }
public int AgreeNum { get; set; } public int AgreeNum { get; set; }
public int SeeNum { get; set; } public int SeeNum { get; set; }
public string Content { get; set; } public string Content { get; set; }

View File

@@ -40,6 +40,7 @@ namespace Yi.BBS.Application.Forum
var entities = await _DbQueryable var entities = await _DbQueryable
.WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title.Contains(input.Title)) .WhereIF(!string.IsNullOrEmpty(input.Title), x => x.Title.Contains(input.Title))
.WhereIF(input.PlateId is not null, x => x.PlateId == input.PlateId) .WhereIF(input.PlateId is not null, x => x.PlateId == input.PlateId)
.OrderByDescending(x => x.CreateTime)
.ToPageListAsync(input.PageNum, input.PageSize, total); .ToPageListAsync(input.PageNum, input.PageSize, total);
var items = await MapToGetListOutputDtosAsync(entities); var items = await MapToGetListOutputDtosAsync(entities);
return new PagedResultDto<DiscussGetListOutputDto>(total, items); return new PagedResultDto<DiscussGetListOutputDto>(total, items);

View File

@@ -38,6 +38,7 @@ namespace Yi.BBS.Domain.Forum.Entities
/// <returns></returns> /// <returns></returns>
public static List<ArticleEntity> Tile(this List<ArticleEntity> entities) public static List<ArticleEntity> Tile(this List<ArticleEntity> entities)
{ {
if(entities is null)return new List<ArticleEntity>();
var result = new List<ArticleEntity>(); var result = new List<ArticleEntity>();
return StartRecursion(entities, result); return StartRecursion(entities, result);
} }

View File

@@ -15,8 +15,8 @@
<PackageReference Include="UAParser" Version="3.1.47" /> <PackageReference Include="UAParser" Version="3.1.47" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\Yi.Framework.DictionaryManager\Yi.Framework.DictionaryManager.csproj" />
<ProjectReference Include="..\..\..\framework\Yi.Framework.Data\Yi.Framework.Data.csproj" /> <ProjectReference Include="..\..\..\framework\Yi.Framework.Data\Yi.Framework.Data.csproj" />
<ProjectReference Include="..\..\..\module\Yi.Framework.DictionaryManager\Yi.Framework.DictionaryManager.csproj" />
<ProjectReference Include="..\..\..\module\Yi.Framework.EventBus\Yi.Framework.EventBus.csproj" /> <ProjectReference Include="..\..\..\module\Yi.Framework.EventBus\Yi.Framework.EventBus.csproj" />
<ProjectReference Include="..\..\..\module\Yi.Framework.FileManager\Yi.Framework.FileManager.csproj" /> <ProjectReference Include="..\..\..\module\Yi.Framework.FileManager\Yi.Framework.FileManager.csproj" />
<ProjectReference Include="..\..\..\module\Yi.Framework.OperLogManager\Yi.Framework.OperLogManager.csproj" /> <ProjectReference Include="..\..\..\module\Yi.Framework.OperLogManager\Yi.Framework.OperLogManager.csproj" />