基于javaweb+mysql的爱游旅行平台设计和实现(java+springboot+ssm)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的旅游管理系统旅行平台(springboot+ssm)
项目意义:
改革开放以来, 我国的旅游业发展迅速,但比较而言,我国旅游业发展的广度和深度都远远不能满足经济发展和人民生活水平提高的需要。 随着市场经济的发展和人民收入水平的进一步提高, 人民对旅游消费的需求将进一步上升, 目前旅游业在国民经济中的地位和作用越来越重要。 但我国旅游产业仍然基础薄弱, 管理手段滞后,信息化程度较低,企业效益较差;旅游行政管理部门的管理方式落后,缺乏信息化管理手段。面对困难和挑战,我国旅游业必须转变观念,创新思维,以信息化建设为突破口和新手段,整合各种资源,从而实现整个行业的新跨越。
项目意义:
本文拟设计并实现的爱游旅行平台前台+后台信息系统, 能够改变旅游企业的传统经营模式,提高各级管理部门的工作效率和管理水平,降低工作成本,加大宣传力度,提高信息实效性;能够满足游客的个性化需求,提高旅游服务质量。 旅游管理的网络化,将会进一步壮大旅游支柱产业, 提升旅游产业整体信息化水平,优化产业结构和资源配置,完善产业链,进而带动众多相关产业发展,拉动内需,扩大就业,对经济发展起到积极的推动作用,从而提高整个旅游产业素质
主要技术:spring、 springmvc、 springboot、 md5 、jpa 、 jquery 、layui、 、bootstarp.js tomcat、富文本编译器、拦截器等
主要功能:网站首页展示、用户登录、用户注册、旅游线路、关注线路、旅游攻略、酒店预订、我发布的旅游攻略、景点预订、关键字搜索酒店和景点信息等主要功能:
主要功能介绍:
系统前台首页:
查看首页一些基本信息和功能操作、比如旅游线路、旅游攻略、酒店预订以及模糊搜索和个人信息等操作
用户登录和注册:
旅游线路相关模块:
点击查看所有的旅行攻略以及我关注的攻略以及根据关键字搜索攻略操作、还可以发布攻略信息、但是需要管理员审核才可以显示等
插入部分代码展示:
package hue.edu.xiong.volunteer_travel.controller;
import hue.edu.xiong.volunteer_travel.core.Result;
import hue.edu.xiong.volunteer_travel.core.ResultGenerator;
import hue.edu.xiong.volunteer_travel.model.*;
import hue.edu.xiong.volunteer_travel.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Controller
@RequestMapping(“/system”)
public class SystemController {
@Autowired
private SystemService systemService;
@RequestMapping(“”)
public String loginUI() {
return “system/login/login”;
@RequestMapping(“/login”)
@ResponseBody
public Result login(SysUser sysUser, HttpServletResponse response) {
return systemService.login(sysUser,response);
@RequestMapping(“/userListUI”)
public String userListUI(Model model, @PageableDefault(size = 10) Pageable pageable) {
Page page = systemService.getUserPage(pageable);
model.addAttribute(“page”,page);
return “system/user/list”;
@RequestMapping(“/saveUser”)
@ResponseBody
public Result saveUser(User user) {
return systemService.saveUser(user);
@RequestMapping(“/getUserById”)
@ResponseBody
public Result getUserById(String id) {
return ResultGenerator.genSuccessResult(systemService.getUserById(id));
@RequestMapping(“/logout”)
public String logout(HttpServletRequest request, HttpServletResponse response) {
systemService.logout(request,response);
return “redirect:/system”;
@RequestMapping(“/hotelListUI”)
public String hotelListUI(Model model, @PageableDefault(size = 10) Pageable pageable) {
Page page = systemService.getHotelPage(pageable);
model.addAttribute(“page”, page);
return “system/hotel/list”;
@RequestMapping(“/saveHotel”)
@ResponseBody
public Result saveHotel(Hotel hotel) {
return systemService.saveHotel(hotel);
@RequestMapping(“/updateStatus”)
@ResponseBody
public Result updateStatus(String id) {
return systemService.updateStatus(id);
@RequestMapping(“/getHotelById”)
@ResponseBody
public Result getHotelById(String id) {
return ResultGenerator.genSuccessResult(systemService.getHotelById(id));
@RequestMapping(“/attractionsListUI”)
public String attractionsListUI(Model model, @PageableDefault(size = 10) Pageable pageable) {
Page page = systemService.getAttractionsPage(pageable);
model.addAttribute(“page”, page);
return “system/attractions/list”;
@RequestMapping(“/getAttractionsById”)
@ResponseBody
public Result getAttractionsById(String id) {
return ResultGenerator.genSuccessResult(systemService.getAttractionsById(id));
@RequestMapping(“/updateAttractionsStatus”)
@ResponseBody
public Result updateAttractionsStatus(String id) {
return systemService.updateAttractionsStatus(id);
@RequestMapping(“/saveAttractions”)
@ResponseBody
public Result saveAttractions(Attractions attractions) {
return systemService.saveAttractions(attractions);
@RequestMapping(“/travelRouteListUI”)
public String travelRouteListUI(Model model, @PageableDefault(size = 10) Pageable pageable) {
Page page = systemService.getTravelRoutePage(pageable);
model.addAttribute(“page”, page);
return “system/route/list”;
@RequestMapping(“/getTravelRouteById”)
@ResponseBody
public Result getTravelRouteById(String id) {
return ResultGenerator.genSuccessResult(systemService.getTravelRouteById(id));
@RequestMapping(“/updateTravelRouteStatus”)
@ResponseBody
public Result updateTravelRouteStatus(String id) {
return systemService.updateTravelRouteStatus(id);
@RequestMapping(“/saveTravelRoute”)
@ResponseBody
public Result saveTravelRoute(TravelRoute travelRoute) {
return systemService.saveTravelRoute(travelRoute);
@RequestMapping(“/travelStrategyListUI”)
public String travelStrategyListUI(Model model, @PageableDefault(size = 10) Pageable pageable) {
Page page = systemService.getTravelStrategyPage(pageable);
model.addAttribute(“page”, page);
return “system/strategy/list”;
@RequestMapping(“/getTravelStrategyById”)
@ResponseBody
public Result getTravelStrategyById(String id) {
return ResultGenerator.genSuccessResult(systemService.getTravelStrategyById(id));
@RequestMapping(“/updateTravelStrategyStatus”)
@ResponseBody
public Result updateTravelStrategyStatus(String id) {
return systemService.updateTravelStrategyStatus(id);
@RequestMapping(“/saveTravelStrategy”)
@ResponseBody
public Result saveTravelStrategy(HttpServletRequest request,TravelStrategy travelStrategy) {
return systemService.saveTravelStrategy(request,travelStrategy);
酒店和景点预订:
用户登录后可以进行酒店信息和景点信息查看以及预订
酒店和景点详情信息:
旅游攻略相关模块:
点击查看所有的旅行线路以及我关注的线路以及根据关键字搜索线路操作等
收藏、关注、预订:
对于酒店、线路、景点 用户可以旅行攻略收藏、景点关注、预订酒店
后台管理模块:
后台管理模块主要是一些基础数据的维护和管理、具体有用户管理、酒店信息管理、景点信息管理、攻略信息管理、路线信息管理、发布功率审核、以及登录退出等
用户发布攻略审核:
主要数据表表设计:
酒店表:
CREATE TABLE NewTable
(
id
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
image
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
hotel_name
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
hotel_address
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
hotel_describe
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
hotel_status
int(2) NULL DEFAULT 0 ,
create_date
datetime NOT NULL ,
PRIMARY KEY (id
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
ROW_FORMAT=COMPACT
景区表:
CREATE TABLE NewTable
(
id
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
image
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
attractions_name
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
attractions_address
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
attractions_describe
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
attractions_status
int(2) NULL DEFAULT 0 ,
create_date
datetime NOT NULL ,
PRIMARY KEY (id
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
ROW_FORMAT=COMPACT
管理员控制层:
/**
- 控制器层
*/
@Controller
@CrossOrigin
@RequestMapping(“/admin”)
public class AdminController {
@Autowired
private AdminService adminService;
@Autowired
BCryptPasswordEncoder encoder;
/**
-
查询全部数据
-
@return
*/
@ResponseBody
@RequestMapping(method= RequestMethod.GET)
public Result findAll(){
return new Result(true, StatusCode.OK,“查询成功”,adminService.findAll());
/**
-
根据ID查询
-
@param id ID
-
@return
*/
@ResponseBody
@RequestMapping(value=“/{id}”,method= RequestMethod.GET)
public Result findById(@PathVariable Long id){
return new Result(true,StatusCode.OK,“查询成功”,adminService.findById(id));
/**
-
分页+多条件查询
-
@param searchMap 查询条件封装
-
@param page 页码
-
@param size 页大小
-
@return 分页结果
*/
@ResponseBody
@RequestMapping(value=“/search/{page}/{size}”,method=RequestMethod.POST)
public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
Page pageList = adminService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,“查询成功”, new PageResult(pageList.getTotalElements(), pageList.getContent()) );
/**
-
根据条件查询
-
@param searchMap
-
@return
*/
@ResponseBody
@RequestMapping(value=“/search”,method = RequestMethod.POST)
public Result findSearch( @RequestBody Map searchMap){
return new Result(true,StatusCode.OK,“查询成功”,adminService.findSearch(searchMap));
/**
-
增加
-
@param admin
*/
@ResponseBody
@RequestMapping(method=RequestMethod.POST)
public Result add(@RequestBody Admin admin ){
adminService.add(admin);
return new Result(true,StatusCode.OK,“增加成功”);
/**
-
修改
-
@param admin
*/
@ResponseBody
@RequestMapping(value=“/{id}”,method= RequestMethod.PUT)
public Result update(@RequestBody Admin admin, @PathVariable Long id ){
admin.setId(id);
adminService.update(admin);
return new Result(true,StatusCode.OK,“修改成功”);
/**
-
删除
-
@param id
*/
@ResponseBody
@RequestMapping(value=“/{id}”,method= RequestMethod.DELETE)
public Result delete(@PathVariable String id ){
adminService.deleteById(id);
return new Result(true,StatusCode.OK,“删除成功”);
/**
-
管理员跳转
-
@return
*/
@RequestMapping(value = “/adminlogin”)
public String adminlogin()
return “admin/login/login”;
/**
-
admin登录
-
@param loginMap
-
@param request
-
@return
*/
@ResponseBody
@RequestMapping(value=“/login”,method= RequestMethod.POST)
public Result login(@RequestParam Map<String,String> loginMap,HttpServletRequest request){
Admin admin = adminService.finbyNameAndPassword(loginMap.get(“name”),loginMap.get(“password”));
if (admin!=null){
request.getSession().setAttribute(“admin”,admin);
Map map=new HashMap();
map.put(“name”,admin.getName());
return new Result(true,StatusCode.OK,“登录成功”);
}else {
return new Result(false,StatusCode.ERROR,“账号密码错误”);
/**
-
管理员登录成功
-
@return
*/
@RequestMapping(value = “/index”)
public String success(){
return “admin/index”;
/**
-
用户列表
-
@return
*/
@RequestMapping(value = “/userList”)
public String user(){
return “admin/usermanage/userList”;
@RequestMapping(value = “/echars”)
public String analysis(){
return “admin/echars/console”;
/**
-
管理员退出登录
-
@return
*/
@RequestMapping(value = “/logout”)
public String logout(HttpSession session){
session.removeAttribute(“admin”);
return “admin/login/login”;
/**
-
管理员修改密码
-
@return
*/
@ResponseBody
@RequestMapping(value = “/passwd”)
public Result passwd(HttpSession session,String passwd,String oldpad){
Admin admindmin= (Admin) session.getAttribute(“admin”);
Admin admins=adminService.findById(admindmin.getId());
boolean old=encoder.matches(oldpad,admins.getPassword());
if (old){
String newPassd=encoder.encode(passwd);
admins.setPassword(newPassd);
adminService.update(admins);
return new Result(true,StatusCode.OK,“成功”);
}else {
return new Result(false,StatusCode.ERROR,“更新失败”);
酒店信息控制层:
/**
- 控制器层
*/
@Controller
@CrossOrigin
@RequestMapping(“/hotel”)
public class HotelController {
@Autowired
private HotelService hotelService;
@Autowired
private ScenicService scenicService;
/**
-
查询全部酒店信息
-
@return
*/
@ResponseBody
@RequestMapping(value = “/list”,method= RequestMethod.GET)
public Result findAll(){
List all = hotelService.findAll();
return new Result(true, StatusCode.OK,“查询成功”,all,all.size());
/**
-
根据ID查询
-
@param id ID
-
@return
*/
@ResponseBody
@RequestMapping(value=“/{id}”,method= RequestMethod.GET)
public Result findById(@PathVariable Long id){
return new Result(true,StatusCode.OK,“查询成功”,hotelService.findById(id));
/**
-
酒店添加操作
-
@param hotel
*/
@ResponseBody
@RequestMapping(value = “/add”,method=RequestMethod.POST)
public Result add(Hotel hotel){
if(StringUtils.isEmpty(hotel.getName())){
return new Result(false,StatusCode.ERROR,“请填写酒店名称”);
if(StringUtils.isEmpty(hotel.getImg())){
return new Result(false,StatusCode.ERROR,“请上传酒店封面图片”);
if(StringUtils.isEmpty(hotel.getAddr())){
return new Result(false,StatusCode.ERROR,“请填写酒店地址”);
if(StringUtils.isEmpty(hotel.getMiaoshu())){
return new Result(false,StatusCode.ERROR,“请填写酒店描述”);
hotel.setCommentCount(0);
hotel.setStar(0);
if(hotelService.add(hotel)==null){
return new Result(false,StatusCode.ERROR,“酒店添加失败”);
return new Result(true,StatusCode.OK,“添加成功”);
/**
-
分页+多条件查询
-
@param searchMap 查询条件封装
-
@param page 页码
-
@param size 页大小
-
@return 分页结果
*/
@ResponseBody
@RequestMapping(value=“/search/{page}/{size}”,method=RequestMethod.POST)
public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
Page pageList = hotelService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,“查询成功”, new PageResult(pageList.getTotalElements(), pageList.getContent()) );
/**
-
根据条件查询
-
@param searchMap
-
@return
*/
@ResponseBody
@RequestMapping(value=“/search”,method = RequestMethod.POST)
public Result findSearch( @RequestBody Map searchMap){
return new Result(true,StatusCode.OK,“查询成功”,hotelService.findSearch(searchMap));
/**
-
修改
-
@param hotel
*/
@ResponseBody
@RequestMapping(value=“/edit”,method= RequestMethod.PUT)
public Result update(Hotel hotel){
Hotel hotelById = hotelService.findById(hotel.getId());
if(hotelById==null){
return new Result(false,StatusCode.ERROR,“该酒店信息不存在”);
if(StringUtils.isEmpty(hotel.getName())){
return new Result(false,StatusCode.ERROR,“请填写酒店名称”);
BeanUtils.copyProperties(hotel,hotelById,“id”,“img”,“miaoshu”,“day”,“startdate”,“addr”,“commentCount”);
if(hotelService.update(hotelById)==null){
return new Result(false,StatusCode.ERROR,“酒店编辑失败”);
return new Result(true,StatusCode.OK,“修改成功”);
/**
-
删除
-
@param id
*/
@ResponseBody
@RequestMapping(value=“/{id}”,method= RequestMethod.DELETE)
public Result delete(@PathVariable String id ){
hotelService.deleteById(id);
return new Result(true,StatusCode.OK,“删除成功”);
/**
-
酒店列表跳转路径
-
@return
*/
@RequestMapping(value = “/hotelList”)
public String hotelList(){
return “admin/hotelmanage/hotelList”;
@RequestMapping(value = “/hotelAdd”)
public String hotelAdd(){
return “admin/hotelmanage/hotelAdd”;
/**
-
查询单个酒店
-
@param model
-
@param id
-
@return
*/
@RequestMapping(“/oneAttr”)
public String One_attr(Model model, Long id){
Hotel scenic=hotelService.findById(id);
model.addAttribute(“oneAttr”,scenic);
return “page/hotelDetail”;
@RequestMapping(“/local”)
public String localRefresh(Model model,Long id) {
Hotel hotel=hotelService.findById(id);
// Sort sort=new Sort(Sort.Direction.DESC,“star”);
System.out.println(“1111”+hotel.toString());
List scenics=scenicService.findByCountryLike(hotel.getAddr());
System.out.println(“2222”+scenics.toString());
Collections.sort(scenics, new Comparator() {
@Override
public int compare(Scenic o1, Scenic o2) {
if (o1.getStart()<o2.getStart()){
return 2;
if (o1.getStart().equals(o2.getStart()) ){
return 1;
return -1;
});
if (scenics.size()>=4){
List newList=scenics.subList(0,3);
model.addAttribute(“scenics”,newList);
}else {
model.addAttribute(“scenics”,scenics);
return “page/hotelDetail::table_refresh”;
景点星级控制层:
/**
- 景点星级控制层
*/
@Controller
@CrossOrigin
@RequestMapping(“/travel”)
public class RecomTravelController {
@Autowired
private ScenicService scenicService;
@Autowired
private ScenicDao scenicDao;
@Autowired
private HotelService hotelService;
@Autowired
private HotelDao hotelDao;
/**
*查询星级
- @return
*/
@ResponseBody
@RequestMapping(value = “/star”,method = RequestMethod.POST)
public Result judgeStar(String id,String start){
System.out.println(id+“====”+start);
Optional s = scenicDao.findById(id);
if (s.isPresent()){
Scenic scenic = s.get();
int valuestar = (Integer.valueOf(start)+Integer.valueOf(scenic.getStart()))/2;
scenic.setStart(valuestar);
scenicDao.save(scenic);
System.out.println(“数据不为空!”);
return new Result(true,1,“”,“”);
}else {
System.out.println(“数据为空!”);
return new Result(false,0,“”,“”);
/**
*查询星级
- @return
*/
@ResponseBody
@RequestMapping(value = “/hotel”,method = RequestMethod.POST)
public Result judgeHotelStar(Long id,String start){
Hotel scenic = hotelService.findById(id);
if (scenic!=null){
int valuestar = (Integer.valueOf(start)+Integer.valueOf(scenic.getStar()))/2;
scenic.setStar(valuestar);
hotelDao.save(scenic);
System.out.println(“数据不为空!”);
return new Result(true,1,“”,“”);
}else {
System.out.println(“数据为空!”);
return new Result(false,0,“”,“”);
/**
-
查询单个景点
-
@param model
-
@param id
-
@return
*/
@RequestMapping(“/oneAttr”)
public String One_attr(Model model,Long id){
Scenic scenic=scenicService.findById(id);
model.addAttribute(“oneAttr”,scenic);
return “page/product”;
/**
-
景点模糊查询分页
-
@param model
-
@param start
-
@param limit
-
@param search_key
-
@return
*/
@RequestMapping(“/search_attrs”)
public String search_attrs(Model model,@RequestParam(value = “start” ,defaultValue = “0”)Integer start,
@RequestParam(value = “limit” ,defaultValue = “6”)Integer limit,
@RequestParam String search_key){
start=start<0?0:start;
Sort sort=new Sort(Sort.Direction.DESC,“id”);
Pageable pageable=PageRequest.of(start,limit,sort);
Specification specification=new Specification() {
@Override
public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
List scenics=new ArrayList<>();
if (StringUtils.isNotBlank(search_key)){
scenics.add( criteriaBuilder.like(root.get(“name”),“%”+search_key+“%”));
return criteriaBuilder.and(scenics.toArray(new Predicate[scenics.size()]));
};
Page page=scenicDao.findAll(specification,pageable);
model.addAttribute(“name”,search_key);
model.addAttribute(“attrs”,page);
model.addAttribute(“number”,page.getNumber());
model.addAttribute(“numberOfElements”,page.getNumberOfElements());
model.addAttribute(“size”,page.getSize());
model.addAttribute(“totalElements”,page.getTotalElements());
model.addAttribute(“totalPages”,page.getTotalPages());
model.addAttribute(“first”,page.isFirst());
model.addAttribute(“last”,page.isLast());
return “page/travel”;
@RequestMapping(“/local”)
public String localRefresh(Model model,Long id) {
Scenic scenic=scenicService.findById(id);
System.out.println(scenic.toString());
List hotels=hotelService.findByCountryLike(scenic.getContry());
Collections.sort(hotels, new Comparator() {
@Override
public int compare(Hotel o1, Hotel o2) {
if (o1.getStar()<o2.getStar()){
return 2;
if (o1.getStar().equals(o2.getStar()) ){
return 1;
return -1;
});
if (hotels.size()>=4){
List newList=hotels.subList(0,3);
model.addAttribute(“scenics”,newList);
System.out.println(“个数:”+newList.size());
}else {
model.addAttribute(“scenics”,hotels);
System.out.println(“个数2:”+hotels.size());
return “page/product::table_refresh”;