基于javaweb+mysql的ssm+maven旅游管理系统(前台、后台)(java+jsp+ssm+maven+mysql)

基于javaweb+mysql的ssm+maven旅游管理系统(前台、后台)(java+jsp+ssm+maven+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

分为前台用户和后台管理员功能

管理员

  • 登录、管理用户、管理景点、管理酒店、管理论坛帖子、管理评论等

用户端

  • 登录、注册、景点、酒店、论坛、评论等功能的浏览和评论等

idea运行/eclipse/MyEclipse运行

前台

后台

技术框架

JavaBean MVC JSP SSM(Spring SpringMVC MyBatis) Maven MySQL jQuery JavaScript CSS

基于javaweb+mysql的SSM+Maven旅游管理系统(前台、后台)(java+jsp+ssm+maven+mysql)

	@Autowired
    HotelDao hotelDao;
	/**
	 * 跳转定制
	 */
	@RequestMapping(value = "index", method = RequestMethod.GET)
	public String index() {
		return "proscenium/cust/index";
	}

	/**
	 * 定制返回景
	 */
	@ResponseBody
	@RequestMapping(value = "viewPoint", method = RequestMethod.GET)
	public List<ViewPoint> viewPoint(String tpLocation) {
		ViewPointExample example = new ViewPointExample();
		example.createCriteria().andTpLocationEqualTo(tpLocation);
		example.setOrderByClause("tp_vid desc");
		List<ViewPoint> viewPoints = viewPointDao.selectByExample(example);
		return viewPoints;
	}

	/**
	 * 定制返回酒店
	 */
	@ResponseBody
	@RequestMapping(value = "hotel", method = RequestMethod.GET)
	public List<Hotel> hotel(String local) {
		String filePath = "/static/upload/hotelAvatar/";
		HotelExample example = new HotelExample();
		example.createCriteria().andLocalEqualTo(local);
		example.setOrderByClause("hid desc");
		System.out.println(example);
		List<Hotel> hotels = hotelDao.selectByExample(example);
		for (Hotel hotel : hotels){
			String fileSuffix = hotel.getImgUrl();
			hotel.setImgUrl(filePath + fileSuffix);
		}
		System.out.println(hotels);
		return hotels;
	}
}

	 */
	@RequestMapping(value="/saveforumWords")
	public String saveForumWords(Words words){
		if(words != null){
			String forumId = words.getLw_forumId();//获取什么类型的ID
			viewPointService.saveWords(words);
			return "redirect:toForumArticleView.do?tpFid=" + forumId;
		}else{
			return null;
		}
	}

	/**
	 * 跳转到论坛
	 */

	@RequestMapping(value="/toForumArticleView")
	public String toForumArticleView(@RequestParam int tpFid, Model model){
		//封装留言信息
		lw_list = viewPointService.findByWords();
		model.addAttribute("lw_list",lw_list);

		//封装回复信息
		lr_list = viewPointService.findByReply();
		model.addAttribute("lr_list",lr_list);

		//查询文章信息
		Forum forum = forumDao.selectByPrimaryKey(tpFid);

		System.out.println("查询到当前文章的ID值:" + forum.getTpFid());

		if (forum != null) {
			model.addAttribute("forum", forum);
			return "proscenium/forum/content";
		} else {
			return null;
		}
	}

	 * 跳转景点更新业务
	 */
	@RequestMapping(value = "hoteldelete", method = RequestMethod.GET)
	public String hotelDelete(Integer hid) {
		hotelDao.deleteByPrimaryKey(hid);
		session.setAttribute("msg", Msg.success("删除酒店成功!"));
		return "redirect:hotellist";
	}

	/**
	 * 酒店
	 * 批量删除
	 */

	@RequestMapping(value = "hotelMutiDelete", method = RequestMethod.GET)
	@ResponseBody//返回给前端
	public String hotelMutiDelete(Integer[] hids) {
		for (Integer hid : hids) {
			hotelDao.deleteByPrimaryKey(hid);
		}
		session.setAttribute("msg", Msg.success(Arrays.toString(hids) + "号景点批量删除成功!"));
		return "1";
	}

	/**
	 * 酒店
	 * 新增表单跳转
	 */
	@RequestMapping(value = "hotelInsertForm", method = RequestMethod.GET)
	public String hotelInsertForm() {
		return "admin/hotel_insert";
	}

	/**
	 * 酒店新增
	 */
	@RequestMapping(value = "hotelInsert", method = RequestMethod.POST)
	public String hotelInsert(Hotel hotel, Model model) {
		if (hotel.getHid() == null) {
			hotelDao.insertSelective(hotel);
			model.addAttribute("msg", Msg.success("新增景点成功!"));
			return "redirect:hotellist";
		}
		model.addAttribute("msg", Msg.fail("新增景点失败!"));
		return "redirect:hoteledit";
		}
	}

	/**
	 * 跳转到论坛
	 */

	@RequestMapping(value="/toForumArticleView")
	public String toForumArticleView(@RequestParam int tpFid, Model model){
		//封装留言信息
		lw_list = viewPointService.findByWords();
		model.addAttribute("lw_list",lw_list);

		//封装回复信息
		lr_list = viewPointService.findByReply();
		model.addAttribute("lr_list",lr_list);

		//查询文章信息
		Forum forum = forumDao.selectByPrimaryKey(tpFid);

		System.out.println("查询到当前文章的ID值:" + forum.getTpFid());

		if (forum != null) {
			model.addAttribute("forum", forum);
			return "proscenium/forum/content";
		} else {
			return null;
		}
	}

	/**
	 * 保存论坛回复信息
	 */
	@RequestMapping(value="/saveHotelReply")
	public String saveHotelReply(Reply reply){
		if(reply != null){
			viewPointService.saveReply(reply);
			String hid = reply.getLr_hotel_id();
			return "redirect:toHotelArticleView.do?hid=" + hid;
		}else{
			return null;
		}
	}

	/**
	 * 保存论坛留言信息
	 */
	@RequestMapping(value="/saveHotelWords")
		ViewPoint viewPoint = new ViewPoint();

		viewPoint.setTpVname(keyword);
		viewPoint.setTpVtype(keyword);
		viewPoint.setTpLocation(keyword);
		List<ViewPoint> viewPoints = viewPointDao.viewPointSearch(viewPoint);

		for (ViewPoint vp : viewPoints){
			String imgUrl = vp.getTpVpic();
			vp.setTpVpic(prefix + imgUrl);
		}

		model.addAttribute("viewPoints", viewPoints);
		model.addAttribute("msg", Msg.success("景点查询成功!"));

		return "admin/view_list";
	}

	/**
	 * 后台酒店模糊搜索
	 */
	@RequestMapping(value = "hotelPointSearch", method = RequestMethod.GET)
	public String hotelPointSearch(String keyword, Model model) {
		String prefix = "/static/upload/hotelAvatar/";

		Hotel hotel = new Hotel();

		hotel.setLocal(keyword);
		hotel.setHouseType(keyword);
		hotel.setBedType(keyword);

		List<Hotel> hotels = hotelDao.hotelPointSearch(hotel);

		for (Hotel hotelForEach : hotels){
			String imgUrl = hotelForEach.getImgUrl();
			hotelForEach.setImgUrl(prefix + imgUrl);
		}

		model.addAttribute("hotels", hotels);
		model.addAttribute("msg", Msg.success("酒店查询成功!"));

		return "admin/hotel_list";
	}

	/**
	 * 后台论坛模糊搜索
	 */
	@RequestMapping(value = "forumPointSearch", method = RequestMethod.GET)
	public String forumPointSearch(String keyword, Model model) {
		String fileName = dropFile.getOriginalFilename();
		String fileSuffix = fileName.substring(fileName.lastIndexOf('.'));

		//文件存放路径
		String realPath = request.getSession().getServletContext().getRealPath(prefix);

		File file = new File(realPath);
		//判断文件是否存在
		if (!file.exists()){
			file.mkdir();
		}
		file = new File(realPath, UUID.randomUUID() + fileSuffix);
		try {
			dropFile.transferTo(file);

		} catch (IOException e) {
			e.printStackTrace();
		}
		//传到前端
		result.put("errno",0);
		result.put("data",new String[] {prefix + file.getName()});
		return result;
	}

	/**
	 * 后台内容图片上传
	 * @param dropFile
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "fourmContentUpload", method = RequestMethod.POST)
	public Map<String, Object> fourmContentUpload(MultipartFile dropFile, HttpServletRequest request) {
		Map<String, Object> result = new HashMap<>();
		//前缀路径 Scheme服务端提供的协议 getServerName服务器名称 port 端口
		//String server = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();

		//图片显示路径
		String prefix = "/static/upload/forumFile/";

		//获取文件后缀
		String fileName = dropFile.getOriginalFilename();
		String fileSuffix = fileName.substring(fileName.lastIndexOf('.'));

	@RequestMapping(value = "replyMutiDelete", method = RequestMethod.GET)
	public String replyMutiDelete(Integer[] lr_ids, Model model) {
		for (Integer lr_id : lr_ids){
			replyDao.deleteByPrimaryKey(lr_id);

		}
		model.addAttribute("msg", Msg.success(Arrays.toString(lr_ids) + "号删除成功!"));
		return "1";
	}

	/**
	 * 单击删除
	 * @return
	 */
	@RequestMapping(value = "replyDelete", method = RequestMethod.GET)
	public String replyDelete(Integer lr_id, Model model) {
		replyDao.deleteByPrimaryKey(lr_id);
		model.addAttribute("msg", Msg.success(lr_id + "号删除成功!"));
		return "redirect:replyList";
	}

}

/**
 * 文件上传控制器
 */

	/**
	 * 后台内容图片上传
	 * @param dropFile
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "viewContentUpload", method = RequestMethod.POST)
	public Map<String, Object> viewContentUpload(MultipartFile dropFile, HttpServletRequest request) {
		Map<String, Object> result = new HashMap<>();
		//前缀路径 Scheme服务端提供的协议 getServerName服务器名称 port 端口
		//String server = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();

		//图片显示路径
		String prefix = "/static/upload/contentFile/";

		//获取文件后缀
		String fileName = dropFile.getOriginalFilename();
		String fileSuffix = fileName.substring(fileName.lastIndexOf('.'));

		//文件存放路径
		String realPath = request.getSession().getServletContext().getRealPath(prefix);

		File file = new File(realPath);
		//判断文件是否存在
		if (!file.exists()){
			file.mkdir();
		}
		file = new File(realPath, UUID.randomUUID() + fileSuffix);
		try {
			dropFile.transferTo(file);

		} catch (IOException e) {
			e.printStackTrace();
		}
		//传到前端
		result.put("errno",0);
		result.put("data",new String[] {prefix + file.getName()});
		return result;
	}

	/**
	 * 文件上传
	 * @param dropFile
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "hotelAvatar", method = RequestMethod.POST)
	public Map<String, Object> hotelAvatar(MultipartFile dropFile, HttpServletRequest request) {
		Map<String, Object> result = new HashMap<>();
		//文件存放路径
		String filePath = "/static/upload/hotelAvatar/";

	/**********user start***************
	 * 查看用户列表
	 */
	@RequestMapping(value = "userlist", method = RequestMethod.GET)
	public String userList() {
		String prefix = "/static/upload/useravatar/";
		List<User> users = userService.selectAll();
		for (User user : users) {
			String suffix = user.getUpic();
			user.setUpic(prefix + suffix);
		}
		session.setAttribute("users", users);
		return "admin/user_list";
	}

	/**
	 * 用户模糊搜索
	 */
	@RequestMapping(value = "usersearch", method = RequestMethod.GET)
	public String userSearch(String keyword, HttpSession session) {
		System.out.println(keyword);
		String prefix = "/static/upload/useravatar/";
		List<User> users = userService.search(keyword);
		for (User user : users){
			String imgUrl = user.getUpic();
			user.setUpic(prefix + imgUrl);
		}
		session.setAttribute("users", users);
		session.setAttribute("msg", Msg.success("用户查询成功!"));

		return "admin/user_list";
	}

	/**
	 * 景点模糊搜索
	 */
	@RequestMapping(value = "viewPointSearch", method = RequestMethod.GET)
	public String viewPointSearch(String keyword, Model model) {
		String prefix = "/static/upload/viewavatar/";

		ViewPoint viewPoint = new ViewPoint();

		viewPoint.setTpVname(keyword);
		viewPoint.setTpVtype(keyword);
		viewPoint.setTpLocation(keyword);
		List<ViewPoint> viewPoints = viewPointDao.viewPointSearch(viewPoint);

		for (ViewPoint vp : viewPoints){
			String imgUrl = vp.getTpVpic();
			file.mkdir();
		}
		file = new File(realPath,UUID.randomUUID() + fileSuffix);
		try {
			dropFile.transferTo(file);
		} catch (IOException e) {
			e.printStackTrace();
		}
		result.put("fileName",file.getName());
		return result;
	}

	/**
	 * 后台内容图片上传
	 * @param dropFile
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "viewContentUpload", method = RequestMethod.POST)
	public Map<String, Object> viewContentUpload(MultipartFile dropFile, HttpServletRequest request) {
		Map<String, Object> result = new HashMap<>();
		//前缀路径 Scheme服务端提供的协议 getServerName服务器名称 port 端口
		//String server = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();

		//图片显示路径
		String prefix = "/static/upload/contentFile/";

		//获取文件后缀
		String fileName = dropFile.getOriginalFilename();
		String fileSuffix = fileName.substring(fileName.lastIndexOf('.'));

		//文件存放路径
		String realPath = request.getSession().getServletContext().getRealPath(prefix);

		File file = new File(realPath);
		//判断文件是否存在
		if (!file.exists()){
			file.mkdir();
		}
		file = new File(realPath, UUID.randomUUID() + fileSuffix);
		try {
			dropFile.transferTo(file);
	 */
	@RequestMapping(value = "trafficDelete", method = RequestMethod.GET)
	public String trafficDelete(Integer tpTid, Model model) {
		trafficDao.deleteByPrimaryKey(tpTid);
		model.addAttribute("msg", Msg.success(tpTid + "号删除成功!"));
		return "redirect:trafficList";
	}
	/**
	 * 批量删除
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "trafficMutiDelete", method = RequestMethod.GET)
	public String trafficsMutiDelete(Integer[] tpTids, Model model) {

		for (Integer tpTid : tpTids){
			trafficDao.deleteByPrimaryKey(tpTid);

		}
		model.addAttribute("msg", Msg.success(Arrays.toString(tpTids) + "号删除成功!"));
		return "1";
	}

	/**
	 * 跳转交通编辑页面
	 * @return String
	 */
	@RequestMapping(value = "trafficEdit", method = RequestMethod.GET)
	public String trafficEdit(Integer tpTid, Model model) {
		Traffic traffic = trafficDao.selectByPrimaryKey(tpTid);

		model.addAttribute("traffic", traffic);
		return "admin/traffic_edit";
	}

	/**
	 * 交通编辑
	 * @return
	 */
	@RequestMapping(value = "trafficEditHandle", method = RequestMethod.POST)
	public String trafficEditHandle(Traffic traffic, String currentTime, String arriveTime, Model model) {
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			return "proscenium/forum/edit";
		}
		model.addAttribute("msg", Msg.fail("您还未登录!"));
		return "redirect:index";
	}

	/**
	 * content
	 */
	@RequestMapping(value = "savecontent", method = RequestMethod.POST)
	public String saveContent(Forum forum, Model model){
		forumDao.insert(forum);
		model.addAttribute("msg", Msg.success("发帖成功"));
		return "redirect:index";
	}

	/*############后台开始##############*/

}

@Controller
@RequestMapping(value = "view")
public class ViewPointController {
	@Autowired
	private ViewPointService viewPointService;

	private HttpSession session;
	@Autowired
	private ViewPointExample viewPointExample;
	@Autowired
	private ViewPointDao viewPointDao;

	/**
	}

	/**
	 * 发帖功能 跳转编辑页面
	 */
	@RequestMapping(value = "issue", method = RequestMethod.GET)
	public String issue(Integer uid, Model model){
		if (uid != null){
			return "proscenium/forum/edit";
		}
		example.setOrderByClause("tp_fid desc");
		List<Forum> forums = forumDao.selectByExampleWithBLOBs(example);
		model.addAttribute("forums",forums);
		model.addAttribute("msg", Msg.fail("您还未登录!"));
		return "proscenium/forum/index";
	}

	/**
	 * 编辑页面
	 */
	@RequestMapping(value = "edit", method = RequestMethod.GET)
	public String edit(Integer uid, Model model){
		if (uid != null){
			return "proscenium/forum/edit";
		}
		model.addAttribute("msg", Msg.fail("您还未登录!"));
		return "redirect:index";
	}

	/**
	 * content
	 */
	@RequestMapping(value = "savecontent", method = RequestMethod.POST)
	public String saveContent(Forum forum, Model model){
		forumDao.insert(forum);
		model.addAttribute("msg", Msg.success("发帖成功"));
		return "redirect:index";
	}

	/*############后台开始##############*/

}


	/**
	 * 跳转回复列表
	 * @return
	 */
	@RequestMapping(value = "replyList", method = RequestMethod.GET)
	public String ReplyList(Model model) {
		List<Reply> replys = viewPointService.findByReply();
		model.addAttribute("replys", replys);
		return "admin/reply_list";
	}

	/**
	 * 回复批量删除
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "replyMutiDelete", method = RequestMethod.GET)
	public String replyMutiDelete(Integer[] lr_ids, Model model) {
		for (Integer lr_id : lr_ids){
			replyDao.deleteByPrimaryKey(lr_id);

		}
		model.addAttribute("msg", Msg.success(Arrays.toString(lr_ids) + "号删除成功!"));
		return "1";
	}

	/**
	 * 单击删除
	 * @return
	 */
	@RequestMapping(value = "replyDelete", method = RequestMethod.GET)
	public String replyDelete(Integer lr_id, Model model) {
		replyDao.deleteByPrimaryKey(lr_id);
		model.addAttribute("msg", Msg.success(lr_id + "号删除成功!"));
		return "redirect:replyList";
	}

}

	 * 后台交通列表模糊搜索
	 */
	@RequestMapping(value = "trafficPointSearch", method = RequestMethod.GET)
	public String trafficPointSearch(String keyword, Model model) {

		Traffic traffic = new Traffic();

		traffic.setTpType(keyword);
		traffic.setTpCurrent(keyword);
		traffic.setTpDestination(keyword);

		List<Traffic> traffics = trafficDao.trafficPointSearch(traffic);

		model.addAttribute("traffics", traffics);
		model.addAttribute("msg", Msg.success("交通查询成功!"));

		return "admin/traffic_list";
	}

	/**
	 * 用户单个单击删除
	 */
	@RequestMapping(value = "userdelete", method = RequestMethod.GET)
	public String userDelete(String uid) {
		System.out.println(uid);
		String prefix = "/static/upload/useravatar/";
		userService.userDelete(uid);
		List<User> users = userService.selectAll();
		for (User user : users){
			String imgUrl = user.getUpic();
			user.setUpic(prefix + imgUrl);
		}
		session.setAttribute("users", users);
		session.setAttribute("msg", Msg.success(uid + "号用户删除成功!"));
		return "admin/user_list";
	}

	/**
	 * 用户新增表单跳转
	 */
	@RequestMapping(value = "userform", method = RequestMethod.GET)
	public String userForm() {
		return "admin/user_form";
	}

	/**
		List<Forum> forums = forumDao.selectByExample(example);
		List<Forum> queryForums = new ArrayList<>();
		for(Forum forum : forums){
			if (uid.equals(forum.getTpAuthorId())){
				queryForums.add(forum);
			}
		}
		model.addAttribute("forums", queryForums);
		return "proscenium/user/forum";
	}

	///**
	// * 用户发表论坛编辑
	// */
	//@RequestMapping(value = "forumEdit", method = RequestMethod.GET)
	//public String forumEdit(Integer tpFid, Model model) {
	//	Forum forum = forumDao.selectByPrimaryKey(tpFid);
	//	model.addAttribute("forum", forum);
	//	return "proscenium/user/forum_edit";
	//}
}

@Controller
@RequestMapping(value = "article")
public class ArticleController {
	//声明用于存放留言回复信息的List集合
	private List<Words> lw_list;
	private List<Reply> lr_list;

	@Autowired
    ViewPointService viewPointService;
	@Autowired
    ForumDao forumDao;
	@Autowired
    HotelDao hotelDao;

	/**
	 * 保存景点留言信息
	 */
	@RequestMapping(value="/saveWords")
	private HttpSession session;
	@Autowired
	private ForumDao forumDao;
	@Autowired
	private ForumExample example;

	/**
	 * index页用户登录
	 */
	@RequestMapping(value = "login", method = RequestMethod.POST)
	public String userLogin(String uemail, String upwd, Model model) {
		//index页面登录成功图片显示路径
		String prefix = "/static/upload/useravatar/";
		//index页用户登录验证
		if (uemail == null || uemail == "" || upwd == null || upwd == "") {
			session.setAttribute("msg", Msg.fail("邮箱或密码不可为空!"));
			return "redirect:/index";
		}
		User user = userService.userLogin(new User(uemail, upwd));
		if (user != null) {
			String suffix = user.getUpic();
			user.setUpic(prefix+suffix);
			session.setAttribute("user", user);
			return "redirect:/index";
		} else {
			session.setAttribute("msg", Msg.fail("还未注册或邮箱密码错误,请重新输入!"));
			return "redirect:/index";
		}

	}

	/**
	 * 前台用户注销
	 *
	 * @return
	 */
	@RequestMapping(value = "loginout", method = RequestMethod.GET)
	public String loginOut() {
		session.invalidate();
		return "redirect:/index";

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值