(Vue+SpringBoot+elementUi+WangEditer)仿论坛项目

news2024/11/15 7:52:31

项目使用到的技术与库

1.前端 Vue2 elementUi Cookie WangEditer

2.后端 SpringBoot Mybatis-Plus

3.数据库 MySql

一、效果展示

1.1主页效果:

1.2 文章编辑页面:

1.3 成功发布文章

1.4 文章关键字搜索提示

 1.5 文章查询结果展示

1.6 文章内容及交互展示


二、表单设计的sql

用户:

create table paitool.user
(
    id                int auto_increment
        primary key,
    account           varchar(255)                                          not null,
    password          varchar(255)                                          not null,
    phone             varchar(20)                                           null,
    address           varchar(255)                                          null,
    isVip             tinyint(1)                  default 0                 null,
    email             varchar(255)                                          null,
    registration_date datetime                    default CURRENT_TIMESTAMP null,
    last_login        datetime                                              null,
    status            enum ('active', 'inactive') default 'active'          null,
    constraint account_UNIQUE
        unique (account),
    constraint email_UNIQUE
        unique (email),
    constraint phone_UNIQUE
        unique (phone)
);

文章:

create table paitool.forum_posts
(
    id         int auto_increment
        primary key,
    title      varchar(255)                            not null,
    content    text                                    not null,
    author_id  int                                     not null,
    created_at timestamp     default CURRENT_TIMESTAMP null,
    updated_at timestamp     default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP,
    heat_value int           default 0                 null,
    rating     decimal(3, 2) default 0.00              null,
    tag        varchar(10)   default '其它'              null,
    constraint forum_posts_ibfk_1
        foreign key (author_id) references paitool.user (id)
);

文章交互表-点赞:

create table paitool.forum_post_likes
(
    user_id int not null,
    post_id int not null,
    primary key (user_id, post_id),
    constraint forum_post_likes_ibfk_1
        foreign key (user_id) references paitool.user (id),
    constraint forum_post_likes_ibfk_2
        foreign key (post_id) references paitool.forum_posts (id)
);

文章交互表-收藏:

create table paitool.forum_post_favorites
(
    user_id int not null,
    post_id int not null,
    primary key (user_id, post_id),
    constraint forum_post_favorites_ibfk_1
        foreign key (user_id) references paitool.user (id),
    constraint forum_post_favorites_ibfk_2
        foreign key (post_id) references paitool.forum_posts (id)
);

文章交互表-评论

create table paitool.forum_comments
(
    id           int auto_increment
        primary key,
    post_id      int                                 not null,
    user_id      int                                 not null,
    comment_text text                                not null,
    created_at   timestamp default CURRENT_TIMESTAMP null,
    constraint forum_comments_ibfk_1
        foreign key (user_id) references paitool.user (id),
    constraint forum_comments_ibfk_2
        foreign key (post_id) references paitool.forum_posts (id)
);

三、前端代码

3.1 论坛主页

Html:

<template>
    <div id="forumLayOut">

        <div id="Top" style="background-color: rgb(250, 250, 250); padding-top: 20px">

            <div id="serchBorder" style="padding-bottom: 13px;">
                <!-- 搜索框 -->
                <el-autocomplete v-model="searchKeyWord" :fetch-suggestions="querySearchAsync" :trigger-on-focus="false"
                    placeholder="请输入关键字" style="width: 300px;" @select="handleSelect">
                </el-autocomplete>
                <el-button type="primary" @click="onSubmit">查询</el-button>
            </div>

            <!-- 分类查询 -->
            <div>

                <div style="margin-bottom: 15px;">
                    <el-checkbox-group v-model="checkboxGroup1" :max="1">
                        <el-checkbox-button v-for="city in cities" :label="city" :key="city">{{ city
                            }}</el-checkbox-button>
                    </el-checkbox-group>
                </div>

            </div>


            <div style="height: 380px; width: 100%;">
                <!-- 轮播图 -->
                <div class="block" style="width: 30%; float: left; margin-left: 5%; height: 400px;">
                    <el-carousel height="350px" style="width: 100%;  ">
                        <el-carousel-item v-for="item in 4" :key="item">
                            <img src="https://img95.699pic.com/photo/50035/3211.jpg_wh860.jpg" alt="风景测试">
                            <h3 class="small">{{ item }}</h3>
                        </el-carousel-item>
                    </el-carousel>
                </div>


                <div style=" height: 350px; background-color: rgb(250, 250, 250); width: 25%; float: left;
                border: 1px solid rgb(240, 240, 242);  margin-left: 3%;">


                    <div style="height: 50px; width: 100%; background-color: rgb(245, 245, 245); ">
                        <i class="el-icon-share"></i>
                        <div><b>热门</b></div>
                        <hr>
                    </div>

                    <div class="link-container">
                        <a href="#" class="link" id="TurnLink">杀死谷歌,成为AI时代的搜索皇帝!</a>
                        <p style="color: gray;">Perplexity CEO 最新四万字访谈</p>
                    </div>

                    <div class="link-container">
                        <a href="#" class="link" id="TurnLink">重写系统后痛批:这门语言烂透了!</a>
                        <p style="color: gray;">耗时18个月,开发者弃TypeScript投Rust</p>
                    </div>
                    <div class="link-container">
                        <a href="#" class="link" id="TurnLink">Shire 编码智能体语言</a>
                        <p style="color: gray;">打造你的专属 AI 编程助手</p>
                    </div>


                </div>


                <div style="float: left;  margin-left: 3%; height: 350px; background-color: rgb(250, 250, 250); width: 25%; float: left;
                     border: 1px solid rgb(240, 240, 242); ">


                    <div style="height: 50px; width: 100%; background-color: rgb(245, 245, 245); ">
                        <i class="el-icon-message-solid"></i>
                        <div><b>头条</b></div>
                        <hr>
                    </div>

                    <div class="link-container">
                        <a href="#" class="link" id="TurnLink">史上开发最久的游戏!</a>
                        <p style="color: gray;">耗时 22 年,5 名打工人凑了几百欧就开工,只剩 1 人坚守到发布...</p>
                    </div>

                    <div class="link-container">
                        <a href="#" class="link" id="TurnLink">实习期间创下 Transformer</a>
                        <p style="color: gray;">他说:当年整个 AI 圈都无法预见我们今天的高度</p>
                    </div>

                    <div class="link-container">
                        <a href="#" class="link" id="TurnLink">杀死谷歌,成为AI时代的搜索皇帝!</a>
                        <p style="color: gray;">Perplexity CEO 最新四万字访谈</p>
                    </div>

                </div>
            </div>


        </div>

        <el-divider></el-divider>
        <div id="bottom">

            <!-- Tabs 标签页  -->
            <el-tabs v-model="activeName" @tab-click="handleClick" style="padding-left: 2em; ">

                <el-tab-pane label="我的文章" name="first">
                    <div class="parent-div" style="min-height: 500px">

                        <div v-if="posts.length === 0">
                            <el-empty :image-size="200"></el-empty>
                        </div>

                        <div class="custom-card" v-for="(post, index) in posts" :key="index"
                            @click="getForumPostDetail(post.id)">
                            <div class="card-content">
                                <h1 class="card-title">标题: {{ post.title }}</h1>
                                <div class="card-meta">
                                    <span>作者: {{ post.account }}</span>
                                    <span>标签: {{ post.tag }}</span>
                                    <span><i class="el-icon-view">{{ post.heatValue }}</i></span>
                                </div>
                                <div class="card-rating">
                                    <span>文章评分:</span>
                                    <el-rate v-model="post.rating" disabled show-score text-color="#ff9900"
                                        score-template="{value}" style="display: inline-block;"></el-rate>
                                </div>
                            </div>
                        </div>
                    </div>


                </el-tab-pane>


                <el-tab-pane label="推荐文章" name="second">

                    <div v-if="posts.length === 0">
                        <el-empty :image-size="200"></el-empty>
                    </div>

                    <div class="custom-card" v-for="(post, index) in posts" :key="index"
                        @click="getForumPostDetail(post.postId)">
                        <div class="card-content">
                            <h1 class="card-title">标题: {{ post.title }}</h1>
                            <div class="card-meta">
                                <span>作者: {{ post.account }}</span>
                                <span>标签: {{ post.tag }}</span>
                                <span><i class="el-icon-view">{{ post.heat_value }}</i></span>
                            </div>
                            <div class="card-rating">
                                <span>文章评分:</span>
                                <el-rate v-model="post.rating" disabled show-score text-color="#ff9900"
                                    score-template="{value}" style="display: inline-block;"></el-rate>
                            </div>
                        </div>
                    </div>

                </el-tab-pane>
                <el-tab-pane label="热门文章" name="third">



                    <div class="parent-div" style="min-height: 500px">
                        <div v-if="posts.length === 0">
                            <el-empty :image-size="200"></el-empty>
                        </div>
                        <div class="custom-card" v-for="(post, index) in posts" :key="index"
                            @click="getForumPostDetail(post.id)">
                            <div class="card-content">
                                <h1 class="card-title">标题: {{ post.title }}</h1>
                                <div class="card-meta">
                                    <span>作者: {{ post.account }}</span>
                                    <span>标签: {{ post.tag }}</span>
                                    <span><i class="el-icon-view">{{ post.heatValue }}</i></span>
                                </div>
                                <div class="card-rating">
                                    <span>文章评分:</span>
                                    <el-rate v-model="post.rating" disabled show-score text-color="#ff9900"
                                        score-template="{value}" style="display: inline-block;"></el-rate>
                                </div>
                            </div>
                        </div>
                    </div>




                </el-tab-pane>

                <el-tab-pane label="优质文章" name="fourth">


                    <div class="parent-div" style="min-height: 500px">
                        <div v-if="posts.length === 0">
                            <el-empty :image-size="200"></el-empty>
                        </div>
                        <div class="custom-card" v-for="(post, index) in posts" :key="index"
                            @click="getForumPostDetail(post.id)">
                            <div class="card-content">
                                <h1 class="card-title">标题: {{ post.title }}</h1>
                                <div class="card-meta">
                                    <span>作者: {{ post.account }}</span>
                                    <span>标签: {{ post.tag }}</span>
                                    <span><i class="el-icon-view">{{ post.heatValue }}</i></span>
                                </div>
                                <div class="card-rating">
                                    <span>文章评分:</span>
                                    <el-rate v-model="post.rating" disabled show-score text-color="#ff9900"
                                        score-template="{value}" style="display: inline-block;"></el-rate>
                                </div>
                            </div>
                        </div>
                    </div>



                </el-tab-pane>

                <el-tab-pane label="我的收藏" name="fifth">
                    <div v-if="posts.length === 0">
                        <el-empty :image-size="200"></el-empty>
                    </div>



                    <div class="parent-div" style="min-height: 500px">
                        <div v-if="posts.length === 0">
                            <el-empty :image-size="200"></el-empty>
                        </div>
                        <div class="custom-card" v-for="(post, index) in posts" :key="index"
                            @click="getForumPostDetail(post.id)">
                            <div class="card-content">
                                <h1 class="card-title">标题: {{ post.title }}</h1>
                                <div class="card-meta">
                                    <span>作者: {{ post.account }}</span>
                                    <span>标签: {{ post.tag }}</span>
                                    <span><i class="el-icon-view">{{ post.heatValue }}</i></span>
                                </div>
                                <div class="card-rating">
                                    <span>文章评分:</span>
                                    <el-rate v-model="post.rating" disabled show-score text-color="#ff9900"
                                        score-template="{value}" style="display: inline-block;"></el-rate>
                                </div>
                            </div>
                        </div>
                    </div>


                </el-tab-pane>
            </el-tabs>

            <el-button type="warning" round id="iWantPost" @click="navigateToPostEdit">我要发布文章</el-button>

        </div>




    </div>
</template>

js:

<script>
import axios from 'axios';
import Cookies from 'js-cookie';

const cityOptions = ['新闻报道', '科技动态', '生活时尚', '教育学习', '健康养生'];
export default {
    components: {

    },

    data() {
        return {
            searchKeyWord: '',
            suggestions: [], // 添加这个属性
            checkboxGroup1: [],
            cities: cityOptions,
            activeName: 'first',
            currentPage1: 5,
            currentPage2: 5,
            currentPage3: 5,
            currentPage4: 4,
            posts: [
            ],
            
        }
    },
    methods: {
        onSubmit() {
            this.$router.push({
                name: 'ArticalSearchView',
                params: {
                    searchKeyWord: this.searchKeyWord
                }
            })


        },
        handleClick(tab) {

            // 我的文章
            if (tab.name === 'first') {
                this.posts = []
                this.getMyArticle();

            }

            // 推荐文章
            if (tab.name === 'second') {
                this.posts = [];

                axios.get('/api/forum/getAllForumPost', {
                    params: {
                        pageSize: 1,
                        pageNumber: 10
                    }
                }).then((response) => {
                    console.log(response.data.data);
                    
                    this.posts = response.data.data;
                });


            }
            // 热门文章
            if (tab.name === 'third') {
                this.posts = [];

                axios.get('/api/forum/getHotPosts').then((response) => {
                    console.log(response.data.data);
                    this.posts = response.data.data;
                });


            }

            // 优质文章
            if (tab.name === 'fourth') {
                this.posts = [];

                axios.get('/api/forum/getOutStandPosts').then((response) => {
                    console.log(response.data.data);
                    this.posts = response.data.data;
                });

            }

            // 我的收藏
            if (tab.name === 'fifth') {
                this.posts = [];
                const id = Cookies.get("userId");

                if (id === null) {
                    this.$message({
                        message: '请先登录',
                        type: 'warning'
                    });
                    return;
                }

                axios.get('/api/forum/getMyFavorite', {
                    params: {
                        id: id
                    }
                }).then((response) => {
                    console.log(response.data.data);
                    this.posts = response.data.data;
                });

            }



        },

        // 处理分页功能
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
        },

        navigateToPostEdit() {
            this.$router.push({ name: 'ForumPostEditView' });
        },


        // 跳转到文章详情
        getForumPostDetail(postId) {
            console.log("getForumPostDetail");
            console.log(postId);
            this.$router.push(`/post/${postId}`);
        },

        getMyArticle() {
            this.posts = [];
            const id = Cookies.get("userId");

            if (id === null) {
                this.$message({
                    message: '请先登录',
                    type: 'warning'
                });
                return;
            } else {
                axios.get('/api/forum/MyArticle', {
                    params: {
                        id: id
                    }
                }).then((response) => {
                    console.log(response.data.data);
                    this.posts = response.data.data;
                })

            }

        },
        // 异步获取建议列表
        querySearchAsync(queryString, cb) {
            if (queryString.length === 0) {
                return cb([]); // 当查询字符串为空时,直接返回空数组
            }
            axios.get('/api/forum/getLikeSearch', { params: { keyword: queryString } })
                .then(response => {
                    // 确保从后端返回的数据中提取出正确的数组
                    const results = response.data.data || [];
                    // 调用callback函数,传入搜索结果
                    cb(results);
                })
                .catch(error => {
                    console.error('Error fetching search suggestions:', error);
                   
                    cb([]);
                });
        },
        // 处理选择事件
        handleSelect(item) {
            this.searchKeyWord = item.value; 
            this.onSubmit();
        }


    },

    mounted() {
        this.getMyArticle();

    }


}

</script>

css:

<style scoped>
#forumLayOut {

    background-color: white;
    height: auto;
    width: 100%;
    line-height: normal;
}

#serchBorder {

    line-height: normal;
}

.el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 150px;
    margin: 0;
}

.el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
}

#Pagination {
    align-self: center;
    /* 居中对齐 */
    margin-bottom: 1rem;
    /* 可选,增加底部边距 */
    margin-top: 10%;
}


#iWantPost {
    position: fixed;
    /* 设置为固定定位 */
    bottom: 60px;
    /* 距离底部的距离,可根据需要调整 */
    right: 40px;
    /* 距离右侧的距离,可根据需要调整 */
}


.el-tabs__content {
    overflow: hidden;
    position: relative;
    height: auto;
}

.custom-card {
    background-color: #ffffff;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
    transition: box-shadow 0.3s ease-in-out;
}

.custom-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    background-color: rgb(245, 245, 245);
}

.card-content {
    padding: 16px;
}

.card-title {
    font-size: 1.2em;
    margin-bottom: 8px;
    color: #333;
}

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    color: #666;
}

.card-rating {
    color: #666;
}

.link-container {
    line-height: normal;
    float: left;
    width: 100%;
    text-align: left;
    padding-left: 40px;
    padding-top: 10px;
}

.link {
    text-decoration: none;
    font-size: large;
    color: black;
}

.link:hover {
    text-decoration: underline;
}
</style>

 

3.2 发布文章页面

<template>

    <div style="border: 1px solid #ccc; line-height: normal; height: 100%;">
        <div>

            <el-form :inline="true" :model="formInline" class="demo-form-inline">
                <el-form-item label="文章标题">
                    <el-input v-model="formInline.title" placeholder="请输入文章标题" maxlength="20"></el-input>
                </el-form-item>


                <el-form-item label="类别">
                    <el-select v-model="formInline.category" placeholder="请选择文章类别">
                        <el-option label="新闻报道" value="news"></el-option>
                        <el-option label="科技动态" value="technology"></el-option>
                        <el-option label="生活时尚" value="lifestyle"></el-option>
                        <el-option label="教育学习" value="education"></el-option>
                        <el-option label="健康养生" value="health"></el-option>
                    </el-select>
                </el-form-item>


                <el-form-item>
                    <el-button type="primary" @click="onSubmit"
                        v-loading.fullscreen.lock="fullscreenLoading">提交</el-button>
                </el-form-item>
            </el-form>

        </div>
        <Toolbar style="border-bottom: 1px solid #ccc" :editor="editor" :defaultConfig="toolbarConfig" :mode="mode" />
        <Editor style="height: 500px; overflow-y: hidden; height: 100%;" v-model="html" :defaultConfig="editorConfig"
            :mode="mode" @onCreated="onCreated" />
    </div>

</template>


<script>
import Vue from 'vue'
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
import axios from 'axios'
import Cookies from 'js-cookie'


export default Vue.extend({
    components: { Editor, Toolbar },
    data() {
        return {
            editor: null,
            html: ' ',
            toolbarConfig: {},
            editorConfig: { placeholder: '请输入内容...' },
            mode: 'default', // or 'simple'
            formInline: {
                title: '',
                category: ''
            },
            fullscreenLoading: false
        }
    },
    methods: {
        onCreated(editor) {
            this.editor = Object.seal(editor) // 一定要用 Object.seal() ,否则会报错

        },
        onSubmit() {

            this.fullscreenLoading = true;

            const userId = Cookies.get('userId'); // 获取并转换userId

            axios.post('/api/forum/add', {

                "title": this.formInline.title,

                "content": this.editor.getHtml(), 

                "authorId": userId,

                "tag": this.formInline.category,

            }).then((response) => {

                console.log(response.data);

                this.fullscreenLoading = false;

                this.$router.push({ name: 'ForumSucessPostView' });

            }).catch(error => {

                console.error(error);

                this.fullscreenLoading = false;

            });

        },

    },
    mounted() {

    },
    beforeDestroy() {
        const editor = this.editor
        if (editor == null) return
        editor.destroy() // 组件销毁时,及时销毁编辑器


    },

})
</script>


<style src="@wangeditor/editor/dist/css/style.css"></style>

3.3 文章发布成功页面


3.4 查看文章页面

html:

<template>
    <div style="line-height: normal; background-color: rgb(246, 247, 249); height: auto; min-height: 80%;">

        <!-- 文章信息 -->
        <div style="padding-top: 10px; width: auto; min-width: 40%;">
            <!-- 实现文字垂直居中 -->
            <div id="Infor" style="background-color: white;">
                <h1 style="font-size: 28px; text-align: center">文章标题:{{title}}</h1>
                <span>创作者:{{author}}</span>
                <span style="margin-left: 20px;">创作日期:{{createAt}}</span>
                <span style="margin-left: 20px;"><i class="el-icon-view">{{heatValue}}</i></span>
            </div>

            <el-divider><i class="el-icon-mobile-phone"></i></el-divider>


            <!-- 文章内容展示区 -->
            <div id="contentDisplay">
                <div v-html="content"
                    style="padding-left: 2em; padding-top: 15px; padding-right: 2em; padding-bottom: 30px;"></div>
            </div>
        </div>

        <el-divider><i class="el-icon-edit"></i></el-divider>

        <!-- 交互按键 -->
        <div id="buttom">
            <el-button type="warning" round @click="getBackToForum">返回到论坛</el-button>
            <el-button type="warning" icon="el-icon-star-off" circle @click="PostFavorite"></el-button>
            <el-button type="danger" icon="el-icon-thumb" circle @click="PostLike"></el-button>

        </div>

        <!-- 评论区 -->
        <div id="commentListShow">
            <el-card class="box-card">
                <div slot="header" class="clearfix">
                    <span>评论详情</span>
                </div>
                <div id="commentInputArea">

                    <el-input type="textarea" placeholder="请您输入友善的评论吧" v-model="textarea" maxlength="300"
                        show-word-limit id="inputFrame" :clearable="clearAble" resize="none">
                    </el-input>
                    <div style="margin-top: 10px; padding-bottom: 50px;">
                        <el-button type="primary" @click="SubmitComment">发表评论</el-button>
                        <el-button type="primary" @click="CancelComment">取消评论</el-button>
                    </div>
                </div>

                <div id="commentList">
                    <div class="comment-card" v-for="comment in comments" :key="comment.id">
                        <div class="comment-head">
                            <h1 class="username">{{ comment.account }}</h1>
                            <p class="created-at">发表于:{{ comment.createdAt }}</p>
                        </div>
                        <el-divider></el-divider>
                        <p class="comment-text">{{ comment.commentText }}</p>
                    </div>
                </div>

            </el-card>
        </div>


    </div>
</template>

script:

<script>
import axios from 'axios';
import Cookies from 'js-cookie';


export default{
    data() {
        return {
            postId: '',
            title: '',
            content: '',
            value1: null,
            textarea: '',
            userId:'',
            clearAble: true,
            comments:{},
            author:'',
            createAt:'',
            heatValue:'',
        }
    },
    created() {

        this.postId = this.$route.params.postId;
        this.fetchPostDetail(this.$route.params.postId);
        this.userId = Cookies.get('userId');
    },
    mounted() {
        this.readComment();
        
    },
    methods: {
        // 前端实现路径传参
        async fetchPostDetail(postId) {
            try {
                this.fullscreenLoading = true;
                const url = `/api/forum/post/${postId}`;
                // 发起GET请求
                const response = await axios.get(url);

                if (response.status === 200) {
                    // 请求成功,处理响应数据
                    const postData = response.data;
                    console.log('文章详情:', postData);
                    // 更新组件状态或执行其他操作
                    this.title = response.data.data.title;
                    this.content = response.data.data.content;
                    this.author = response.data.data.account;
                    this.createAt = response.data.data.createdAt;
                    this.heatValue = response.data.data.heatValue;
                    this.fullscreenLoading = false;
                } else {
                    console.error('请求失败,状态码:', response.status);
                }
            } catch (error) {
                console.error('请求错误:', error);
            }
        },

        getBackToForum() {
            this.$router.push({ name: 'forum' });
        },


        // 取消评论
        CancelComment(){
            this.textarea = '';

        },

        // 执行点赞按钮
        PostLike(){
            this.isLogin();
            axios.get('/api/forum/like',{
                params:{
                    postId : this.postId,
                    userId : this.userId
                }
            }).then((response)=>{
               this.MessageNotify(response);
            })
        },

        // 执行收藏按钮
        PostFavorite(){
            this.isLogin();
            axios.get('/api/forum/favorite',{
                params:{
                    postId : this.postId,
                    userId : this.userId
                }
            }).then((response)=>{
               this.MessageNotify(response);
            })


        },
        SubmitComment(){

            this.isLogin();

            axios.post('/api/forum/writeComment',{
                postId : this.postId,
                userId : this.userId,
                commentText : this.textarea
            }).then((response)=>{
                this.MessageNotify(response);
                this.textarea = '';
                this.readComment();
            })

            console.log("submit");
        },

        isLogin(){
            if(Cookies.get('userId') == null){
                this.$message.error('请先登录');
                return;
            }
        },

        // 消息提醒
        MessageNotify(response){
            if(response.data.code == 200){
                this.$message.success(response.data.data);
            }else{
                console.log(response.data);
                this.$message.error(response.data.message);
            }
        },

        readComment(){
            axios.get('/api/forum/getComment',{
                params:{
                    postId : this.postId
                }
            }).then((response)=>{
                this.comments = response.data.data;
            })
        },


    }

}


</script>

css:


3.5 文章搜索页面

html:

<template>
    <div id="layout">

        <div id="searchFrame">
            <div id="InputFrame">
                <el-input type="textarea" placeholder="请输入内容" v-model="textarea" rows="1" resize="none"
                    style="font-size: larger; width: 80%;">
                </el-input>
                <el-button type="warning" @click="SearchSubmit"  icon="el-icon-search">查询</el-button>
            </div>
        </div>

        <div id="excess">

            <div id="Interate">
                <i class="el-icon-search"> 搜索结果</i>
            </div>

        </div>

        
        <div id="SearchContent">

            <div v-if="posts.length === 0">
                <el-empty :image-size="200"></el-empty>
            </div>



            <div class="custom-card" v-for="(post, index) in posts" :key="index" @click="getForumPostDetail(post.id)">
                <div class="card-content">
                    <h1 class="card-title">标题: {{ post.title }}</h1>
                    <div class="card-meta">
                        <span>作者: {{ post.account }}</span>
                        <span>标签: {{ post.tag }}</span>
                        <span><i class="el-icon-view">{{ post.heatValue }}</i></span>
                    </div>
                    <div class="card-rating">
                        <span>文章评分:</span>
                        <el-rate v-model="post.rating" disabled show-score text-color="#ff9900" score-template="{value}"
                            style="display: inline-block;"></el-rate>
                    </div>
                </div>
            </div>
        </div>


    </div>
</template>

script:

<script>
import axios from 'axios';


export default {
    data() {
        return {
            textarea: '',
            searchKeyWord: '',
            posts: [],
        }
    },

    methods: {
        SearchSubmit() {
            console.log(this.textarea);
            axios.get('/api/forum/search', {
                params: {
                    searchKeyWord: this.textarea
                }
            }).then((response) => {

                if (response.data.code !== 200) {
                    this.$notify({
                        title: '警告',
                        message: '搜索失败',
                        type: 'warning'
                    });
                }

                console.log(response.data.data);
                this.posts = response.data.data;
            });
        },


        Search() {

            axios.get('/api/forum/search', {
                params: {
                    searchKeyWord: this.searchKeyWord
                }
            }).then((response) => {

                if (response.data.code !== 200) {
                    this.$notify({
                        title: '警告',
                        message: '搜索失败',
                        type: 'warning'
                    });
                }

                console.log(response.data.data);
                this.posts = response.data.data;
            });
        },

         // 跳转到文章详情
         getForumPostDetail(postId) {
            console.log("getForumPostDetail");
            console.log(postId);
            this.$router.push(`/post/${postId}`);
        },



    },

    mounted() {
        this.searchKeyWord = this.$route.params.searchKeyWord;
        this.textarea = this.searchKeyWord;
        this.Search();
    }

}
</script>

css:

<style scoped>
#layout {
    width: 100%;
    min-height: 90%;
    background-color: rgb(245, 246, 247);
    line-height: normal;
}

#SearchContent{
    min-height: 800px;
    

}

#searchFrame {
    height: 70px;
    width: 100%;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
    position: -webkit-sticky;
    /* Safari */
    position: sticky;
    top: 0;
    z-index: 1000;
    line-height: normal;
}

#InputFrame {
    width: 40%;
    margin: 0 auto;
    height: 60%;
    padding-top: 15px;
}

#Interate {

    float: left;
    margin-top: 20px;
    margin-left: 20px;
}

#excess {

    height: 61px;
    width: 80%;
    background-color: white;
    margin: 0 auto;
    margin-top: 25px;
    border: 1px solid rgb(245, 245, 245);
    border-radius: 4px;
}



.custom-card {
    background-color: #ffffff;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
    transition: box-shadow 0.3s ease-in-out;
    width: 80%;
    margin: 0 auto;

    border: 1px solid rgb(245, 245, 245);
}

.custom-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    background-color: rgb(245, 245, 245);
}

.card-content {
    padding: 16px;
}

.card-title {
    font-size: 1.2em;
    margin-bottom: 8px;
    color: #333;
}

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    color: #666;
}

.card-rating {
    color: #666;
}

.card-rating {
    color: #666;
}
</style>

 


 

四、后端代码

4.1项目后端依赖库

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.3.1</version>
        </dependency>

        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.8.11</version>
        </dependency>

        <dependency>
             <groupId>com.baomidou</groupId>
             <artifactId>mybatis-plus-boot-starter</artifactId>
             <version>3.5.3.1</version>
        </dependency>

        <!--swagger-->
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>knife4j-spring-boot-starter</artifactId>
            <version>3.0.2</version>
        </dependency>

        <!--web-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>5.3.15</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-spring-web</artifactId>
            <version>3.0.0</version>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.76</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.alibaba/dashscope-sdk-java -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dashscope-sdk-java</artifactId>
            <version>2.8.2</version>
        </dependency>
        <!--okhttp3 依赖-->
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.9.3</version>
        </dependency>

        <!-- Lombok dependency -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <!--        验证码模块-->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>

4.2工具类Result类与实体类

public class Result<T> {
    // 状态码常量
    public static final int SUCCESS = 200;
    public static final int ERROR = 500;
    
    private int code; // 状态码
    private String message; // 消息
    private T data; // 数据

    // 构造函数,用于创建成功的结果对象
    private Result(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    // 成功结果的静态方法
    public static <T> Result<T> success(T data) {
        return new Result<>(SUCCESS, "Success", data);
    }


    // 错误结果的静态方法
    public static <T> Result<T> error(String message) {
        return new Result<>(ERROR, message, null);
    }

    // 错误结果的静态方法,可以传入自定义的状态码
    public static <T> Result<T> error(int code, String message) {
        return new Result<>(code, message, null);
    }

    // 获取状态码
    public int getCode() {
        return code;
    }

    // 设置状态码
    public void setCode(int code) {
        this.code = code;
    }

    // 获取消息
    public String getMessage() {
        return message;
    }

    // 设置消息
    public void setMessage(String message) {
        this.message = message;
    }

    // 获取数据
    public T getData() {
        return data;
    }

    // 设置数据
    public void setData(T data) {
        this.data = data;
    }

    // 用于转换为Map类型的方法,方便序列化为JSON
    public Map<String, Object> toMap() {
        Map<String, Object> map = new HashMap<>();
        map.put("code", code);
        map.put("message", message);
        map.put("data", data);
        return map;
    }
}

Entity:

Forumpost:

@TableName(value ="forum_posts")
@Data
public class ForumPosts implements Serializable {
    /**
     * 
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 
     */
    @TableField(value = "title")
    private String title;
    /**
     * 
     */
    @TableField(value = "content")
    private String content;
    /**
     * 
     */
    @TableField(value = "author_id")
    private Integer authorId;
    /**
     * 
     */
    @TableField(value = "created_at")
    private LocalDateTime createdAt;
    /**
     * 
     */
    @TableField(value = "updated_at")
    private LocalDateTime updatedAt;
    /**
     * 
     */
    @TableField(value = "heat_value")
    private Integer heatValue;
    /**
     * 
     */
    @TableField(value = "rating")
    private BigDecimal rating;
    /**
     * 
     */
    @TableField(value = "tag")
    private String tag;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        ForumPosts other = (ForumPosts) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
            && (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
            && (this.getAuthorId() == null ? other.getAuthorId() == null : this.getAuthorId().equals(other.getAuthorId()))
            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
            && (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()))
            && (this.getHeatValue() == null ? other.getHeatValue() == null : this.getHeatValue().equals(other.getHeatValue()))
            && (this.getRating() == null ? other.getRating() == null : this.getRating().equals(other.getRating()))
            && (this.getTag() == null ? other.getTag() == null : this.getTag().equals(other.getTag()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
        result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
        result = prime * result + ((getAuthorId() == null) ? 0 : getAuthorId().hashCode());
        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
        result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
        result = prime * result + ((getHeatValue() == null) ? 0 : getHeatValue().hashCode());
        result = prime * result + ((getRating() == null) ? 0 : getRating().hashCode());
        result = prime * result + ((getTag() == null) ? 0 : getTag().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", title=").append(title);
        sb.append(", content=").append(content);
        sb.append(", authorId=").append(authorId);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", updatedAt=").append(updatedAt);
        sb.append(", heatValue=").append(heatValue);
        sb.append(", rating=").append(rating);
        sb.append(", tag=").append(tag);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
ForumPostLike:
@Data

@TableName(value ="forum_post_likes")

public class ForumPostLike {

    private int userId;

    private int postId;


}
ForumPostFavorites:
@Data
@TableName(value ="forum_post_favorites")
public class ForumPostFavorites {

    private int userId;

    private int postId;

}
ForumComments
@TableName(value ="forum_comments")
@Data
public class ForumComments implements Serializable {
    /**
     * 
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 
     */
    @TableField(value = "post_id")
    private Integer postId;

    /**
     * 
     */
    @TableField(value = "user_id")
    private Integer userId;

    /**
     * 
     */
    @TableField(value = "comment_text")
    private String commentText;

    /**
     * 
     */
    @TableField(value = "created_at")
    private LocalDateTime createdAt;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        ForumComments other = (ForumComments) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getPostId() == null ? other.getPostId() == null : this.getPostId().equals(other.getPostId()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
            && (this.getCommentText() == null ? other.getCommentText() == null : this.getCommentText().equals(other.getCommentText()))
            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getPostId() == null) ? 0 : getPostId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getCommentText() == null) ? 0 : getCommentText().hashCode());
        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", postId=").append(postId);
        sb.append(", userId=").append(userId);
        sb.append(", commentText=").append(commentText);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}

 DTO:

@Data
public class CommentDTO {


    private int  userId;

    private int postId;

    private String commentText;


}
@Data
public class ForumAddPostDTO {

    @JsonProperty("title")
    private String title;

    @JsonProperty("content")
    private String content;

    @JsonProperty("authorId")
    private Integer authorId;

    @JsonProperty("tag")
    private String tag;
}

 VO:

@Data
public class ArticleVO {

    private String title;

    private String content;

    private String account;

    private Integer heatValue;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;

}
@Data
public class CommentVo {

    private int id;

    private String commentText;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;

    private String account;
}
@Data
public class LikeSearchVo {
    private String value;
}

 


4.3 自定义异常与全局异常

public class BaseException extends RuntimeException{

    public BaseException(){
    }
    public BaseException(String msg){
        super(msg);
    }
    
}
public class NotFoundArticleException extends BaseException{
    public NotFoundArticleException(String msg){
        super(msg);
    }

}
public class AlreadyLikeException extends BaseException{

    public AlreadyLikeException(String msg){
        super(msg);
    }


}

全局异常处理类:

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler
    public Result exceptionHandler(BaseException ex){
        log.error("异常信息:{}", ex.getMessage());
        return Result.error(ex.getMessage());
    }

}

4.4Controller层

1.ForumPostController

@RequestMapping("/forum")
@RestController
@Api(tags = "文章管理")
@Slf4j
public class ForumPostController {

    @Autowired
    ForumPostsService forumPostsService;

    @Autowired
    UserService userService;

    @Autowired
    ForumCommentsService forumCommentsService;




    @ApiOperation("新增文章")
    @PostMapping("/add")
    public Result addForumPost(@RequestBody ForumAddPostDTO forumAddPostDTO) throws ParseException {
        ForumPosts forumPosts = new ForumPosts();
        BeanUtils.copyProperties(forumAddPostDTO, forumPosts);
        forumPostsService.save(forumPosts);
        return Result.success("新增成功");
    }


    @GetMapping("/getAllForumPost")
    @ApiOperation("推荐文章查询")
    public Result getAllForumPost(@RequestParam(value="pageSize", defaultValue = "10") int pageSize,
                                  @RequestParam(value="pageNumber", defaultValue = "1") int pageNumber){


        Page<ForumPosts> page = new Page<>(pageNumber, pageSize);
        // 创建查询包装器并指定排序规则
        QueryWrapper<ForumPosts> queryWrapper = new QueryWrapper<>();
        // 假设你想按照创建时间降序排序
        queryWrapper.orderByDesc("created_at");
        Page<ForumPosts> paged = forumPostsService.page(page,queryWrapper);
        List<ForumPosts> postsList = paged.getRecords();
        List<ForumPageVO> posts = new ArrayList<>();


        for (ForumPosts post : postsList) {
            ForumPageVO vo = new ForumPageVO();
            // 获取账户信息
            User user = userService.getById(post.getAuthorId());
            vo.setAccount(user.getAccount());

            // 直接从ForumPosts对象复制其他字段
            vo.setTag(post.getTag());
            vo.setRating(post.getRating()); // 如果需要字符串形式
            vo.setTitle(post.getTitle());
            vo.setPostId(post.getId());
            vo.setHeat_value(post.getHeatValue());
            // 添加到列表
            posts.add(vo);
        }


        return Result.success(posts);

    }


//    文章阅读
    @ApiOperation("读取文章")
    @GetMapping("post/{id}")
    public Result<ArticleVO> readArtical(@PathVariable int id){
        ArticleVO articleVO =  forumPostsService.readArticle(id);
        return Result.success(articleVO);
    }


//   我的文章功能
    @ApiOperation("我的文章")
    @GetMapping("/MyArticle")
    public Result getMyArticle(@Param("id") int id){
        List<ForumPosts> forumPostsList = forumPostsService.getByAuthorId(id);
        return Result.success(forumPostsList);
    }

//    热门文章功能
    @ApiOperation("热门文章")
    @GetMapping("/getHotPosts")
    public Result getHotPosts(){
        QueryWrapper<ForumPosts> queryWrapper = new QueryWrapper();
        queryWrapper.orderByDesc("heat_value");
        List<ForumPosts> forumPosts = forumPostsService.list(queryWrapper);
        return Result.success(forumPosts);
    }

    //    热门文章功能
    @ApiOperation("优质文章")
    @GetMapping("/getOutStandPosts")
    public Result getOutStandPosts(){

        QueryWrapper<ForumPosts> queryWrapper = new QueryWrapper();
        queryWrapper.orderByDesc("rating");
        List<ForumPosts> forumPosts = forumPostsService.list(queryWrapper);
        return Result.success(forumPosts);
    }


    //  我的收藏
    @ApiOperation("我的收藏")
    @GetMapping("/getMyFavorite")
    public Result getMyFavorite(@Param("id") int id){

       List<ForumPosts> forumPostsList =  forumPostsService.getMyFavorite(id);

        return Result.success(forumPostsList);
    }


//    文章查询
    @ApiOperation("文章查询")
    @GetMapping("/search")
    public Result postSearch(@RequestParam("searchKeyWord") String searchText){

        if (searchText == null){
            return Result.error("不能输入为空噢");
        }
        LambdaQueryWrapper<ForumPosts> lambdaQueryWrapper = new LambdaQueryWrapper<>();

//        TODO:通过LamdaQueryWrapper 模糊查询
        // 模糊查询title字段,%searchText%会被自动添加
        lambdaQueryWrapper.like(ForumPosts::getTitle, searchText);

        // 假设这里有一个service接口用于操作ForumPosts表
        List<ForumPosts> postsList = forumPostsService.list(lambdaQueryWrapper);

        // 根据你的Result类的具体实现,返回查询结果
        return Result.success(postsList);
    }

    /**
     * 标题模糊查询
     * @param keyword 关键词
     * @return 匹配的标题列表
     */
    @GetMapping("/getLikeSearch")
    @ApiOperation("标题模糊查询")
    public Result getLikeSearch(@RequestParam String keyword){
        List<LikeSearchVo> titles = forumPostsService.findTitlesByKeyword(keyword);
        return Result.success(titles);
    }


//    用户交互
    //    点赞
    @ApiOperation("点赞")
    @GetMapping("/like")
    public Result PostLike(@RequestParam("postId") int postId,@RequestParam("userId") int userId){
        String result =  forumPostsService.PostLike(postId,userId);
        return Result.success(result);
    }

//    收藏
    @ApiOperation("收藏")
    @GetMapping("/favorite")
    public Result PostFavorite(@RequestParam("postId") int postId,@RequestParam("userId") int userId){

        String result = forumPostsService.PostFavorite(postId,userId);

        return Result.success(result);
    }

//    写评论
  @ApiOperation("写评论")
  @PostMapping("/writeComment")
   public Result WriteComment(@RequestBody CommentDTO commentdto){

      ForumComments forumComments = new ForumComments();
      BeanUtils.copyProperties(commentdto,forumComments);
      forumCommentsService.save(forumComments);
      return Result.success("评论成功");
  }


//    读评论
    @ApiOperation("读取评论")
    @GetMapping("/getComment")
    public Result<List<CommentVo>> GetComment(@RequestParam("postId") int postId){
        List<CommentVo> comment = forumCommentsService.getComment(postId);
        return Result.success(comment);
    }


}


4.5 Service层
 

public interface ForumPostsService extends IService<ForumPosts> {

    List<ForumPosts> getByAuthorId(Integer id);

    String PostLike(int postId, int userId);

    String PostFavorite(int postId, int userId);

    ArticleVO readArticle(int id);

    List<ForumPosts> getMyFavorite(int id);

    List<LikeSearchVo> findTitlesByKeyword(String keyword);
}
public interface ForumCommentsService extends IService<ForumComments> {

    List<CommentVo> getComment(int postId);
}

4.6 Mapper层

public interface ForumCommentsMapper extends BaseMapper<ForumComments> {

}
@Mapper
public interface ForumPostFavoritesMapper extends BaseMapper<ForumPostFavorites> {
}
@Mapper
public interface ForumPostLikeMapper extends BaseMapper<ForumPostLike> {
}
@Mapper
public interface ForumPostsMapper extends BaseMapper<ForumPosts> {


    @Select("select  * from paitool.user as a,paitool.forum_posts as b where  a.id=b.author_id and a.id = #{id}")
    List<ForumPosts> getByAuthorId(Integer id);
    

}

 


五、进阶思路

1.通过ElasticSearch优化搜索引擎

2.使用Redis存储热门文章,以减少数据库压力

3.通过若依框架+AI 完善管理系统


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1922661.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

统信UOS服务器操作系统离线安装postgresql数据库

原文链接&#xff1a;统信UOS服务器离线安装postgresql数据库 Hello&#xff0c;大家好啊&#xff01;今天给大家带来一篇关于在统信UOS服务器操作系统上离线安装PostgreSQL数据库的文章。PostgreSQL是一款功能强大的开源对象-关系型数据库管理系统。由于某些环境中无法直接访问…

免费开源的工业物联网(IoT)解决方案

什么是 IoT&#xff1f; 物联网 (IoT) 是指由实体设备、车辆、电器和其他实体对象组成的网络&#xff0c;这些实体对象内嵌传感器、软件和网络连接&#xff0c;可以收集和共享数据。 IoT 设备&#xff08;也称为“智能对象”&#xff09;范围广泛&#xff0c;包括智能恒温器等…

SpringBoot+Vue(2)excel后台管理页面

一、需求 SpringBootVue写excel后台管理页面&#xff08;二级页面打开展示每一个excel表&#xff0c;数据库存储字段为“下载、删除、文件详情、是否共享、共享详情”&#xff09; 二、解答 后端(Spring Boot) 1. 项目设置 使用Spring Initializr创建一个新的Spring Boot项目…

深入理解 Elasticsearch 分页技术

原文链接&#xff1a;https://zhuanlan.zhihu.com/p/609576187 Elasticsearch 是一款分布式的搜索引擎&#xff0c;提供了灵活的分页技术。本文主要介绍 Elasticsearch&#xff08;简称 ES&#xff09; 的几种分页技术&#xff0c;并深入分析各种分页技术的优缺点及应用场景。 …

基于AT89C51单片机篮球计时计分器的设计(含文档、源码与proteus仿真,以及系统详细介绍)

本篇文章论述的是基于AT89C51单片机篮球计时计分器的设计的详情介绍&#xff0c;如果对您有帮助的话&#xff0c;还请关注一下哦&#xff0c;如果有资源方面的需要可以联系我。 目录 绪论 原理图 ​编辑 仿真图 系统总体设计图 代码实现 系统论文 资源下载 绪论 本次…

内网服务器通过squid代理访问外网

一、背景 现在要对172.16.58.158服务器进行openssh升级操作,我用之前写好的升级脚本执行后,发现没有备份旧的ssh程序文件,然后还卸载了oenssl-devel,然后我发现其他服务器ssh该服务器失败。同时脚本执行时报错“ configure: error: *** zlib.h missing - please install first …

windows查看局域网所有设备ip

windows如何查看局域网所有设备ip 操作方法 一 . 在搜索栏里输入cmd 二 .在命令行黑窗口输入arp -a 三 . 最上面显示的动态地址就是所有设备ip

day20、21、22补卡

235. 二叉搜索树的最近公共祖先 这道题的解题思路&#xff0c;我想了一会都没想出来&#xff0c;看了题解想&#xff1a;对于二叉搜索树&#xff0c;当我们从上向下去递归遍历&#xff0c;第一次遇到 cur节点是数值在[q, p]区间中&#xff0c;那么cur就是 q和p的最近公共祖先。…

Database数据库 vs Data Warehouse数据仓库 vs Data Mart数据集市 vs Data Lake数据湖

1.DATABASE 数据库 数据库是一个结构化的数据集合&#xff0c;用于存储、管理和检索数据。数据库设计用于支持事务处理&#xff08;OLTP&#xff0c;Online Transaction Processing&#xff09;和日常操作。 数据库通常由数据库管理系统&#xff08;DBMS&#xff09;控制&…

webRtc架构与目录结构

整体架构 目录结构 webrtc Modules目录

基于PCIe总线架构的2路1GSPS AD、4路1GSPS DA信号处理平台(100%国产化)

板卡概述 PCIE723-165是基于PCIE总线架构的2通道1GSPS采样率14位分辨率、4通道1GSPS采样率16位分辨率信号处理平台&#xff0c;该板卡采用国产16nm FPGA作为实时处理器&#xff0c;支持2路高速采集以及4路高速数据回放&#xff0c;板载2组DDR4 SDRAM大容量数据缓存&#xff0c;…

宝兰德参编金融智能体标准,深耕大模型场景化落地

随着数智化浪潮的不断推进&#xff0c;人工智能技术正深刻影响着金融服务的模式和流程&#xff0c;金融智能体在大模型的加持下&#xff0c;业务场景的应用能力得到强化。然而&#xff0c;作为新型技术&#xff0c;金融智能体在隐私保护、透明性、数据泄露等方面仍存在诸多风险…

图片存储问题总结

参考博客&#xff1a; https://blog.csdn.net/BUPT_Kwong/article/details/100972964 今天发现图片保存的一个神奇的问题&#xff0c;就是说原始的jpg图片打开后&#xff0c;重新保存成jpg格式&#xff0c;会发现这个结果不是很对的 example from PIL import Image import n…

房屋出租管理系统小程序需求分析及功能介绍

房屋租赁管理系统适用于写字楼、办公楼、厂区、园区、商城、公寓等商办商业不动产的租赁管理及租赁营销&#xff1b;提供资产管理&#xff0c;合同管理&#xff0c;租赁管理&#xff0c; 物业管理&#xff0c;门禁管理等一体化的运营管理平台&#xff0c;提高项目方管理运营效率…

【qt】QTcpSocket相关的信号

QTcpSocket可以在这里找到相关的信号 进行信号槽的关联 connect():这个信号在connectToHost()被调用并且连接已经成功建立之后发出 disconnected():该信号在套接字断开连接时发出 stateChanged(QAbstractSocket::SocketState socketState):每当QAbstractSocket的状态发生变化…

基于Adaboost的数据分类算法matlab仿真

目录 1.程序功能描述 2.测试软件版本以及运行结果展示 3.核心程序 4.本算法原理 5.完整程序 1.程序功能描述 基于Adaboost的数据分类算法matlab仿真,分别对比线性分类和非线性分类两种方式。 2.测试软件版本以及运行结果展示 MATLAB2022A版本运行 &#xff08;完整程序…

Python - Word转TXT文本,或TXT文本转Word

Word文档&#xff08;.doc或.docx&#xff09;和纯文本文件&#xff08;.txt&#xff09;是两种常用的文件格式。Word文档通常用于复杂的文档处理和排版&#xff0c;而纯文本文件则用于存储和传输纯文本信息。了解如何在这两种格式之间进行转换能提高工作效率&#xff0c;并便于…

Spring Boot中@Async注解的使用及原理 + 常见问题及解决方案

&#x1f604; 19年之后由于某些原因断更了三年&#xff0c;23年重新扬帆起航&#xff0c;推出更多优质博文&#xff0c;希望大家多多支持&#xff5e; &#x1f337; 古之立大事者&#xff0c;不惟有超世之才&#xff0c;亦必有坚忍不拔之志 &#x1f390; 个人CSND主页——Mi…

AV1 编码标准帧间预测技术详细说明

AV1 编码标准帧间预测 AV1&#xff08;AOMedia Video1&#xff09;是一种开源的视频编码格式&#xff0c;它在帧间预测技术上做出了显著的改进和扩展&#xff0c;以提供比现有标准更高的压缩效率和更好的视频质量。以下是AV1帧间预测技术的几个关键点&#xff1a; 参考帧扩展&a…

关于正点原子的alpha开发板的启动函数(汇编,自己的认识)

我傻逼了&#xff0c;这里的注释还是不要用&#xff1b; 全部换成 /* */ 这里就分为两块&#xff0c;一部分是复位中断部分&#xff0c;第二部分就是IRQ部分&#xff08;中断部分最重要&#xff09; 我就围绕着两部分来展开我的认识 首先声明全局 .global_start 在 ARM 架…