基于springboot vue前后端分离的旅游美景攻略分享网

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

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

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

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

【618】基于springboot vue前后端分离的旅游美景攻略分享网源码和论文


Abstract

Today, with the high popularity of the Internet and the increasing number of mobile phones, computers and other devices, all people can freely share their ideas and fully express themselves on the Internet. This is precisely because in the context of the participation of the whole people, if we share and recommend local tourism beauty, it will be favored by many people, for example, many people have never been there, It is of practical significance to establish a tourism beauty strategy sharing network so that users can communicate with each other simply and cleanly.

This paper designs a travel beauty strategy sharing network based on the front and rear end separation of Springboot. This system is finally realized by referring to and improving its functions, mainly guided by the currently popular "cellular network" software. The development of the system is carried out in strict accordance with the idea of software engineering. First, the system needs analysis, and then the system is designed to divide the system functions. Finally, the system is deployed and implemented through software technology, and the system is tested in an all-round way using the theory of software testing, including but not limited to performance testing, security testing, stability testing, etc.

To sum up, the functions of the tourism beauty strategy sharing network designed and developed in this paper have basically been realized, and the system stability and security have also been strengthened. The system development adopts the front and rear end separation design of SpringBoot+Vue, which makes the interface simple and easy to understand, and effectively realizes various requirements required in the system requirements analysis.

Key words: sharing of tourism beauty; Vue; Springboot; B/S development mode

package com.spring.controller;

import com.jntoo.db.*;
import com.jntoo.db.utils.*;
import com.spring.dao.*;
import com.spring.entity.*;
import com.spring.service.*;
import com.spring.util.*;
import com.spring.util.Info;
import java.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import tk.mybatis.mapper.entity.Example;

/**
 * 分享笔记 */
@Controller
public class FenxiangbijiController extends BaseController {

    @Autowired
    private FenxiangbijiMapper dao;

    @Autowired
    private FenxiangbijiService service;

    /**
     *  后台列表页
     *
     */
    @RequestMapping("/fenxiangbiji_list")
    public String list() {
        // 检测是否有登录,没登录则跳转到登录页面
        if (!checkLogin()) {
            return showError("尚未登录", "./login.do");
        }

        String order = Request.get("order", "id"); // 获取前台提交的URL参数 order  如果没有则设置为id
        String sort = Request.get("sort", "desc"); // 获取前台提交的URL参数 sort  如果没有则设置为desc
        int pagesize = Request.getInt("pagesize", 12); // 获取前台一页多少行数据
        Example example = new Example(Fenxiangbiji.class); //  创建一个扩展搜索类
        Example.Criteria criteria = example.createCriteria(); // 创建一个扩展搜索条件类
        String where = " 1=1 "; // 创建初始条件为:1=1
        where += getWhere(); // 从方法中获取url 上的参数,并写成 sql条件语句
        criteria.andCondition(where); // 将条件写进上面的扩展条件类中
        if (sort.equals("desc")) { // 判断前台提交的sort 参数是否等于  desc倒序  是则使用倒序,否则使用正序
            example.orderBy(order).desc(); // 把sql 语句设置成倒序
        } else {
            example.orderBy(order).asc(); // 把 sql 设置成正序
        }
        int page = request.getParameter("page") == null ? 1 : Integer.valueOf(request.getParameter("page")); // 获取前台提交的URL参数 page  如果没有则设置为1
        page = Math.max(1, page); // 取两个数的最大值,防止page 小于1
        List<Fenxiangbiji> list = service.selectPageExample(example, page, pagesize); // 获取当前页的行数

        // 将列表写给界面使用
        assign("totalCount", request.getAttribute("totalCount"));
        assign("list", list);
        assign("orderby", order); // 把当前排序结果写进前台
        assign("sort", sort); // 把当前排序结果写进前台
        return json(); // 将数据写给前端
    }

    public String getWhere() {
        _var = new LinkedHashMap(); // 重置数据
        String where = " ";
        // 以下也是一样的操作,判断是否符合条件,符合则写入sql 语句
        if (!Request.get("fenxiangbianhao").equals("")) {
            where += " AND fenxiangbianhao LIKE '%" + Request.get("fenxiangbianhao") + "%' ";
        }
        if (!Request.get("fenxiangbiaoti").equals("")) {
            where += " AND fenxiangbiaoti LIKE '%" + Request.get("fenxiangbiaoti") + "%' ";
        }
        if (!Request.get("fenxiangfenlei").equals("")) {
            where += " AND fenxiangfenlei ='" + Request.get("fenxiangfenlei") + "' ";
        }
        return where;
    }

    /**
     * 分享用户列表
     */
    @RequestMapping("/fenxiangbiji_list_fenxiangyonghu")
    public String listfenxiangyonghu() {
        // 检测是否有登录,没登录则跳转到登录页面
        if (!checkLogin()) {
            return showError("尚未登录", "./login.do");
        }
        String order = Request.get("order", "id"); // 获取前台提交的URL参数 order  如果没有则设置为id
        String sort = Request.get("sort", "desc"); // 获取前台提交的URL参数 sort  如果没有则设置为desc
        int pagesize = Request.getInt("pagesize", 12); // 获取前台一页多少行数据

        Example example = new Example(Fenxiangbiji.class); //  创建一个扩展搜索类
        Example.Criteria criteria = example.createCriteria(); // 创建一个扩展搜索条件类
        // 初始化一个条件,条件为:分享用户=当前登录用户
        String where = " fenxiangyonghu='" + request.getSession().getAttribute("username") + "' ";
        where += getWhere();

        criteria.andCondition(where); // 将条件写入
        if (sort.equals("desc")) { // 注释同list
            example.orderBy(order).desc(); // 注释同list
        } else {
            example.orderBy(order).asc(); // 注释同list
        }

        int page = request.getParameter("page") == null ? 1 : Integer.valueOf(request.getParameter("page")); // 注释同list
        page = Math.max(1, page); // 注释同list

        List<Fenxiangbiji> list = service.selectPageExample(example, page, pagesize);
        assign("totalCount", request.getAttribute("totalCount"));
        assign("list", list);
        assign("orderby", order);
        assign("sort", sort);
        return json(); // 将数据写给前端
    }

    /**
     *  前台列表页
     *
     */
    @RequestMapping("/fenxiangbijilist")
    public String index() {
        String order = Request.get("order", "id");
        String sort = Request.get("sort", "desc");
        int pagesize = Request.getInt("pagesize", 12); // 获取前台一页多少行数据

        Example example = new Example(Fenxiangbiji.class);
        Example.Criteria criteria = example.createCriteria();
        String where = " 1=1 ";
        where += " AND issh='是' ";
        where += getWhere();
        criteria.andCondition(where);
        if (sort.equals("desc")) {
            example.orderBy(order).desc();
        } else {
            example.orderBy(order).asc();
        }
        int page = request.getParameter("page") == null ? 1 : Integer.valueOf(request.getParameter("page"));
        page = Math.max(1, page);
        List<Fenxiangbiji> list = service.selectPageExample(example, page, pagesize);

        assign("totalCount", request.getAttribute("totalCount"));
        assign("list", list);
        assign("where", where);
        assign("orderby", order);
        assign("sort", sort);
        return json();
    }

    @RequestMapping("/fenxiangbiji_add")
    public String add() {
        _var = new LinkedHashMap(); // 重置数据

        return json(); // 将数据写给前端
    }

    @RequestMapping("/fenxiangbiji_updt")
    public String updt() {
        _var = new LinkedHashMap(); // 重置数据
        int id = Request.getInt("id");
        // 获取行数据,并赋值给前台jsp页面
        Fenxiangbiji mmm = service.find(id);
        assign("mmm", mmm);
        assign("updtself", 0);

        return json(); // 将数据写给前端
    }

    /**
     * 添加内容
     * @return
     */
    @RequestMapping("/fenxiangbijiinsert")
    public String insert() {
        _var = new LinkedHashMap(); // 重置数据
        String tmp = "";
        Fenxiangbiji post = new Fenxiangbiji(); // 创建实体类
        // 设置前台提交上来的数据到实体类中
        post.setFenxiangbianhao(Request.get("fenxiangbianhao"));

        post.setFenxiangbiaoti(Request.get("fenxiangbiaoti"));

        post.setFenxiangfenlei(Request.get("fenxiangfenlei"));

        post.setFenxiangtupian(Request.get("fenxiangtupian"));

        post.setFenxiangneirong(Info.download(Request.get("fenxiangneirong")));

        post.setFenxiangyonghu(Request.get("fenxiangyonghu"));

        post.setLiulancishu(Request.getInt("liulancishu"));

        post.setPingluncishu(Request.getInt("pingluncishu"));

        post.setIssh("否");

        service.insert(post); // 插入数据
        int charuid = post.getId().intValue();

        if (isAjax()) {
            return jsonResult(post);
        }
        return showSuccess("保存成功", Request.get("referer").equals("") ? request.getHeader("referer") : Request.get("referer"));
    }

    /**
     * 更新内容
     * @return
     */
    @RequestMapping("/fenxiangbijiupdate")
    public String update() {
        _var = new LinkedHashMap(); // 重置数据
        // 创建实体类
        Fenxiangbiji post = new Fenxiangbiji();
        // 将前台表单数据填充到实体类
        if (!Request.get("fenxiangbianhao").equals("")) post.setFenxiangbianhao(Request.get("fenxiangbianhao"));
        if (!Request.get("fenxiangbiaoti").equals("")) post.setFenxiangbiaoti(Request.get("fenxiangbiaoti"));
        if (!Request.get("fenxiangfenlei").equals("")) post.setFenxiangfenlei(Request.get("fenxiangfenlei"));
        if (!Request.get("fenxiangtupian").equals("")) post.setFenxiangtupian(Request.get("fenxiangtupian"));
        if (!Request.get("fenxiangneirong").equals("")) post.setFenxiangneirong(Info.download(Request.get("fenxiangneirong")));
        if (!Request.get("fenxiangyonghu").equals("")) post.setFenxiangyonghu(Request.get("fenxiangyonghu"));
        if (!Request.get("liulancishu").equals("")) post.setLiulancishu(Request.getInt("liulancishu"));
        if (!Request.get("pingluncishu").equals("")) post.setPingluncishu(Request.getInt("pingluncishu"));

        post.setId(Request.getInt("id"));
        service.update(post); // 更新数据
        int charuid = post.getId().intValue();

        if (isAjax()) {
            return jsonResult(post);
        }

        return showSuccess("保存成功", Request.get("referer")); // 弹出保存成功,并跳转到前台提交的 referer 页面
    }

    /**
     *  后台详情
     */
    @RequestMapping("/fenxiangbiji_detail")
    public String detail() {
        _var = new LinkedHashMap(); // 重置数据
        int id = Request.getInt("id");
        Fenxiangbiji map = service.find(id); // 根据前台url 参数中的id获取行数据
        assign("map", map); // 把数据写到前台
        return json(); // 将数据写给前端
    }

    /**
     *  前台详情
     */
    @RequestMapping("/fenxiangbijidetail")
    public String detailweb() {
        _var = new LinkedHashMap(); // 重置数据
        int id = Request.getInt("id");
        Fenxiangbiji map = service.find(id);

        Query.execute("update fenxiangbiji set liulancishu=liulancishu+1 where id='" + request.getParameter("id") + "'");

        Query.execute(
            "insert into liulanjilu(neirongid,biao,biaoti,fenlei,nicheng,liulanyonghu) select id,'fenxiangbiji',fenxiangbiaoti,fenxiangfenlei,'" +
            request.getSession().getAttribute("nicheng") +
            "','" +
            request.getSession().getAttribute("username") +
            "' FROM fenxiangbiji WHERE id='" +
            request.getParameter("id") +
            "' AND 'null'!='" +
            request.getSession().getAttribute("username") +
            "'"
        );

        assign(
            "comments",
            DB.select(
                "SELECT pl.*,u.touxiang,u.nicheng FROM pinglun pl LEFT JOIN yonghu AS u ON pl.pinglunren=u.yonghuming where pl.biao='fenxiangbiji' AND pl.biaoid=? ORDER BY pl.id desc",id
            )
        );

        assign("shoucangCount", Query.make("shoucang").where("biao", "fenxiangbiji").where("xwid", id).count());
        if (!checkLogin()) {
            assign("is_shoucang", false);
        } else {
            assign("is_shoucang", Query.make("shoucang").where("username", session.getAttribute("username")).where("biao", "fenxiangbiji").where("xwid", id).count() > 0);
        }
        assign("dianzanCount", Query.make("dianzan").where("biao", "fenxiangbiji").where("biaoid", id).count());
        if (!checkLogin()) {
            assign("is_dianzan", false);
        } else {
            assign("is_dianzan", Query.make("dianzan").where("username", session.getAttribute("username")).where("biao", "fenxiangbiji").where("biaoid", id).count() > 0);
        }

        assign("map", map);
        return json(); // 将数据写给前端
    }

    /**
     *  删除
     */
    @RequestMapping("/fenxiangbiji_delete")
    public String delete() {
        _var = new LinkedHashMap(); // 重置数据
        if (!checkLogin()) {
            return showError("尚未登录");
        }
        int id = Request.getInt("id"); // 根据id 删除某行数据
        Map map = Query.make("fenxiangbiji").find(id);

        service.delete(id); // 根据id 删除某行数据
        return showSuccess("删除成功", request.getHeader("referer")); //弹出删除成功,并跳回上一页
    }
}
package com.spring.controller;

import com.jntoo.db.*;
import com.jntoo.db.utils.*;
import com.spring.dao.*;
import com.spring.entity.*;
import com.spring.service.*;
import com.spring.util.*;
import com.spring.util.Info;
import java.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import tk.mybatis.mapper.entity.Example;

/**
 * 收藏 */
@Controller
public class ShoucangController extends BaseController {

    @Autowired
    private ShoucangMapper dao;

    @Autowired
    private ShoucangService service;

    /**
     *  后台列表页
     *
     */
    @RequestMapping("/shoucang_list")
    public String list() {
        // 检测是否有登录,没登录则跳转到登录页面
        if (!checkLogin()) {
            return showError("尚未登录", "./login.do");
        }

        String order = Request.get("order", "id"); // 获取前台提交的URL参数 order  如果没有则设置为id
        String sort = Request.get("sort", "desc"); // 获取前台提交的URL参数 sort  如果没有则设置为desc
        int pagesize = Request.getInt("pagesize", 12); // 获取前台一页多少行数据
        Example example = new Example(Shoucang.class); //  创建一个扩展搜索类
        Example.Criteria criteria = example.createCriteria(); // 创建一个扩展搜索条件类
        String where = " 1=1 "; // 创建初始条件为:1=1
        where += getWhere(); // 从方法中获取url 上的参数,并写成 sql条件语句
        criteria.andCondition(where); // 将条件写进上面的扩展条件类中
        if (sort.equals("desc")) { // 判断前台提交的sort 参数是否等于  desc倒序  是则使用倒序,否则使用正序
            example.orderBy(order).desc(); // 把sql 语句设置成倒序
        } else {
            example.orderBy(order).asc(); // 把 sql 设置成正序
        }
        int page = request.getParameter("page") == null ? 1 : Integer.valueOf(request.getParameter("page")); // 获取前台提交的URL参数 page  如果没有则设置为1
        page = Math.max(1, page); // 取两个数的最大值,防止page 小于1
        List<Shoucang> list = service.selectPageExample(example, page, pagesize); // 获取当前页的行数

        // 将列表写给界面使用
        assign("totalCount", request.getAttribute("totalCount"));
        assign("list", list);
        assign("orderby", order); // 把当前排序结果写进前台
        assign("sort", sort); // 把当前排序结果写进前台
        return json(); // 将数据写给前端
    }

    public String getWhere() {
        _var = new LinkedHashMap(); // 重置数据
        String where = " ";
        // 以下也是一样的操作,判断是否符合条件,符合则写入sql 语句
        if (!Request.get("biaoti").equals("")) {
            where += " AND biaoti LIKE '%" + Request.get("biaoti") + "%' ";
        }
        return where;
    }

    /**
     * 用户列表
     */
    @RequestMapping("/shoucang_list_username")
    public String listusername() {
        // 检测是否有登录,没登录则跳转到登录页面
        if (!checkLogin()) {
            return showError("尚未登录", "./login.do");
        }
        String order = Request.get("order", "id"); // 获取前台提交的URL参数 order  如果没有则设置为id
        String sort = Request.get("sort", "desc"); // 获取前台提交的URL参数 sort  如果没有则设置为desc
        int pagesize = Request.getInt("pagesize", 12); // 获取前台一页多少行数据

        Example example = new Example(Shoucang.class); //  创建一个扩展搜索类
        Example.Criteria criteria = example.createCriteria(); // 创建一个扩展搜索条件类
        // 初始化一个条件,条件为:用户=当前登录用户
        String where = " username='" + request.getSession().getAttribute("username") + "' ";
        where += getWhere();

        criteria.andCondition(where); // 将条件写入
        if (sort.equals("desc")) { // 注释同list
            example.orderBy(order).desc(); // 注释同list
        } else {
            example.orderBy(order).asc(); // 注释同list
        }

        int page = request.getParameter("page") == null ? 1 : Integer.valueOf(request.getParameter("page")); // 注释同list
        page = Math.max(1, page); // 注释同list

        List<Shoucang> list = service.selectPageExample(example, page, pagesize);
        assign("totalCount", request.getAttribute("totalCount"));
        assign("list", list);
        assign("orderby", order);
        assign("sort", sort);
        return json(); // 将数据写给前端
    }

    @RequestMapping("/shoucang_add")
    public String add() {
        _var = new LinkedHashMap(); // 重置数据

        return json(); // 将数据写给前端
    }

    /**
     * 添加内容
     * @return
     */
    @RequestMapping("/shoucanginsert")
    public String insert() {
        _var = new LinkedHashMap(); // 重置数据
        String tmp = "";
        Shoucang post = new Shoucang(); // 创建实体类
        // 设置前台提交上来的数据到实体类中
        post.setUsername((String) session.getAttribute("username"));

        post.setXwid(Request.getInt("xwid"));

        post.setBiao(Request.get("biao"));

        post.setBiaoti(Request.get("biaoti"));

        post.setAddtime(Info.getDateStr());

        Map res = Query.make("shoucang").where("biao", Request.get("biao")).where("xwid", Request.get("xwid")).where("username", session.getAttribute("username")).find();
        if (res != null && !res.isEmpty()) {
            Query.make("shoucang").where("id", res.get("id")).delete();
            return showSuccess("已取消收藏");
        }

        service.insert(post); // 插入数据
        int charuid = post.getId().intValue();
        Query.execute(
            "update fenxiangbiji set shoucangshu=shoucangshu+1 where id='" + request.getParameter("xwid") + "' and '" + request.getParameter("biao") + "'='meishifenxiang'"
        );

        if (isAjax()) {
            return jsonResult(post);
        }
        return showSuccess("保存成功", Request.get("referer").equals("") ? request.getHeader("referer") : Request.get("referer"));
    }

    /**
     * 更新内容
     * @return
     */
    @RequestMapping("/shoucangupdate")
    public String update() {
        _var = new LinkedHashMap(); // 重置数据
        // 创建实体类
        Shoucang post = new Shoucang();
        // 将前台表单数据填充到实体类
        if (!Request.get("username").equals("")) post.setUsername(Request.get("username"));
        if (!Request.get("xwid").equals("")) post.setXwid(Request.getInt("xwid"));
        if (!Request.get("biao").equals("")) post.setBiao(Request.get("biao"));
        if (!Request.get("biaoti").equals("")) post.setBiaoti(Request.get("biaoti"));
        if (!Request.get("addtime").equals("")) post.setAddtime(Request.get("addtime"));

        post.setId(Request.getInt("id"));
        service.update(post); // 更新数据
        int charuid = post.getId().intValue();

        if (isAjax()) {
            return jsonResult(post);
        }

        return showSuccess("保存成功", Request.get("referer")); // 弹出保存成功,并跳转到前台提交的 referer 页面
    }

    @RequestMapping("/shoucang_batch")
    public String batch() {
        _var = new LinkedHashMap(); // 重置数据
        if (
            request.getParameter("delete") != null
        ) { // 执行批量删除,根据前台表单的选项 生成 数组ids
            String[] ids = request.getParameterValues("ids"); // 获取前台选择的复选框
            if (ids != null) Query.make("shoucang").where("id", "in", ids).delete(); // 执行删除
        }
        return showSuccess("批量处理成功", request.getHeader("referer")); //弹出批量处理成功,并调回上一页
    }

    /**
     *  删除
     */
    @RequestMapping("/shoucang_delete")
    public String delete() {
        _var = new LinkedHashMap(); // 重置数据
        if (!checkLogin()) {
            return showError("尚未登录");
        }
        int id = Request.getInt("id"); // 根据id 删除某行数据
        Map map = Query.make("shoucang").find(id);

        service.delete(id); // 根据id 删除某行数据
        return showSuccess("删除成功", request.getHeader("referer")); //弹出删除成功,并跳回上一页
    }
}

猜你喜欢

转载自blog.csdn.net/weixin_46437112/article/details/135404623
今日推荐