基于springboot vue前后端分离的美食文化分享网站源码和论文

在互联网普及度非常高的今天,也因为手机、计算机等设备的越来越多,所有人都可以在网络上肆意分享自己的想法,充分的进行自我表达,正是因为在这种全民参与的大背景下,如果专门针对地方美食进行分享推荐,那么一定是会受到很多人青睐的,比如就好多人没有去过四川而言,可以建立一个四川美食的分享网站,让用户和用户之间简单、干净的进行沟通,这时候很有实际意义的。

本文设计了一个基于Springboot的前后端分离的四川美食分享网站,该系统主要是以当下非常火爆的“小红书”软件为引,参考并完善他的功能,最终实现的这个系统。该系统开发严格按照软件工程的思想来进行,首先对系统进行需求分析,之后再对该系统进行系统设计,将系统功能划分出来,最后通过软件技术对该系统进行部署、实现,并使用软件测试的理论思想对该系统进行全方位的测试,包括但不限于性能测试、安全测试、稳定性测试等。

综上所述,本文所设计并开发的四川美食文化分享网站的功能基本上都实现了,系统稳定性、安全性也有一定的力度,系统开发采用了SpringBoot+Vue的前后端分离设计,让界面简单、易懂,出色的实现了系统需求分析中所要求的各种需求。

【622】基于springboot vue前后端分离的美食文化分享网站源码和论文

关键词:美食分享;Vue;Springboot;B/S开发模式


Abstract

In recent years, with the popularity of the Internet and the increasing number of mobile phones, computers and other devices, everyone can freely share their ideas and fully express themselves on the Internet. It is precisely because under the background of national participation, if sharing and recommending local cuisine, it will be favored by many people. For example, many people have not been to Sichuan, At this time, it is meaningful to establish a clean and practical website for users to share delicious food.

This paper designs a Sichuan food sharing website based on the separation of front and rear ends of springboot. The system is mainly guided by the current very popular "little red book" software, refers to and improves its functions, and finally realizes the system. The development of the system is carried out in strict accordance with the idea of software engineering. Firstly, the requirements of the system are analyzed, and then the system is designed to divide the system functions. Finally, the system is deployed and realized through software technology, and the theoretical idea of software testing is used to test the system in an all-round way, including but not limited to performance testing, security testing, stability testing, etc.

To sum up, the functions of the Sichuan food culture sharing website designed and developed in this paper have been basically realized, and the system stability and security have a certain strength. The system development adopts the front and rear end separation design of springboot + Vue, which makes the interface simple and easy to understand, and excellently realizes various requirements required in the system requirements analysis.

Key words: food sharing; Vue; Springboot; B / S development mode

package com.javaDemo.houserent.controller.backend;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.javaDemo.houserent.common.base.BaseController;
import com.javaDemo.houserent.common.constant.Constant;
import com.javaDemo.houserent.common.dto.JsonResult;
import com.javaDemo.houserent.common.enums.HouseStatusEnum;
import com.javaDemo.houserent.common.utils.PageUtil;
import com.javaDemo.houserent.entity.House;
import com.javaDemo.houserent.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * 房子控制器
 */
@Controller
@RequestMapping("/admin")
public class HouseController extends BaseController {

    @Autowired
    private HouseService houseService;


    /**
     * 进入房子管理页面
     */
    @RequestMapping("/house")
    public String houseList(
            @RequestParam(value = "page",defaultValue = "1") Long pageNumber,
            @RequestParam(value = "size",defaultValue = "6") Long pageSize,
            Model model){
        Page page = PageUtil.initMpPage(pageNumber,pageSize);
        House condition = new House();
        //判断用户是否登录,拦截器
        if(getLoginUser()==null){
            return "front/index";
        }
        //如果登录用户时管理员,可以查询所有房子;如果登录用户不是管理员,只能查询自己的房子
        if(!loginUserIsAdmin()){
            condition.setUserId(getLoginUserId());
        }
        Page<House> housePage = houseService.findAll(page,condition);
        model.addAttribute("pageInfo",housePage);
        model.addAttribute("pagePrefix","/admin/house?");
        model.addAttribute("isAdmin",loginUserIsAdmin());
        model.addAttribute("tab","house-list");
        return "admin/house-list";
    }

    /**
     * 进入房子发布页面
     */
    @RequestMapping("/publish")
    public String publish(
            @RequestParam(value = "id",required = false) Long id,
            Model model){
        //判断用户是否登录,拦截器
        if(getLoginUser()==null){
            return "front/index";
        }
        House house = new House();
        //编辑页面
        if(id != null){
            house = houseService.get(id);
            if(house == null){
                return renderNotFond();
            }
            //如果编辑别人的房子,并且没有管理员权限,跳转403
            if(!loginUserIsAdmin() && Objects.equals(house.getUserId(), getLoginUserId())){
                return renderNotAllowAccsee();
            }

        }
        model.addAttribute("house",house);
        return "admin/house-publish";
    }

    /**
     * 发布房子提交
     */
    @RequestMapping("/publish/submit")
    @ResponseBody
    public JsonResult publishSubmit(House house,@RequestParam("key")String key,
                                    HttpSession session){
        try{
            if(house.getId() == null){  //新增
                house.setCreateTime(new Date());
                house.setUserId(getLoginUserId());
            }else {                     //修改
                House queryHouse = houseService.get(house.getId());
                if(queryHouse == null){
                    return JsonResult.error("修改失败,没有这个房子");
                }
                //如果编辑别人的房子,并且没有管理员权限,跳转403
                if(!loginUserIsAdmin() && !Objects.equals(house.getUserId(), getLoginUserId())){
                    return JsonResult.error("你不能编辑别人的房子");
                }
            }
            house.setStatus(HouseStatusEnum.NOT_CHECK.getValue());
            //获取轮播图
            String sessionKey = Constant.SESSION_IMG_PREFIX + key;
            List<String> imgList = (List<String>) session.getAttribute(sessionKey);
            if(imgList != null && imgList.size()>0){
                //把轮播图转换成json格式存储
                house.setSlideUrl(JSON.toJSONString(imgList));
                //把轮播图的第一个图放到缩略图中
                house.setThumbnailUrl(imgList.get(0));
            }
            houseService.insertOrUpdate(house);
        }catch (Exception e){
            return JsonResult.error("发布失败,请填写完整信息");
        }
        return JsonResult.success("发布成功",house.getId());
    }


    /**
     * 下架房子
     */
    @RequestMapping("/down")
    @ResponseBody
    public JsonResult downHouse(@RequestParam("id")long id){
        try{
            House house = houseService.get(id);
            if(house == null){
                return JsonResult.error("没有这个房子");
            }
            //如果下架别人的房子,并且没有管理员权限,跳转403
            if(!loginUserIsAdmin() && !Objects.equals(house.getUserId(), getLoginUserId())){
                return JsonResult.error("你不能下架别人的房子");
            }
            if(Objects.equals(house.getStatus(), HouseStatusEnum.HAS_RENT.getValue())){
                return JsonResult.error("房子正在租住中,不能下架");
            }
            house.setStatus(HouseStatusEnum.HAS_DOWN.getValue());
            houseService.update(house);
        }catch (Exception e){
            return JsonResult.error("下架失败");
        }
        return JsonResult.success("下架成功");
    }

    /**
     * 上架房子
     */
    @RequestMapping("/up")
    @ResponseBody
    public JsonResult upHouse(@RequestParam("id")long id){
        try{
            House house = houseService.get(id);
            if(house == null){
                return JsonResult.error("没有这个房子");
            }
            //如果下架别人的房子,并且没有管理员权限,跳转403
            if(!loginUserIsAdmin() && !Objects.equals(house.getUserId(), getLoginUserId())){
                return JsonResult.error("你不能上架别人的房子");
            }
            if(Objects.equals(house.getStatus(), HouseStatusEnum.HAS_RENT.getValue())){
                return JsonResult.error("房子正在租住中,不能上架");
            }
            house.setStatus(HouseStatusEnum.NOT_RENT.getValue());
            houseService.update(house);
        }catch (Exception e){
            return JsonResult.error("上架失败");
        }
        return JsonResult.success("上架成功");
    }

    /**
     * 房子审核通过
     */
    @RequestMapping("/checkPass")
    @ResponseBody
    public JsonResult checkPassHouse(@RequestParam("id")long id){
        try{
            House house = houseService.get(id);
            if(house == null){
                return JsonResult.error("没有这个房子");
            }
            //只有管理员有权限审核
            if(!loginUserIsAdmin()){
                return JsonResult.error("你没有权限审核");
            }
            if(!Objects.equals(house.getStatus(), HouseStatusEnum.NOT_CHECK.getValue())){
                return JsonResult.error("只能审核待审核的房子");
            }
            house.setStatus(HouseStatusEnum.NOT_RENT.getValue());
            houseService.update(house);
        }catch (Exception e){
            return JsonResult.error("审核失败");
        }
        return JsonResult.success("审核成功");
    }

    /**
     * 房子审核不通过
     */
    @RequestMapping("/checkReject")
    @ResponseBody
    public JsonResult checkRejectHouse(@RequestParam("id")long id){
        try{
            House house = houseService.get(id);
            if(house == null){
                return JsonResult.error("没有这个房子");
            }
            //只有管理员有权限审核
            if(!loginUserIsAdmin()){
                return JsonResult.error("你没有权限审核");
            }
            if(!Objects.equals(house.getStatus(), HouseStatusEnum.NOT_CHECK.getValue())){
                return JsonResult.error("只能审核待审核的房子");
            }
            house.setStatus(HouseStatusEnum.CHECK_REJECT.getValue());
            houseService.update(house);
        }catch (Exception e){
            return JsonResult.error("审核失败");
        }
        return JsonResult.success("驳回成功");
    }


    /**
     * 删除房子
     */
    @RequestMapping("/delete")
    @ResponseBody
    public JsonResult deleteHouse(@RequestParam("id")long id){
        try{
            House house = houseService.get(id);
            if(house == null){
                return JsonResult.error("没有这个房子");
            }
            //如果删除别人的房子,并且没有管理员权限,跳转403
            if(!loginUserIsAdmin() && !Objects.equals(house.getUserId(), getLoginUserId())){
                return JsonResult.error("这不是你的房子,你没有权限删除");
            }
            if(Objects.equals(house.getStatus(), HouseStatusEnum.HAS_RENT.getValue())){
                return JsonResult.error("房子正在租住中,不能删除");
            }
            houseService.delete(id);
        }catch (Exception e){
            return JsonResult.error("删除房子失败");
        }
        return JsonResult.success("删除成功");
    }
}

【管理员】模块,表名:admins 

字段名

字段类型

名称

id

int

(主键)

username

varchar(50)

帐号

pwd

varchar(50)

密码

【用户】模块,表名:yonghu 

字段名

字段类型

名称

id

int

(主键)

yonghuming

varchar(50)

用户名

mima

varchar(50)

密码

nicheng

varchar(50)

昵称

xingbie

varchar(10)

性别

touxiang

varchar(255)

头像

shengri

varchar(25)

生日

dianhua

varchar(50)

电话

youxiang

varchar(50)

邮箱

xingzuo

varchar(50)

星座

gerenjianjie

text

个人简介

fangwencishu

int

访问次数

issh

varchar(10)

是否审核

【友情链接】模块,表名:youqinglianjie 

字段名

字段类型

名称

id

int

(主键)

wangzhanmingcheng

varchar(50)

网站名称

wangzhi

varchar(50)

网址

【留言板】模块,表名:liuyanban 

字段名

字段类型

名称

id

int

(主键)

xingming

varchar(50)

姓名

lianxidianhua

varchar(50)

联系电话

liuyanneirong

text

留言内容

liuyanren

varchar(50)

留言人

huifuneirong

text

回复内容

addtime

timestamp

留言时间

zhuangtai

varchar(50)

状态

【轮播图】模块,表名:lunbotu 

字段名

字段类型

名称

id

int

(主键)

title

varchar(50)

标题

image

varchar(255)

图片

url

varchar(255)

连接地址

【点赞】模块,表名:dianzan 

字段名

字段类型

名称

id

int

(主键)

username

varchar(50)

用户

biaoid

int

关联表id

biao

varchar(50)

关联表

biaoti

varchar(255)

标题

addtime

timestamp

点赞时间

【收藏】模块,表名:shoucang 

字段名

字段类型

名称

id

int

(主键)

username

varchar(50)

用户

xwid

int

关联表id

biao

varchar(50)

关联表

biaoti

varchar(255)

标题

addtime

timestamp

收藏时间

【笔记分类】模块,表名:bijifenlei 

字段名

字段类型

名称

id

int

(主键)

fenleimingcheng

varchar(255)

分类名称

【分享笔记】模块,表名:fenxiangbiji 

字段名

字段类型

名称

id

int

(主键)

fenxiangbianhao

varchar(50)

分享编号

fenxiangbiaoti

varchar(50)

分享标题

fenxiangfenlei

int

分享分类

fenxiangtupian

varchar(255)

分享图片

fenxiangneirong

longtext

分享内容

fenxiangyonghu

varchar(50)

分享用户

liulancishu

int

浏览次数

pingluncishu

int

评论次数

issh

varchar(10)

是否审核

设置索引, 字段:fenxiangfenlei , 关联表【bijifenlei】中的id 字段

【公告信息】模块,表名:gonggaoxinxi 

字段名

字段类型

名称

id

int

(主键)

bianhao

varchar(50)

编号

biaoti

varchar(50)

标题

neirong

longtext

内容

faburen

varchar(50)

发布人

addtime

timestamp

发布时间

【敏感词】模块,表名:minganci 

字段名

字段类型

名称

id

int

(主键)

guanjianzi

varchar(50)

关键字

tihuanci

varchar(50)

替换词

addtime

timestamp

添加时间

【评论】模块,表名:pinglun 

字段名

字段类型

名称

id

int

(主键)

biao

varchar(50)

biaoid

int

表id

biaoti

varchar(255)

标题

pinglunneirong

text

评论内容

pinglunren

varchar(50)

评论人

addtime

timestamp

评论时间

【评论回复】模块,表名:pinglunhuifu 

字段名

字段类型

名称

id

int

(主键)

pinglunid

int

评论id

biao

varchar(50)

biaoid

int

表id

biaoti

varchar(255)

标题

pinglunneirong

text

评论内容

pinglunren

varchar(50)

评论人

huifuneirong

text

回复内容

huifuren

varchar(50)

回复人

addtime

timestamp

回复时间

设置索引, 字段:pinglunid , 关联表【pinglun】中字段id

【浏览记录】模块,表名:liulanjilu 

字段名

字段类型

名称

id

int

(主键)

neirongid

longtext

内容id

biao

varchar(50)

fenlei

int

分类

biaoti

varchar(255)

标题

xingming

varchar(50)

姓名

liulanyonghu

varchar(50)

浏览用户

addtime

timestamp

浏览时间

设置索引, 字段:fenlei , 关联表【bijifenlei】中的id 字段

猜你喜欢

转载自blog.csdn.net/weixin_46437112/article/details/135453557