Java项目:在线旅游路线商城系统(java+JSP+JavaScript+servlet+Mysql)

源码获取:俺的博客首页 "资源" 里下载!

项目介绍

本系统分为前后台,分为普通用户和管理员两种角色;

管理员角色包含以下功能:

管理员登录,用户管理,路线分类管理,路线管理,订单管理,留言管理,新闻管理等功能。

用户角色包含以下功能:
按分类查看,用户登录,修改个人信息,查看旅游线路详情,加入购物车,查看订单,提交订单,提交留言等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 
5.数据库:MySql 5.7版本;
6.是否Maven项目:否;


技术栈

JSP+CSS+JavaScript+java+servlet+mysql


使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中src/com/hr/dao/Basedao.java配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入http://localhost:8080/ 登录
管理员账号/密码:admin/admin 
用户账号/密码:user/123456

 

 

 

 

 

登陆后台管理控制层:

/**
 * 登陆后台管理界面
 *
 */
@Controller
@RequestMapping("/backgroundweb")
public class SysloginController {
	public Logger logger = LoggerFactory
			.getLogger(SysloginController.class);// 输出日志
	@Autowired
	private SceneInformationService sceneInformationService;
	@Autowired
	private StrategyInfoemationService strategyInfoemationService;
	@Autowired
	private TourismUserService tourismUserService;
	@Autowired 
	private SearchRecordService searchRecordService;
   @RequestMapping("/checkLogin")
   @ResponseBody
   public JSONObject checkLogin(HttpServletRequest request,HttpServletResponse response,String userName,String passWord){
	   logger.info("收到的用户名为:"+userName+",密码为:"+passWord);
	   JSONObject json=new JSONObject();
	   if(userName.equals("admin") && passWord.equals("123456")){
		   request.getSession().setAttribute("userName","admin");
		   json.put("fiag", true);
	   }else{
		   json.put("fiag", false);
	   }
	   return json;
   }
   @RequestMapping("/jumpMain")
   public String jumpMain(ModelMap model){
	   model.put("userName","admin");
	   return "backgroundWeb/main";
   }
 //跳转新建景点界面
   @RequestMapping("/addAttractions")
   public String addAttractions(){
	 return "backgroundWeb/addAttractions";
   }
   //跳转用户信息界面
   @RequestMapping("/viewUser")
   public String viewUser(){
	   return "backgroundWeb/viewUser";
   }
   /**
	 * 用户退出
	 * @return
	 */
	@RequestMapping(value="/logout")
	public String dropOut(HttpServletRequest request, HttpServletResponse response){
		HttpSession session = request.getSession();
		session.removeAttribute("userName");
		return "redirect:/login";
	}
  //保存景点信息
   @RequestMapping("/save")
   @ResponseBody
   public JSONObject save (@RequestBody AttractionsDto attractionsDto){
	   JSONObject json =new JSONObject();
	   boolean flag=true;
	   logger.info("保存的实体类信息:"+JSONObject.toJSONString(attractionsDto));
	   try{
		   SceneInformation sceneInformation =new SceneInformation();
		   sceneInformation.setCreateTime(new Date());
		   sceneInformation.setState(1);
		   sceneInformation.setSceneSite(attractionsDto.getSceneSite());
		   sceneInformation.setSceneImage(attractionsDto.getSceneImage());
		   sceneInformation.setSceneName(attractionsDto.getSceneName());
		   sceneInformation.setScenePrice(attractionsDto.getScenePrice());
		   sceneInformation.setSceneTime(attractionsDto.getSceneTime());
		   sceneInformation.setSceneIntroduce(attractionsDto.getSceneIntroduce());
		   Integer aa= sceneInformationService.insert(sceneInformation);
		   logger.info("返回的id为:"+aa+"当前实体类id为:"+sceneInformation.getId());
		   if(aa >0){
			       if(StringUtils.isNotEmpty(attractionsDto.getOneSite())){
			    	   StrategyInfoemation strategyInfoemation =new StrategyInfoemation();
					   strategyInfoemation.setStatus(Constant.isUsd);
					   strategyInfoemation.setCreateTime(new Date());
					   strategyInfoemation.setStrategyAccommodation(attractionsDto.getOneAccommodation());
					   strategyInfoemation.setStrategyDays(1);
					   strategyInfoemation.setStrategyIntroduce(attractionsDto.getOneIntroduce());
					   strategyInfoemation.setStrategySite(attractionsDto.getOneSite());
					   strategyInfoemation.setStrategyTraffic(attractionsDto.getOneTraffic());
					   strategyInfoemation.setSceneId(sceneInformation.getId());
					   strategyInfoemationService.insert(strategyInfoemation);
					   strategyInfoemation=null;
			       }
				   if(StringUtils.isNotEmpty(attractionsDto.getTwoSite())){
					   StrategyInfoemation twoStrategyInfoemation=new StrategyInfoemation();
					   twoStrategyInfoemation.setStatus(Constant.isUsd);
					   twoStrategyInfoemation.setCreateTime(new Date());
					   twoStrategyInfoemation.setStrategyAccommodation(attractionsDto.getTwoAccommodation());
					   twoStrategyInfoemation.setStrategyDays(2);
					   twoStrategyInfoemation.setSceneId(sceneInformation.getId());
					   twoStrategyInfoemation.setStrategyIntroduce(attractionsDto.getTwoIntroduce());
					   twoStrategyInfoemation.setStrategySite(attractionsDto.getTwoSite());
					   twoStrategyInfoemation.setStrategyTraffic(attractionsDto.getTwoTraffic());
					   strategyInfoemationService.insert(twoStrategyInfoemation);
					   twoStrategyInfoemation=null;
				   }
				   if(StringUtils.isNotEmpty(attractionsDto.getThreeSite())){
					   StrategyInfoemation threeStrategyInfoemation=new StrategyInfoemation();
					   threeStrategyInfoemation.setStatus(Constant.isUsd);
					   threeStrategyInfoemation.setCreateTime(new Date());
					   threeStrategyInfoemation.setStrategyAccommodation(attractionsDto.getThreeAccommodation());
					   threeStrategyInfoemation.setStrategyDays(3);
					   threeStrategyInfoemation.setSceneId(sceneInformation.getId());
					   threeStrategyInfoemation.setStrategyIntroduce(attractionsDto.getThreeIntroduce());
					   threeStrategyInfoemation.setStrategySite(attractionsDto.getThreeSite());
					   threeStrategyInfoemation.setStrategyTraffic(attractionsDto.getThreeTraffic());
					   strategyInfoemationService.insert(threeStrategyInfoemation);
					   threeStrategyInfoemation=null;
				   }
		   }else{
			   flag=false;
		   }
	   }catch(Throwable te){
		   flag=false;
		   logger.error("保存景点信息异常信息为:", te); 
	   }
	   json.put("flag", flag);
	   return json;
   }
	@RequestMapping("/selectUserAll") 
	@ResponseBody
	public PageBean<TourismUser> selectUserAll(@RequestBody UserDto userDto){
		PageBean<TourismUser> pageBean = new PageBean<TourismUser>();// 初始化分页的实体
		try {
		   List<TourismUser> list=tourismUserService.selectAllUsers(userDto.getRows(),userDto.getOffset(),userDto.getMobilePhone(),userDto.getUserName());
		   Integer count=tourismUserService.selectUserCount(userDto.getMobilePhone(),userDto.getUserName());
		   pageBean.setRows(list);
		   pageBean.setTotal(count);
		}catch (Throwable te) {
			logger.error("查询用户所有信息异常信息为:", te);
		}
		return pageBean;
	}
	@RequestMapping("/viewSearchRecord")
	public String viewSearchRecord(){
		return "backgroundWeb/viewSearchRecord";
	}
	@RequestMapping("/selectSearchRecordAll")
	@ResponseBody
	public PageBean<SearchRecord> selectSearchRecordAll(@RequestBody SearchRecordDto searchRecordDto){
		PageBean<SearchRecord> pageBean = new PageBean<SearchRecord>();// 初始化分页的实体
		try {
		   List<SearchRecord> list=searchRecordService.selectAllSearchRecord(searchRecordDto.getRows(),searchRecordDto.getOffset(),searchRecordDto.getSearchScene(),searchRecordDto.getUserName());
		   Integer count=searchRecordService.selectSearchRecordCount(searchRecordDto.getSearchScene(),searchRecordDto.getUserName());
		   pageBean.setRows(list);
		   pageBean.setTotal(count);
		}catch (Throwable te) {
			logger.error("查询搜索所有信息异常信息为:", te);
		}
		return pageBean;
		
	}
}

旅游网用户管理控制层:

/**
 * 旅游网用户表 前端控制器
 */
@Controller
@RequestMapping("/tourismUser")
public class TourismUserController {
	public Logger logger = LoggerFactory
			.getLogger(TourismUserController.class);// 输出日志
	@Autowired
	private TourismUserService tourismUserService;
  @RequestMapping("/save")
  @ResponseBody
  public ResponseInformation save(@RequestBody TourismUser tourismUser){
	// 初始化返回码和返回信息,默认处理成功
	ResponseInformation responseInformation=new ResponseInformation();
	  logger.info("保存用户信息为:"+JSONObject.toJSONString(tourismUser));
	  try {
		  tourismUser.setCreateTime(new Date()); 
		  tourismUser.setStatus(Constant.isUsd);
		  Integer  count= tourismUserService.insert(tourismUser);
			if (count > 0) {
				logger.info("保存成功");
			}else{
				responseInformation.setReponseCode(Constant.dataCode);
				responseInformation.setReponseMessage("数据异常");
			}
	  }catch(Throwable te){
			responseInformation.setReponseCode(Constant.dataCode);
			responseInformation.setReponseMessage("保存失败");
			logger.error("保存人员异常信息为:", te); 
	  }
	  return responseInformation;
  }
  @RequestMapping("/checkLogin")
  @ResponseBody
  public JSONObject checkLogin(HttpServletRequest request,HttpServletResponse response,String userName,String passWord){
	   logger.info("收到的用户名为:"+userName+",密码为:"+passWord);
	   JSONObject json=new JSONObject();
	   TourismUser tourismUser =new TourismUser();
	   tourismUser.setStatus(Constant.isUsd);
	   tourismUser.setUserArount(userName);
	   tourismUser.setUserPassword(passWord);
	   TourismUser retTourismUser = tourismUserService.selectOne(tourismUser);
	   if(null != retTourismUser){
		   request.getSession().setAttribute("tourismUser",retTourismUser.getUserName());
		   json.put("fiag", true);
	   }else{
		   json.put("fiag", false);
	   }
	   return json;
  }
  @RequestMapping("/validUserName")
	@ResponseBody
	public JSONObject validUserName(String userName){
		JSONObject json=new JSONObject();
		TourismUser TourismUser=new TourismUser();
		TourismUser.setUserArount(userName);
		TourismUser ret =tourismUserService.selectOne(TourismUser);
		if(null != ret){
			json.put("flag", false);
		}else{
			json.put("flag", true);
		}
		return json;
	}
  @RequestMapping("/update")
  @ResponseBody
  public ResponseInformation update(@RequestBody TourismUser tourismUser){
	// 初始化返回码和返回信息,默认处理成功
	ResponseInformation responseInformation=new ResponseInformation();
	  logger.info("保存用户信息为:"+JSONObject.toJSONString(tourismUser));
	  try {
		  tourismUser.setCreateTime(new Date()); 
		  tourismUser.setStatus(Constant.isUsd);
		  Integer  count= tourismUserService.updateById(tourismUser);
			if (count > 0) {
				logger.info("保存成功");
			}else{
				responseInformation.setReponseCode(Constant.dataCode);
				responseInformation.setReponseMessage("数据异常");
			}
	  }catch(Throwable te){
			responseInformation.setReponseCode(Constant.dataCode);
			responseInformation.setReponseMessage("保存失败");
			logger.error("保存人员异常信息为:", te); 
	  }
	  return responseInformation;
  }
  }

评论收藏管理控制层: 

@Controller
@RequestMapping("/tourismWeb")
public class TourismWebController {
	public Logger logger = LoggerFactory
			.getLogger(TourismWebController.class);// 输出日志
	@Autowired
	private SceneInformationService sceneInformationService;
	@Autowired
	private SceneCommentsService sceneCommentsService;
	@Autowired
	private TourismUserService tourismUserService; 
	@Autowired
	private SceneCollectionService sceneCollectionService;
	@Autowired
	private StrategyInfoemationService  strategyInfoemationService;
	@Autowired
	private SearchRecordService searchRecordService;
	@RequestMapping("/selectSceneAll")
	@ResponseBody
	public List<SceneInformation> selectSceneAll(HttpServletRequest request,HttpServletResponse response,String sceneName){
		List<SceneInformation> list=new ArrayList<SceneInformation>();
		 if(StringUtils.isNotEmpty(sceneName)){
			 Map<String, Object> map=new HashMap<String, Object>(); 
			 map.put("scene_name",sceneName);
			 list=sceneInformationService.selectByMap(map); 
		 }else{
			 list= sceneInformationService.selectByMap(null); 
		 }
		return list;
	}
	@RequestMapping("/selectSceneDetail")
	public String selectSceneDetail(ModelMap map,String id){
		SceneInformation sceneInformation = sceneInformationService.selectById(id);
		map.put("sceneInformation",sceneInformation);
		return "tourismWeb/senceDetail";
	}
	@RequestMapping("/selectSceneCommentsAll")
	@ResponseBody
	public JSONObject selectSceneCommentsAll(String id){
		StringBuffer sb = new StringBuffer();
		JSONObject json=new JSONObject();
		Map<String, Object> map=new HashMap<>();
		map.put("scene_id",id);
		List<SceneComments> list=sceneCommentsService.selectByMap(map);
		if(null != list && list.size() >0){
			for(int i=0;i<list.size();i++){
				sb.append("评论人:"+list.get(i).getCommentsName());
				sb.append("   ");
				sb.append("内容:"+list.get(i).getCommentsContent());
				sb.append("   ");
				sb.append("时间:"+DateUtil.getStrDate(list.get(i).getCreateTime()));
				sb.append("\r\n");
			}
		}else{
			sb.append("暂无");
			sb.append("\r\n");
		}
		json.put("sb", sb);
		return json;
	}
	@RequestMapping("/savecomments")
	@ResponseBody
	public JSONObject savecomments(HttpServletRequest request,HttpServletResponse response,String commentsContent,String sceneId){
		SceneComments sceneComments =new SceneComments();
		JSONObject json=new JSONObject();
		boolean flag=true;
		String userName="";
		try{
			sceneComments.setCreateTime(new Date());
			if(null != request.getSession()){
	    		if(null != request.getSession().getAttribute("tourismUser")){
	    			userName=request.getSession().getAttribute("tourismUser").toString();
	    		}
	    	}
			sceneComments.setCommentsName(userName);
			sceneComments.setCommentsContent(commentsContent);
			sceneComments.setSceneId(Integer.parseInt(sceneId));
			Integer count=sceneCommentsService.insert(sceneComments);
			if(count >0){
				logger.info("保存评论成功");
			}else{
				flag =false;
			}
		}catch(Throwable te){
			flag =false;
			logger.error("保存评论异常信息为:",te);
		}
		json.put("flag", flag);
		json.put("id", sceneId);
		return json;
	}
	@RequestMapping("/jumpMayLike")
	public String jumpMayLike(){
		return "tourismWeb/maylike";
	}
	@RequestMapping("/saveSeceneCollection")
	@ResponseBody
	public JSONObject saveSeceneCollection(HttpServletRequest request,HttpServletResponse response,String sceneId){
		JSONObject json=new JSONObject();
		boolean flag=true;
		String userName = "";
		SceneCollection sceneCollection =new SceneCollection();
		try{
	    	if(null != request.getSession()){
	    		if(null != request.getSession().getAttribute("tourismUser")){
	    			userName=request.getSession().getAttribute("tourismUser").toString();
	    		}
	    	}
	    	TourismUser tourismUser =new TourismUser();
			tourismUser.setUserName(userName);
			TourismUser retTourismUser= tourismUserService.selectOne(tourismUser);
			if(null != retTourismUser){
				sceneCollection.setUserId(retTourismUser.getId());
				sceneCollection.setUserName(retTourismUser.getUserName());
			}
			SceneInformation retSceneInformation=sceneInformationService.selectById(sceneId);
			if(null != retSceneInformation){
				sceneCollection.setSceneId(retSceneInformation.getId());
				sceneCollection.setSceneName(retSceneInformation.getSceneName());
			}
			sceneCollection.setCreateTime(new Date());
			sceneCollection.setStatus(Constant.isUsd);
			Integer count= sceneCollectionService.insert(sceneCollection);
			if(count >0){
				logger.info("收藏成功");
			}else{
				flag=false;
			}
		}catch(Throwable te){
			flag=false;
			te.printStackTrace();
		}
		json.put("flag", flag);
		return json;
	}
	@RequestMapping("/selectMayLikeScene")
	@ResponseBody
	public JSONObject selectMayLikeScene(HttpServletRequest request,HttpServletResponse response){
		String userName="";
		JSONObject json =new JSONObject();
		List<SceneInformation> list=new ArrayList<SceneInformation>();
		try{
			if(null != request.getSession()){
	    		if(null != request.getSession().getAttribute("tourismUser")){
	    			userName=request.getSession().getAttribute("tourismUser").toString();
	    		}
	    	}
			TourismUser tourismUser =new TourismUser();
			tourismUser.setUserName(userName);
			TourismUser retTourismUser= tourismUserService.selectOne(tourismUser);
			if(null != retTourismUser){
				SceneInformation sceneInformation =new SceneInformation();
				sceneInformation.setSceneName(retTourismUser.getWantScene());
				SceneInformation retSceneInformation=sceneInformationService.selectOne(sceneInformation);
				if(null != retSceneInformation){
					list.add(retSceneInformation);
				}
			}
			Map<String, Object> map=new HashMap<>();
			map.put("user_name",userName);
			List<SearchRecord> searchRecordList= searchRecordService.selectByMap(map);
			if(null != searchRecordList){
				for(int i=0;i<searchRecordList.size();i++){
					if(null !=searchRecordList.get(i).getSceneId()){
						SceneInformation ret=sceneInformationService.selectById(searchRecordList.get(i).getSceneId());
						list.add(ret);
					}
				}
			}
		}catch(Throwable te){
			te.printStackTrace();
		}
		json.put("list", list);
		return json;
	}
	@RequestMapping("/jumpTourismPlan")
	public String jumpTourismPlan(){
		return "tourismWeb/tourismPlan";
	}
	@RequestMapping("/selectSeceneCollection")
	@ResponseBody
	public JSONObject selectSeceneCollection(HttpServletRequest request,HttpServletResponse response){
		String userName="";
		Random random = new Random();
		JSONObject json=new JSONObject();
		try{
		if(null != request.getSession()){
    		if(null != request.getSession().getAttribute("tourismUser")){
    			userName=request.getSession().getAttribute("tourismUser").toString();
    		}
    	}
		Map<String, Object> map=new HashMap<>();
		Map<String, Object> strategyInfoemationMap=new HashMap<>();
		map.put("user_name", userName);
		List<SceneCollection> list=sceneCollectionService.selectByMap(map);
		if(null != list && list.size() >0){
			SceneCollection sceneCollection =list.get(random.nextInt(list.size()));
			if(null != sceneCollection){
			 SceneInformation sceneInformation =sceneInformationService.selectById(sceneCollection.getSceneId());
			 json.put("sceneInformation", sceneInformation);
			 strategyInfoemationMap.put("scene_id", sceneCollection.getSceneId());
			 List<StrategyInfoemation> strategyInfoemation =strategyInfoemationService.selectByMap(strategyInfoemationMap);
			 json.put("strategyInfoemation",strategyInfoemation);
			}else{
				json.put("sceneInformation",null);
				json.put("strategyInfoemation", null);
			}
		}else{
			json.put("sceneInformation",null);
			json.put("strategyInfoemation", null);
		}
		}catch(Throwable te){
			te.printStackTrace();
		}
		return json;
	}
	@RequestMapping("/updateSeceneCollection")
	@ResponseBody
	public JSONObject updateSeceneCollection(@RequestBody SaveSceneCollectionDto saveSceneCollectionDto){
		JSONObject json =new JSONObject();
		boolean falg=true;
		try{
			if(StringUtils.isNotEmpty(saveSceneCollectionDto.getSceneId())){
				Map<String, Object> map=new HashMap<>();
				map.put("scene_id", saveSceneCollectionDto.getSceneId());
				Integer count= strategyInfoemationService.deleteByMap(map);
				if(count >0){
					if(null !=saveSceneCollectionDto.getSceneCollectionList() && saveSceneCollectionDto.getSceneCollectionList().size() >0){
						for(int i=0;i<saveSceneCollectionDto.getSceneCollectionList().size();i++){
							StrategyInfoemation strategyInfoemation=saveSceneCollectionDto.getSceneCollectionList().get(i);
							strategyInfoemation.setSceneId(Integer.parseInt(saveSceneCollectionDto.getSceneId()));
							strategyInfoemation.setCreateTime(new Date());
							strategyInfoemation.setStatus(Constant.isUsd);
							strategyInfoemationService.insert(strategyInfoemation);
						}
					}
				}
				
			}else{
				falg=false;
			}
		}catch(Throwable te){
			falg=false;
			te.printStackTrace();
		}
	
		json.put("flag", falg);
		return json;
	}
	@RequestMapping("/editUser")
	public String editUser(){
		return "tourismWeb/editUser";
	}
	@RequestMapping("/selectUserInformation")
	@ResponseBody
	public JSONObject selectUserInformation(HttpServletRequest request,HttpServletResponse response){
		String userName="";
		JSONObject json=new JSONObject();
		if(null != request.getSession()){
    		if(null != request.getSession().getAttribute("tourismUser")){
    			userName=request.getSession().getAttribute("tourismUser").toString();
    		}
    	}
		TourismUser TourismUser=new TourismUser();
		TourismUser.setUserName(userName);
		TourismUser ret =tourismUserService.selectOne(TourismUser);
		json.put("ret", ret);
		return json;
	}
	
}

源码获取:俺的博客首页 "资源" 里下载!

猜你喜欢

转载自blog.csdn.net/pastclouds/article/details/125299100