Source code acquisition: download from "resources" on the blog home page!
Project significance:
Since the reform and opening up, China's tourism has developed rapidly, but comparatively speaking, the breadth and depth of China's tourism development are far from meeting the needs of economic development and the improvement of people's living standards. With the development of market economy and the further improvement of people's income level, people's demand for tourism consumption will further rise. At present, tourism plays a more and more important role in the national economy. However, the foundation of China's tourism industry is still weak, the management means are lagging behind, the degree of informatization is low, and the efficiency of enterprises is poor; The management mode of tourism administration department is backward and lacks information management means. China's tourism industry must face new ideas and challenges with innovation, so as to realize the breakthrough of the whole tourism industry.
Project significance:
The foreground + background information system of Aiyou travel platform designed and implemented in this paper can change the traditional business model of tourism enterprises, improve the work efficiency and management level of management departments at all levels, reduce work costs, strengthen publicity and improve the effectiveness of information; It can meet the personalized needs of tourists and improve the quality of tourism service. The networking of tourism management will further expand the tourism pillar industry, improve the overall informatization level of the tourism industry, optimize the industrial structure and resource allocation, improve the industrial chain, drive the development of many related industries, stimulate domestic demand, expand employment, and play a positive role in promoting economic development, so as to improve the quality of the whole tourism industry
Main technologies: spring, springmvc, springboot, md5, mybatis, jquery, layui,, bootstart JS tomcat, rich text compiler, interceptor, etc
Main functions: website home page display, user login, user registration, tourism routes, routes of interest, tourism strategy, hotel reservation, tourism strategy published by me, scenic spot reservation, keyword search for hotel and scenic spot information and other main functions:
Main functions:
Front page of the system:
View some basic information and function operations of the home page, such as tourism routes, tourism strategies, hotel reservations, fuzzy search and personal information
User login and registration:
Tourism route related modules:
Click to view all travel strategies and strategies I pay attention to, search strategies according to keywords, publish strategy information, but it can be displayed only after being approved by the administrator, etc
Insert partial code display:
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<User> 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<Hotel> 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<Attractions> 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<TravelRoute> 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<TravelStrategy> 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); } }
Hotel and attraction reservations:
After logging in, users can view and book hotel information and scenic spot information
Hotel and attraction details:
Tourism strategy related modules:
Click to view all travel routes and routes I pay attention to, and search routes according to keywords
Collection, attention and Reservation:
For hotels, routes and scenic spots, users can collect travel strategies, pay attention to scenic spots and book hotels
Background management module:
The background management module mainly includes the maintenance and management of some basic data, including user management, hotel information management, scenic spot information management, strategy information management, route information management, release power audit, login and exit, etc
User release strategy review:
Main data sheet design:
Hotel schedule:
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 ;
List of scenic spots:
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 ;
Administrator control layer:
/** * Controller layer */ @Controller @CrossOrigin @RequestMapping("/admin") public class AdminController { @Autowired private AdminService adminService; @Autowired BCryptPasswordEncoder encoder; /** * Query all data * @return */ @ResponseBody @RequestMapping(method= RequestMethod.GET) public Result findAll(){ return new Result(true, StatusCode.OK,"query was successful",adminService.findAll()); } /** * Query by ID * @param id ID * @return */ @ResponseBody @RequestMapping(value="/{id}",method= RequestMethod.GET) public Result findById(@PathVariable Long id){ return new Result(true,StatusCode.OK,"query was successful",adminService.findById(id)); } /** * Paging + multi condition query * @param searchMap Query condition encapsulation * @param page Page number * @param size Page size * @return Paging results */ @ResponseBody @RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST) public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){ Page<Admin> pageList = adminService.findSearch(searchMap, page, size); return new Result(true,StatusCode.OK,"query was successful", new PageResult<Admin>(pageList.getTotalElements(), pageList.getContent()) ); } /** * Query by criteria * @param searchMap * @return */ @ResponseBody @RequestMapping(value="/search",method = RequestMethod.POST) public Result findSearch( @RequestBody Map searchMap){ return new Result(true,StatusCode.OK,"query was successful",adminService.findSearch(searchMap)); } /** * increase * @param admin */ @ResponseBody @RequestMapping(method=RequestMethod.POST) public Result add(@RequestBody Admin admin ){ adminService.add(admin); return new Result(true,StatusCode.OK,"Increase success"); } /** * modify * @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,"Modified successfully"); } /** * delete * @param id */ @ResponseBody @RequestMapping(value="/{id}",method= RequestMethod.DELETE) public Result delete(@PathVariable String id ){ adminService.deleteById(id); return new Result(true,StatusCode.OK,"Deleted successfully"); } /** * Administrator jump * @return */ @RequestMapping(value = "/adminlogin") public String adminlogin() { return "admin/login/login"; } /** * admin Sign in * @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,"Login successful"); }else { return new Result(false,StatusCode.ERROR,"Account password error"); } } /** * Administrator login succeeded * @return */ @RequestMapping(value = "/index") public String success(){ return "admin/index"; } /** * User list * @return */ @RequestMapping(value = "/userList") public String user(){ return "admin/usermanage/userList"; } @RequestMapping(value = "/echars") public String analysis(){ return "admin/echars/console"; } /** * Administrator log out * @return */ @RequestMapping(value = "/logout") public String logout(HttpSession session){ session.removeAttribute("admin"); return "admin/login/login"; } /** * Administrator changes password * @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,"success"); }else { return new Result(false,StatusCode.ERROR,"Update failed"); } } }
Hotel information control layer:
/** * Controller layer * */ @Controller @CrossOrigin @RequestMapping("/hotel") public class HotelController { @Autowired private HotelService hotelService; @Autowired private ScenicService scenicService; /** * Query all hotel information * @return */ @ResponseBody @RequestMapping(value = "/list",method= RequestMethod.GET) public Result findAll(){ List<Hotel> all = hotelService.findAll(); return new Result(true, StatusCode.OK,"query was successful",all,all.size()); } /** * Query by ID * @param id ID * @return */ @ResponseBody @RequestMapping(value="/{id}",method= RequestMethod.GET) public Result findById(@PathVariable Long id){ return new Result(true,StatusCode.OK,"query was successful",hotelService.findById(id)); } /** * Hotel add operation * @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,"Please fill in the name of the hotel"); } if(StringUtils.isEmpty(hotel.getImg())){ return new Result(false,StatusCode.ERROR,"Please upload the hotel cover picture"); } if(StringUtils.isEmpty(hotel.getAddr())){ return new Result(false,StatusCode.ERROR,"Please fill in the hotel address"); } if(StringUtils.isEmpty(hotel.getMiaoshu())){ return new Result(false,StatusCode.ERROR,"Please fill in the hotel description"); } hotel.setCommentCount(0); hotel.setStar(0); if(hotelService.add(hotel)==null){ return new Result(false,StatusCode.ERROR,"Failed to add Hotel"); } return new Result(true,StatusCode.OK,"Added successfully"); } /** * Paging + multi condition query * @param searchMap Query condition encapsulation * @param page Page number * @param size Page size * @return Paging results */ @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,"query was successful", new PageResult<Hotel>(pageList.getTotalElements(), pageList.getContent()) ); } /** * Query by criteria * @param searchMap * @return */ @ResponseBody @RequestMapping(value="/search",method = RequestMethod.POST) public Result findSearch( @RequestBody Map searchMap){ return new Result(true,StatusCode.OK,"query was successful",hotelService.findSearch(searchMap)); } /** * modify * @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,"The hotel information does not exist"); } if(StringUtils.isEmpty(hotel.getName())){ return new Result(false,StatusCode.ERROR,"Please fill in the name of the hotel"); } BeanUtils.copyProperties(hotel,hotelById,"id","img","miaoshu","day","startdate","addr","commentCount"); if(hotelService.update(hotelById)==null){ return new Result(false,StatusCode.ERROR,"Hotel editing failed"); } return new Result(true,StatusCode.OK,"Modified successfully"); } /** * delete * @param id */ @ResponseBody @RequestMapping(value="/{id}",method= RequestMethod.DELETE) public Result delete(@PathVariable String id ){ hotelService.deleteById(id); return new Result(true,StatusCode.OK,"Deleted successfully"); } /** * Hotel list jump path * @return */ @RequestMapping(value = "/hotelList") public String hotelList(){ return "admin/hotelmanage/hotelList"; } @RequestMapping(value = "/hotelAdd") public String hotelAdd(){ return "admin/hotelmanage/hotelAdd"; } /** * Query individual hotels * @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<Scenic> scenics=scenicService.findByCountryLike(hotel.getAddr()); System.out.println("2222"+scenics.toString()); Collections.sort(scenics, new Comparator<Scenic>() { @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"; } }
Star control level of scenic spots:
/** * Star control level of scenic spots */ @Controller @CrossOrigin @RequestMapping("/travel") public class RecomTravelController { @Autowired private ScenicService scenicService; @Autowired private ScenicDao scenicDao; @Autowired private HotelService hotelService; @Autowired private HotelDao hotelDao; /** *Query star * @return */ @ResponseBody @RequestMapping(value = "/star",method = RequestMethod.POST) 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("Data is not empty!"); return new Result(true,1,"",""); }else { System.out.println("Data is empty!"); return new Result(false,0,"",""); } } /** *Query star * @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("Data is not empty!"); return new Result(true,1,"",""); }else { System.out.println("Data is empty!"); return new Result(false,0,"",""); } } /** * Query individual attractions * @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 spot fuzzy query paging * @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<Predicate> 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<Scenic> 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<Hotel> hotels=hotelService.findByCountryLike(scenic.getContry()); Collections.sort(hotels, new Comparator<Hotel>() { @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("number:"+newList.size()); }else { model.addAttribute("scenics",hotels); System.out.println("Number 2:"+hotels.size()); } return "page/product::table_refresh"; } }