Food culture sharing website source code and papers based on springboot vue separation of front-end and back-end

Today, when the Internet is very popular, and because of the increasing number of mobile phones, computers and other devices, everyone can freely share their ideas on the Internet and fully express themselves. It is precisely because in this kind of universal participation Under the general background, if you specifically share and recommend local food, it will definitely be favored by many people. For example, many people have never been to Sichuan. You can build a sharing website for Sichuan food to make it easy for users to communicate with each other. , clean communication is very practical at this time.

This article designs a Sichuan food sharing website based on Springboot with front-end and back-end separation. This system is mainly based on the currently very popular "Little Red Book" software, referencing and improving its functions, and finally realizing this system. The development of this system is carried out strictly in accordance with the ideas of software engineering. First, the system needs to be analyzed, and then the system is designed, and the system functions are divided. Finally, the system is deployed and implemented through software technology, and tested using software. The theoretical ideas are used to conduct comprehensive tests on the system, 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 article have basically been realized, and the system stability and security are also strong. The system development adopts the front-end and back-end separation design of SpringBoot+Vue, so that the interface Simple, easy to understand, and excellently implements various requirements required in system requirements analysis.

【622】Food culture sharing website source code and paper based on springboot vue separation of front and back ends

Keywords: food sharing; Vue; Springboot; B/S development model


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("删除成功");
    }
}

[Administrator] module, table name: admins 

Field name

Field Type

name

id

int

(primary key)

username

varchar(50)

account number

pwd

varchar(50)

password

[User] module, table name: yonghu 

Field name

Field Type

name

id

int

(primary key)

yonghuming

varchar(50)

username

mima

varchar(50)

password

nicheng

varchar(50)

Nick name

xingbie

varchar(10)

gender

touxiang

varchar(255)

avatar

shengri

varchar(25)

Birthday

dianhua

varchar(50)

Telephone

youxiang

varchar(50)

Mail

xingzuo

varchar(50)

constellation

gerenjianjie

text

Personal profile

fangwencishu

int

Visits

ISI

varchar(10)

Whether to review

[Friendly link] Module, table name: youqinglianjie 

Field name

Field Type

name

id

int

(primary key)

wangzhanmingcheng

varchar(50)

Website name

wangzhi

varchar(50)

URL

[Message board] module, table name: liuyanban 

Field name

Field Type

name

id

int

(primary key)

xingming

varchar(50)

Name

lianxidianhua

varchar(50)

contact number

liuyanneirong

text

Message content

liuyanren

varchar(50)

commenter

huifuneirong

text

Reply content

addtime

timestamp

Message Time

zhuangtai

varchar(50)

state

【Carousel】Module, table name: lunbotu 

Field name

Field Type

name

id

int

(primary key)

title

varchar(50)

title

image

varchar(255)

picture

url

varchar(255)

connection address

【点赞】模块,表名: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 字段

Guess you like

Origin blog.csdn.net/weixin_46437112/article/details/135453557