基于springboot vue前后端分离的旅游网站

随着旅游行业的不断发展,各家旅游行业之间的竞争日益激烈,旅游部门所需的信息量越来越大,业务操作中涉及的各种线路情况、客户情况以及旅游协作部门的情况越来越复杂多变。而除了一些个别地区已采用了的旅游网站,一般通常是以原始的手工方式处理/交流信息。但工作人员若仅靠手工方式处理大量资料,很可能带来出错率的增长以及量资源的浪费和闲置等问题。因此,只有加强对旅游信息资源的整合、统一管理,才能使旅游部门运行更加合理、高效地运转。

论文主要围绕旅游网站的设计与实现展开研究,遵循软件工程设 计流程,在需求分析的基础上,明确了旅游网站的各项功能。利用springboot、 VUE等技术,设计实现了一个基于B/S模式的旅游网站,可完成用户管理、景点推荐管理、景点预订信息、旅游路线管理、旅游路线预订信息、酒店管理、酒店预订信息、旅游攻略管理、我的收藏、留言管理、管理员管理等功能,并对该旅游网站的各个功能模块进行测试。所设计的用户操作界面布局合理、交互友好。

关键字: 旅游网站;B/S模式;springboot;mysql

【722】基于springboot vue前后端分离的旅游网站设计与实现

ABSTRACT

With the continuous development of the tourism industry, the competition between various tourism industries is becoming increasingly fierce. The amount of information required by tourism departments is growing. The various routes, customers and tourism cooperation departments involved in business operations are becoming more and more complex and changeable. Except for some tourism websites that have been adopted in some regions, information is usually processed/exchanged in the original manual way. However, if the staff only handle a large amount of data manually, it is likely to bring about the growth of error rate and the waste and idleness of resources. Therefore, only by strengthening the integration and unified management of tourism information resources can tourism departments operate more reasonably and efficiently.

The paper mainly focuses on the design and implementation of tourism websites, follows the software engineering design process, and clarifies the functions of the personnel management system on the basis of demand analysis. Using spring boot, VUE and other technologies, a tourism website based on B/S mode is designed and implemented, which can complete user management, scenic spot recommendation management, scenic spot reservation information, tourism route management, tourism route reservation information, hotel management, hotel reservation information, tourism strategy management, my collection, message management, administrator management and other functions, and test each functional module of the tourism website. The user interface designed is reasonable in layout and friendly in interaction.

Keywords: tourism website; B/S mode; springboot; mysql

package com.mty.travel.controller;

import com.mty.travel.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import com.mty.travel.entity.User;
import com.mty.travel.entity.ParamQuery;
import com.mty.travel.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Date;

/**
 * @description: 用户控制层
 * @author: mty
 */
@RestController
@RequestMapping("user")
public class UserController {

    // 依赖注入
    @Autowired
    private UserService userService;


    /**
     * 分页查询
     */
    @PostMapping("selectAll")
    public PageInfo<User> selectAll(@RequestBody Map<String,String> mp) {
        PageHelper.startPage(Integer.parseInt(mp.get("currentPage").toString()), Integer.parseInt(mp.get("pagesize").toString()));
        List<User> list = userService.queryAllByLimit(mp);
        PageInfo<User> pageInfo = new PageInfo<User>(list);
        return pageInfo;
    }

    /**
     * 修改
     */
    @RequestMapping("edit")
    public String edit(@RequestBody User user) {
        try {
            List<User> users = userService.queryCondition(new User());
            for(int i=0;i<users.size();i++){
                if(user.getUsername().equals(users.get(i).getUsername()) && !users.get(i).getId().equals(user.getId())){
                    return "202";
                }
            }
            userService.update(user);
            return "200";
        }catch (Exception e){
            e.printStackTrace();
            return "201";
        }
    }


    /**
     * 修改
     */
    @RequestMapping("editInfo")
    public Result editInfo(@RequestBody User user) {
        Result result = new Result();
        try {
            List<User> users = userService.queryCondition(new User());
            for(int i=0;i<users.size();i++){
                if(user.getUsername().equals(users.get(i).getUsername()) && !users.get(i).getId().equals(user.getId())){
                    result.setCode(202);
                    result.setMsg("用户名重复,请重试");
                    return result;
                }
            }
            if(user.getPasswords()!=null && !user.getPasswords().equals("")){
                user.setPassword(user.getPasswords());
            }
            userService.update(user);
            User user1 = userService.queryById(user.getId());
            result.setCode(200);
            result.setData(user1);
            result.setMsg("修改成功");
            return result;
        }catch (Exception e){
            e.printStackTrace();
            result.setCode(201);
            result.setMsg("系统错误");
            return result;
        }
    }

    /**
     * 新增
     */
    @RequestMapping("add")
    public String add(@RequestBody User user) {
        try {
            List<User> users = userService.queryCondition(new User());
            for(int i=0;i<users.size();i++){
                if(user.getUsername().equals(users.get(i).getUsername())){
                    return "202";
                }
            }
            Date date = new Date();
            user.setCreateTime(date);
            userService.insert(user);
            return "200";
        }catch (Exception e){
            e.printStackTrace();
            return "201";
        }
    }

    /**
     * 通过主键查询单条数据
     */
    @GetMapping("selectOne")
    public User selectOne(Integer id) {
        return userService.queryById(id);
    }


    /**
     * 通过主键删除数据
     */
    @GetMapping("deleteById")
    public String deleteById(Integer id) {
        try {
            userService.deleteById(id);
            return "200";
        }catch (Exception e){
            e.printStackTrace();
            return "201";
        }
    }


    /**
     * 导出excel
     */
    @RequestMapping("/downExcel")
    public List<User> downExcel(){
        User user = new User();
        return userService.queryCondition(user);
    }


}

 


package com.controller;

import java.util.List;
import java.util.Arrays;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.UsersEntity;
import com.service.TokenService;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UsersController {
	
	@Autowired
	private UsersService usersService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UsersEntity user = usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		R r = R.ok();
		r.put("token", token);
		r.put("role",user.getRole());
		r.put("userId",user.getId());
		return r;
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UsersEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        usersService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}

	/**
	 * 修改密码
	 */
	@GetMapping(value = "/updatePassword")
	public R updatePassword(String  oldPassword, String  newPassword, HttpServletRequest request) {
		UsersEntity users = usersService.selectById((Integer)request.getSession().getAttribute("userId"));
		if(newPassword == null){
			return R.error("新密码不能为空") ;
		}
		if(!oldPassword.equals(users.getPassword())){
			return R.error("原密码输入错误");
		}
		if(newPassword.equals(users.getPassword())){
			return R.error("新密码不能和原密码一致") ;
		}
		users.setPassword(newPassword);
		usersService.updateById(users);
		return R.ok();
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UsersEntity user = usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        usersService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UsersEntity user){
        EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>();
    	PageUtils page = usersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UsersEntity user){
       	EntityWrapper<UsersEntity> ew = new EntityWrapper<UsersEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", usersService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UsersEntity user = usersService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Integer id = (Integer)request.getSession().getAttribute("userId");
        UsersEntity user = usersService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UsersEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(usersService.selectOne(new EntityWrapper<UsersEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        usersService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UsersEntity user){
//        ValidatorUtils.validateEntity(user);
        usersService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		List<UsersEntity> user = usersService.selectList(null);
		if(user.size() > 1){
			usersService.deleteBatchIds(Arrays.asList(ids));
		}else{
			return R.error("管理员最少保留一个");
		}
        return R.ok();
    }
}

  • 19
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序猿毕业分享网

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值