作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
本项目分为前后台,前台为普通用户登录,后台为管理员登录;
管理员角色包含以下功能:
管理员登录,管理员信息管理,用户信息管理,新闻公告管理,套餐类型信息管理,城市信息管理,摄影基地信息管理,套餐信息管理,订单信息管理,查看评价信息等功能。
用户角色包含以下功能:
按分类查看,用户登录,查看商品详情,加入购物车,提交订单,查看订单,修改个人信息,查看网站公告,查看摄影基地等功能。
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项目:否;
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+jQuery
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
- package com.service.impl;
-
- import java.util.List;
- import javax.annotation.Resource;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.dao.AdminDAO;
- import com.entity.Admin;
- import com.service.AdminService;
-
- @Service("adminService")
- public class AdminServiceImpl implements AdminService {
- @Autowired
- @Resource
- private AdminDAO adminDAO;
-
- @Override // 继承接口的新增 返回值0(失败),1(成功)
- public int insertAdmin(Admin admin) {
- return this.adminDAO.insertAdmin(admin);
- }
-
- @Override // 继承接口的更新 返回值0(失败),1(成功)
- public int updateAdmin(Admin admin) {
- return this.adminDAO.updateAdmin(admin);
- }
-
- @Override // 继承接口的删除 返回值0(失败),1(成功)
- public int deleteAdmin(String adminid) {
- return this.adminDAO.deleteAdmin(adminid);
- }
-
- @Override // 继承接口的查询全部
- public List
getAllAdmin() { - return this.adminDAO.getAllAdmin();
- }
-
- @Override // 继承接口的按条件精确查询
- public List
getAdminByCond(Admin admin) { - return this.adminDAO.getAdminByCond(admin);
- }
-
- @Override // 继承接口的按条件模糊查询
- public List
getAdminByLike(Admin admin) { - return this.adminDAO.getAdminByLike(admin);
- }
-
- @Override // 继承接口的按主键查询 返回Entity实例
- public Admin getAdminById(String adminid) {
- return this.adminDAO.getAdminById(adminid);
- }
-
- }
- package com.action;
-
- import java.util.List;
-
- import javax.annotation.Resource;
-
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
-
- import com.entity.Peihuo;
- import com.service.PeihuoService;
-
- //定义为控制器
- @Controller
- // 设置路径
- @RequestMapping(value = "/ajax", produces = "text/plain;charset=utf-8")
- public class AjaxAction extends BaseAction {
-
- @Autowired
- @Resource
- private PeihuoService peihuoService;
-
- // 准备添加数据
- @RequestMapping("getPeihuo.action")
- @ResponseBody
- public String getPeihuo() throws JSONException {
- String cityid = this.getRequest().getParameter("cityid");
- Peihuo peihuo = new Peihuo();
- peihuo.setCityid(cityid);
- List
peihuoList = this.peihuoService.getPeihuoByCond(peihuo); - JSONArray peihuoid = new JSONArray(); // 存放ID
- JSONArray peihuoname = new JSONArray(); // 存放名称
- for (Peihuo c : peihuoList) {
- peihuoid.put(c.getPeihuoid());
- peihuoname.put(c.getPeihuoname());
- }
- JSONObject json = new JSONObject();
- json.put("peihuoid", peihuoid.toString().replaceAll("\"", ""));
- json.put("peihuoname", peihuoname.toString().replaceAll("\"", ""));
- System.out.println(json.toString());
- return json.toString();
- }
-
- }
- package com.action;
-
- import java.util.ArrayList;
- import java.util.List;
- import javax.annotation.Resource;
- import org.springframework.beans.factory.annotation.Autowired;
-
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import com.entity.Article;
- import com.service.ArticleService;
- import com.util.PageHelper;
- import com.util.VeDate;
-
- //定义为控制器
- @Controller
- // 设置路径
- @RequestMapping(value = "/article", produces = "text/plain;charset=utf-8")
- public class ArticleAction extends BaseAction {
- // 注入Service 由于标签的存在 所以不需要getter setter
- @Autowired
- @Resource
- private ArticleService articleService;
-
- // 准备添加数据
- @RequestMapping("createArticle.action")
- public String createArticle() {
- return "admin/addarticle";
- }
-
- // 添加数据
- @RequestMapping("addArticle.action")
- public String addArticle(Article article) {
- article.setAddtime(VeDate.getStringDateShort());
- article.setHits("0");
- this.articleService.insertArticle(article);
- return "redirect:/article/createArticle.action";
- }
-
- // 通过主键删除数据
- @RequestMapping("deleteArticle.action")
- public String deleteArticle(String id) {
- this.articleService.deleteArticle(id);
- return "redirect:/article/getAllArticle.action";
- }
-
- // 批量删除数据
- @RequestMapping("deleteArticleByIds.action")
- public String deleteArticleByIds() {
- String[] ids = this.getRequest().getParameterValues("articleid");
- for (String articleid : ids) {
- this.articleService.deleteArticle(articleid);
- }
- return "redirect:/article/getAllArticle.action";
- }
-
- // 更新数据
- @RequestMapping("updateArticle.action")
- public String updateArticle(Article article) {
- this.articleService.updateArticle(article);
- return "redirect:/article/getAllArticle.action";
- }
-
- // 显示全部数据
- @RequestMapping("getAllArticle.action")
- public String getAllArticle(String number) {
- List
articleList = this.articleService.getAllArticle(); - PageHelper.getPage(articleList, "article", null, null, 10, number, this.getRequest(), null);
- return "admin/listarticle";
- }
-
- // 按条件查询数据 (模糊查询)
- @RequestMapping("queryArticleByCond.action")
- public String queryArticleByCond(String cond, String name, String number) {
- Article article = new Article();
- if (cond != null) {
- if ("title".equals(cond)) {
- article.setTitle(name);
- }
- if ("image".equals(cond)) {
- article.setImage(name);
- }
- if ("contents".equals(cond)) {
- article.setContents(name);
- }
- if ("addtime".equals(cond)) {
- article.setAddtime(name);
- }
- if ("hits".equals(cond)) {
- article.setHits(name);
- }
- }
-
- List
nameList = new ArrayList(); - List
valueList = new ArrayList(); - nameList.add(cond);
- valueList.add(name);
- PageHelper.getPage(this.articleService.getArticleByLike(article), "article", nameList, valueList, 10, number, this.getRequest(),
- "query");
- name = null;
- cond = null;
- return "admin/queryarticle";
- }
-
- // 按主键查询数据
- @RequestMapping("getArticleById.action")
- public String getArticleById(String id) {
- Article article = this.articleService.getArticleById(id);
- this.getRequest().setAttribute("article", article);
- return "admin/editarticle";
- }
-
- public ArticleService getArticleService() {
- return articleService;
- }
-
- public void setArticleService(ArticleService articleService) {
- this.articleService = articleService;
- }
-
- }
- package com.action;
-
- import java.util.ArrayList;
- import java.util.List;
- import javax.annotation.Resource;
- import org.springframework.beans.factory.annotation.Autowired;
-
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import com.entity.Jiancai;
- import com.service.JiancaiService;
- import com.entity.Cate;
- import com.service.CateService;
- import com.util.PageHelper;
-
- //定义为控制器
- @Controller
- // 设置路径
- @RequestMapping(value = "/jiancai", produces = "text/plain;charset=utf-8")
- public class JiancaiAction extends BaseAction {
- // 注入Service 由于标签的存在 所以不需要getter setter
- @Autowired
- @Resource
- private JiancaiService jiancaiService;
- @Autowired
- @Resource
- private CateService cateService;
-
- // 准备添加数据
- @RequestMapping("createJiancai.action")
- public String createJiancai() {
- List
cateList = this.cateService.getAllCate(); - this.getRequest().setAttribute("cateList", cateList);
- return "admin/addjiancai";
- }
-
- // 添加数据
- @RequestMapping("addJiancai.action")
- public String addJiancai(Jiancai jiancai) {
- jiancai.setHits("0");
- jiancai.setSellnum("0");
- this.jiancaiService.insertJiancai(jiancai);
- return "redirect:/jiancai/createJiancai.action";
- }
-
- // 通过主键删除数据
- @RequestMapping("deleteJiancai.action")
- public String deleteJiancai(String id) {
- this.jiancaiService.deleteJiancai(id);
- return "redirect:/jiancai/getAllJiancai.action";
- }
-
- // 批量删除数据
- @RequestMapping("deleteJiancaiByIds.action")
- public String deleteJiancaiByIds() {
- String[] ids = this.getRequest().getParameterValues("jiancaiid");
- for (String jiancaiid : ids) {
- this.jiancaiService.deleteJiancai(jiancaiid);
- }
- return "redirect:/jiancai/getAllJiancai.action";
- }
-
- // 更新数据
- @RequestMapping("updateJiancai.action")
- public String updateJiancai(Jiancai jiancai) {
- this.jiancaiService.updateJiancai(jiancai);
- return "redirect:/jiancai/getAllJiancai.action";
- }
-
- // 显示全部数据
- @RequestMapping("getAllJiancai.action")
- public String getAllJiancai(String number) {
- List
jiancaiList = this.jiancaiService.getAllJiancai(); - PageHelper.getPage(jiancaiList, "jiancai", null, null, 10, number, this.getRequest(), null);
- return "admin/listjiancai";
- }
-
- // 按条件查询数据 (模糊查询)
- @RequestMapping("queryJiancaiByCond.action")
- public String queryJiancaiByCond(String cond, String name, String number) {
- Jiancai jiancai = new Jiancai();
- if (cond != null) {
- if ("jiancainame".equals(cond)) {
- jiancai.setJiancainame(name);
- }
- if ("image".equals(cond)) {
- jiancai.setImage(name);
- }
- if ("cateid".equals(cond)) {
- jiancai.setCatename(name);
- }
- if ("price".equals(cond)) {
- jiancai.setPrice(name);
- }
- if ("recommend".equals(cond)) {
- jiancai.setRecommend(name);
- }
- if ("thestart".equals(cond)) {
- jiancai.setThestart(name);
- }
- if ("theend".equals(cond)) {
- jiancai.setTheend(name);
- }
- if ("hits".equals(cond)) {
- jiancai.setHits(name);
- }
- if ("sellnum".equals(cond)) {
- jiancai.setSellnum(name);
- }
- if ("contents".equals(cond)) {
- jiancai.setContents(name);
- }
- }
-
- List
nameList = new ArrayList(); - List
valueList = new ArrayList(); - nameList.add(cond);
- valueList.add(name);
- PageHelper.getPage(this.jiancaiService.getJiancaiByLike(jiancai), "jiancai", nameList, valueList, 10, number, this.getRequest(), "query");
- name = null;
- cond = null;
- return "admin/queryjiancai";
- }
-
- // 按主键查询数据
- @RequestMapping("getJiancaiById.action")
- public String getJiancaiById(String id) {
- Jiancai jiancai = this.jiancaiService.getJiancaiById(id);
- this.getRequest().setAttribute("jiancai", jiancai);
- List
cateList = this.cateService.getAllCate(); - this.getRequest().setAttribute("cateList", cateList);
- return "admin/editjiancai";
- }
-
- public JiancaiService getJiancaiService() {
- return jiancaiService;
- }
-
- public void setJiancaiService(JiancaiService jiancaiService) {
- this.jiancaiService = jiancaiService;
- }
-
- }
如果也想学习本系统,下面领取。关注并回复:191ssm