基于SpringBooy的安康旅游网站的设计与实现

news2024/9/25 22:35:17

目录

前言

 一、技术栈

二、系统功能介绍

登录模块的实现

景点信息管理界面

酒店信息管理界面

特产管理界面

游客管理界面

景点购票订单管理界面

系统主界面

游客注册界面

景点信息详情界面

酒店详情界面

特产详情界面

三、核心代码

1、登录模块

 2、文件上传模块

3、代码封装


前言

随着旅游业的迅速发展,传统的旅游信息查询方式,已经无法满足用户需求,因此,结合计算机技术的优势和普及,针对安康旅游,特开发了本基于JSP的安康旅游网站。

本论文首先对安康旅游网站进行需求分析,从系统开发环境、系统目标、设计流程、功能设计等几个方面进行系统的总体设计,开发出本基于JSP的安康旅游网站,主要实现了游客功能模块和管理员功能模块两大部分,游客可查看景点信息、旅游线路、特产信息、酒店信息等,注册登录后可进行景点购票、酒店预订、特产购买等操作,同时管理员可进入系统后台对系统进行全面管理操作。通过对系统的功能进行测试,测试结果证明该系统界面友好、功能完善,有着较高的使用价值,具有庞大的潜在用户群体和较广阔的应用前景。

本安康旅游网站基于Springboot框架、Vue技术、Java编程语言、MYSQL数据库开发完成,“操作简单,功能实用”这是本软件设计的核心理念,本系统力求创造最好的用户体验。

 一、技术栈

末尾获取源码
SpringBoot+Vue+JS+ jQuery+Ajax...

二、系统功能介绍

登录模块的实现

用户要想进入本系统,必须通过正确的用户名和密码,选择登录类型进行登录操作,在登录时系统会以用户名、密码和登录类型为参数进行登录信息的验证,信息正确则登录进入对应用户功能界面可进行功能处理,反之登录失败。

景点信息管理界面

管理员可添加、修改和删除景点信息信息 

 

酒店信息管理界面

管理员可增删改查酒店信息

特产管理界面

管理员可增删改查特产信息

 

游客管理界面

管理员可查看、添加、修改和删除游客信息

景点购票订单管理界面

管理员可查看景点购票订单信息,并可对其进行审核、修改和删除操作

 

系统主界面

游客进入本系统可查看系统信息

游客注册界面

未有账号的游客可进入注册界面进行注册操作

 

景点信息详情界面

游客可选择景点信息查看景点信息详情信息,登录后可进行购票操作

酒店详情界面

游客可选择酒店查看详情信息,登录后可进行预订下单操作

 

特产详情界面

游客可选择特产查看详情信息,登录后可进行购买操作

三、核心代码

1、登录模块

 
package com.controller;
 
 
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;
 
/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;
 
	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }
 
	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }
 
	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }
 
    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
 
    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }
 
    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }
 
    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

 2、文件上传模块

package com.controller;
 
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
 
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
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 org.springframework.web.multipart.MultipartFile;
 
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;
 
/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
		if(StringUtils.isNotBlank(type) && type.equals("1")) {
			ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
			if(configEntity==null) {
				configEntity = new ConfigEntity();
				configEntity.setName("faceFile");
				configEntity.setValue(fileName);
			} else {
				configEntity.setValue(fileName);
			}
			configService.insertOrUpdate(configEntity);
		}
		return R.ok().put("file", fileName);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

3、代码封装

package com.utils;
 
import java.util.HashMap;
import java.util.Map;
 
/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}
 
	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}
 
	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

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

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

相关文章

Nginx + PHP 异常排查,open_basedir 异常处理

新上一个网站&#xff0c;通过域名访问失败&#xff0c;排查方法如下&#xff1a; 开启异常日志 开启域名下&#xff0c;nginx的异常日志&#xff0c;并查看日志 tail -f /var/log/nginx/nginx.localhost.error.log开启php的异常日志&#xff0c;该配置位于php.ini文件下 …

Java 21:虚拟线程介绍

Java 21 版本更新中最重要的功能之一就是虚拟线程 (JEP 444)。这些轻量级线程减少了编写、维护和观察高吞吐量并发应用程序所需的工作量。 正如我的许多其他文章一样&#xff0c;在推出新功能之前&#xff0c;让我们先看看 Java 21 版本更新前的现状&#xff0c;以便更好地了解…

Denoising Score Matching (DSM) 去噪得分匹配模型变分推理(VAE)退火郎之万动力学

Denoising Score Matching——DSM 有没有谁通俗的讲一下Denoising score matching? Denoising Score Matching (DSM) 论文 << A Connection Between Score Matching and Denoising Autoencoders>> 作者是将denoising autoencoder和score mathching 联系在了一起…

图像处理与计算机视觉--第七章-神经网络-单层感知器

文章目录 1.单层感知器原理介绍2.单层感知器算法流程3.单层感知器算法实现4.单层感知器效果展示5.参考文章与致谢 1.单层感知器原理介绍 1.单层感知器是感知器中最简单的一种&#xff0c;有单个神经元组成的单层感知器只能用于解决线性可分的二分性问题2.在空间中如果输入的数据…

《spring security in action》读书笔记

1. why spring security 是强大的高度可定制的 身份验证 和 访问控制 应用级框架。 常见的漏洞包含&#xff1a; 身份验证失效&#xff0c;会话固定&#xff0c;跨站脚本xss请求伪造&#xff0c;CSRF注入敏感数据泄漏缺乏方法访问控制。 身份验证失效&#xff1a; 不能仅仅验…

基于正点原子alpha开发板的第三篇系统移植

系统移植的三大步骤如下&#xff1a; 系统uboot移植系统linux移植系统rootfs制作 一言难尽&#xff0c;踩了不少坑&#xff0c;当时只是想学习驱动开发&#xff0c;发现必须要将第三篇系统移植弄好才可以学习后面驱动&#xff0c;现将移植好的文件分享出来&#xff1a; 仓库&…

一篇讲清楚Java for循环详解

for 语句是应用最广泛、功能最强的一种循环语句。大部分情况下&#xff0c;for 循环可以代替 while 循环、do while 循环。 for 语句是一种在程序执行前就要先判断条件表达式是否为真的循环语句。假如条件表达式的结果为假&#xff0c;那么它的循环语句根本不会执行。for 语句通…

七个有用的 GIT 命令

在这篇文章中&#xff0c;我将与你分享7个 GIT 命令。 它们是有用的简短命令&#xff0c;但有时我们会错过它们。 01、查看之前的分支 我们将从一个非常短的 git 命令开始这个列表。 有时&#xff0c;我们在分支机构工作。 对于某些季节&#xff0c;我们需要切换到另一个分支…

图片批量处理:将长图切割成短图,轻松高效!

在日常生活中&#xff0c;我们经常需要处理大量的图片&#xff0c;包括上传和下载的图片。有时候&#xff0c;我们可能需要将这些长图切割成几个短图&#xff0c;以便更好地管理和使用。但是&#xff0c;如何快速高效地完成这个任务呢&#xff1f;今天&#xff0c;我们将向你介…

ViewPager、RecycleView实现轮播图

1.ViewPager实现轮播图形效果。 1&#xff09;layout中&#xff0c;PageIndicatorView轮播的View <RelativeLayoutandroid:layout_width"match_parent"android:layout_height"200dp"android:orientation"vertical"><androidx.viewpager…

nio 文件传输

transferto方法一次只能传输2个g的数据 文件大于2个g时

双十一孩子护眼台灯应该怎么选?2023好用护眼台灯推荐

在快节奏的生活中&#xff0c;孩子的压力越来越大&#xff0c;越来越需要良好的光线进行学习&#xff0c;越来越多的家长考虑到孩子的视力问题&#xff0c;选择购买护眼台灯来为孩子提供良好舒适的光线环境&#xff0c;选择一款舒适的护眼台灯尤为重要&#xff0c;那么&#xf…

fastadmin 后台列表数据多表查询筛选

记录一下fastadmin后台列表数据连表查询筛选提示&#xff1a; 1&#xff1a;下拉框方式搜索 示例&#xff1a; 在对应js文件中添加如下代码&#xff1a; 代码&#xff1a; {field: s.area_id,title: __(所属片区),visible: false,//不显示在列表中operate: ,searchList: $.…

3.2.OpenCV技能树--二值图像处理--图像腐蚀与膨胀

文章目录 1.文章内容来源2.图像膨胀处理2.1.图像膨胀原理简介2.2.图像膨胀核心代码2.3.图像膨胀效果展示 3.图像腐蚀处理3.1.图像腐蚀原理简介3.2.图像腐蚀核心代码3.3.图像腐蚀效果展示 4.易错点总结与反思 1.文章内容来源 1.题目来源:https://edu.csdn.net/skill/practice/o…

芥墨 | 设计需要平衡那些我们都会跳跃的创意

在这个空间很显然&#xff0c;洞石是作为设计师的首选&#xff0c;在电视墙、壁炉、都用了温润柔和的洞石铺设而成。设计这个门洞也是请了设计师最喜爱的工匠合作&#xff0c;他们知道如何配合设计师&#xff0c;精准的执行&#xff0c;对细节有着极致的标准。

如何解决openal32.dll丢失,有什么办法解决

你第一次知道openal32.dll文件是在什么情况下&#xff0c;你了解过openal32.dll文件吗&#xff1f;如果电脑中openal32.dll丢失有什么办法可以解决&#xff0c;今天就教大家如何解决openal32.dll丢失&#xff0c;都有哪些办法可以解决openal32.dll丢失。 一&#xff0e;openal3…

解决: 使用html2canvas和print-js打印组件时, 超出高度出现空白页

如果所示&#xff1a;当我利用html2canvas转换成图片后, 然后使用print-js打印多张图片, 第一张会出现空白页 打印组件可参考这个: Vue-使用html2canvas和print-js打印组件 解决: 因为是使用html2canvas转换成图片后才打印的, 而图片是行内块级元素, 会有间隙, 所以被挤下去了…

基于YOLOv5的火灾烟雾检测系统

目录 1&#xff0c;YOLOv5算法原理介绍 2&#xff0c;代码实现 3&#xff0c;结果展示 1&#xff0c;YOLOv5算法原理介绍 YOLOv5是目前应用广泛的目标检测算法之一&#xff0c;其主要结构分为两个部分&#xff1a;骨干网络和检测头。 骨干网络采用的是CSPDarknet53&#xff…

机器学习必修课 - 交叉验证 Cross-Validation

想象一下你有一个包含5000行数据的数据集。通常情况下&#xff0c;你会将约20%的数据保留作为验证数据集&#xff0c;即1000行。但这会在确定模型得分时引入一些随机性。也就是说&#xff0c;一个模型可能在一组1000行数据上表现良好&#xff0c;即使在另一组1000行数据上表现不…

信息收集-01-WEB应用

针对各种应用的信息收集&#xff08;Web网站、APP应用、PC应用、小程序应用、微信公众号等&#xff09; 常见查询网址和平台 1.业务资产 企业资产分五类&#xff1a;Web应用、APP应用、PC端应用、小程序应用、微信公众号、其他产品 信息收集目标&#xff1a;某某企业、某某…