基于javaweb+springboot的旅游网站管理系统设计和实现(java+springboot+jsp+mysql+spring)
运行环境: java jdk 1.8
IDE环境: IDEA
tomcat环境: Tomcat 7.x,8.x,9.x版本均可
主要功能说明:
管理员角色包含以下功能:管理员登录,用户管理,旅游路线管理,旅游景点管理,酒店管理,旅游攻略管理,车票管理,订单管理,数据分析等功能。
用户角色包含以下功能:用户注册,用户登录,旅游路线预定,旅游景区预定,餐饮住宿,车票预定,旅游保险预定,旅游攻略,我的订单查看,个人资料管理等功能。
用了技术框架: HTML+CSS+JavaScript+jsp+mysql+Spring+Springboot+mybatis+maven+layui
所用的数据库: Mysql数据库
主要功能截图:
用户端:
注册和登录
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
![](https://i-blog.csdnimg.cn/blog_migrate/7a7585bc77ea31dc78392dcc90880030.png)
hotel.setCommentCount(commentCount);
hotel.setStar(avgStar);
Integer hotel1 = hotelService.updateStar(hotel);
hotel_ordersService.updateStarStatus(orderId);
if(hotel1==null){
return new Result(false,StatusCode.ERROR,"评分更新失败!");
}
return new Result(true,StatusCode.OK,"评价成功!");
}
/**
* 景点评分
* @param scenic
* @return
*/
@ResponseBody
@PostMapping("/travelOrderStar")
public Result travelOrderStar(Scenic scenic,@RequestParam("orderId")Long orderId){
Long id = scenic.getId();
Scenic newScenic = scenicService.findById(id);
if(newScenic==null){
return new Result(false,StatusCode.ERROR,"未找到该景点!");
}
Integer totalStar = newScenic.getStart();
Integer currentStar = scenic.getStart();
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);
private HotelService hotelService;
@Autowired
private ScenicService scenicService;
/**
* 查询全部酒店信息
* @return
*/
@ResponseBody
@RequestMapping(value = "/list",method= RequestMethod.GET)
public Result findAll(){
List<Hotel> all = hotelService.findAll();
return new Result(true, StatusCode.OK,"查询成功",all,all.size());
}
}
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
*/
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";
}
}
订单控制层:
/**
* 控制器层
* @author yy
*
*/
@Controller
/**
* 分页+多条件查询
* @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<Hotel> pageList = hotelService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,"查询成功", new PageResult<Hotel>(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));
}
* @return
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.GET)
public Result findById(@PathVariable Long id){
return new Result(true,StatusCode.OK,"查询成功",ordersService.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<Orders> pageList = ordersService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,"查询成功", new PageResult<Orders>(pageList.getTotalElements(), pageList.getContent()) );
}
/**
* 根据条件查询
* @param searchMap
* 查询单个景点
* @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";
}
/**
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);
public String findAllOrders(HttpSession session, Model model) throws ParseException {
User user= (User) session.getAttribute("user");
model.addAttribute("orders",ordersService.findOrders(user.getId().toString()));
return "index_header::table_refresh";
}
/**
* 查询全部订单
* @return
*/
@ResponseBody
@RequestMapping(value = "/allorder",method = RequestMethod.POST)
public List<Orders> findAllOrder(HttpSession session) throws ParseException {
User user= (User) session.getAttribute("user");
return ordersService.findOrders(user.getId().toString());
}
/**
* 查询全部订单
*/
@ResponseBody
@RequestMapping(value = "/list",method= RequestMethod.GET)
public Result findAll(){
List<Orders> all = ordersService.findAll();
return new Result(true, StatusCode.OK,"查询成功",all,all.size());
}
/**
* 查询全部订单
* @return
*/
@ResponseBody
@RequestMapping(value = "/allorders",method = RequestMethod.POST)
public String findAllOrders(HttpSession session, Model model) throws ParseException {
User user= (User) session.getAttribute("user");
model.addAttribute("orders",ordersService.findOrders(user.getId().toString()));
return "index_header::table_refresh";
}
/**
* 查询全部订单
* @return
*/
@ResponseBody
@RequestMapping(value = "/allorder",method = RequestMethod.POST)
return hotel_orders;
}
/**
* 根据ID查询
* @param id ID
* @return
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.GET)
public Result findById(@PathVariable Long id){
return new Result(true,StatusCode.OK,"查询成功",ordersService.findById(id));
}
/**
* 分页+多条件查询
* @param searchMap 查询条件封装
* @param page 页码
* @param size 页大小
* @return 分页结果
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,"修改成功");
}
/**
* 查询全部酒店信息
* @return
*/
@ResponseBody
@RequestMapping(value = "/list",method= RequestMethod.GET)
public Result findAll(){
List<Hotel> 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));
}
/**
Long id = hotel.getId();
Hotel newHotel = hotelService.findById(id);
if(newHotel==null){
return new Result(false,StatusCode.ERROR,"未找到该酒店!");
}
Integer currentStar = hotel.getStar();
Integer totalStar = newHotel.getStar();
if(currentStar<0){
return new Result(false,StatusCode.ERROR,"请选择评分!");
}
Integer commentCount = newHotel.getCommentCount();
commentCount=commentCount+1;
totalStar=currentStar+totalStar;
int avgStar = totalStar / commentCount;
* @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);
@RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST)
public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
Page<Orders> pageList = ordersService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,"查询成功", new PageResult<Orders>(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,"查询成功",ordersService.findSearch(searchMap));
}
/**
* 订单添加操作
@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<Hotel> all = hotelService.findAll();
return new Result(true, StatusCode.OK,"查询成功",all,all.size());
}
/**
public Result judgeStar(String id,String start){
System.out.println(id+"===="+start);
Optional<Scenic> 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
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)
* @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,"请填写酒店名称");
}
@RequestMapping(value = "/ordersList")
public String ordersList(){
return "admin/ordersmanage/orderslist";
}
/**
* 酒店评分
* @param hotel
* @return
*/
@ResponseBody
@PostMapping("/hotelOrderStar")
public Result hotelOrderStar(Hotel hotel,@RequestParam("orderId")Long orderId){
Long id = hotel.getId();
Hotel newHotel = hotelService.findById(id);
if(newHotel==null){
return new Result(false,StatusCode.ERROR,"未找到该酒店!");
}
Integer currentStar = hotel.getStar();
Integer totalStar = newHotel.getStar();
if(currentStar<0){
return new Result(false,StatusCode.ERROR,"请选择评分!");
}
Integer commentCount = newHotel.getCommentCount();
commentCount=commentCount+1;
return new Result(false,StatusCode.ERROR,"未找到该酒店!");
}
Integer currentStar = hotel.getStar();
Integer totalStar = newHotel.getStar();
if(currentStar<0){
return new Result(false,StatusCode.ERROR,"请选择评分!");
}
Integer commentCount = newHotel.getCommentCount();
commentCount=commentCount+1;
totalStar=currentStar+totalStar;
int avgStar = totalStar / commentCount;
hotel.setCommentCount(commentCount);
hotel.setStar(avgStar);
Integer hotel1 = hotelService.updateStar(hotel);
*
*/
@Controller
@CrossOrigin
@RequestMapping("/orders")
public class OrdersController {
@Autowired
private OrdersService ordersService;
@Autowired
private HotelOrdersService hotel_ordersService;
@Autowired
private HotelService hotelService;
@Autowired
private ScenicService scenicService;
}
return ordersService.add(orders,user.getId(),orders.getId(),orders.getQty());
}
/**
* 修改
* @param
*/
@ResponseBody
@RequestMapping(value="/{id}",method= RequestMethod.PUT)
public Result update(@PathVariable Long id){
ordersService.updateStatus(id);
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<Hotel> pageList = hotelService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,"查询成功", new PageResult<Hotel>(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));
适用
课程设计,大作业,毕业设计,项目练习,学习演示等