源码获取:俺的博客首页 "资源" 里下载!
项目介绍
系统分为前台跟后台两个项目 前台: 展示旅游新闻、景区信息、美食信息、旅游线路、在线留言
后台管理员: 账号管理、地区管理、景点信息管理、地方美食管理、旅游线路管理、订单信息管理、新闻管理、系统管理 普通用户:旅游线路、订单信息
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7/8.0版本均可;
5.是否Maven项目:是;
技术栈
后端框架:Springboot
前端技术:ElementUI、vue、css、JavaScript、axios
使用说明
项目运行:
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,控制台提示运行成功后再去运行前端项目;
5. 管理员用户名密码:admin/admin
普通用户名密码:user/123456
文档介绍(项目研究背景、研究目的及意义、开发软件介绍、技术介绍、Mysql数据库、系统分析、可行性研究、经济上的可行性、技术上的可行性、操作上的可行性、开发结构分析、功能需求分析、数据流图、业务流程分析、数据字典、旅游网站总体设计、系统功能描述、系统界面设计、系统功能结构图、系统设计目标、系统实现的软硬件平台、数据库设计、数据库概念结构设计、数据库逻辑结构设计、系统详细设计):
景点列表展示:
人情景点列表展示:
旅游线路列表展示:
美食列表展示:
新闻信息列表展示:
登录管理展示页面:
后台功能管理-地方没事查询展示:
旅游线路查询页面展示:
登录管理控制层:
@WebServlet("/Login")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
BaseDao dao = new BaseDaoImpl();
PrintWriter out = null;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
// service
// 方法类-----------------------------------------------------------------------------------------------------
ObjectService service = new ObjectService();
HttpSession session = request.getSession();
UsersEntity use = service.setObject(request, UsersEntity.class);
// 全局变量类----------------------------------------------------------------------------------------------------------
String method = request.getParameter("method");
System.out.println(method);
out = response.getWriter();
File[] files = File.listRoots();
String rootpath = files[files.length - 1].getPath();
if ("login".equals(method)) {// 登录
Object[] params = { use.getUname(), use.getPassword() };
System.out.println(use.getUname() + use.getPassword());
JSONObject user = null;
try {
user = dao.findJSONObject("select * from users where uname = ? and password = ?", params);
System.out.println(user);
System.out.println(user.get("uname"));
System.out.println(user.get("utype"));
request.getSession().setAttribute("uname", user.get("uname"));
request.getSession().setAttribute("utype", user.get("utype"));
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (user.size() > 0) {
out.write("1");
out.flush();
out.close();
}
}
} else if ("exit".equals(method)) {// 退出登录
request.getSession().removeAttribute("uname");
request.getSession().removeAttribute("utype");
request.getSession().removeAttribute("rootpath");
response.sendRedirect("login.jsp");
} else if ("index".equals(method)) {// 进入首页
String uname = (String) session.getAttribute("uname");
System.out.println(uname);
String utype = "" + session.getAttribute("utype");
request.getSession().setAttribute("rootpath", rootpath);
System.out.println(utype);
if (utype.equals("1")) {
request.getRequestDispatcher("index.jsp").forward(request, response);
}
} else if ("updateUsers".equals(method)) {// 修改密码
String pwd = request.getParameter("pwd");
String pwd1 = request.getParameter("pwd1");
System.out.println(pwd);
System.out.println(pwd1);
String uname = (String) request.getSession().getAttribute("uname");
Object[] params = { pwd1, uname };
try {
int m = (int) dao.getCount("select count(*) from users where password = ?", pwd);
if (m > 0) {
dao.update("update users set password = ? where uname = ?", params);
out.write("1");
out.flush();
out.close();
} else {
out.write("2");
out.flush();
out.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("users".equals(method)) {// 管理员信息
JSONArray records;
try {
records = dao.findJSONArray("select * from users where uname=?", use.getUname());
request.setAttribute("records", records);
request.getRequestDispatcher("admin-info.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
美食管理控制层:
@WebServlet("/FoodServlet") // 用户类
@MultipartConfig
public class FoodServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
BaseDao dao = new BaseDaoImpl();
PrintWriter out = null;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
// service
// 方法类-----------------------------------------------------------------------------------------------------
ObjectService service = new ObjectService();
FoodEntity foo = service.setObject(request, FoodEntity.class);
out = response.getWriter();
// 全局变量类----------------------------------------------------------------------------------------------------------
String method = request.getParameter("method");
System.out.println(method);
if ("foodList".equals(method)) {// 列表
try {
JSONArray food = dao
.findJSONArray("select s.sce_name,f.* from food f left join scenic s on s.sce_id=f.sce_id");
request.setAttribute("food", food);
request.getRequestDispatcher("admin-food.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("searchFood".equals(method)) {// 查询
try {
System.out.println(foo.getFooName());
JSONArray food = dao.findJSONArray(
"select s.sce_name,f.* from food f left join scenic s on s.sce_id=f.sce_id where f.foo_name like '%"
+ foo.getFooName() + "%'");
String sceId = request.getParameter("sceId");
System.out.println(sceId);
if (sceId != null && sceId != "") {
food = dao.findJSONArray(
"select s.sce_name,f.* from food f left join scenic s on s.sce_id=f.sce_id where f.sce_id="
+ sceId + " and f.foo_name like '%" + foo.getFooName() + "%'");
}
request.setAttribute("food", food);
request.getRequestDispatcher("admin-food.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("foodAdd".equals(method)) {// 增加
Part part = request.getPart("Savatar");
String heads_url = service.imagepath(part);
String img_url = heads_url;
Object[] params = { foo.getFooName(), img_url, foo.getAddress(), foo.getSceId(), foo.getDescription() };
try {
int i = dao.update("INSERT INTO food(foo_name,img_url,address,sce_id,description) VALUES(?,?,?,?,?)",
params);
if (i > 0) {
response.sendRedirect("FoodServlet?method=foodList");
}
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("deleteFood".equals(method)) {// 删除
try {
int i = dao.update("delete from food where foo_id=?", foo.getFooId());
if (i > 0) {
response.sendRedirect("FoodServlet?method=foodList");
}
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("updateFood".equals(method)) {// 修改
Object[] params = { foo.getFooId() };
try {
JSONObject food = dao.findJSONObject(
"select s.sce_name,f.* from food f left join scenic s on s.sce_id=f.sce_id where f.foo_id = ?",
params);
request.setAttribute("food", food);
request.getRequestDispatcher("admin-foodUpdate.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("updateFood1".equals(method)) {// 完成修改
String img_url = null;
Part part1 = request.getPart("Savatar");
if (part1.getSize() > 0) {
String savepath = service.imagepath(part1);
img_url = savepath;
} else {
img_url = foo.getImgUrl();
}
Object[] params = { foo.getFooName(), img_url, foo.getAddress(), foo.getSceId(), foo.getDescription(),
foo.getFooId() };
try {
int i = dao.update(
"update food set foo_name = ?,img_url=?,address=?,sce_id=?,description=? where foo_id=?",
params);
if (i > 0) {
response.sendRedirect("FoodServlet?method=foodList");
}
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("foodCllentList".equals(method)) {// 用户查看列表
String ctel = (String) request.getSession().getAttribute("ctel");
try {
String sql = "select IF(ISNULL(c.ctel),'0','1') count,IF(ISNULL(fo.foo_id),'0',CONVERT( COUNT(*) USING UTF8)) num ,f.* "
+ "from foo_collect fo " + "left join food f on fo.foo_id=f.foo_id "
+ "left join cllent c on c.ctel=fo.ctel " + "and c.ctel=? where f.sce_id=? "
+ "GROUP BY f.foo_id order by num desc";
JSONArray food = dao.findJSONArray(sql, ctel, foo.getSceId());
request.setAttribute("food", food);
request.getRequestDispatcher("food-list.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("foodCllentSearch".equals(method)) {// 用户搜索列表
String ctel = (String) request.getSession().getAttribute("ctel");
try {
String sql = "select IF(ISNULL(c.ctel),'0','1') count,IF(ISNULL(fo.foo_id),'0',CONVERT( COUNT(*) USING UTF8)) num ,f.* "
+ "from foo_collect fo " + "left join food f on fo.foo_id=f.foo_id "
+ "left join cllent c on c.ctel=fo.ctel " + "and c.ctel=" + ctel + " where f.sce_id = "
+ foo.getSceId() + " and f.foo_name like '%" + foo.getFooName() + "%' "
+ "GROUP BY f.foo_id order by num desc";
JSONArray food = dao.findJSONArray(sql);
request.setAttribute("food", food);
request.getRequestDispatcher("food-list.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("detailFood".equals(method)) {// 美食详情
try {
JSONObject food = dao.findJSONObject("select * from food where foo_id=?", foo.getFooId());
request.setAttribute("food", food);
request.getRequestDispatcher("food-detail.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
个人信息管理控制层:
@WebServlet("/InforTwo")
@MultipartConfig
public class InformationTwoServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
BaseDao dao = new BaseDaoImpl();
ObjectService ob = new ObjectService();
PrintWriter out = response.getWriter();
CllentEntity cll = ob.setObject(request, CllentEntity.class);
File[] files = File.listRoots();
String rootpath = files[files.length - 1].getPath();
//======================================================================================
String method = request.getParameter("method");
System.out.println(method);
if ("queryInfor".equals(method)) {//查询用户个人信息
String ctel =""+request.getSession().getAttribute("ctel");
System.out.println(ctel);
try {
String sql = "select * from cllent where ctel="+ctel;
JSONObject cllent = dao.findJSONObject(sql);
// System.out.println(cllent);
request.setAttribute("cllent", cllent);
request.getRequestDispatcher("information2.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
}
}else if ("updateInfor".equals(method)){//修改个人信息
String ctel = ""+ request.getSession().getAttribute("ctel");
System.out.println(ctel);
try {
Object[] params = { cll.getCllName(), cll.getCsex(), cll.getAge(),cll.getIdCode(), ctel };
int i = dao.update( "update cllent set cll_name=?,csex=?,age=?,id_code=? where ctel=?",
params);
if(i>0){
System.out.println("修改成功");
String sql = "insert into log(ctel,time,message) values(?,?,?)";
Object []params1 = {ctel,ob.getNowTime(),"用户["+ctel+"]修改了个人信息"};
int j = dao.update(sql, params1);
if(j>0){
response.sendRedirect("InforTwo?method=queryInfor");
}else{
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}else if("updatePwd".equals(method)){//修改密码
String ctel = ""+request.getSession().getAttribute("ctel");
System.out.println(ctel);
try {
String pwd = request.getParameter("pwd");
String Cpwd = request.getParameter("Cpwd");
String sql = "select * from cllent where ctel="+ctel;
CllentEntity cllent = dao.findBean(CllentEntity.class,sql);
if(pwd.equals(cllent.getPassword())){
int i = dao.update("update cllent set password=? where ctel=?",Cpwd,ctel);
if(i>0){
System.out.println("修改密码成功");
Object[] params1 = {ctel,ob.getNowTime(),"用户["+ctel+"]修改了密码"};
i = dao.update( "insert into log(ctel,time,message) values(?,?,?)", params1);
if(i>0){
System.out.println("增加成功");
}
}else{
System.out.println("修改密码失败");
}
}else {
out.write("原密码错误!");
out.flush();
out.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
景点收藏管理控制层:
@WebServlet("/CollectServlet") // 用户类
@MultipartConfig
public class CollectServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
BaseDao dao = new BaseDaoImpl();
PrintWriter out = null;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
// service
// 方法类-----------------------------------------------------------------------------------------------------
ObjectService service = new ObjectService();
FoodEntity foo = service.setObject(request, FoodEntity.class);
ScenicEntity sce = service.setObject(request, ScenicEntity.class);
out = response.getWriter();
// 全局变量类----------------------------------------------------------------------------------------------------------
String method = request.getParameter("method");
System.out.println(method);
if ("sce_collect".equals(method)) {// 景点收藏
try {
String sce_collect = "select count(*) value,s.sce_name name from scenic s "
+ "join sce_collect sc on s.sce_id = sc.sce_id join cllent c on sc.ctel = c.ctel "
+ " GROUP BY s.sce_id ORDER BY value DESC limit 0,15";
JSONArray scenic = dao.findJSONArray(sce_collect);
service.outWrite(out, JSON.toJSONString(scenic));
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("foo_collect".equals(method)) {// 美食收藏
try {
String foo_collect = "select count(*) value,f.foo_name name from food f "
+ "join foo_collect fc on f.foo_id = fc.foo_id join cllent c on fc.ctel = c.ctel "
+ "GROUP BY f.foo_id ORDER BY value DESC limit 0,15";
JSONArray food = dao.findJSONArray(foo_collect);
service.outWrite(out, JSON.toJSONString(food));
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("deleteFoo".equals(method)) {// 取消美食收藏
String ctel = (String) request.getSession().getAttribute("ctel");
Object[] params = { foo.getFooId(), ctel };
System.out.println(foo.getFooId() + " " + ctel);
try {
int a = dao.update("delete from foo_collect where foo_id=? and ctel=?", params);
if (a > 0) {
service.outWrite(out, "1");
} else {
service.outWrite(out, "2");
}
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("addFoo".equals(method)) {// 美食收藏
String ctel = (String) request.getSession().getAttribute("ctel");
Object[] params = { foo.getFooId(), ctel };
System.out.println(foo.getFooId() + " " + ctel);
try {
int a = dao.update("insert into foo_collect(foo_id,ctel) values(?,?)", params);
if (a > 0) {
service.outWrite(out, "1");
} else {
service.outWrite(out, "2");
}
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("deleteSce".equals(method)) {// 取消美食收藏
String ctel = (String) request.getSession().getAttribute("ctel");
Object[] params = { sce.getSceId(), ctel };
try {
int a = dao.update("delete from sce_collect where sce_id=? and ctel=?", params);
if (a > 0) {
service.outWrite(out, "1");
} else {
service.outWrite(out, "2");
}
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("addSce".equals(method)) {// 美食收藏
String ctel = (String) request.getSession().getAttribute("ctel");
Object[] params = { sce.getSceId(), ctel };
try {
int a = dao.update("insert into sce_collect(sce_id,ctel) values(?,?)", params);
if (a > 0) {
service.outWrite(out, "1");
} else {
service.outWrite(out, "2");
}
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("collectSec".equals(method)) {// 用户查看景点收藏
String ctel = (String) request.getSession().getAttribute("ctel");
try {
String sce_collect = "select s.* from scenic s join sce_collect sc on s.sce_id = sc.sce_id join cllent c on sc.ctel = c.ctel where sc.ctel=?";
JSONArray scenic = dao.findJSONArray(sce_collect,ctel);
request.setAttribute("collect", scenic);
request.getRequestDispatcher("collectSce-list.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
}
} else if ("collectFoo".equals(method)) {// 美食收藏
String ctel = (String) request.getSession().getAttribute("ctel");
try {
String foo_collect = "select f.* from food f join foo_collect fc on f.foo_id = fc.foo_id join cllent c on fc.ctel = c.ctel where fc.ctel=?";
JSONArray food = dao.findJSONArray(foo_collect,ctel);
request.setAttribute("collect", food);
request.getRequestDispatcher("collectFoo-list.jsp").forward(request, response);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
源码获取:俺的博客首页 "资源" 里下载!