作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
该项目为前后台项目,分为普通用户与管理员两种角色,前台普通用户登录,后台管理员登录;
管理员角色包含以下功能:
管理员登录,用户管理,一级分类管理,二级分类管理,美食管理,留言管理等功能。
用户角色包含以下功能:
用户登录,按分类查看,写留言等功能。
演示视频:点此查看
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
更多项目源码,请到“源码空间站”,地址:http://www.shuyue.fun/
环境需要
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+jQuery+Ajax
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
运行指导教程
idea导入源码空间站项目教程说明(Windows版)-ssm篇:
关于IDEA导入源码空间站源码的使用教程(windows版)
源码看好后直接在网站付款下单即可,付款成功会自动弹出百度网盘链接,网站地址:http://www.shuyue.fun/ 。
其它问题请关注公众号:程序员MM,关注后发送消息即可,都会给您回复的。 若没有及时回复请耐心等待,通常当天会有回复
运行截图
前台界面
后台界面
相关代码
CategorySecondServiceImpl
package com.shop.serviceImpl;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import com.shop.Utils.PageBean;
import com.shop.mapper.CategorysecondMapper;
import com.shop.po.Categorysecond;
import com.shop.po.CategorysecondExample;
import com.shop.po.CategorysecondExample.Criteria;
import com.shop.service.CategorySecondService;public class CategorySecondServiceImpl implements CategorySecondService {@Autowiredprivate CategorysecondMapper categorysecondMapper;@Overridepublic PageBean<Categorysecond> adminCategorySecond_findAllByPage(int page) {PageBean<Categorysecond> pageBean = new PageBean<>();// 设置这是第几页pageBean.setPage(page);// 设置10个int limitPage = 10;pageBean.setLimitPage(limitPage);// 设置一共多少页int totlePage = 0;// 查询一共有多少页CategorysecondExample example = new CategorysecondExample();totlePage = categorysecondMapper.countByExample(example);if (Math.ceil(totlePage % limitPage) == 0) {totlePage = totlePage / limitPage;} else {totlePage = totlePage / limitPage + 1;}pageBean.setTotlePage(totlePage);int beginPage= (page-1)*limitPage;// 集合 分页查询CategorysecondExample csexample = new CategorysecondExample();csexample.setBeginPage(beginPage);csexample.setLimitPage(limitPage);List<Categorysecond> list = categorysecondMapper.selectByExample(csexample);pageBean.setList(list);return pageBean;}@Overridepublic void adminCategorySecond_save(Categorysecond categorysecond)throws Exception {categorysecondMapper.insert(categorysecond);}@Overridepublic Categorysecond findByCsid(int csid) throws Exception {return categorysecondMapper.selectByPrimaryKey(csid);}@Overridepublic void adminCategorySecond_update(Categorysecond categorysecond) {categorysecondMapper.updateByPrimaryKey(categorysecond);}@Overridepublic void adminCategorySecond_delete(int csid) {categorysecondMapper.deleteByPrimaryKey(csid);}@Overridepublic List<Categorysecond> findAll() throws Exception {return categorysecondMapper.selectByExample1();}@Overridepublic void adminCategorySecond_deleteByCid(int cid) throws Exception {CategorysecondExample example = new CategorysecondExample();Criteria createCriteria = example.createCriteria();createCriteria.andCidEqualTo(cid);categorysecondMapper.deleteByExample(example);}
}
CategoryServiceImpl
package com.shop.serviceImpl;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import com.shop.mapper.CategoryMapper;
import com.shop.po.Category;
import com.shop.po.CategoryExample;
import com.shop.service.CategoryService;public class CategoryServiceImpl implements CategoryService{@Autowiredprivate CategoryMapper categoryMapper;@Override//查询一级目录public List<Category> findCategory() throws Exception {List<Category> list = categoryMapper.findCategoryAndSecondcategory();if(list!=null && list.size()>0){return list;}return null;}@Overridepublic void addCategory(Category addCategory) throws Exception {categoryMapper.insert(addCategory);}@Overridepublic List<Category> adminbFindCategory() {System.out.println("3333333333333");CategoryExample example = new CategoryExample();List<Category> list = categoryMapper.selectByExample(example);if(list!=null && list.size()>0){return list;}return null;}@Overridepublic Category findCategory(int cid) throws Exception {return categoryMapper.selectByPrimaryKey(cid);}@Overridepublic void adminCategory_update(Category category) {categoryMapper.updateByPrimaryKey(category);}@Overridepublic void deleteCategoryByCid(int cid) throws Exception {categoryMapper.deleteByPrimaryKey(cid);}
}
MessageServiceImpl
package com.shop.serviceImpl;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import com.shop.Utils.PageBean;
import com.shop.mapper.MessageMapper;
import com.shop.po.Message;
import com.shop.service.MessageService;public class MessageServiceImpl implements MessageService {@Autowiredprivate MessageMapper messagesMapper;@Overridepublic void insertMessage(Message messages) throws Exception {messagesMapper.insert(messages);}@Overridepublic PageBean<Message> findAllMessageByPage(int page) throws Exception {PageBean<Message> pageBean = new PageBean<>();
// 设置这是第几页pageBean.setPage(page);
// 设置10个int limitPage =4;pageBean.setLimitPage(limitPage);
// 设置一共多少页int totlePage = 0;
// 查询一共有多少页totlePage = messagesMapper.countAllMessage();if(Math.ceil(totlePage % limitPage)==0){totlePage=totlePage / limitPage;}else{totlePage=totlePage / limitPage+1;}pageBean.setTotlePage(totlePage);int beginPage= (page-1)*limitPage;//商品集合List<Message> list = messagesMapper.findAllMessageByPage(beginPage, limitPage) ;pageBean.setList(list);return pageBean;}@Overridepublic void deleteMessage(int messageid) throws Exception {messagesMapper.deleteByPrimaryKey(messageid);}
}
OrderServiceImpl
package com.shop.serviceImpl;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import com.shop.Utils.PageBean;
import com.shop.mapper.OrderitemMapper;
import com.shop.mapper.OrdersMapper;
import com.shop.po.Orderitem;
import com.shop.po.Orders;
import com.shop.service.OrderService;public class OrderServiceImpl implements OrderService {@Autowiredprivate OrdersMapper ordersMapper;@Autowiredprivate OrderitemMapper orderitemMapper;public void toOrder(Orders orders) throws Exception {ordersMapper.insert(orders);}@Overridepublic void toOrderItem(Orderitem orderitem) throws Exception {orderitemMapper.insert(orderitem);}@Overridepublic void payOrder(Orders orders) throws Exception {Orders payOrder = ordersMapper.selectByPrimaryKey(orders.getOid());if(orders.getReceiveinfo()!=null && orders.getPhonum()!=null){payOrder.setPhonum(orders.getPhonum());payOrder.setReceiveinfo(orders.getReceiveinfo());payOrder.setAccepter(orders.getAccepter());payOrder.setState(1);}ordersMapper.updateByPrimaryKeySelective(payOrder);}@Overridepublic PageBean<Orders> findOrderByUidAndPage(int page, Integer uid)throws Exception {PageBean<Orders> pageBean = new PageBean<>();
// 设置这是第几页pageBean.setPage(page);
// 设置10个int limitPage =4;pageBean.setLimitPage(limitPage);
// 设置一共多少页int totlePage = 0;
// 查询一共有多少页totlePage = ordersMapper.countOrdersByUid(uid);if(Math.ceil(totlePage % limitPage)==0){totlePage=totlePage / limitPage;}else{totlePage=totlePage / limitPage+1;}pageBean.setTotlePage(totlePage);int beginPage= (page-1)*limitPage;
// 商品集合List<Orders> list = ordersMapper.findOrderByUidAndPage(uid,beginPage,limitPage);pageBean.setList(list);return pageBean;}@Overridepublic Orders findOrderByOid(int oid) {return ordersMapper.selectByPrimaryKey(oid);}@Overridepublic PageBean<Orders> findAllOrderByStateAndPage(int page)throws Exception {PageBean<Orders> pageBean = new PageBean<>();
// 设置这是第几页pageBean.setPage(page);
// 设置10个int limitPage = 4;pageBean.setLimitPage(limitPage);
// 设置一共多少页int totlePage = 0;
// 查询一共有多少页totlePage = ordersMapper.countAllOrders();if(Math.ceil(totlePage % limitPage)==0){totlePage=totlePage / limitPage;}else{totlePage=totlePage / limitPage+1;}pageBean.setTotlePage(totlePage);int beginPage= (page-1)*limitPage;//商品集合List<Orders> list = ordersMapper.findAllOrderByPage(beginPage,limitPage);pageBean.setList(list);return pageBean;}@Overridepublic void updateOrderStatus(int oid, int status) throws Exception {Orders payOrder = ordersMapper.selectByPrimaryKey(oid);payOrder.setState(status); ordersMapper.updateByPrimaryKeySelective(payOrder);}@Overridepublic PageBean<Orders> findAllOrderByStateAndPage(int state,int page)throws Exception {PageBean<Orders> pageBean = new PageBean<>();
// 设置这是第几页pageBean.setPage(page);
// 设置10个int limitPage =4;pageBean.setLimitPage(limitPage);
// 设置一共多少页int totlePage = 0;
// 查询一共有多少页totlePage = ordersMapper.countOrdersByState(state);if(Math.ceil(totlePage % limitPage)==0){totlePage=totlePage / limitPage;}else{totlePage=totlePage / limitPage+1;}pageBean.setTotlePage(totlePage);int beginPage= (page-1)*limitPage;//商品集合List<Orders> list = ordersMapper.findAllOrderByStateAndPage(state, beginPage, limitPage) ;pageBean.setList(list);return pageBean;}
}
ProductServiceImpl
package com.shop.serviceImpl;import java.util.ArrayList;
import java.util.List;import javax.swing.text.StyledEditorKit.ForegroundAction;import org.springframework.beans.factory.annotation.Autowired;import com.shop.Utils.PageBean;
import com.shop.mapper.ProductMapper;
import com.shop.po.Category;
import com.shop.po.CategoryExample;
import com.shop.po.CategorysecondExample;
import com.shop.po.Product;
import com.shop.po.ProductExample;
import com.shop.po.ProductExample.Criteria;
import com.shop.service.ProductService;public class ProductServiceImpl implements ProductService {@Autowiredprivate ProductMapper productMapper;
// 查询热门商品 带分页的查询public List<Product> findHotProduct() throws Exception {ProductExample example = new ProductExample();ProductExample.Criteria criteria = example.createCriteria();criteria.andIsHotEqualTo(1);example.setOrderByClause("pdate DESC");example.setBeginPage(0);example.setEnd(4); List<Product> list = productMapper.selectByExample(example);/*for (Product product : list) {System.out.println(product.getPname());}*/if(list!=null && list.size()>0){return list;}return null;}@Overridepublic List<Product> findNewProduct() throws Exception {ProductExample example = new ProductExample();ProductExample.Criteria criteria = example.createCriteria();example.setOrderByClause("pdate DESC");example.setBeginPage(0);example.setEnd(8); List<Product> list = productMapper.selectByExample(example);/*for (Product product : list) {System.out.println(product.getPname());}*/if(list!=null && list.size()>0){return list;}return null;}
// 根据id查找商品public Product productFindByPid(int pid) throws Exception {return productMapper.selectByPrimaryKey(pid);}
// 根据cid查找商品public PageBean<Product> findProductyBycid(int cid, int page)throws Exception {PageBean<Product> pageBean = new PageBean<>();
// 设置这是第几页pageBean.setPage(page);
// 设置10个int limitPage =12;pageBean.setLimitPage(limitPage);
// 设置一共多少页int totlePage = 0;
// 查询一共有多少页totlePage = productMapper.countProducyByCid(cid);if(Math.ceil(totlePage % limitPage)==0){totlePage=totlePage / limitPage;}else{totlePage=totlePage / limitPage+1;}pageBean.setTotlePage(totlePage);int beginPage= (page-1)*limitPage;
// 商品集合List<Product> list = productMapper.findProductByCid(cid,beginPage,limitPage);pageBean.setList(list);return pageBean;}
// 根据csid查找商品public PageBean<Product> finbProductByCsid(int csid, int page) {PageBean<Product> pageBean = new PageBean<>();pageBean.setPage(page);
// 设置10个int limitPage =12;pageBean.setLimitPage(limitPage);
// 设置一共多少页int totlePage = 0;
// 查询一共有多少页totlePage = productMapper.countProducyByCsid(csid);if(Math.ceil(totlePage % limitPage)==0){totlePage=totlePage / limitPage;}else{totlePage=totlePage / limitPage+1;}pageBean.setTotlePage(totlePage);int beginPage= (page-1)*limitPage;
// 商品集合List<Product> list = productMapper.findProductBycsid(csid,beginPage,limitPage);pageBean.setList(list);return pageBean;}@Overridepublic Product finbProductByPid(int pid) {return productMapper.selectByPrimaryKey(pid);}@Overridepublic PageBean<Product> findAllProduct(int page) throws Exception {PageBean<Product> pageBean = new PageBean<>();pageBean.setPage(page);
// 设置10个int limitPage =12;pageBean.setLimitPage(limitPage);
// 设置一共多少页int totlePage = 0;
// 查询一共有多少页ProductExample example = new ProductExample();totlePage = productMapper.countByExample(example);if(Math.ceil(totlePage % limitPage)==0){totlePage=totlePage / limitPage;}else{totlePage=totlePage / limitPage+1;}pageBean.setTotlePage(totlePage);int beginPage= (page-1)*limitPage;
// 商品集合List<Product> list = productMapper.findAllProduct(beginPage,limitPage);pageBean.setList(list);return pageBean;}@Overridepublic void adminProduct_save(Product product) throws Exception {productMapper.insert(product);}@Overridepublic void adminProduct_deletecs(int pid) throws Exception {productMapper.deleteByPrimaryKey(pid);}@Overridepublic void adminProduct_update(Product product) throws Exception {productMapper.updateByPrimaryKey(product);}@Overridepublic List<Product> searchProduct(String condition) throws Exception {List<Product> list = productMapper.searchProduct(condition) ;if(list!=null && list.size()>0){return list;}return null;}
}
如果也想学习本系统,下面领取。关注并回复:163ssm