Java如何实现诚途旅游系统
发表于:2025-01-16 作者:千家信息网编辑
千家信息网最后更新 2025年01月16日,这篇文章主要为大家展示了"Java如何实现诚途旅游系统",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"Java如何实现诚途旅游系统"这篇文章吧。采用ssm架
千家信息网最后更新 2025年01月16日Java如何实现诚途旅游系统
这篇文章主要为大家展示了"Java如何实现诚途旅游系统",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"Java如何实现诚途旅游系统"这篇文章吧。
采用ssm架构实现的旅游网站系统 包括网站展示和后台管理功能,网站主要是页面浏览以及评论、制定旅游方案、智能推荐功能 后台就是维护网站展示的内容,添加旅游景点、管理用户、查看用户的搜索记录功能
酒店信息控制层:
/** * 控制器层 * */@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(){ Listall = 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() =4){ List newList=scenics.subList(0,3); model.addAttribute("scenics",newList); }else { model.addAttribute("scenics",scenics); } return "page/hotelDetail::table_refresh"; }}
管理员信息控制器层:
/** * 控制器层 * */@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){ PagepageList = 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 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("/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); Optionals = 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() =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"; } }
订单控制器层:
/** * 订单控制器层 * */@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 */ @ResponseBody @RequestMapping(value = "/list",method= RequestMethod.GET) public Result findAll(){ Listall = 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) public List findAllOrder(HttpSession session) throws ParseException { User user= (User) session.getAttribute("user"); return ordersService.findOrders(user.getId().toString()); } /** * 查询全部订单 * @return */ @ResponseBody @RequestMapping(value = "/allorderhotel",method = RequestMethod.POST) public List findAllOrderHotel(HttpSession session){ User user= (User) session.getAttribute("user"); List hotel_orders=hotel_ordersService.hotel_orders(user.getId()); 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 分页结果 */ @ResponseBody @RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST) public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){ Page pageList = ordersService.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,"查询成功",ordersService.findSearch(searchMap)); } /** * 订单添加操作 * @param orders */ @ResponseBody @RequestMapping(value ="/add",method=RequestMethod.POST) public Result add(Orders orders, HttpSession session){ //获取数量 User user = (User) session.getAttribute("user"); if (user == null){ return new Result(false,StatusCode.ACCESSERROR,"请登录"); } 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 id */ @ResponseBody @RequestMapping(value="/{id}",method= RequestMethod.DELETE) public Result delete(@PathVariable Long id ){ ordersService.deleteById(id); return new Result(true,StatusCode.OK,"删除成功"); } @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; totalStar=currentStar+totalStar; int avgStar = totalStar / commentCount; 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(); if(currentStar<0){ return new Result(false,StatusCode.ERROR,"请选择评分!"); } Integer commentCount = newScenic.getCommentCount(); commentCount=commentCount+1; totalStar=currentStar+totalStar; int avgStar = totalStar / commentCount; scenic.setCommentCount(commentCount); scenic.setStart(avgStar); Integer scenic1 = scenicService.updateStar(scenic); ordersService.updateStarStatus(orderId); if(scenic1==null){ return new Result(false,StatusCode.ERROR,"评分更新失败!"); } return new Result(true,StatusCode.OK,"评价成功!"); } }
以上是"Java如何实现诚途旅游系统"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!
查询
成功
酒店
条件
控制
景点
管理
旅游
信息
数据
订单
评分
控制器
管理员
登录
系统
内容
网站
功能
大小
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
服务器端口开放那些比较安全
网络技术员入门知识
南山医院网络技术科需要多少人
股票的交易软件开发
数据库压缩日志
数据库密码查询mdb
戴尔服务器蓝屏进不去怎么办
优酷 服务器
服务器可以当手机用吗
网络安全与一次性光盘
互联网科技产品骗局
php数据库版本控制
数据库表空间大小怎么查
武汉软件开发公司官网
计算机网络技术想专升本难吗
卫士通网络安全产品价格
网络安全网络攻击
国际网络安全问题有哪些
数据库描述事物的符号
最大的服务器可以上多少cpu
牟平区管理系统软件开发解决方案
定期检查网络安全
药用植物数据库
网络安全审计工具下载
网络安全态势感知大屏
派出所网络安全检查开展情况
安徽省公安厅网络安全合作单位
魔兽世界转移服务器可以换种族吗
十四运会场馆网络安全
多维数据库模型