基于javaweb+mysql的springboot旅游网站管理系统设计和实现(java+springboot+html+mysql+spring)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot旅游网站管理系统设计和实现(java+springboot+html+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数据库
主要功能截图:
用户端:
注册和登录
首页功能菜单展示:
线路管理
旅游景点查看和预订等、预订完成在我的订单查看付款
餐饮查看和预订等、预订完成在我的订单查看付款
车票查看和预订等、预订完成在我的订单查看付款
保险查看和预订等、预订完成在我的订单查看付款
旅游攻略
注意事项:
后台管理员功能:
数据分析:
if (Tools.isEmpty(userName)||Tools.isEmpty(password)){
redirectAttributes.addFlashAttribute("message","用户名密码不得为空!");
return new ModelAndView(new RedirectView("/goLogin"));
}
try {
User user = userService.login(userName, password);
if (Tools.isEmpty(user)){
redirectAttributes.addFlashAttribute("message","用户名不存在或密码错误!");
return new ModelAndView(new RedirectView("/goLogin"));
}else{
if (user.getState() == 1) {
httpSession.setAttribute("userName",userName);
return new ModelAndView(new RedirectView("/userCenter"));
} else {
redirectAttributes.addFlashAttribute("message","账户已被注销!");
return new ModelAndView(new RedirectView("/goLogin"));
}
}
} catch (Exception e) {
e.printStackTrace();
}
return new ModelAndView(new RedirectView("/goLogin"));
}
@RequestMapping("/register")
public ModelAndView register(){
ModelAndView mv = this.getModeAndView();
mv.setViewName("portal/register");
return mv;
}
@RequestMapping("/registering")
public ModelAndView registering(HttpServletRequest request, String checkPassword, RedirectAttributes redirectAttributes) throws Exception{
User user = new User();
this.bindValidateRequestEntity(request,user);
if(Tools.isEmpty(user)){
redirectAttributes.addFlashAttribute("message","用户名密码不得为空!");
return new ModelAndView(new RedirectView("/register"));
}
if(!user.getPassword().equals(checkPassword)){
redirectAttributes.addFlashAttribute("message","密码与确认密码不一致!");
return new ModelAndView(new RedirectView("/register"));
}
User entity = userService.findByUserName(user.getUserName());
if (entity != null) {
ModelAndView mv = this.getModeAndView();
User entity = null;
try {
if(Tools.notEmpty(id)){
entity = userService.findById(id);
}else{
entity = new User();
}
this.bindValidateRequestEntity(request,entity);
if (Tools.isEmpty(entity.getId())){
User object = userService.findByUserName(entity.getUserName());
if (object != null) {
mv.addObject("message","用户名已存在!");
mv.addObject("entity",entity);
mv.setViewName("user/userEdit");
return mv;
}
entity.setId(Tools.getUUID());
userService.save(entity);
}else{
userService.update(entity);
}
} catch (Exception e) {
e.printStackTrace();
}
mv.addObject("pageData", userService.findByPage(1, 10,null));
PageParam pageParam =new PageParam();
long count = 0;
try {
count = userService.count();
} catch (Exception e) {
e.printStackTrace();
}
pageParam.setCount(count);
if(count<=10){
pageParam.setSize(1);
}else{
pageParam.setSize(count%10==0?count/10:count/10+1);
}
pageParam.setPageNumber(1);
pageParam.setPageSize(10);
mv.addObject("pageParam",pageParam);
mv.setViewName("user/allUsers");
return mv;
}
@RequestMapping("/userDelete")
public String userDelete(String id){
if(Tools.notEmpty(id)){
try {
userService.deleteByid(id);
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",carService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("car/carEdit");
return mv;
}
@RequestMapping("/carSave")
public String travelRouteSave(HttpServletRequest request, String id, @RequestParam("fileName") MultipartFile file){
Car entity = null;
try {
if(Tools.notEmpty(id)){
entity = carService.findById(id);
}else{
entity = new Car();
}
this.bindValidateRequestEntity(request,entity);
if(file != null && !file.isEmpty()){
String fileName = file.getOriginalFilename();
int size = (int) file.getSize();
System.out.println(fileName + "-->" + size);
String path = filePath+"/car" ;
File dest = new File(path + "/" + fileName);
if(!dest.getParentFile().exists()){ //判断文件父目录是否存在
dest.getParentFile().mkdir();
}
try {
file.transferTo(dest); //保存文件
entity.setImgUrl("/car/" + fileName);
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
if (Tools.isEmpty(entity.getId())){
entity.setId(Tools.getUUID());
carService.save(entity);
}else{
carService.update(entity);
}
} catch (Exception e) {
e.printStackTrace();
}
return REDIRECT+"/manager/carList";
}
@RequestMapping("/carDelete")
@Controller
public class ScenicSpotPortalController extends BaseController {
@Autowired
IScenicSpotService scenicSpotService;
@Autowired
IUserService userService;
@Autowired
IOrderService orderService;
@RequestMapping("/travelSpot")
public ModelAndView travelSpot(PageParam pageParam) throws Exception {
ModelAndView mv = this.getModeAndView();
if(pageParam.getPageNumber()<1){
pageParam =new PageParam();
long count = 0;
try {
count = scenicSpotService.count2();
} catch (Exception e) {
e.printStackTrace();
}
pageParam.setCount(count);
if(count<=7){
pageParam.setSize(1);
}else{
pageParam.setSize(count%7==0?count/7:count/7+1);
}
pageParam.setPageNumber(1);
pageParam.setPageSize(7);
}
mv.addObject("pageData", scenicSpotService.findByPage(pageParam.getPageNumber(),pageParam.getPageSize()));
mv.addObject("pageParam",pageParam);
mv.setViewName("portal/travelSpot");
return mv;
}
@RequestMapping("/scenicSpotPortalView")
public ModelAndView scenicSpotPortalView(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",scenicSpotService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("portal/travelSpotView");
return mv;
return mv;
}
@RequestMapping("/travelRoutePortalView")
public ModelAndView travelRoutePortalView(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",travelRouteService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("portal/travelRouteView");
return mv;
}
@RequestMapping("/travelRouteCreatOrder")
public ModelAndView travelRouteCreatOrder(String id,HttpSession httpSession){
ModelAndView mv = this.getModeAndView();
try {
TravelRoute travelRoute = travelRouteService.findById(id);
User user = userService.findByUserName(httpSession.getAttribute("userName").toString());
Order order = new Order();
order.setImgUrl(travelRoute.getImgUrl());
order.setId(Tools.getUUID());
order.setUserId(user.getId());
order.setUserName(user.getUserName());
order.setProductId(travelRoute.getId());
order.setProductName(travelRoute.getTitle());
order.setFee(travelRoute.getPrice());
order.setProductType(0);
order.setLinkTel(user.getLinkTel());
order.setIcCode(user.getIcCode());
order.setRequirement("无");
order.setState(0);
order.setOrderCode("O"+Tools.getUUID().substring(0,6).toUpperCase());
order.setOrderTime(Tools.date2Str(new Date(),"yyyy-MM-dd"));
order.setSetoffTime(travelRoute.getStartTime());
orderService.save(order);
mv.addObject("entity",travelRoute);
mv.addObject("CreatSuccess",true);
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("portal/travelRouteView");
return mv;
}
}
if (Tools.notEmpty(query)) {
mv.addObject("query", query);
pageParam.setCount(list.size());
if (list.size() > pageParam.getPageSize()) {
pageParam.setSize(list.size() / pageParam.getPageSize());
} else {
pageParam.setSize(1);
}
}
mv.addObject("pageParam",pageParam);
mv.setViewName("order/orderList");
return mv;
}
@RequestMapping("/orderAdd")
public ModelAndView travelRouteAdd(){
ModelAndView mv = this.getModeAndView();
mv.addObject("entity",new Order());
mv.setViewName("order/orderEdit");
return mv;
}
@RequestMapping("/orderView")
public ModelAndView orderView(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",orderService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("order/orderView");
return mv;
}
@RequestMapping("/orderEdit")
public ModelAndView orderEdit(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",orderService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("order/orderEdit");
return mv;
}
@RequestMapping("/orderSave")
public String orderSave(HttpServletRequest request, String id){
Order entity = null;
try {
if(Tools.notEmpty(id)){
@Controller
@RequestMapping("/manager")
public class ScenicSpotController extends BaseController {
@Autowired
ScenicSpotService scenicSpotService;
private String filePath = System.getProperty("user.dir") + "/src/main/resources/static/";
@RequestMapping("/scenicSpotList")
public ModelAndView scenicSpotList(PageParam pageParam, @RequestParam(value = "query", required = false) String query){
ModelAndView mv = this.getModeAndView();
if(pageParam.getPageNumber()<1){
pageParam =new PageParam();
long count = 0;
try {
count = scenicSpotService.count();
} catch (Exception e) {
e.printStackTrace();
}
pageParam.setCount(count);
if(count<=10){
pageParam.setSize(1);
}else{
pageParam.setSize(count%10==0?count/10:count/10+1);
}
pageParam.setPageNumber(1);
pageParam.setPageSize(10);
}
List<ScenicSpot> list = scenicSpotService.findByPage(pageParam.getPageNumber(),pageParam.getPageSize(), query);
public ModelAndView scenicSpotEdit(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",scenicSpotService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("scenicSpot/scenicSpotEdit");
return mv;
}
@RequestMapping("/scenicSpotSave")
public String scenicSpotSave(HttpServletRequest request, String id, @RequestParam("fileName") MultipartFile file){
ScenicSpot entity = null;
try {
if(Tools.notEmpty(id)){
entity = scenicSpotService.findById(id);
}else{
entity = new ScenicSpot();
}
this.bindValidateRequestEntity(request,entity);
if(file != null && !file.isEmpty()){
String fileName = file.getOriginalFilename();
int size = (int) file.getSize();
System.out.println(fileName + "-->" + size);
String path = filePath+"/scenicSpot" ;
File dest = new File(path + "/" + fileName);
if(!dest.getParentFile().exists()){ //判断文件父目录是否存在
dest.getParentFile().mkdir();
}
try {
file.transferTo(dest); //保存文件
entity.setImgUrl("/scenicSpot/" + fileName);
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (Tools.isEmpty(entity.getId())){
entity.setId(Tools.getUUID());
scenicSpotService.save(entity);
}else{
scenicSpotService.update(entity);
}
}
@Controller
@RequestMapping("/manager")
public class OrderController extends BaseController {
@Autowired
OrderService orderService;
@RequestMapping("/orderList")
public ModelAndView orderList(PageParam pageParam, @RequestParam(value = "query", required = false) String query) {
ModelAndView mv = this.getModeAndView();
if(pageParam.getPageNumber()<1){
pageParam =new PageParam();
long count = 0;
try {
count = orderService.count();
} catch (Exception e) {
e.printStackTrace();
}
pageParam.setCount(count);
if(count<=10){
pageParam.setSize(1);
}else{
pageParam.setSize(count%10==0?count/10:count/10+1);
}
pageParam.setPageNumber(1);
pageParam.setPageSize(10);
}
List<Order> list = orderService.findByPage(pageParam.getPageNumber(),pageParam.getPageSize(), query);
mv.addObject("pageData", list);
if (Tools.notEmpty(query)) {
mv.addObject("query", query);
pageParam.setCount(list.size());
if (list.size() > pageParam.getPageSize()) {
}else{
pageParam.setSize(count%7==0?count/7:count/7+1);
}
pageParam.setPageNumber(1);
pageParam.setPageSize(7);
}
mv.addObject("pageData", carService.findByPage(pageParam.getPageNumber(),pageParam.getPageSize()));
mv.addObject("pageParam",pageParam);
mv.setViewName("portal/car");
return mv;
}
@RequestMapping("/carPortalView")
public ModelAndView travelRoutePortalView(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",carService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("portal/carView");
return mv;
}
@RequestMapping("/carCreatOrder")
public ModelAndView travelRouteCreatOrder(String id,HttpSession httpSession){
ModelAndView mv = this.getModeAndView();
try {
Car car =carService.findById(id);
User user = userService.findByUserName(httpSession.getAttribute("userName").toString());
Order order = new Order();
order.setImgUrl(car.getImgUrl());
order.setId(Tools.getUUID());
order.setUserId(user.getId());
order.setUserName(user.getUserName());
order.setProductId(car.getId());
order.setProductName(car.getTitle());
order.setFee(car.getPrice());
order.setProductType(3);
order.setLinkTel(user.getLinkTel());
order.setIcCode(user.getIcCode());
@Controller
@RequestMapping("/manager")
public class TravelRouteController extends BaseController {
@Autowired
TravelRouteService travelRouteService;
private String filePath = System.getProperty("user.dir") + "/src/main/resources/static/";
@RequestMapping("/travelRouteList")
public ModelAndView travelRouteList(PageParam pageParam, @RequestParam(value = "query", required = false) String query){
ModelAndView mv = this.getModeAndView();
if(pageParam.getPageNumber()<1){
pageParam =new PageParam();
long count = 0;
try {
count = travelRouteService.count();
} catch (Exception e) {
e.printStackTrace();
}
pageParam.setCount(count);
if(count<=10){
pageParam.setSize(1);
}else{
pageParam.setSize(count%10==0?count/10:count/10+1);
}
pageParam.setPageNumber(1);
pageParam.setPageSize(10);
}
List<TravelRoute> list = travelRouteService.findByPage(pageParam.getPageNumber(),pageParam.getPageSize(), query);
mv.addObject("pageData", list);
if (Tools.notEmpty(query)) {
mv.addObject("query", query);
pageParam.setCount(list.size());
if (list.size() > pageParam.getPageSize()) {
pageParam.setSize(list.size() / pageParam.getPageSize());
} else {
pageParam.setSize(1);
}
}
mv.addObject("pageParam",pageParam);
mv.setViewName("travelRoute/travelRouteList");
return mv;
}
try {
mv.addObject("entity",insuranceService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("insurance/insuranceEdit");
return mv;
}
@RequestMapping("/insuranceSave")
public String insuranceSave(HttpServletRequest request, String id, @RequestParam("fileName") MultipartFile file){
Insurance entity = null;
try {
if(Tools.notEmpty(id)){
entity = insuranceService.findById(id);
}else{
entity = new Insurance();
}
this.bindValidateRequestEntity(request,entity);
if(file != null && !file.isEmpty()){
String fileName = file.getOriginalFilename();
int size = (int) file.getSize();
System.out.println(fileName + "-->" + size);
String path = filePath+"/insurance" ;
File dest = new File(path + "/" + fileName);
if(!dest.getParentFile().exists()){ //判断文件父目录是否存在
dest.getParentFile().mkdir();
}
try {
file.transferTo(dest); //保存文件
entity.setImgUrl("/insurance/" + fileName);
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (Tools.isEmpty(entity.getId())){
entity.setId(Tools.getUUID());
insuranceService.save(entity);
}else{
insuranceService.update(entity);
}
} catch (Exception e) {
e.printStackTrace();
}
return REDIRECT+"/manager/insuranceList";
}
@RequestMapping("/insuranceDelete")
public String insuranceDelete(String id){
if(Tools.notEmpty(id)){
return mv;
}
@RequestMapping("/travelRouteAdd")
public ModelAndView travelRouteAdd(){
ModelAndView mv = this.getModeAndView();
mv.addObject("entity",new TravelRoute());
mv.setViewName("travelRoute/travelRouteEdit");
return mv;
}
@RequestMapping("/travelRouteView")
public ModelAndView travelRouteView(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",travelRouteService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("travelRoute/travelRouteView");
return mv;
}
@RequestMapping("/travelRouteEdit")
public ModelAndView travelRouteEdit(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",travelRouteService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("travelRoute/travelRouteEdit");
return mv;
}
@RequestMapping("/travelRouteSave")
public String travelRouteSave(HttpServletRequest request, String id, @RequestParam("fileName") MultipartFile file){
TravelRoute entity = null;
try {
if(Tools.notEmpty(id)){
entity = travelRouteService.findById(id);
}else{
entity = new TravelRoute();
}
this.bindValidateRequestEntity(request,entity);
if(file != null && !file.isEmpty()){
String fileName = file.getOriginalFilename();
int size = (int) file.getSize();
System.out.println(fileName + "-->" + size);
String path =filePath+"/travelRoute";
File dest = new File(path + "/" + fileName);
@RequestMapping("/goReserve")
public ModelAndView goReserve(String id,HttpSession httpSession){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",hotelService.findById(id));
mv.addObject("user",userService.findByUserName(httpSession.getAttribute("userName").toString()));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("portal/reserve");
return mv;
}
@RequestMapping("/hotelCreatOrder")
public ModelAndView hotelCreatOrder(String hotelId, HttpServletRequest request,HttpSession httpSession){
ModelAndView mv = this.getModeAndView();
try {
Hotel hotel = hotelService.findById(hotelId);
User user = userService.findByUserName(httpSession.getAttribute("userName").toString());
Order order = new Order();
this.bindValidateRequestEntity(request,order);
order.setId(Tools.getUUID());
order.setUserId(user.getId());
if(Tools.isEmpty(order.getUserName())){
order.setUserName(user.getUserName());
}
if(Tools.isEmpty(order.getLinkTel())){
order.setLinkTel(user.getLinkTel());
}
if(Tools.isEmpty(order.getIcCode())){
order.setIcCode(user.getIcCode());
}
order.setProductId(hotel.getId());
order.setImgUrl(hotel.getImgUrl());
order.setProductName(hotel.getHotelName());
order.setProductType(2);
order.setState(0);
order.setOrderCode("O"+Tools.getUUID().substring(0,6).toUpperCase());
order.setOrderTime(Tools.date2Str(new Date(),"yyyy-MM-dd"));
orderService.save(order);
mv.addObject("entity",hotel);
mv.addObject("CreatSuccess",true);
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("portal/hotelAccommodationView");
return mv;
}
}
@RequestMapping("/personInfo")
public ModelAndView personInfo(HttpSession httpSession){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",userService.findByUserName(httpSession.getAttribute("userName").toString()));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("portal/personalIntro");
return mv;
}
@RequestMapping("/personSave")
public String personSave(HttpServletRequest request, String id){
User entity = null;
try{
if(Tools.notEmpty(id)){
entity = userService.findById(id);
}
this.bindValidateRequestEntity(request,entity);
userService.update(entity);
} catch (Exception e) {
e.printStackTrace();
}
return REDIRECT+"/userCenter";
}
@RequestMapping("/changePassword")
public ModelAndView changePassword(HttpSession httpSession){
ModelAndView mv = this.getModeAndView();
mv.setViewName("portal/changePassword");
return mv;
}
@RequestMapping("/changePasswordSave")
public ModelAndView changePasswordSave(String password,String newPassword,String checkPassword,HttpSession httpSession) throws Exception {
ModelAndView mv = this.getModeAndView();
if(Tools.isEmpty(password)||Tools.isEmpty(newPassword)||Tools.isEmpty(checkPassword)){
mv.addObject("message","密码输入不能为空!");
mv.setViewName("portal/changePassword");
return mv;
}
User user = userService.findByUserName(httpSession.getAttribute("userName").toString());
if(!user.getPassword().equals(password)){
mv.addObject("message","原密码输入不正确!");
mv.setViewName("portal/changePassword");
return mv;
}else if(!newPassword.equals(checkPassword)){
mv.addObject("message","新密码与确认密码不一致!");
mv.setViewName("portal/changePassword");
mv.addObject("state2",carService.state2count());
mv.addObject("type0",carService.type0count());
mv.addObject("type1",carService.type1count());
mv.addObject("type2",carService.type2count());
mv.setViewName("data/carData");
return mv;
}
@RequestMapping("/insuranceData")
public ModelAndView insuranceDate()throws Exception{
ModelAndView mv=this.getModeAndView();
mv.addObject("state0",insuranceService.state0count());
mv.addObject("state1",insuranceService.state1count());
mv.addObject("state2",insuranceService.state2count());
mv.addObject("company0",insuranceService.company0count());
mv.addObject("company1",insuranceService.company1count());
mv.setViewName("data/insuranceData");
return mv;
}
}
@Controller
public class HotelPortalController extends BaseController {
}
}
mv.addObject("pageParam",pageParam);
mv.setViewName("hotel/hotelList");
return mv;
}
@RequestMapping("/hotelAdd")
public ModelAndView hotelAdd(){
ModelAndView mv = this.getModeAndView();
mv.addObject("entity",new Hotel());
mv.setViewName("hotel/hotelEdit");
return mv;
}
@RequestMapping("/hotelView")
public ModelAndView hotelView(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",hotelService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("hotel/hotelView");
return mv;
}
@RequestMapping("/hotelEdit")
public ModelAndView hotelEdit(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",hotelService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("hotel/hotelEdit");
return mv;
}
@RequestMapping("/hotelSave")
public String hotelSave(HttpServletRequest request, String id, @RequestParam("fileName") MultipartFile file){