基于javaweb+mysql的springboot旅游网站管理系统设计和实现(java+springboot+html+mysql+spring+maven)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot旅游网站管理系统设计和实现(java+springboot+html+mysql+spring+maven)
运行环境: java jdk 1.8 IDE环境
主要功能说明: 管理员角色包含以下功能:管理员登录,用户管理,旅游路线管理,旅游景点管理,酒店管理,旅游攻略管理,车票管理,订单管理,数据分析等功能。 用户角色包含以下功能:用户注册,用户登录,旅游路线预定,旅游景区预定,餐饮住宿,车票预定,旅游保险预定,旅游攻略,我的订单查看,个人资料管理等功能。 用了技术框架: HTML+CSS+JavaScript+jsp+mysql+Spring+Springboot+mybatis+maven+layui 所用的数据库: Mysql数据库
主要功能截图:
用户端:
注册和登录
首页功能菜单展示:
线路管理
旅游景点查看和预订等、预订完成在我的订单查看付款
餐饮查看和预订等、预订完成在我的订单查看付款
车票查看和预订等、预订完成在我的订单查看付款
保险查看和预订等、预订完成在我的订单查看付款
旅游攻略
注意事项:
后台管理员功能:
数据分析:
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());
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(car.getStartDateAndTime());
orderService.save(order);
mv.addObject("entity",car);
mv.addObject("CreatSuccess",true);
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)){
entity = orderService.findById(id);
}else{
entity = new Order();
}
this.bindValidateRequestEntity(request,entity);
if (Tools.isEmpty(entity.getId())){
entity.setId(Tools.getUUID());
orderService.save(entity);
}else{
orderService.update(entity);
}
} catch (Exception e) {
e.printStackTrace();
}
return REDIRECT+"/manager/orderList";
}
@RequestMapping("/orderDelete")
public String orderDelete(String id){
if(Tools.notEmpty(id)){
try {
orderService.deleteByid(id);
}catch (Exception e){
e.printStackTrace();
}
}
return REDIRECT+"/manager/orderList";
}
@Controller
@RequestMapping("/manager")
public class UserController extends BaseController {
@Autowired
UserService userService;
@RequestMapping("/userList")
public ModelAndView userList(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 = 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);
}
List<User> list = userService.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()) {
@Controller
public class MessagePortalController extends BaseController {
@Autowired
IMessageService messageService;
@Autowired
UserService userService;
@RequestMapping("/myMessage")
public ModelAndView myMessage(HttpSession httpSession) throws Exception {
ModelAndView mv = this.getModeAndView();
User user = userService.findByUserName(httpSession.getAttribute("userName").toString());
mv.addObject("messageCount", messageService.countByUserId(user.getId()));
mv.setViewName("portal/myMessage");
return mv;
}
@RequestMapping("/saveMeessage")
public ModelAndView saveMeessage(HttpSession httpSession,HttpServletRequest request) throws Exception {
ModelAndView mv = this.getModeAndView();
User user = userService.findByUserName(httpSession.getAttribute("userName").toString());
Message message = new Message();
this.bindValidateRequestEntity(request,message);
message.setId(Tools.getUUID());
message.setUserId(user.getId());
message.setUserName(user.getUserName());
message.setName(user.getName());
message.setState(1);
messageService.save(message);
mv.addObject("messageCount", messageService.countByUserId(user.getId()));
mv.addObject("message","保存成功!");
mv.setViewName("portal/myMessage");
return mv;
}
@RequestMapping("/messageList")
public ModelAndView messageList(
HttpSession httpSession,
@RequestParam(value = "pageNum", required = false, defaultValue = "1") int pageNum,
@RequestParam(value = "pageSize", required = false, defaultValue = "7") int pageSize
) throws Exception {
ModelAndView mv = this.getModeAndView();
@Controller
@RequestMapping("/manager")
public class AdminController extends BaseController {
@Autowired
AdminService adminService;
@RequestMapping("/adminList")
public ModelAndView adminList(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 = adminService.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<Admin> list = adminService.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("admin/adminList");
return mv;
@RequestMapping("/strategyEdit")
public ModelAndView scenicSpotEdit(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",strategyService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("strategy/strategyEdit");
return mv;
}
@RequestMapping("/strategySave")
public String strategySave(HttpServletRequest request, String id, @RequestParam("fileName1") MultipartFile file1,
@RequestParam("fileName2") MultipartFile file2){
Strategy entity = null;
try {
if(Tools.notEmpty(id)){
entity = strategyService.findById(id);
}else{
entity = new Strategy();
}
this.bindValidateRequestEntity(request,entity);
if(file1!= null && !file1.isEmpty()){
String fileName = file1.getOriginalFilename();
int size = (int) file1.getSize();
System.out.println(fileName + "-->" + size);
String path = "F:/最代码/旅游/travel/target/classes/static/strategy" ;
File dest = new File(path + "/" + fileName);
if(!dest.getParentFile().exists()){ //判断文件父目录是否存在
dest.getParentFile().mkdir();
}
try {
file1.transferTo(dest); //保存文件
entity.setImgUrl("/strategy/" + fileName);
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
mv.addObject("message","新密码与确认密码不一致!");
mv.setViewName("portal/changePassword");
return mv;
}else{
user.setPassword(newPassword);
userService.update(user);
}
mv.setViewName("portal/userCenter");
return mv;
}
}
@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();
@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);
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("scenicSpot/scenicSpotList");
return mv;
}
@RequestMapping("/scenicSpotAdd")
public ModelAndView scenicSpotAdd(){
ModelAndView mv = this.getModeAndView();
mv.addObject("entity",new ScenicSpot());
mv.setViewName("scenicSpot/scenicSpotEdit");
return mv;
}
@RequestMapping("/scenicSpotView")
public ModelAndView scenicSpotView(String id){
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("scenicSpot/scenicSpotList");
return mv;
}
@RequestMapping("/scenicSpotAdd")
public ModelAndView scenicSpotAdd(){
ModelAndView mv = this.getModeAndView();
mv.addObject("entity",new ScenicSpot());
mv.setViewName("scenicSpot/scenicSpotEdit");
return mv;
}
@RequestMapping("/scenicSpotView")
public ModelAndView scenicSpotView(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",scenicSpotService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("scenicSpot/scenicSpotView");
return mv;
}
@RequestMapping("/scenicSpotEdit")
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("/travelRouteDelete")
public String travelRouteDelete(String id){
if(Tools.notEmpty(id)){
try {
travelRouteService.deleteByid(id);
}catch (Exception e){
e.printStackTrace();
}
}
return REDIRECT+"/manager/travelRouteList";
}
}
@Controller
@RequestMapping("/manager")
public class InsuranceController extends BaseController{
@Autowired
InsuranceService insuranceService;
private String filePath = System.getProperty("user.dir") + "/src/main/resources/static/";
@RequestMapping("/insuranceList")
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;
}
}
}
} 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) {
redirectAttributes.addFlashAttribute("message","用户名已存在!");
return new ModelAndView(new RedirectView("/register"));
}
try {
user.setId(Tools.getUUID());
user.setState(1);
userService.save(user);
} catch (Exception e) {
e.printStackTrace();
}
redirectAttributes.addFlashAttribute("message","注册成功,请登陆!");
return new ModelAndView(new RedirectView("/goLogin"));
}
@RequestMapping("/personInfo")
public ModelAndView personInfo(HttpSession httpSession){
ModelAndView mv = this.getModeAndView();
@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()) {
pageParam.setSize(list.size() / pageParam.getPageSize());
} else {
pageParam.setSize(1);
}
}
mv.addObject("pageParam",pageParam);
mv.setViewName("order/orderList");
return mv;
mv.addObject("state1",orderService.state1count());
mv.addObject("state2",orderService.state2count());
mv.setViewName("data/orderData");
return mv;
}
@RequestMapping("/strategyData")
public ModelAndView strategyDate()throws Exception{
ModelAndView mv=this.getModeAndView();
mv.addObject("state0",strategyService.state0count());
mv.addObject("state1",strategyService.state1count());
mv.addObject("state2",strategyService.state2count());
mv.setViewName("data/strategyData");
return mv;
}
@RequestMapping("/carData")
public ModelAndView carDate()throws Exception{
ModelAndView mv=this.getModeAndView();
mv.addObject("state0",carService.state0count());
mv.addObject("state1",carService.state1count());
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;
}
}
mv.addObject("entity",new Insurance());
mv.setViewName("insurance/insuranceEdit");
return mv;
}
@RequestMapping("/insuranceView")
public ModelAndView insuranceView(String id){
ModelAndView mv = this.getModeAndView();
try {
mv.addObject("entity",insuranceService.findById(id));
}catch (Exception e){
e.printStackTrace();
}
mv.setViewName("insurance/insuranceView");
return mv;
}
@RequestMapping("/insuranceEdit")
public ModelAndView insuranceEdit(String id){
ModelAndView mv = this.getModeAndView();
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()){
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;
}
@RequestMapping("/travelSpotCreatOrder")
public ModelAndView travelSpotCreatOrder(String id,HttpSession httpSession){
ModelAndView mv = this.getModeAndView();
try {
ScenicSpot scenicSpot = scenicSpotService.findById(id);
User user = userService.findByUserName(httpSession.getAttribute("userName").toString());
return REDIRECT+"/manager/strategyList";
}
@RequestMapping("/strategyDelete")
public String strategyDelete(String id){
if(Tools.notEmpty(id)){
try {
strategyService.deleteByid(id);
}catch (Exception e){
e.printStackTrace();
}
}
return REDIRECT+"/manager/strategyList";
}
}
@Controller
public class UserPortalController extends BaseController {
@Autowired
UserService userService;
@RequestMapping("/userLoging")
public ModelAndView userLoging(String userName,String password,RedirectAttributes redirectAttributes,HttpSession httpSession){
if(Tools.notEmpty(httpSession.getAttribute("userName"))){
return new ModelAndView(new RedirectView("/userCenter"));
}
@Controller
@RequestMapping("/manager")
public class DataController extends BaseController {
@Autowired
UserService userService;
@Autowired
TravelRouteService travelRouteService;
@Autowired
ScenicSpotService scenicSpotService;
@Autowired
HotelService hotelService;
@Autowired
OrderService orderService;
@Autowired
StrategyService strategyService;
@Autowired
CarService carService;
@Autowired
InsuranceService insuranceService;
@RequestMapping("/userData")
public ModelAndView userDate()throws Exception{
ModelAndView mv=this.getModeAndView();
mv.addObject("state1",userService.state1count());
mv.addObject("state2",userService.state2count());
mv.setViewName("data/userData");
return mv;
}
@RequestMapping("/travelRouteData")
public ModelAndView travelRouteDate()throws Exception{
ModelAndView mv=this.getModeAndView();
mv.addObject("state0",travelRouteService.state0count());
mv.addObject("state1",travelRouteService.state1count());
mv.addObject("state2",travelRouteService.state2count());
mv.setViewName("data/travelRouteData");
return mv;
}
@RequestMapping("/scenicSpotData")
public ModelAndView scenicSpotDate()throws Exception{
ModelAndView mv=this.getModeAndView();