├── picture ├── picture1.png ├── picture10.png ├── picture11.png ├── picture12.png ├── picture13.png ├── picture2.png ├── picture3.png ├── picture4.png ├── picture5.png ├── picture6.png ├── picture7.png ├── picture8.png └── picture9.png ├── src └── main │ ├── webapp │ ├── index.jsp │ └── WEB-INF │ │ ├── page │ │ ├── forepage │ │ │ ├── noPro.jsp │ │ │ ├── registerSuccess.jsp │ │ │ ├── cart_noPro.jsp │ │ │ ├── forePayed.jsp │ │ │ ├── foreRegister.jsp │ │ │ └── forelogin.jsp │ │ ├── adminPage.jsp │ │ ├── index.jsp │ │ ├── unauthorized.jsp │ │ ├── productmodule │ │ │ ├── category-edit.jsp │ │ │ ├── category-list.jsp │ │ │ └── product-add.jsp │ │ ├── ordermodule │ │ │ ├── orderItem-list.jsp │ │ │ └── order-list.jsp │ │ ├── syspage │ │ │ ├── admin-permission-add.jsp │ │ │ ├── admin-permission-edit.jsp │ │ │ ├── admin-add.jsp │ │ │ ├── admin-role-add.jsp │ │ │ ├── admin-edit.jsp │ │ │ ├── admin-permission.jsp │ │ │ ├── admin-role.jsp │ │ │ └── admin-role-edit.jsp │ │ ├── login.jsp │ │ ├── pinglunpage │ │ │ └── pinglun.jsp │ │ └── cstpage │ │ │ ├── zixun-list.jsp │ │ │ └── cst-list.jsp │ │ ├── include │ │ ├── publicFooter.jsp │ │ ├── publicMeta.jsp │ │ ├── publicHeader.jsp │ │ └── publicMenu.jsp │ │ └── web.xml │ ├── resources │ ├── jdbc.properties │ ├── mybatis │ │ └── mybatis.xml │ ├── 注意事项 │ ├── log4j.properties │ └── mapper │ │ ├── CategoryMapper.xml │ │ ├── RoleMapper.xml │ │ ├── UserRoleMapper.xml │ │ ├── RolePermissionMapper.xml │ │ └── PermissionMapper.xml │ └── java │ └── com │ └── byh │ └── biyesheji │ ├── dao │ ├── RoleMapper.java │ ├── OrderMapper.java │ ├── ReviewMapper.java │ ├── UserRoleMapper.java │ ├── CategoryMapper.java │ ├── OrderItemMapper.java │ ├── PermissionMapper.java │ ├── RolePermissionMapper.java │ ├── ZiXunMapper.java │ ├── CustomerMapper.java │ ├── UserMapper.java │ ├── ProductMapper.java │ ├── SysDao.java │ └── CrudDao.java │ ├── service │ ├── CategoryService.java │ ├── ReviewService.java │ ├── ForeService.java │ ├── ZiXunService.java │ ├── CustomerService.java │ ├── CrudService.java │ ├── UserRoleService.java │ ├── RolePermissionService.java │ ├── OrderService.java │ ├── OrderItemService.java │ ├── impl │ │ ├── ForeServiceImpl.java │ │ ├── CategoryServiceImpl.java │ │ ├── CustomerServiceImpl.java │ │ ├── ZiXunServiceImpl.java │ │ ├── ReviewServiceImpl.java │ │ ├── UserRoleServiceimpl.java │ │ ├── RolePermissionServiceImpl.java │ │ ├── UserServiceImpl.java │ │ ├── RoleServiceImpl.java │ │ ├── OrderServiceImpl.java │ │ ├── OrderItemServiceImpl.java │ │ └── ProductServiceImpl.java │ ├── RoleService.java │ ├── UserService.java │ ├── PermissionService.java │ └── ProductService.java │ ├── util │ ├── UploadUtil.java │ └── Page.java │ ├── pojo │ ├── UserRole.java │ ├── RolePermission.java │ ├── Role.java │ ├── ProductVO.java │ ├── Category.java │ ├── Permission.java │ ├── OrderItem.java │ ├── Customer.java │ ├── ZiXun.java │ ├── Review.java │ ├── User.java │ ├── Order.java │ └── Product.java │ ├── controller │ ├── PageController.java │ ├── ReviewController.java │ ├── ZiXunController.java │ ├── CustomerController.java │ ├── CategoryController.java │ ├── OrderController.java │ ├── PermissionController.java │ ├── LoginController.java │ └── RoleController.java │ ├── exception │ └── DefaultExceptionHandler.java │ ├── realm │ └── AdminDatabaseRealm.java │ ├── filter │ └── URLPathMatchingFilter.java │ └── Interceptor │ └── LoginInterceptor.java ├── .gitignore └── README.md /picture/picture1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture1.png -------------------------------------------------------------------------------- /picture/picture10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture10.png -------------------------------------------------------------------------------- /picture/picture11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture11.png -------------------------------------------------------------------------------- /picture/picture12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture12.png -------------------------------------------------------------------------------- /picture/picture13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture13.png -------------------------------------------------------------------------------- /picture/picture2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture2.png -------------------------------------------------------------------------------- /picture/picture3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture3.png -------------------------------------------------------------------------------- /picture/picture4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture4.png -------------------------------------------------------------------------------- /picture/picture5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture5.png -------------------------------------------------------------------------------- /picture/picture6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture6.png -------------------------------------------------------------------------------- /picture/picture7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture7.png -------------------------------------------------------------------------------- /picture/picture8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture8.png -------------------------------------------------------------------------------- /picture/picture9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ynwynw/orderFood-public/HEAD/picture/picture9.png -------------------------------------------------------------------------------- /src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <% 2 | response.sendRedirect(request.getContextPath()+"fore/foreIndex"); //项目启动时,自动跳转到前台首页 3 | %> -------------------------------------------------------------------------------- /src/main/resources/jdbc.properties: -------------------------------------------------------------------------------- 1 | jdbc.jdbcUrl=jdbc:mysql://localhost:3306/orderfood?characterEncoding=utf-8 2 | jdbc.user=root 3 | jdbc.password=root -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Example user template template 3 | ### Example user template 4 | *.mp4 5 | # IntelliJ project files 6 | .idea 7 | *.iml 8 | target 9 | out 10 | gen 11 | .zip 12 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | import com.byh.biyesheji.pojo.Role; 4 | import com.byh.biyesheji.pojo.RoleExample; 5 | 6 | import java.util.List; 7 | 8 | public interface RoleMapper extends SysDao { 9 | 10 | List selectByExample(RoleExample example); 11 | 12 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/OrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | import com.byh.biyesheji.pojo.Order; 4 | import com.byh.biyesheji.pojo.OrderExample; 5 | 6 | import java.util.List; 7 | 8 | public interface OrderMapper extends CrudDao{ 9 | 10 | List selectByExample(OrderExample example); 11 | 12 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/CategoryService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.Category; 4 | 5 | public interface CategoryService extends CrudService { 6 | /** 7 | * 更新分类 8 | * @param category 9 | */ 10 | public void update(Category category); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/resources/mybatis/mybatis.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/ReviewMapper.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | import com.byh.biyesheji.pojo.Review; 4 | import com.byh.biyesheji.pojo.ReviewExample; 5 | 6 | import java.util.List; 7 | 8 | public interface ReviewMapper extends CrudDao{ 9 | 10 | List selectByExample(ReviewExample example); 11 | 12 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/UserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | import com.byh.biyesheji.pojo.UserRole; 4 | import com.byh.biyesheji.pojo.UserRoleExample; 5 | 6 | import java.util.List; 7 | 8 | public interface UserRoleMapper extends SysDao{ 9 | 10 | List selectByExample(UserRoleExample example); 11 | 12 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/CategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | import com.byh.biyesheji.pojo.Category; 4 | import com.byh.biyesheji.pojo.CategoryExample; 5 | 6 | import java.util.List; 7 | 8 | public interface CategoryMapper extends CrudDao{ 9 | 10 | List selectByExample(CategoryExample example); 11 | 12 | } -------------------------------------------------------------------------------- /src/main/resources/注意事项: -------------------------------------------------------------------------------- 1 | webapp/images/product下的商品自行删除掉,因为我不放图片在里面; 2 | 改数据库在jdbc.properties里面,怎么改太简单了,不用多说吧; 3 | 数据库脚本为biyesheji.sql; 4 | 后台超级管理员: 5 | http://localhost:8989/login 6 | name:小白 7 | password:adminadmin 8 | 有了这个账号登上去后,就能看所有功能了,后台管理员的密码是加密放入数据库的,看不了 9 | 前台客户登陆请查看customer里面的记录,我测试前台用的: 10 | http://localhost:8989/fore/foreIndex 11 | name:byh 12 | password:12345 -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/OrderItemMapper.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | import com.byh.biyesheji.pojo.OrderItem; 4 | import com.byh.biyesheji.pojo.OrderItemExample; 5 | 6 | import java.util.List; 7 | 8 | public interface OrderItemMapper extends CrudDao{ 9 | 10 | List selectByExample(OrderItemExample example); 11 | 12 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/PermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | import com.byh.biyesheji.pojo.Permission; 4 | import com.byh.biyesheji.pojo.PermissionExample; 5 | 6 | import java.util.List; 7 | 8 | public interface PermissionMapper extends SysDao{ 9 | 10 | List selectByExample(PermissionExample example); 11 | 12 | } -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Global logging configuration 2 | log4j.rootLogger=ERROR, stdout 3 | # MyBatis logging configuration... 4 | log4j.logger.com.byh.biyesheji=TRACE 5 | # Console output... 6 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 7 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 8 | log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/RolePermissionMapper.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | import com.byh.biyesheji.pojo.RolePermission; 4 | import com.byh.biyesheji.pojo.RolePermissionExample; 5 | 6 | import java.util.List; 7 | 8 | public interface RolePermissionMapper extends SysDao{ 9 | 10 | List selectByExample(RolePermissionExample example); 11 | 12 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/ReviewService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.Review; 4 | 5 | import java.util.List; 6 | 7 | public interface ReviewService extends CrudService{ 8 | 9 | /** 10 | * 获得一个商品的所有评论 11 | * @param id 商品id 12 | * @return 13 | */ 14 | List getReviewListByPid(int id); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/ZiXunMapper.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | import com.byh.biyesheji.pojo.ZiXun; 4 | import com.byh.biyesheji.pojo.ZiXunExample; 5 | 6 | import java.util.List; 7 | 8 | public interface ZiXunMapper extends CrudDao { 9 | 10 | List selectByExample(ZiXunExample example); 11 | 12 | /** 13 | * 资讯审核 14 | * @param zid 15 | */ 16 | void shenhe(int zid); 17 | 18 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/ForeService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.Category; 4 | import com.byh.biyesheji.pojo.Product; 5 | 6 | import java.util.List; 7 | 8 | public interface ForeService { 9 | 10 | /** 11 | * 返回保存6个分类对象的List集合 12 | * @return 13 | */ 14 | public List listToThree(); 15 | 16 | public List getFivePro(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/CustomerMapper.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | import com.byh.biyesheji.pojo.Customer; 4 | import com.byh.biyesheji.pojo.CustomerExample; 5 | 6 | import java.util.List; 7 | 8 | public interface CustomerMapper extends CrudDao{ 9 | 10 | List selectByExample(CustomerExample example); 11 | 12 | /** 13 | * 开启用户会员状态 14 | * @param id 15 | */ 16 | void enableStatus(int id); 17 | 18 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/ZiXunService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.ZiXun; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 资讯 9 | */ 10 | public interface ZiXunService extends CrudService { 11 | 12 | /** 13 | * 资讯审核通过 14 | * @param zid 15 | */ 16 | void shenhe(int zid); 17 | 18 | /** 19 | * 连带未审核的资讯 20 | * @return 21 | */ 22 | List list1(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/CustomerService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.Customer; 4 | 5 | public interface CustomerService extends CrudService{ 6 | 7 | /** 8 | * 返回登陆的用户 9 | * @param customer 10 | * @return 11 | */ 12 | public Customer foreLogin(Customer customer); 13 | 14 | /** 15 | * 设置会员 16 | * @param id 17 | */ 18 | public void shezhihuiyuan(int id); 19 | 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | import com.byh.biyesheji.pojo.User; 4 | import com.byh.biyesheji.pojo.UserExample; 5 | 6 | import java.util.List; 7 | 8 | public interface UserMapper extends SysDao{ 9 | 10 | List selectByExample(UserExample example); 11 | 12 | /** 13 | * 停用管理员账号 14 | * @param name 15 | */ 16 | void enableStatus(String name); 17 | 18 | /** 19 | * 开启管理员账号 20 | * @param name 21 | */ 22 | void stopStatus(String name); 23 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/CrudService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import java.util.List; 4 | 5 | public interface CrudService { 6 | 7 | /** 8 | * 所有数据 9 | * @return 10 | */ 11 | public List list(); 12 | 13 | /** 14 | * 保存数据 15 | * @param entity 16 | */ 17 | public void save(T entity); 18 | 19 | /** 20 | * 删除数据 21 | * @param id 22 | */ 23 | public void del(int id); 24 | 25 | /** 26 | * 获得单条数据 27 | * @param id 28 | * @return 29 | */ 30 | T get(int id); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/UserRoleService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.User; 4 | 5 | public interface UserRoleService { 6 | 7 | /** 8 | * 给管理员设置角色s 9 | * @param user 10 | * @param roleIds 11 | */ 12 | public void setRoles(User user, long[] roleIds); 13 | 14 | /** 15 | * 删除当前管理员的所有角色 16 | * @param userId 17 | */ 18 | public void deleteByUser(long userId); 19 | 20 | /** 21 | * 根据角色id删除权限 删除所有拥有传入角色的权限记录 22 | * @param roleId 23 | */ 24 | public void deleteByRole(long roleId); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/util/UploadUtil.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.util; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.springframework.web.multipart.MultipartFile; 6 | 7 | /** 8 | * 文件上传工具类 9 | */ 10 | public class UploadUtil { 11 | /* 12 | 这里的字段image必须和上传页面upload.jsp中的image 13 | 一样的名字 14 | */ 15 | private MultipartFile image; 16 | 17 | public MultipartFile getImage() { 18 | return image; 19 | } 20 | 21 | public void setImage(MultipartFile image) { 22 | this.image = image; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/RolePermissionService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.Role; 4 | 5 | public interface RolePermissionService { 6 | 7 | /** 8 | * 设置角色能拥有的权限 9 | * @param role 角色 10 | * @param permissionIds 权限ids 11 | */ 12 | public void setPermissions(Role role, long[] permissionIds); 13 | 14 | /** 15 | * 根据角色id删除角色下的所有权限 16 | * @param roleId 17 | */ 18 | public void deleteByRole(long roleId); 19 | 20 | /** 21 | * 根据权限id删除一条权限 22 | * @param permissionId 23 | */ 24 | public void deleteByPermission(long permissionId); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/UserRole.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | 3 | public class UserRole { 4 | private Long id; 5 | 6 | private Long uid; 7 | 8 | private Long rid; 9 | 10 | public Long getId() { 11 | return id; 12 | } 13 | 14 | public void setId(Long id) { 15 | this.id = id; 16 | } 17 | 18 | public Long getUid() { 19 | return uid; 20 | } 21 | 22 | public void setUid(Long uid) { 23 | this.uid = uid; 24 | } 25 | 26 | public Long getRid() { 27 | return rid; 28 | } 29 | 30 | public void setRid(Long rid) { 31 | this.rid = rid; 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/forepage/noPro.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/11/26 5 | Time: 15:38 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ include file="../../foreinclude/foreHander1.jsp"%> 10 | 14 |
15 |
商品已被下架,请浏览其他商品!
16 |
17 | <%@ include file="../../foreinclude/foreFooter.jsp"%> 18 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/RolePermission.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | 3 | public class RolePermission { 4 | private Long id; 5 | 6 | private Long rid; 7 | 8 | private Long pid; 9 | 10 | public Long getId() { 11 | return id; 12 | } 13 | 14 | public void setId(Long id) { 15 | this.id = id; 16 | } 17 | 18 | public Long getRid() { 19 | return rid; 20 | } 21 | 22 | public void setRid(Long rid) { 23 | this.rid = rid; 24 | } 25 | 26 | public Long getPid() { 27 | return pid; 28 | } 29 | 30 | public void setPid(Long pid) { 31 | this.pid = pid; 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.Order; 4 | import com.byh.biyesheji.pojo.OrderItem; 5 | 6 | import java.util.List; 7 | 8 | public interface OrderService extends CrudService { 9 | 10 | /** 11 | * 更新订单 12 | * @param c 13 | */ 14 | public void update(Order c); 15 | 16 | /** 17 | * 生成完整订单 18 | * @param o 订单 19 | * @param ois 订单项 20 | * @return 21 | */ 22 | public float add(Order o, List ois); 23 | 24 | /** 25 | * 用户订单列表 26 | * @param cstid 用户id 27 | * @return 28 | */ 29 | public List list(int cstid); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/forepage/registerSuccess.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/10/21 5 | Time: 19:50 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ include file="../../foreinclude/foreHander1.jsp"%> 10 | 14 |
15 |
注册成功,返回首页
16 |
17 | <%@ include file="../../foreinclude/foreFooter.jsp"%> -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/forepage/cart_noPro.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/11/25 5 | Time: 20:47 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ include file="../../foreinclude/foreHander1.jsp"%> 10 | 14 |
15 |
购物车空空如也,去购物》
16 |
17 | <%@ include file="../../foreinclude/foreFooter.jsp"%> 18 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/forepage/forePayed.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/11/25 5 | Time: 17:34 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ include file="../../foreinclude/foreHander1.jsp"%> 10 | 14 |
15 |
您已支付成功,共计${total}元查看订单》
16 |
17 | <%@ include file="../../foreinclude/foreFooter.jsp"%> 18 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/Role.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | 3 | public class Role { 4 | private Long id; 5 | 6 | private String name; 7 | 8 | private String desc_; 9 | 10 | public Long getId() { 11 | return id; 12 | } 13 | 14 | public void setId(Long id) { 15 | this.id = id; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.name = name == null ? null : name.trim(); 24 | } 25 | 26 | public String getDesc_() { 27 | return desc_; 28 | } 29 | 30 | public void setDesc_(String desc_) { 31 | this.desc_ = desc_ == null ? null : desc_.trim(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/ProductVO.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | 3 | /** 4 | * 传入商品id和url封装 5 | */ 6 | public class ProductVO { 7 | 8 | private int id; 9 | private String imageUrl; 10 | 11 | public int getId() { 12 | return id; 13 | } 14 | 15 | public void setId(int id) { 16 | this.id = id; 17 | } 18 | 19 | public String getImageUrl() { 20 | return imageUrl; 21 | } 22 | 23 | public void setImageUrl(String imageUrl) { 24 | this.imageUrl = imageUrl; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "ProductVO{" + 30 | "id=" + id + 31 | ", imageUrl='" + imageUrl + '\'' + 32 | '}'; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/Category.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | 3 | import java.util.List; 4 | 5 | public class Category { 6 | private Integer id; 7 | 8 | private String name; 9 | 10 | private List products; 11 | 12 | public List getProducts() { 13 | return products; 14 | } 15 | 16 | public void setProducts(List products) { 17 | this.products = products; 18 | } 19 | 20 | public Integer getId() { 21 | return id; 22 | } 23 | 24 | public void setId(Integer id) { 25 | this.id = id; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name == null ? null : name.trim(); 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/include/publicFooter.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/9/29 5 | Time: 15:32 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/OrderItemService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.Order; 4 | import com.byh.biyesheji.pojo.OrderItem; 5 | 6 | import java.util.List; 7 | 8 | public interface OrderItemService extends CrudService { 9 | 10 | /** 11 | * 更新订单项 12 | * @param c 13 | */ 14 | public void update(OrderItem c); 15 | 16 | /** 17 | * 根据用户id返回用户的订单项集合 18 | * @param cstid 用户id 19 | * @return 20 | */ 21 | public List listByCustomer(int cstid); 22 | 23 | /** 24 | * 给订单集合中的每个订单设置有哪些订单项,设置订单项对应的商品,设置每个订单总价 25 | * @param os 订单集合 26 | */ 27 | public void fill(List os); 28 | 29 | /** 30 | * 给订单设置订单项,订单项对应的商品,订单总价 31 | * @param o 32 | */ 33 | public void fill(Order o); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/ProductMapper.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | import com.byh.biyesheji.pojo.Product; 4 | import com.byh.biyesheji.pojo.ProductExample; 5 | import com.byh.biyesheji.pojo.ProductVO; 6 | 7 | import java.util.List; 8 | 9 | public interface ProductMapper extends CrudDao{ 10 | 11 | List selectByExample(ProductExample example); 12 | 13 | /** 14 | * 商品上线 15 | * @param name 16 | */ 17 | void enableStatus(String name); 18 | 19 | /** 20 | * 商品下线 21 | * @param name 22 | */ 23 | void stopStatus(String name); 24 | 25 | /** 26 | * 设置图片保存的位置 27 | * @param vo 28 | */ 29 | void setImageUrl(ProductVO vo); 30 | 31 | /** 32 | * 随机五条商品 33 | * @return 34 | */ 35 | List randFive(); 36 | 37 | boolean findProByCid(int cid); 38 | 39 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/Permission.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | 3 | public class Permission { 4 | private Long id; 5 | 6 | private String name; 7 | 8 | private String desc_; 9 | 10 | private String url; 11 | 12 | public Long getId() { 13 | return id; 14 | } 15 | 16 | public void setId(Long id) { 17 | this.id = id; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name == null ? null : name.trim(); 26 | } 27 | 28 | public String getDesc_() { 29 | return desc_; 30 | } 31 | 32 | public void setDesc_(String desc_) { 33 | this.desc_ = desc_ == null ? null : desc_.trim(); 34 | } 35 | 36 | public String getUrl() { 37 | return url; 38 | } 39 | 40 | public void setUrl(String url) { 41 | this.url = url == null ? null : url.trim(); 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/controller/PageController.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | 7 | /** 8 | * 专门用于显示页面的控制器 9 | */ 10 | @Controller 11 | @RequestMapping("") 12 | public class PageController { 13 | 14 | /** 15 | * 后台主页页面 16 | * @return 17 | */ 18 | @RequestMapping("/index") 19 | public String index(){ 20 | return "index"; 21 | } 22 | 23 | /** 24 | * 后台登陆页面 25 | * @return 26 | */ 27 | @RequestMapping(value="login",method= RequestMethod.GET) 28 | public String login(){ 29 | return "login"; 30 | } 31 | 32 | /** 33 | * 无权限页面 34 | * @return 35 | */ 36 | @RequestMapping("/unauthorized") 37 | public String noPerms(){ 38 | return "unauthorized"; 39 | } 40 | 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/SysDao.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | /** 4 | * 管理员模块公共方法 5 | * @param 6 | */ 7 | public interface SysDao { 8 | /** 9 | * 删除数据 10 | * @param id 11 | * @return 12 | */ 13 | public int deleteByPrimaryKey(Long id); 14 | 15 | /** 16 | * 插入数据 17 | * @param entity 18 | * @return 19 | */ 20 | public int insert(T entity); 21 | 22 | /** 23 | * 动态保存数据 24 | * @param entity 25 | * @return 26 | */ 27 | public int insertSelective(T entity); 28 | 29 | /** 30 | * 获取单条数据 31 | * @param id 32 | * @return 33 | */ 34 | public T selectByPrimaryKey(Long id); 35 | 36 | /** 37 | * 更新数据 38 | * @param entity 39 | * @return 40 | */ 41 | public int updateByPrimaryKey(T entity); 42 | 43 | /** 44 | * 动态更新 45 | * @param entity 46 | * @return 47 | */ 48 | public int updateByPrimaryKeySelective(T entity); 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/dao/CrudDao.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.dao; 2 | 3 | /** 4 | * 公共dao层方法 5 | * @param 6 | */ 7 | public interface CrudDao { 8 | 9 | /** 10 | * 删除数据 11 | * @param id 12 | * @return 13 | */ 14 | public int deleteByPrimaryKey(int id); 15 | 16 | /** 17 | * 插入数据 18 | * @param entity 19 | * @return 20 | */ 21 | public int insert(T entity); 22 | 23 | /** 24 | * 动态保存数据 25 | * @param entity 26 | * @return 27 | */ 28 | public int insertSelective(T entity); 29 | 30 | /** 31 | * 获取单条数据 32 | * @param id 33 | * @return 34 | */ 35 | public T selectByPrimaryKey(int id); 36 | 37 | /** 38 | * 更新数据 39 | * @param entity 40 | * @return 41 | */ 42 | public int updateByPrimaryKey(T entity); 43 | 44 | /** 45 | * 动态更新 46 | * @param entity 47 | * @return 48 | */ 49 | public int updateByPrimaryKeySelective(T entity); 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/exception/DefaultExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.exception; 2 | 3 | import org.apache.shiro.authz.UnauthorizedException; 4 | import org.springframework.http.HttpStatus; 5 | import org.springframework.web.bind.annotation.ControllerAdvice; 6 | import org.springframework.web.bind.annotation.ExceptionHandler; 7 | import org.springframework.web.bind.annotation.ResponseStatus; 8 | import org.springframework.web.context.request.NativeWebRequest; 9 | import org.springframework.web.servlet.ModelAndView; 10 | 11 | /** 12 | * 全局异常类 13 | */ 14 | @ControllerAdvice 15 | public class DefaultExceptionHandler { 16 | @ExceptionHandler({UnauthorizedException.class}) //异常判断类 17 | @ResponseStatus(HttpStatus.UNAUTHORIZED) 18 | public ModelAndView processUnauthenticatedException(NativeWebRequest request, UnauthorizedException e) { 19 | ModelAndView mv = new ModelAndView(); 20 | mv.addObject("ex", e); 21 | mv.setViewName("unauthorized"); 22 | return mv; 23 | } 24 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/impl/ForeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service.impl; 2 | 3 | import com.byh.biyesheji.dao.CategoryMapper; 4 | import com.byh.biyesheji.dao.ProductMapper; 5 | import com.byh.biyesheji.pojo.Category; 6 | import com.byh.biyesheji.pojo.CategoryExample; 7 | import com.byh.biyesheji.pojo.Product; 8 | import com.byh.biyesheji.service.ForeService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.List; 13 | 14 | @Service 15 | public class ForeServiceImpl implements ForeService { 16 | 17 | @Autowired 18 | private CategoryMapper categoryMapper; 19 | @Autowired 20 | private ProductMapper productMapper; 21 | 22 | @Override 23 | public List listToThree() { 24 | CategoryExample example = new CategoryExample(); 25 | example.createCriteria().andIdBetween(1,4); //从1开始计数 26 | List categories = categoryMapper.selectByExample(example); 27 | return categories; 28 | } 29 | 30 | @Override 31 | public List getFivePro() { 32 | return productMapper.randFive(); 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.Role; 4 | import com.byh.biyesheji.pojo.User; 5 | 6 | import java.util.List; 7 | import java.util.Set; 8 | 9 | public interface RoleService { 10 | 11 | /** 12 | * 根据管理员名字获得所有拥有的角色名集合 13 | * @param userName 14 | * @return 15 | */ 16 | public Set listRoleNames(String userName); 17 | 18 | /** 19 | * 当前管理员拥有的角色 20 | * @param userName 21 | * @return 22 | */ 23 | public List listRoles(String userName); 24 | 25 | /** 26 | * 当前管理员的所有角色实体列表 27 | * @param user 28 | * @return 29 | */ 30 | public List listRoles(User user); 31 | 32 | /** 33 | * 数据库所有的角色 34 | * @return 35 | */ 36 | public List list(); 37 | 38 | /** 39 | * 添加角色 40 | * @param role 41 | */ 42 | public void add(Role role); 43 | 44 | /** 45 | * 删除角色 46 | * @param id 47 | */ 48 | public void delete(Long id); 49 | 50 | /** 51 | * 获得一条角色 52 | * @param id 53 | * @return 54 | */ 55 | public Role get(Long id); 56 | 57 | /** 58 | * 更新角色 59 | * @param role 60 | */ 61 | public void update(Role role); 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.User; 4 | 5 | import java.util.List; 6 | 7 | public interface UserService { 8 | /** 9 | * 获得密码 10 | * @param name 管理员名字 11 | * @return 12 | */ 13 | public String getPassword(String name); 14 | 15 | /** 16 | * 获得管理员实体 17 | * @param name 管理员名字 18 | * @return 19 | */ 20 | public User getByName(String name); 21 | 22 | /** 23 | * 管理员列表 24 | * @return 25 | */ 26 | public List list(); 27 | 28 | /** 29 | * 添加管理员 30 | * @param user 31 | */ 32 | public void add(User user); 33 | 34 | /** 35 | * 删除管理员 36 | * @param id 37 | */ 38 | public void delete(Long id); 39 | 40 | /** 41 | * 获得一个管理员 42 | * @param id 43 | * @return 44 | */ 45 | public User get(Long id); 46 | 47 | /** 48 | * 更新一个管理员 49 | * @param user 50 | */ 51 | public void update(User user); 52 | 53 | /** 54 | * 管理员启用 55 | * @param name 56 | * @return 57 | */ 58 | public String enableStatus(String name); 59 | 60 | /** 61 | * 管理员禁用 62 | * @param name 63 | * @return 64 | */ 65 | public String stopStatus(String name); 66 | 67 | /** 68 | * 根据商品id获得所属商家(管理员即商家) 69 | * @param id 70 | * @return 71 | */ 72 | public User getUserByPid(int id); 73 | } 74 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/adminPage.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/10/11 5 | Time: 18:07 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java"%> 9 | 19 |
20 | 41 |
-------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/impl/CategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service.impl; 2 | 3 | import com.byh.biyesheji.dao.CategoryMapper; 4 | import com.byh.biyesheji.pojo.Category; 5 | import com.byh.biyesheji.service.CategoryService; 6 | import com.byh.biyesheji.service.ProductService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | 12 | @Service 13 | public class CategoryServiceImpl implements CategoryService { 14 | 15 | @Autowired 16 | private CategoryMapper categoryMapper; 17 | @Autowired 18 | private ProductService productService; 19 | 20 | @Override 21 | public List list() { 22 | List categoryList = categoryMapper.selectByExample(null); 23 | return categoryList; 24 | } 25 | 26 | @Override 27 | public void save(Category category) { 28 | categoryMapper.insert(category); 29 | } 30 | 31 | @Override 32 | public void del(int id) { 33 | boolean cunzai = productService.findProByCid(id); 34 | if(!cunzai){ 35 | categoryMapper.deleteByPrimaryKey(id); 36 | } 37 | } 38 | 39 | @Override 40 | public Category get(int id) { 41 | return categoryMapper.selectByPrimaryKey(id); 42 | } 43 | 44 | @Override 45 | public void update(Category category) { 46 | categoryMapper.updateByPrimaryKeySelective(category); 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/controller/ReviewController.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.controller; 2 | 3 | import com.byh.biyesheji.pojo.Review; 4 | import com.byh.biyesheji.service.ProductService; 5 | import com.byh.biyesheji.service.ReviewService; 6 | import com.byh.biyesheji.util.Page; 7 | import com.github.pagehelper.PageHelper; 8 | import com.github.pagehelper.PageInfo; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.ui.Model; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * 评论模块controller 18 | */ 19 | @Controller 20 | @RequestMapping("/review") 21 | public class ReviewController { 22 | 23 | @Autowired 24 | private ReviewService reviewService; 25 | @Autowired 26 | private ProductService productService; 27 | 28 | @RequestMapping("/list") 29 | public String list(Model model, Page page){ 30 | PageHelper.offsetPage(page.getStart(),page.getCount());//分页查询 31 | List list= reviewService.list(); 32 | int total = (int) new PageInfo<>(list).getTotal();//总条数 33 | page.setTotal(total); 34 | 35 | model.addAttribute("totals",list.size()); 36 | model.addAttribute("list",list); 37 | return "pinglunpage/pinglun"; 38 | } 39 | 40 | @RequestMapping("/del") 41 | public String del(int id){ 42 | reviewService.del(id); 43 | return "redirect:list"; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/PermissionService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.Permission; 4 | import com.byh.biyesheji.pojo.Role; 5 | 6 | import java.util.List; 7 | import java.util.Set; 8 | 9 | public interface PermissionService { 10 | 11 | /** 12 | * 获得当前管理员的权限列表 13 | * @param userName 管理员名字 14 | * @return 15 | */ 16 | public Set listPermissions(String userName); 17 | 18 | /** 19 | * 所有存在数据库的权限集合 20 | * @return 21 | */ 22 | public List list(); 23 | 24 | /** 25 | * 添加权限 26 | * @param permission 27 | */ 28 | public void add(Permission permission); 29 | 30 | /** 31 | * 删除权限 32 | * @param id 权限id 33 | */ 34 | public void delete(Long id); 35 | 36 | /** 37 | * 获得一条权限 38 | * @param id 权限id 39 | * @return 40 | */ 41 | public Permission get(Long id); 42 | 43 | /** 44 | * 更新权限信息 45 | * @param permission 46 | */ 47 | public void update(Permission permission); 48 | 49 | /** 50 | * 根据角色获取权限 51 | * @param role 52 | * @return 53 | */ 54 | public List list(Role role); 55 | 56 | /** 57 | * 查询传入的url是否被维护 58 | * @param requestURI 59 | * @return 有?true:false 60 | */ 61 | public boolean needInterceptor(String requestURI); 62 | 63 | /** 64 | * 获得对应管理员的拥有角色的权限能访问的url 65 | * @param userName 66 | * @return 67 | */ 68 | public Set listPermissionURLs(String userName); 69 | } 70 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/index.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/9/29 5 | Time: 14:59 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %> 9 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 10 | 11 | <%@include file="../include/publicMeta.jsp"%> 12 | <%@include file="../include/publicHeader.jsp"%> 13 | <%@include file="../include/publicMenu.jsp"%> 14 | 15 | 16 |
17 | 21 |
22 |
23 |

欢迎使用校园点餐平台

24 |
25 | 26 |
27 |

感谢jQuery、layer、laypage、Validform、UEditor、My97DatePicker、iconfont、Datatables、WebUploaded、icheck、highcharts、bootstrap-Switch
Copyright ©2015 H-ui.admin v3.0 All Rights Reserved.
本后台系统由H-ui前端框架提供前端技术支持

28 |
29 |
30 |
31 | 32 | <%@include file="../include/publicFooter.jsp"%> 33 | 34 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/impl/CustomerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service.impl; 2 | 3 | import com.byh.biyesheji.dao.CustomerMapper; 4 | import com.byh.biyesheji.pojo.Customer; 5 | import com.byh.biyesheji.pojo.CustomerExample; 6 | import com.byh.biyesheji.service.CustomerService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | 12 | @Service 13 | public class CustomerServiceImpl implements CustomerService { 14 | 15 | @Autowired 16 | private CustomerMapper customerMapper; 17 | @Override 18 | public Customer foreLogin(Customer customer) { 19 | CustomerExample example = new CustomerExample(); 20 | example.createCriteria().andNameEqualTo(customer.getName()).andPasswordEqualTo(customer.getPassword()); 21 | List customers = customerMapper.selectByExample(example); 22 | 23 | return customers.size()>0?customers.get(0):null; 24 | } 25 | 26 | @Override 27 | public void save(Customer customer) { 28 | customerMapper.insert(customer); 29 | } 30 | 31 | @Override 32 | public Customer get(int cstid) { 33 | return customerMapper.selectByPrimaryKey(cstid); 34 | } 35 | 36 | @Override 37 | public List list() { 38 | return customerMapper.selectByExample(null); 39 | } 40 | 41 | @Override 42 | public void shezhihuiyuan(int id) { 43 | customerMapper.enableStatus(id); 44 | } 45 | 46 | @Override 47 | public void del(int id) { 48 | customerMapper.deleteByPrimaryKey(id); 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service; 2 | 3 | import com.byh.biyesheji.pojo.Category; 4 | import com.byh.biyesheji.pojo.Product; 5 | import com.byh.biyesheji.pojo.ProductVO; 6 | import com.byh.biyesheji.pojo.User; 7 | 8 | import java.util.List; 9 | 10 | public interface ProductService extends CrudService{ 11 | 12 | /** 13 | * 商品上线 14 | * @param name 15 | * @return 16 | */ 17 | public String enableStatus(String name); 18 | 19 | /** 20 | * 商品下线 21 | * @param name 22 | * @return 23 | */ 24 | public String stopStatus(String name); 25 | 26 | /** 27 | * 设置商品图片保存位置 28 | * @param vo 29 | */ 30 | public void setImageURL(ProductVO vo); 31 | 32 | /** 33 | * 获得分类实体 34 | * @param id 分类id 35 | * @return 36 | */ 37 | public Category getCategoryByCid(int id); 38 | 39 | /** 40 | * 更新商品 41 | * @param product 42 | */ 43 | public void update(Product product); 44 | 45 | /** 46 | * 获取分类下的所有上线商品列表 47 | * @param id 48 | * @return 49 | */ 50 | public List getProductsByCid(Integer id); 51 | 52 | /** 53 | * 获得商品所属商家 54 | * @param id 商家id 55 | * @return 56 | */ 57 | public User getUserByBid(long id); 58 | 59 | /** 60 | * 模糊搜索 61 | * @param pName 商品name 62 | * @return 商品集合 63 | */ 64 | public List findByName(String pName); 65 | 66 | /** 67 | * 68 | * @param cid 69 | * @return 70 | */ 71 | public List findByCid(int cid); 72 | 73 | public boolean findProByCid(int id); 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/unauthorized.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/10/10 5 | Time: 17:06 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | <%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %> 11 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 12 | 13 | <%@include file="../include/publicMeta.jsp"%> 14 | <%@include file="../include/publicHeader.jsp"%> 15 | <%@include file="../include/publicMenu.jsp"%> 16 | 17 | 18 |
19 | 23 | 24 |
25 |

26 | 权限不足 27 |

28 |

不好意思,您的权限不足~

29 |

您可以: 30 | < 返回上一页 31 | | 32 | 去首页 > 33 |

34 |
35 | 36 |
37 | 38 | <%@include file="../include/publicFooter.jsp"%> 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/controller/ZiXunController.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.controller; 2 | 3 | import com.byh.biyesheji.pojo.ZiXun; 4 | import com.byh.biyesheji.service.ZiXunService; 5 | import com.byh.biyesheji.util.Page; 6 | import com.github.pagehelper.PageHelper; 7 | import com.github.pagehelper.PageInfo; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | import java.util.List; 15 | 16 | @Controller 17 | @RequestMapping("/zixun") 18 | public class ZiXunController { 19 | 20 | @Autowired 21 | private ZiXunService ziXunService; 22 | 23 | @RequestMapping("/list") 24 | public String list(Page page, Model model){ 25 | PageHelper.offsetPage(page.getStart(),page.getCount());//分页查询 26 | List list = ziXunService.list1(); 27 | int total = (int) new PageInfo(list).getTotal();//总条数 28 | page.setTotal(total); 29 | 30 | model.addAttribute("list",list); 31 | model.addAttribute("totals",total); 32 | 33 | return "cstpage/zixun-list"; 34 | } 35 | 36 | /** 37 | * 审核 38 | * @param zid 39 | * @return 40 | */ 41 | @RequestMapping("/zixunshenhe") 42 | @ResponseBody 43 | public String zixunshenhe(int zid){ 44 | ziXunService.shenhe(zid); 45 | return "success"; 46 | } 47 | 48 | @RequestMapping("/del") 49 | public String del(int id){ 50 | ziXunService.del(id); 51 | return "redirect:list"; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/OrderItem.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | 3 | public class OrderItem { 4 | private Integer id; 5 | 6 | private Integer pid; 7 | 8 | private Integer oid; 9 | 10 | private Integer cstid; 11 | 12 | private Integer number;//购买数量 13 | //新增 14 | private Product product; 15 | 16 | public Integer getId() { 17 | return id; 18 | } 19 | 20 | public void setId(Integer id) { 21 | this.id = id; 22 | } 23 | 24 | public Integer getPid() { 25 | return pid; 26 | } 27 | 28 | public void setPid(Integer pid) { 29 | this.pid = pid; 30 | } 31 | 32 | public Integer getOid() { 33 | return oid; 34 | } 35 | 36 | public void setOid(Integer oid) { 37 | this.oid = oid; 38 | } 39 | 40 | public Integer getCstid() { 41 | return cstid; 42 | } 43 | 44 | public void setCstid(Integer cstid) { 45 | this.cstid = cstid; 46 | } 47 | 48 | public Integer getNumber() { 49 | return number; 50 | } 51 | 52 | public void setNumber(Integer number) { 53 | this.number = number; 54 | } 55 | 56 | public Product getProduct() { 57 | return product; 58 | } 59 | 60 | public void setProduct(Product product) { 61 | this.product = product; 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | return "OrderItem{" + 67 | "id=" + id + 68 | ", pid=" + pid + 69 | ", oid=" + oid + 70 | ", cstid=" + cstid + 71 | ", number=" + number + 72 | ", product=" + product + 73 | '}'; 74 | } 75 | } -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/productmodule/category-edit.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/10/10 5 | Time: 17:45 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <%@include file="../../include/publicMeta.jsp"%> 11 | 12 |
13 |
14 |
15 | 16 |
17 | 18 |
19 |
20 | 21 | 22 | 23 |
24 |
25 | 26 |
27 |
28 |
29 |
30 | <%@include file="../../include/publicFooter.jsp"%> 31 | 32 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/Customer.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | 3 | public class Customer { 4 | private Integer id; 5 | 6 | private String name; 7 | 8 | private String password; 9 | 10 | private String address; 11 | 12 | private String phone; 13 | 14 | private Integer status; 15 | 16 | public Integer getId() { 17 | return id; 18 | } 19 | 20 | public void setId(Integer id) { 21 | this.id = id; 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public void setPassword(String password) { 37 | this.password = password; 38 | } 39 | 40 | public String getAddress() { 41 | return address; 42 | } 43 | 44 | public void setAddress(String address) { 45 | this.address = address; 46 | } 47 | 48 | public String getPhone() { 49 | return phone; 50 | } 51 | 52 | public void setPhone(String phone) { 53 | this.phone = phone; 54 | } 55 | 56 | public Integer getStatus() { 57 | return status; 58 | } 59 | 60 | public void setStatus(Integer status) { 61 | this.status = status; 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | return "Customer{" + 67 | "id=" + id + 68 | ", name='" + name + '\'' + 69 | ", password='" + password + '\'' + 70 | ", address='" + address + '\'' + 71 | ", phone='" + phone + '\'' + 72 | ", status=" + status + 73 | '}'; 74 | } 75 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/controller/CustomerController.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.controller; 2 | 3 | import com.byh.biyesheji.pojo.Customer; 4 | import com.byh.biyesheji.service.CustomerService; 5 | import com.byh.biyesheji.util.Page; 6 | import com.github.pagehelper.PageHelper; 7 | import com.github.pagehelper.PageInfo; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | import java.util.List; 15 | 16 | /** 17 | * 用户模块controller 18 | */ 19 | @Controller 20 | @RequestMapping("/customer") 21 | public class CustomerController { 22 | 23 | @Autowired 24 | private CustomerService customerService; 25 | 26 | @RequestMapping("/list") 27 | public String list(Model model, Page page){ 28 | PageHelper.offsetPage(page.getStart(),page.getCount());//分页查询 29 | List list= customerService.list(); 30 | int total = (int) new PageInfo(list).getTotal();//总条数 31 | page.setTotal(total); 32 | 33 | model.addAttribute("list",list); 34 | model.addAttribute("totals",total); 35 | return "cstpage/cst-list"; 36 | } 37 | 38 | /** 39 | * 设置会员 40 | * @param id 41 | * @return 42 | */ 43 | @RequestMapping("/shezhihuiyuan") 44 | @ResponseBody 45 | public String shezhihuiyuan(int id){ 46 | customerService.shezhihuiyuan(id); 47 | return "success"; 48 | } 49 | 50 | @RequestMapping("/del") 51 | public String del(int id){ 52 | customerService.del(id); 53 | return "redirect:list"; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/ZiXun.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | 3 | import java.util.Date; 4 | 5 | public class ZiXun { 6 | private Integer id; 7 | 8 | private String content; 9 | 10 | private Integer cstid; 11 | 12 | private Integer status; 13 | 14 | private Date fabudate; 15 | 16 | private Customer customer; 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public String getContent() { 27 | return content; 28 | } 29 | 30 | public void setContent(String content) { 31 | this.content = content; 32 | } 33 | 34 | public Integer getCstid() { 35 | return cstid; 36 | } 37 | 38 | public void setCstid(Integer cstid) { 39 | this.cstid = cstid; 40 | } 41 | 42 | public Integer getStatus() { 43 | return status; 44 | } 45 | 46 | public void setStatus(Integer status) { 47 | this.status = status; 48 | } 49 | 50 | public Date getFabudate() { 51 | return fabudate; 52 | } 53 | 54 | public void setFabudate(Date fabudate) { 55 | this.fabudate = fabudate; 56 | } 57 | 58 | public Customer getCustomer() { 59 | return customer; 60 | } 61 | 62 | public void setCustomer(Customer customer) { 63 | this.customer = customer; 64 | } 65 | 66 | @Override 67 | public String toString() { 68 | return "ZiXun{" + 69 | "id=" + id + 70 | ", content='" + content + '\'' + 71 | ", cstid=" + cstid + 72 | ", status=" + status + 73 | ", fabudate=" + fabudate + 74 | ", customer=" + customer + 75 | '}'; 76 | } 77 | } -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/ordermodule/orderItem-list.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: baiyuhong 5 | Date: 2018/10/4 6 | Time: 21:20 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | <%@include file="../../include/publicMeta.jsp"%> 12 | 13 |
14 |
15 |
16 |
17 | 共有数据:${total} 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
ID商品名价格数量
${orderItem.id}${orderItem.product.name}${orderItem.product.price}${orderItem.number}
39 |
40 | 总价${totalPrice} 41 |
42 |
43 |
44 |
45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **完整代码收费 可以加qq 931708230 或者加微信ynwwxid 咨询** 2 | 3 | **接毕业设计和论文** 4 | 5 | **博客地址:[https://blog.csdn.net/2303_76227485/article/details/128701556](https://blog.csdn.net/2303_76227485/article/details/128701556)** 6 | 7 | **视频演示:[https://www.bilibili.com/video/BV1XV411u7BW/](https://www.bilibili.com/video/BV1XV411u7BW/)** 8 | 9 | **毕业设计所有选题地址:[https://github.com/ynwynw/allProject](https://github.com/ynwynw/allProject)** 10 | 11 | ## 基于ssm的校园网上订餐系统(源代码+数据库) 12 | 13 | ## 一、系统介绍 14 | 15 | 本项目分为管理员与普通用户两种角色 16 | 17 | - 前台模块 18 | 前台主要功能有:用户注册、用户登录、我的购物车、我的订单、商品评论、校园资讯、修改密码 19 | - 后台模块 20 | 后台主要功能有:用户管理、商品管理、订单管理、评论管理、资讯管理等 21 | 22 | 23 | ## 二、所用技术 24 | 25 | - 后端使用Java+ssm+MyBatis+MySQL+shiro 26 | - 前端使用jsp+bootstrap 27 | 28 | 29 | ## 三、环境介绍 30 | 31 | 基础环境 :IDEA/eclipse, JDK 1.8, Mysql5.7,Maven,tomcat8.0 32 | 33 | 所有项目以及源代码本人均调试运行无问题 可支持远程调试运行 34 | 35 | ## 四、页面截图 36 | 37 | 38 | 39 | ![contents](./picture/picture1.png) 40 | 41 | ![contents](./picture/picture2.png) 42 | 43 | ![contents](./picture/picture3.png) 44 | 45 | ![contents](./picture/picture4.png) 46 | 47 | ![contents](./picture/picture5.png) 48 | 49 | ![contents](./picture/picture6.png) 50 | 51 | ![contents](./picture/picture7.png) 52 | 53 | ![contents](./picture/picture8.png) 54 | 55 | ![contents](./picture/picture9.png) 56 | 57 | ![contents](./picture/picture10.png) 58 | 59 | ![contents](./picture/picture11.png) 60 | 61 | ![contents](./picture/picture12.png) 62 | 63 | ![contents](./picture/picture13.png) 64 | 65 | 66 | ## 五、浏览地址 67 | 68 | 后台超级管理员: 69 | http://localhost:8989/login 70 | 71 | 用户名:小白 密码:adminadmin 72 | 73 | 前台地址: 74 | http://localhost:8989/fore/foreIndex 75 | 76 | 用户名:byh 密码:12345 77 | 78 | ## 六、安装教程 79 | 80 | 1. 使用Navicat或者其它工具、在mysql中创建对应名称的数据库、并导入项目的sql文件; 81 | 2. 使用IDEA/Eclipse导入项目,若为maven项目请选择maven,导入成功后请执行maven clean;maven install命令 82 | 3. 修改resource里面的jdbc.properties里面的数据库配置 83 | 4. 将项目加入到tomcat容器里面,启动项目 84 | 85 | **完整代码收费 可以加qq 931708230 或者加微信ynwwxid 咨询** 86 | 87 | **接毕业设计和论文** 88 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/impl/ZiXunServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service.impl; 2 | 3 | import com.byh.biyesheji.dao.CustomerMapper; 4 | import com.byh.biyesheji.dao.ZiXunMapper; 5 | import com.byh.biyesheji.pojo.Customer; 6 | import com.byh.biyesheji.pojo.ZiXun; 7 | import com.byh.biyesheji.pojo.ZiXunExample; 8 | import com.byh.biyesheji.service.ZiXunService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.List; 13 | 14 | @Service 15 | public class ZiXunServiceImpl implements ZiXunService { 16 | 17 | @Autowired 18 | private ZiXunMapper ziXunMapper; 19 | @Autowired 20 | private CustomerMapper customerMapper; 21 | 22 | @Override 23 | public List list() { 24 | ZiXunExample example = new ZiXunExample(); 25 | example.createCriteria().andStatusEqualTo(1); 26 | List ziXuns = ziXunMapper.selectByExample(example); 27 | for (ZiXun z:ziXuns){ 28 | Customer customer =customerMapper.selectByPrimaryKey(z.getCstid()); 29 | z.setCustomer(customer); 30 | } 31 | return ziXuns; 32 | } 33 | 34 | @Override 35 | public void save(ZiXun entity) { 36 | ziXunMapper.insert(entity); 37 | } 38 | 39 | @Override 40 | public void del(int id) { 41 | ziXunMapper.deleteByPrimaryKey(id); 42 | } 43 | 44 | @Override 45 | public ZiXun get(int id) { 46 | return ziXunMapper.selectByPrimaryKey(id); 47 | } 48 | 49 | @Override 50 | public void shenhe(int zid) { 51 | ziXunMapper.shenhe(zid); 52 | } 53 | 54 | @Override 55 | public List list1() { 56 | List ziXuns = ziXunMapper.selectByExample(null); 57 | for (ZiXun z:ziXuns){ 58 | Customer customer =customerMapper.selectByPrimaryKey(z.getCstid()); 59 | z.setCustomer(customer); 60 | } 61 | return ziXuns; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/controller/CategoryController.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.controller; 2 | 3 | import com.byh.biyesheji.pojo.Category; 4 | import com.byh.biyesheji.service.CategoryService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Controller; 7 | import org.springframework.ui.Model; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * 商品分类模块controller 15 | */ 16 | @Controller 17 | @RequestMapping("/category") 18 | public class CategoryController { 19 | 20 | @Autowired 21 | private CategoryService categoryService; 22 | 23 | @RequestMapping("/list") 24 | public String list(Model model){ 25 | List list = categoryService.list(); 26 | model.addAttribute("list",list); 27 | model.addAttribute("size",list.size()); 28 | return "productmodule/category-list"; 29 | } 30 | 31 | @RequestMapping("/addCategory") 32 | public String add(@RequestParam(value = "name")String name){ 33 | Category category = new Category(); 34 | category.setName(name); 35 | categoryService.save(category); 36 | return "productmodule/category-list"; 37 | } 38 | 39 | @RequestMapping("/delCategory") 40 | public String del(@RequestParam(value = "id")int id){ 41 | categoryService.del(id); 42 | return "redirect:list"; 43 | } 44 | 45 | @RequestMapping("/editCategory") 46 | public String edit(@RequestParam(value = "id")int id, Model model){ 47 | Category category = categoryService.get(id); 48 | model.addAttribute("category",category); 49 | return "productmodule/category-edit"; 50 | } 51 | 52 | @RequestMapping("/updateCategory") 53 | public String update(Category category, Model model){ 54 | categoryService.update(category); 55 | return "redirect:list"; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/include/publicMeta.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/9/29 5 | Time: 15:37 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java"%> 9 | <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | 30 | 34 | 35 | 点餐平台后台 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/Review.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | 3 | import java.util.Date; 4 | 5 | public class Review { 6 | private Integer id; 7 | 8 | private String content; 9 | 10 | private Integer cstid; 11 | 12 | private Integer pid; 13 | 14 | private Date createtime; 15 | 16 | private Customer customer; 17 | 18 | private Product product; 19 | 20 | public Integer getId() { 21 | return id; 22 | } 23 | 24 | public void setId(Integer id) { 25 | this.id = id; 26 | } 27 | 28 | public String getContent() { 29 | return content; 30 | } 31 | 32 | public void setContent(String content) { 33 | this.content = content; 34 | } 35 | 36 | public Integer getCstid() { 37 | return cstid; 38 | } 39 | 40 | public void setCstid(Integer cstid) { 41 | this.cstid = cstid; 42 | } 43 | 44 | public Integer getPid() { 45 | return pid; 46 | } 47 | 48 | public void setPid(Integer pid) { 49 | this.pid = pid; 50 | } 51 | 52 | public Date getCreatetime() { 53 | return createtime; 54 | } 55 | 56 | public void setCreatetime(Date createtime) { 57 | this.createtime = createtime; 58 | } 59 | 60 | public Customer getCustomer() { 61 | return customer; 62 | } 63 | 64 | public void setCustomer(Customer customer) { 65 | this.customer = customer; 66 | } 67 | 68 | public Product getProduct() { 69 | return product; 70 | } 71 | 72 | public void setProduct(Product product) { 73 | this.product = product; 74 | } 75 | 76 | @Override 77 | public String toString() { 78 | return "Review{" + 79 | "id=" + id + 80 | ", content='" + content + '\'' + 81 | ", cstid=" + cstid + 82 | ", pid=" + pid + 83 | ", createtime=" + createtime + 84 | ", customer=" + customer + 85 | ", product=" + product + 86 | '}'; 87 | } 88 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/util/Page.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.util; 2 | 3 | import lombok.ToString; 4 | 5 | /** 6 | * 分页工具类 7 | */ 8 | @ToString 9 | public class Page { 10 | 11 | private int start; //开始页数 12 | private int count; //每页显示个数 13 | private int total; //总个数 14 | 15 | private static final int defaultCount = 8; //默认每页显示5条 16 | 17 | 18 | public Page (){ 19 | count = defaultCount; 20 | } 21 | public Page(int start, int count) { 22 | this(); 23 | this.start = start; 24 | this.count = count; 25 | } 26 | 27 | public int getStart() { 28 | return start; 29 | } 30 | public void setStart(int start) { 31 | this.start = start; 32 | } 33 | public int getCount() { 34 | return count; 35 | } 36 | public void setCount(int count) { 37 | this.count = count; 38 | } 39 | 40 | public boolean isHasPreviouse(){ 41 | if(start==0) 42 | return false; 43 | return true; 44 | } 45 | public boolean isHasNext(){ 46 | if(start==getLast()) 47 | return false; 48 | return true; 49 | } 50 | 51 | public int getTotalPage(){ 52 | int totalPage; 53 | // 假设总数是50,是能够被5整除的,那么就有10页 54 | if (0 == total % count) 55 | totalPage = total /count; 56 | // 假设总数是51,不能够被5整除的,那么就有11页 57 | else 58 | totalPage = total / count + 1; 59 | 60 | if(0==totalPage) 61 | totalPage = 1; 62 | return totalPage; 63 | 64 | } 65 | 66 | public int getLast(){ 67 | int last; 68 | // 假设总数是50,是能够被5整除的,那么最后一页的开始就是45 69 | if (0 == total % count) 70 | last = total - count; 71 | // 假设总数是51,不能够被5整除的,那么最后一页的开始就是50 72 | else 73 | last = total - total % count; 74 | last = last<0?0:last; 75 | return last; 76 | } 77 | 78 | public int getTotal() { 79 | return total; 80 | } 81 | public void setTotal(int total) { 82 | this.total = total; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/impl/ReviewServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service.impl; 2 | 3 | import com.byh.biyesheji.dao.CustomerMapper; 4 | import com.byh.biyesheji.dao.ProductMapper; 5 | import com.byh.biyesheji.dao.ReviewMapper; 6 | import com.byh.biyesheji.pojo.*; 7 | import com.byh.biyesheji.service.ReviewService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | @Service 14 | public class ReviewServiceImpl implements ReviewService { 15 | 16 | @Autowired 17 | private ReviewMapper reviewMapper; 18 | @Autowired 19 | private CustomerMapper customerMapper; 20 | @Autowired 21 | private ProductMapper productMapper; 22 | 23 | @Override 24 | public List list() { 25 | List reviews = reviewMapper.selectByExample(null); 26 | for (Review review:reviews){ 27 | Customer customer = customerMapper.selectByPrimaryKey(review.getCstid()); 28 | Product product = productMapper.selectByPrimaryKey(review.getPid()); 29 | review.setCustomer(customer); 30 | review.setProduct(product); 31 | } 32 | return reviews; 33 | } 34 | 35 | @Override 36 | public List getReviewListByPid(int id) { 37 | ReviewExample example = new ReviewExample(); 38 | example.createCriteria().andPidEqualTo(id); 39 | List reviews = reviewMapper.selectByExample(example); 40 | for (Review review:reviews){ 41 | Customer customer = customerMapper.selectByPrimaryKey(review.getCstid()); 42 | review.setCustomer(customer); 43 | } 44 | 45 | return reviews; 46 | } 47 | 48 | @Override 49 | public void del(int id) { 50 | reviewMapper.deleteByPrimaryKey(id); 51 | } 52 | 53 | @Override 54 | public Review get(int id) { 55 | return reviewMapper.selectByPrimaryKey(id); 56 | } 57 | 58 | @Override 59 | public void save(Review review) { 60 | reviewMapper.insert(review); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/syspage/admin-permission-add.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/10/8 5 | Time: 17:34 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@include file="../../include/publicMeta.jsp"%> 10 | 11 |
12 |
13 |
14 | 15 |
16 | 17 |
18 |
19 |
20 | 21 |
22 | 23 |
24 |
25 |
26 | 27 |
28 | 29 |
30 |
31 |
32 |
33 | 34 |
35 |
36 |
37 |
38 | <%@include file="../../include/publicFooter.jsp"%> 39 | 40 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/impl/UserRoleServiceimpl.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service.impl; 2 | 3 | import com.byh.biyesheji.dao.UserRoleMapper; 4 | import com.byh.biyesheji.pojo.User; 5 | import com.byh.biyesheji.pojo.UserRole; 6 | import com.byh.biyesheji.pojo.UserRoleExample; 7 | import com.byh.biyesheji.service.UserRoleService; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | @Service 14 | public class UserRoleServiceimpl implements UserRoleService { 15 | 16 | @Autowired 17 | UserRoleMapper userRoleMapper; 18 | 19 | @Override 20 | public void setRoles(User user, long[] roleIds) { 21 | //删除当前管理员所有的角色 22 | UserRoleExample example= new UserRoleExample(); 23 | example.createCriteria().andUidEqualTo(user.getId()); 24 | 25 | List urs= userRoleMapper.selectByExample(example); 26 | 27 | for (UserRole userRole : urs) 28 | userRoleMapper.deleteByPrimaryKey(userRole.getId()); 29 | 30 | //设置新的角色关系 31 | if(null!=roleIds) 32 | for (long rid : roleIds) { 33 | UserRole userRole = new UserRole(); 34 | userRole.setRid(rid); 35 | userRole.setUid(user.getId());//插入管理员新的所有权限 36 | userRoleMapper.insert(userRole); 37 | } 38 | } 39 | 40 | @Override 41 | public void deleteByUser(long userId) { 42 | UserRoleExample example= new UserRoleExample(); 43 | example.createCriteria().andUidEqualTo(userId); 44 | List urs= userRoleMapper.selectByExample(example);//urs:传进来的管理员的id去作为条件查询UserRole表的记录的集合 45 | for (UserRole userRole : urs) {//依次删除记录 46 | userRoleMapper.deleteByPrimaryKey(userRole.getId()); 47 | } 48 | } 49 | 50 | @Override 51 | public void deleteByRole(long roleId) { 52 | UserRoleExample example= new UserRoleExample(); 53 | example.createCriteria().andRidEqualTo(roleId); 54 | List urs= userRoleMapper.selectByExample(example);//查询UserRole表为角色id的记录 下面删除 55 | for (UserRole userRole : urs) { 56 | userRoleMapper.deleteByPrimaryKey(userRole.getId()); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/User.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | 3 | import java.util.Date; 4 | 5 | public class User { 6 | 7 | private Long id; 8 | 9 | private String name; 10 | 11 | private String password; 12 | 13 | private String salt; 14 | 15 | private Integer status; 16 | 17 | private String address; 18 | 19 | private String phone; 20 | 21 | private Date lasttime; 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Long id) { 28 | this.id = id; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public String getPassword() { 40 | return password; 41 | } 42 | 43 | public void setPassword(String password) { 44 | this.password = password; 45 | } 46 | 47 | public String getSalt() { 48 | return salt; 49 | } 50 | 51 | public void setSalt(String salt) { 52 | this.salt = salt; 53 | } 54 | 55 | public Integer getStatus() { 56 | return status; 57 | } 58 | 59 | public void setStatus(Integer status) { 60 | this.status = status; 61 | } 62 | 63 | public String getAddress() { 64 | return address; 65 | } 66 | 67 | public void setAddress(String address) { 68 | this.address = address; 69 | } 70 | 71 | public String getPhone() { 72 | return phone; 73 | } 74 | 75 | public void setPhone(String phone) { 76 | this.phone = phone; 77 | } 78 | 79 | public Date getLasttime() { 80 | return lasttime; 81 | } 82 | 83 | public void setLasttime(Date lasttime) { 84 | this.lasttime = lasttime; 85 | } 86 | 87 | @Override 88 | public String toString() { 89 | return "User{" + 90 | "id=" + id + 91 | ", name='" + name + '\'' + 92 | ", password='" + password + '\'' + 93 | ", salt='" + salt + '\'' + 94 | ", status=" + status + 95 | ", address='" + address + '\'' + 96 | ", phone='" + phone + '\'' + 97 | ", lasttime=" + lasttime + 98 | '}'; 99 | } 100 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.controller; 2 | 3 | 4 | import com.byh.biyesheji.pojo.Order; 5 | import com.byh.biyesheji.service.OrderItemService; 6 | import com.byh.biyesheji.service.OrderService; 7 | import com.byh.biyesheji.util.Page; 8 | import com.github.pagehelper.PageHelper; 9 | import com.github.pagehelper.PageInfo; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.ui.Model; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * 订单模块controller 19 | */ 20 | @Controller 21 | @RequestMapping("/order") 22 | public class OrderController { 23 | 24 | @Autowired 25 | OrderService orderService; 26 | @Autowired 27 | OrderItemService orderItemService; 28 | 29 | /** 30 | * 所有订单 31 | * @param model 32 | * @param page 33 | * @return 34 | */ 35 | @RequestMapping("/list") 36 | public String list(Model model, Page page){ 37 | PageHelper.offsetPage(page.getStart(),page.getCount()); 38 | 39 | List os= orderService.list(); 40 | 41 | int total = (int) new PageInfo<>(os).getTotal(); 42 | page.setTotal(total); 43 | //为订单添加订单项数据 44 | orderItemService.fill(os); 45 | 46 | model.addAttribute("os", os); 47 | model.addAttribute("page", page); 48 | model.addAttribute("totals", total); 49 | 50 | return "ordermodule/order-list"; 51 | } 52 | 53 | /** 54 | * 订单发货 55 | * @param o 56 | * @return 57 | */ 58 | @RequestMapping("/orderDelivery") 59 | public String delivery(Order o){ 60 | o.setStatus(2); 61 | orderService.update(o); 62 | return "redirect:list"; 63 | } 64 | 65 | /** 66 | * 查看当前订单的订单项 67 | * @param oid 68 | * @param model 69 | * @return 70 | */ 71 | @RequestMapping("/seeOrderItem") 72 | public String seeOrderItem(int oid, Model model){ 73 | Order o = orderService.get(oid); 74 | orderItemService.fill(o); 75 | model.addAttribute("orderItems",o.getOrderItems()); 76 | model.addAttribute("total",o.getOrderItems().size()); 77 | model.addAttribute("totalPrice",o.getTotal()); 78 | return "ordermodule/orderItem-list"; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/impl/RolePermissionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service.impl; 2 | 3 | 4 | import com.byh.biyesheji.dao.RolePermissionMapper; 5 | import com.byh.biyesheji.pojo.Role; 6 | import com.byh.biyesheji.pojo.RolePermission; 7 | import com.byh.biyesheji.pojo.RolePermissionExample; 8 | import com.byh.biyesheji.service.RolePermissionService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.List; 13 | 14 | @Service 15 | public class RolePermissionServiceImpl implements RolePermissionService { 16 | 17 | @Autowired 18 | RolePermissionMapper rolePermissionMapper; 19 | 20 | @Override 21 | public void setPermissions(Role role, long[] permissionIds) { 22 | //删除当前角色所有的权限 23 | RolePermissionExample example= new RolePermissionExample(); 24 | example.createCriteria().andRidEqualTo(role.getId()); 25 | List rps= rolePermissionMapper.selectByExample(example); 26 | for (RolePermission rolePermission : rps) 27 | rolePermissionMapper.deleteByPrimaryKey(rolePermission.getId()); 28 | 29 | //设置新的权限关系 30 | if(null!=permissionIds) 31 | for (long pid : permissionIds) { 32 | RolePermission rolePermission = new RolePermission(); 33 | rolePermission.setPid(pid); 34 | rolePermission.setRid(role.getId()); 35 | rolePermissionMapper.insert(rolePermission); 36 | } 37 | } 38 | 39 | @Override 40 | public void deleteByRole(long roleId) { 41 | RolePermissionExample example= new RolePermissionExample(); 42 | example.createCriteria().andRidEqualTo(roleId); 43 | List rps= rolePermissionMapper.selectByExample(example); 44 | for (RolePermission rolePermission : rps) 45 | rolePermissionMapper.deleteByPrimaryKey(rolePermission.getId()); 46 | } 47 | 48 | @Override 49 | public void deleteByPermission(long permissionId) { 50 | RolePermissionExample example= new RolePermissionExample(); 51 | example.createCriteria().andPidEqualTo(permissionId); 52 | List rps= rolePermissionMapper.selectByExample(example); 53 | for (RolePermission rolePermission : rps) 54 | rolePermissionMapper.deleteByPrimaryKey(rolePermission.getId()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | manager 7 | 8 | 9 | 10 | contextConfigLocation 11 | 12 | classpath:spring/spring-mybatis.xml, 13 | classpath:spring/spring-shiro.xml 14 | 15 | 16 | 17 | org.springframework.web.context.ContextLoaderListener 18 | 19 | 20 | 21 | 22 | mvc-dispatcher 23 | org.springframework.web.servlet.DispatcherServlet 24 | 25 | 26 | contextConfigLocation 27 | classpath:spring/springmvc.xml 28 | 29 | 1 30 | 31 | 32 | mvc-dispatcher 33 | / 34 | 35 | 36 | 37 | 38 | CharacterEncodingFilter 39 | org.springframework.web.filter.CharacterEncodingFilter 40 | 41 | encoding 42 | utf-8 43 | 44 | 45 | 46 | CharacterEncodingFilter 47 | /* 48 | 49 | 50 | 51 | 52 | shiroFilter 53 | org.springframework.web.filter.DelegatingFilterProxy 54 | 55 | targetFilterLifecycle 56 | true 57 | 58 | 59 | 60 | shiroFilter 61 | /* 62 | 63 | 64 | 65 | index.jsp 66 | 67 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/realm/AdminDatabaseRealm.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.realm; 2 | 3 | import com.byh.biyesheji.pojo.User; 4 | import com.byh.biyesheji.service.PermissionService; 5 | import com.byh.biyesheji.service.RoleService; 6 | import com.byh.biyesheji.service.UserService; 7 | import org.apache.shiro.authc.*; 8 | import org.apache.shiro.authz.AuthorizationInfo; 9 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 10 | import org.apache.shiro.realm.AuthorizingRealm; 11 | import org.apache.shiro.subject.PrincipalCollection; 12 | import org.apache.shiro.util.ByteSource; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | 15 | import java.util.Set; 16 | 17 | /** 18 | * 管理员权限验证realm 19 | */ 20 | public class AdminDatabaseRealm extends AuthorizingRealm { 21 | 22 | @Autowired 23 | private UserService userService; 24 | @Autowired 25 | private RoleService roleService; 26 | @Autowired 27 | private PermissionService permissionService; 28 | 29 | @Override 30 | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { 31 | //能进入到这里,表示账号已经通过验证了 32 | String userName =(String) principalCollection.getPrimaryPrincipal(); 33 | //通过service获取角色和权限 34 | Set permissions = permissionService.listPermissions(userName); 35 | Set roles = roleService.listRoleNames(userName); 36 | 37 | //授权对象 38 | SimpleAuthorizationInfo s = new SimpleAuthorizationInfo(); 39 | //把通过service获取到的角色和权限放进去 40 | s.setStringPermissions(permissions); 41 | s.setRoles(roles); 42 | return s; 43 | } 44 | 45 | @Override 46 | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { 47 | //获取账号密码 48 | UsernamePasswordToken t = (UsernamePasswordToken) token; 49 | String userName= token.getPrincipal().toString(); 50 | //获取数据库中的密码 51 | User user =userService.getByName(userName); 52 | String passwordInDB = user.getPassword(); 53 | String salt = user.getSalt(); 54 | //盐放进去 55 | //这样通过spirng-shiro.xml里配置的 HashedCredentialsMatcher 进行自动校验 56 | //认证信息里存放账号密码, getName() 是当前Realm的继承方法,通常返回当前类名 :AdminDatabaseRealm 57 | SimpleAuthenticationInfo a = new SimpleAuthenticationInfo(userName,passwordInDB,ByteSource.Util.bytes(salt),getName()); 58 | return a; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/syspage/admin-permission-edit.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/10/8 5 | Time: 17:42 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | <%@include file="../../include/publicMeta.jsp"%> 11 | 12 |
13 |
14 |
15 | 16 |
17 | 18 |
19 |
20 |
21 | 22 |
23 | 24 |
25 |
26 |
27 | 28 |
29 | 30 |
31 |
32 | 33 | 34 | 35 |
36 |
37 | 38 |
39 |
40 |
41 |
42 | <%@include file="../../include/publicFooter.jsp"%> 43 | 44 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/controller/PermissionController.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.controller; 2 | 3 | import com.byh.biyesheji.pojo.Permission; 4 | import com.byh.biyesheji.service.PermissionService; 5 | import com.byh.biyesheji.util.Page; 6 | import com.github.pagehelper.PageHelper; 7 | import com.github.pagehelper.PageInfo; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * 权限模块controller 17 | */ 18 | @Controller 19 | @RequestMapping("/config") 20 | public class PermissionController { 21 | @Autowired 22 | PermissionService permissionService; 23 | 24 | /** 25 | * 添加权限页面 26 | * @return 27 | */ 28 | @RequestMapping("/adminPerAddUI") 29 | public String addUI(){ 30 | return "syspage/admin-permission-add"; 31 | } 32 | 33 | /** 34 | * 权限列表 35 | * @param model 36 | * @param page 37 | * @return 38 | */ 39 | @RequestMapping("/listPermission") 40 | public String list(Model model, Page page){ 41 | PageHelper.offsetPage(page.getStart(),page.getCount());//分页查询 42 | List ps= permissionService.list(); 43 | int total = (int) new PageInfo<>(ps).getTotal();//总条数 44 | page.setTotal(total); 45 | 46 | model.addAttribute("ps", ps); 47 | model.addAttribute("perCount",ps.size()); 48 | return "syspage/admin-permission"; 49 | } 50 | 51 | @RequestMapping("/editPermission") 52 | public String list(Model model, long id){ 53 | Permission permission =permissionService.get(id); 54 | model.addAttribute("permission", permission); 55 | return "syspage/admin-permission-edit"; 56 | } 57 | 58 | @RequestMapping("/updatePermission") 59 | public String update(Permission permission){ 60 | permissionService.update(permission); 61 | return "redirect:listPermission"; 62 | } 63 | 64 | @RequestMapping("/addPermission") 65 | public String list(Model model, Permission permission){ 66 | permissionService.add(permission); 67 | return "redirect:listPermission"; 68 | } 69 | 70 | @RequestMapping("/deletePermission") 71 | public String delete(Model model, long id){ 72 | permissionService.delete(id); 73 | return "redirect:listPermission"; 74 | } 75 | 76 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/filter/URLPathMatchingFilter.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.filter; 2 | 3 | import com.byh.biyesheji.service.PermissionService; 4 | import org.apache.shiro.SecurityUtils; 5 | import org.apache.shiro.authz.UnauthorizedException; 6 | import org.apache.shiro.subject.Subject; 7 | import org.apache.shiro.web.filter.PathMatchingFilter; 8 | import org.apache.shiro.web.util.WebUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | 11 | import javax.servlet.ServletRequest; 12 | import javax.servlet.ServletResponse; 13 | import java.util.Set; 14 | 15 | /** 16 | * 后台登陆状态权限拦截验证 没有登陆挑战login 没有权限跳转unauthorized 17 | */ 18 | public class URLPathMatchingFilter extends PathMatchingFilter { 19 | @Autowired 20 | PermissionService permissionService; 21 | 22 | @Override 23 | protected boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) 24 | throws Exception { 25 | String requestURI = getPathWithinApplication(request); 26 | 27 | System.out.println("requestURI:" + requestURI); 28 | 29 | Subject subject = SecurityUtils.getSubject(); 30 | // 如果没有登录,就跳转到登录页面 31 | if (!subject.isAuthenticated()) { 32 | WebUtils.issueRedirect(request, response, "/login"); 33 | return false; 34 | } 35 | 36 | // 看看这个路径权限里有没有维护,如果没有维护,一律放行(也可以改为一律不放行) 37 | boolean needInterceptor = permissionService.needInterceptor(requestURI); //查看是否有这个url的权限维护 有true 无false 38 | if (!needInterceptor) { 39 | return true; 40 | } else {//有维护 41 | boolean hasPermission = false; 42 | String userName = subject.getPrincipal().toString(); 43 | //查询当前用户名拥有的权限 44 | Set permissionUrls = permissionService.listPermissionURLs(userName); 45 | for (String url : permissionUrls) { 46 | // 这就表示当前用户有这个权限 47 | if (url.equals(requestURI)) { 48 | hasPermission = true; 49 | break; 50 | } 51 | } 52 | 53 | if (hasPermission) 54 | return true; 55 | else { 56 | UnauthorizedException ex = new UnauthorizedException("当前用户没有访问路径 " + requestURI + " 的权限"); 57 | 58 | subject.getSession().setAttribute("ex", ex); 59 | 60 | WebUtils.issueRedirect(request, response, "/unauthorized"); 61 | return false; 62 | } 63 | 64 | } 65 | 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service.impl; 2 | 3 | import com.byh.biyesheji.dao.ProductMapper; 4 | import com.byh.biyesheji.dao.UserMapper; 5 | import com.byh.biyesheji.pojo.Product; 6 | import com.byh.biyesheji.pojo.User; 7 | import com.byh.biyesheji.pojo.UserExample; 8 | import com.byh.biyesheji.service.UserRoleService; 9 | import com.byh.biyesheji.service.UserService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.List; 14 | 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | UserMapper userMapper; 20 | @Autowired 21 | UserRoleService userRoleService; 22 | @Autowired 23 | ProductMapper productMapper; 24 | 25 | @Override 26 | public String getPassword(String name) { 27 | User u = getByName(name); 28 | if (null == u) return null; 29 | return u.getPassword(); 30 | } 31 | 32 | @Override 33 | public User getByName(String name) { 34 | UserExample example = new UserExample(); 35 | example.createCriteria().andNameEqualTo(name); 36 | List users = userMapper.selectByExample(example); 37 | if (users.isEmpty()) return null; 38 | return users.get(0); 39 | } 40 | 41 | @Override 42 | public List list() { 43 | 44 | return userMapper.selectByExample(null); 45 | } 46 | 47 | @Override 48 | public void add(User user) { 49 | userMapper.insert(user); 50 | } 51 | 52 | @Override 53 | public void delete(Long id) { 54 | userMapper.deleteByPrimaryKey(id); 55 | userRoleService.deleteByUser(id); 56 | } 57 | 58 | @Override 59 | public User get(Long id) { 60 | return userMapper.selectByPrimaryKey(id); 61 | } 62 | 63 | @Override 64 | public void update(User user) { 65 | userMapper.updateByPrimaryKeySelective(user); 66 | } 67 | 68 | @Override 69 | public String enableStatus(String name) { 70 | userMapper.enableStatus(name); 71 | return "success"; 72 | } 73 | 74 | @Override 75 | public String stopStatus(String name) { 76 | userMapper.stopStatus(name); 77 | return "success"; 78 | } 79 | 80 | @Override 81 | public User getUserByPid(int id) { 82 | Product product = productMapper.selectByPrimaryKey(id); 83 | User user = userMapper.selectByPrimaryKey(product.getBid()); 84 | return user; 85 | } 86 | 87 | 88 | } -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/login.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/9/29 5 | Time: 15:42 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 11 | 12 | 13 | 14 | 校园点餐后台登陆 15 | 16 | 29 | 30 | 31 | 32 | 33 | 34 |
35 |
36 |
37 |
38 |
39 | ${error} 40 | 41 | 42 | 43 |
44 |
45 |
46 |
47 |
48 |
49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.controller; 2 | 3 | import com.byh.biyesheji.pojo.User; 4 | import com.byh.biyesheji.service.UserService; 5 | import org.apache.shiro.SecurityUtils; 6 | import org.apache.shiro.authc.AuthenticationException; 7 | import org.apache.shiro.authc.UsernamePasswordToken; 8 | import org.apache.shiro.session.Session; 9 | import org.apache.shiro.subject.Subject; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Controller; 12 | import org.springframework.ui.Model; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestMethod; 15 | 16 | import java.text.ParsePosition; 17 | import java.text.SimpleDateFormat; 18 | import java.util.Date; 19 | 20 | /** 21 | * 后台登陆 22 | */ 23 | @Controller 24 | @RequestMapping("") 25 | public class LoginController { 26 | 27 | @Autowired 28 | UserService userService; 29 | 30 | @RequestMapping(value="/login",method= RequestMethod.POST) 31 | public String login(Model model, String name, String password){//throws ParseException 32 | Subject subject = SecurityUtils.getSubject(); 33 | UsernamePasswordToken token = new UsernamePasswordToken(name,password); 34 | try { 35 | subject.login(token); 36 | User us = userService.getByName(name); 37 | String lastLoginTime = ""; 38 | if(us!=null){ 39 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 40 | //上次时间 41 | Date time = us.getLasttime(); 42 | lastLoginTime = sdf.format(time); 43 | //新时间 44 | String format = sdf.format(new Date()); 45 | //string转date 不处理时间格式会不理想 46 | ParsePosition pos = new ParsePosition(0); 47 | Date strtodate = sdf.parse(format, pos); 48 | us.setLasttime(strtodate); 49 | userService.update(us); 50 | } 51 | if (us.getStatus()==1){ 52 | Session session=subject.getSession(); 53 | session.setAttribute("subject", subject); 54 | session.setAttribute("lastLoginTime",lastLoginTime); 55 | return "redirect:index"; 56 | }else { 57 | model.addAttribute("error", "账号已被停用!"); 58 | return "/login"; 59 | } 60 | 61 | } catch (AuthenticationException e) { 62 | model.addAttribute("error", "验证失败!"); 63 | return "/login"; 64 | } 65 | } 66 | 67 | 68 | } -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/include/publicHeader.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/9/29 5 | Time: 15:30 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 50 | 51 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/Order.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | import java.util.List; 3 | 4 | public class Order { 5 | 6 | private Integer id; 7 | 8 | private String code;//订单编号 9 | 10 | private String address; 11 | 12 | private Integer status; 13 | 14 | private Integer cstid; 15 | 16 | private List orderItems; 17 | 18 | private Customer customer; 19 | 20 | private float total; //总价 21 | 22 | private int totalNumber; //总数量 23 | 24 | public Integer getId() { 25 | return id; 26 | } 27 | 28 | public void setId(Integer id) { 29 | this.id = id; 30 | } 31 | 32 | public String getCode() { 33 | return code; 34 | } 35 | 36 | public void setCode(String code) { 37 | this.code = code; 38 | } 39 | 40 | public String getAddress() { 41 | return address; 42 | } 43 | 44 | public void setAddress(String address) { 45 | this.address = address; 46 | } 47 | 48 | public Integer getStatus() { 49 | return status; 50 | } 51 | 52 | public void setStatus(Integer status) { 53 | this.status = status; 54 | } 55 | 56 | public Integer getCstid() { 57 | return cstid; 58 | } 59 | 60 | public void setCstid(Integer cstid) { 61 | this.cstid = cstid; 62 | } 63 | 64 | public List getOrderItems() { 65 | return orderItems; 66 | } 67 | 68 | public void setOrderItems(List orderItems) { 69 | this.orderItems = orderItems; 70 | } 71 | 72 | public Customer getCustomer() { 73 | return customer; 74 | } 75 | 76 | public void setCustomer(Customer customer) { 77 | this.customer = customer; 78 | } 79 | 80 | public float getTotal() { 81 | return total; 82 | } 83 | 84 | public void setTotal(float total) { 85 | this.total = total; 86 | } 87 | 88 | public int getTotalNumber() { 89 | return totalNumber; 90 | } 91 | 92 | public void setTotalNumber(int totalNumber) { 93 | this.totalNumber = totalNumber; 94 | } 95 | 96 | @Override 97 | public String toString() { 98 | return "Order{" + 99 | "id=" + id + 100 | ", code='" + code + '\'' + 101 | ", address='" + address + '\'' + 102 | ", status=" + status + 103 | ", cstid=" + cstid + 104 | ", orderItems=" + orderItems + 105 | ", customer=" + customer + 106 | ", total=" + total + 107 | ", totalNumber=" + totalNumber + 108 | '}'; 109 | } 110 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service.impl; 2 | 3 | 4 | import com.byh.biyesheji.dao.RoleMapper; 5 | import com.byh.biyesheji.dao.UserRoleMapper; 6 | import com.byh.biyesheji.pojo.*; 7 | import com.byh.biyesheji.service.RoleService; 8 | import com.byh.biyesheji.service.UserService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.ArrayList; 13 | import java.util.HashSet; 14 | import java.util.List; 15 | import java.util.Set; 16 | 17 | @Service 18 | public class RoleServiceImpl implements RoleService { 19 | @Autowired 20 | RoleMapper roleMapper; 21 | @Autowired 22 | UserRoleMapper userRoleMapper; 23 | @Autowired 24 | UserService userService; 25 | 26 | @Override //name的所有角色 27 | public Set listRoleNames(String userName) { 28 | Set result = new HashSet<>(); 29 | //查出管理员相应的角色 30 | List roles = listRoles(userName); 31 | //把每个角色名放到set集合中 32 | for (Role role : roles) { 33 | result.add(role.getName()); 34 | } 35 | return result; 36 | } 37 | 38 | @Override //查出管理员相应的角色 39 | public List listRoles(String userName) { 40 | List roles = new ArrayList<>(); 41 | //通过name获得user实体 42 | User user = userService.getByName(userName); 43 | if(null==user) 44 | return roles; 45 | roles = listRoles(user);//调用下面的方法 46 | return roles; 47 | } 48 | 49 | @Override //查出管理员相应的角色 50 | public List listRoles(User user) { 51 | List roles = new ArrayList<>(); 52 | //通过管理员id获取管理员的角色 53 | UserRoleExample example = new UserRoleExample(); 54 | example.createCriteria().andUidEqualTo(user.getId()); 55 | List userRoles = userRoleMapper.selectByExample(example);//关联查询 查出用户id对应的角色id的记录 56 | 57 | //通过关联查询 ,查出表Role的给出指定主键id的记录 58 | for (UserRole userRole : userRoles){ 59 | Role role = roleMapper.selectByPrimaryKey(userRole.getRid()); 60 | roles.add(role); 61 | } 62 | return roles; 63 | } 64 | 65 | @Override 66 | public List list() { 67 | RoleExample example =new RoleExample(); 68 | example.setOrderByClause("id desc"); 69 | return roleMapper.selectByExample(example); 70 | } 71 | 72 | @Override 73 | public void add(Role role) { 74 | roleMapper.insert(role); 75 | } 76 | 77 | @Override 78 | public void delete(Long id) { 79 | roleMapper.deleteByPrimaryKey(id); 80 | } 81 | 82 | @Override 83 | public Role get(Long id) { 84 | return roleMapper.selectByPrimaryKey(id); 85 | } 86 | 87 | @Override 88 | public void update(Role role) { 89 | roleMapper.updateByPrimaryKeySelective(role); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/impl/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service.impl; 2 | 3 | import com.byh.biyesheji.dao.OrderMapper; 4 | import com.byh.biyesheji.pojo.Customer; 5 | import com.byh.biyesheji.pojo.Order; 6 | import com.byh.biyesheji.pojo.OrderExample; 7 | import com.byh.biyesheji.pojo.OrderItem; 8 | import com.byh.biyesheji.service.CustomerService; 9 | import com.byh.biyesheji.service.OrderItemService; 10 | import com.byh.biyesheji.service.OrderService; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Service; 13 | import org.springframework.transaction.annotation.Propagation; 14 | import org.springframework.transaction.annotation.Transactional; 15 | 16 | import java.util.List; 17 | 18 | @Service 19 | public class OrderServiceImpl implements OrderService { 20 | @Autowired 21 | OrderMapper orderMapper; 22 | @Autowired 23 | CustomerService customerService; 24 | @Autowired 25 | OrderItemService orderItemService; 26 | 27 | @Override 28 | public void save(Order c) { 29 | orderMapper.insert(c); 30 | } 31 | 32 | @Override 33 | public void del(int id) { 34 | orderMapper.deleteByPrimaryKey(id); 35 | } 36 | 37 | @Override 38 | public void update(Order c) { 39 | orderMapper.updateByPrimaryKeySelective(c); 40 | } 41 | 42 | @Override 43 | public Order get(int id) { 44 | return orderMapper.selectByPrimaryKey(id); 45 | } 46 | 47 | public List list(){ 48 | OrderExample example =new OrderExample(); 49 | example.setOrderByClause("id desc"); 50 | List result =orderMapper.selectByExample(example); 51 | setCust(result); 52 | return result; 53 | } 54 | //给每个订单设置客户 55 | public void setCust(List os){ 56 | for (Order o : os) 57 | setCust(o); 58 | } 59 | //给客户实体设置客户 60 | public void setCust(Order o){ 61 | int cstid = o.getCstid(); 62 | Customer customer = customerService.get(cstid); 63 | o.setCustomer(customer); 64 | } 65 | 66 | @Transactional(propagation= Propagation.REQUIRED,rollbackForClassName="Exception") 67 | @Override 68 | public float add(Order o, List ois) { 69 | float total = 0; 70 | save(o);//新增订单数据 71 | 72 | if(false) 73 | throw new RuntimeException(); //用来模拟当增加订单后出现异常,观察事务管理是否预期发生。(需要把false修改为true才能观察到) 74 | 75 | for (OrderItem oi: ois) { 76 | oi.setOid(o.getId());//给订单项设置订单id 关联起来 77 | orderItemService.update(oi); 78 | total+=oi.getProduct().getPrice()*oi.getNumber();//商品的价格+当前订单项购买数量 79 | } 80 | return total; 81 | } 82 | 83 | @Override 84 | public List list(int cstid) { 85 | OrderExample example =new OrderExample(); 86 | example.createCriteria().andCstidEqualTo(cstid); 87 | example.setOrderByClause("id asc"); 88 | return orderMapper.selectByExample(example); 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/syspage/admin-add.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: baiyuhong 5 | Date: 2018/10/5 6 | Time: 18:46 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | <%@include file="../../include/publicMeta.jsp"%> 11 | 12 |
13 |
14 |
15 | 16 |
17 | 18 |
19 |
20 |
21 | 22 |
23 | 24 |
25 |
26 |
27 | 28 |
29 | 34 |
35 |
36 |
37 | 38 |
39 | 40 |
41 |
42 |
43 | 44 |
45 | 46 |
47 |
48 |
49 |
50 | 51 |
52 |
53 |
54 |
55 | <%@include file="../../include/publicFooter.jsp"%> 56 | 57 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/controller/RoleController.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.controller; 2 | 3 | import com.byh.biyesheji.pojo.Permission; 4 | import com.byh.biyesheji.pojo.Role; 5 | import com.byh.biyesheji.service.PermissionService; 6 | import com.byh.biyesheji.service.RolePermissionService; 7 | import com.byh.biyesheji.service.RoleService; 8 | import com.byh.biyesheji.util.Page; 9 | import com.github.pagehelper.PageHelper; 10 | import com.github.pagehelper.PageInfo; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.ui.Model; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | 16 | import java.util.HashMap; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | /** 21 | * 管理员角色controler 22 | */ 23 | @Controller 24 | @RequestMapping("/config") 25 | public class RoleController { 26 | @Autowired 27 | RoleService roleService; 28 | @Autowired 29 | RolePermissionService rolePermissionService; 30 | @Autowired 31 | PermissionService permissionService; 32 | 33 | @RequestMapping("/addRoleUI") 34 | public String addRole(){ 35 | 36 | return "syspage/admin-role-add"; 37 | } 38 | 39 | @RequestMapping("/listRole") 40 | public String list(Model model, Page page){ 41 | PageHelper.offsetPage(page.getStart(),page.getCount());//分页查询 42 | List rs= roleService.list(); 43 | int total = (int) new PageInfo<>(rs).getTotal();//总条数 44 | page.setTotal(total); 45 | 46 | model.addAttribute("rs", rs); 47 | 48 | model.addAttribute("roleSize",total); 49 | 50 | Map> role_permissions = new HashMap<>(); 51 | 52 | for (Role role : rs) { 53 | List ps = permissionService.list(role); 54 | role_permissions.put(role, ps); 55 | } 56 | model.addAttribute("role_permissions", role_permissions); 57 | 58 | return "syspage/admin-role"; 59 | } 60 | 61 | @RequestMapping("/editRole") 62 | public String list(Model model, long id){ 63 | Role role =roleService.get(id); 64 | model.addAttribute("role", role); 65 | //所有权限 66 | List ps = permissionService.list(); 67 | model.addAttribute("ps", ps); 68 | //当前管理员拥有的权限 69 | List currentPermissions = permissionService.list(role); 70 | model.addAttribute("currentPermissions", currentPermissions); 71 | 72 | return "syspage/admin-role-edit"; 73 | } 74 | 75 | @RequestMapping("/updateRole") 76 | public String update(Role role,long[] permissionIds){ 77 | rolePermissionService.setPermissions(role, permissionIds); 78 | roleService.update(role); 79 | return "redirect:listRole"; 80 | } 81 | 82 | @RequestMapping("/addRole") 83 | public String list(Model model, Role role){ 84 | roleService.add(role); 85 | return "redirect:listRole"; 86 | } 87 | 88 | @RequestMapping("/deleteRole") 89 | public String delete(Model model, long id){ 90 | roleService.delete(id); 91 | return "redirect:listRole"; 92 | } 93 | 94 | } -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/include/publicMenu.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/9/29 5 | Time: 15:32 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/syspage/admin-role-add.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/10/8 5 | Time: 15:31 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@include file="../../include/publicMeta.jsp"%> 10 | 11 |
12 |
13 |
14 | 15 |
16 | 17 |
18 |
19 |
20 | 21 |
22 | 23 |
24 |
25 |
26 |
27 | 28 |
29 |
30 |
31 |
32 | 33 | <%@include file="../../include/publicFooter.jsp"%> 34 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/pojo/Product.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.pojo; 2 | 3 | public class Product { 4 | private Integer id; 5 | 6 | private String name; 7 | 8 | private Float price; 9 | 10 | private Integer zan; 11 | 12 | private Integer number; 13 | 14 | private Integer status; 15 | 16 | private String imageurl; 17 | 18 | private String miaoshu; 19 | 20 | private Integer cid; 21 | 22 | private Long bid; 23 | 24 | private Category category; 25 | private User user; 26 | 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Integer id) { 32 | this.id = id; 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | public Float getPrice() { 44 | return price; 45 | } 46 | 47 | public void setPrice(Float price) { 48 | this.price = price; 49 | } 50 | 51 | public Integer getZan() { 52 | return zan; 53 | } 54 | 55 | public void setZan(Integer zan) { 56 | this.zan = zan; 57 | } 58 | 59 | public Integer getNumber() { 60 | return number; 61 | } 62 | 63 | public void setNumber(Integer number) { 64 | this.number = number; 65 | } 66 | 67 | public Integer getStatus() { 68 | return status; 69 | } 70 | 71 | public void setStatus(Integer status) { 72 | this.status = status; 73 | } 74 | 75 | public String getImageurl() { 76 | return imageurl; 77 | } 78 | 79 | public void setImageurl(String imageurl) { 80 | this.imageurl = imageurl; 81 | } 82 | 83 | public String getMiaoshu() { 84 | return miaoshu; 85 | } 86 | 87 | public void setMiaoshu(String miaoshu) { 88 | this.miaoshu = miaoshu; 89 | } 90 | 91 | public Integer getCid() { 92 | return cid; 93 | } 94 | 95 | public void setCid(Integer cid) { 96 | this.cid = cid; 97 | } 98 | 99 | public Long getBid() { 100 | return bid; 101 | } 102 | 103 | public void setBid(Long bid) { 104 | this.bid = bid; 105 | } 106 | 107 | public Category getCategory() { 108 | return category; 109 | } 110 | 111 | public void setCategory(Category category) { 112 | this.category = category; 113 | } 114 | 115 | public User getUser() { 116 | return user; 117 | } 118 | 119 | public void setUser(User user) { 120 | this.user = user; 121 | } 122 | 123 | @Override 124 | public String toString() { 125 | return "Product{" + 126 | "id=" + id + 127 | ", name='" + name + '\'' + 128 | ", price=" + price + 129 | ", zan=" + zan + 130 | ", number=" + number + 131 | ", status=" + status + 132 | ", imageurl='" + imageurl + '\'' + 133 | ", miaoshu='" + miaoshu + '\'' + 134 | ", cid=" + cid + 135 | ", bid=" + bid + 136 | ", category=" + category + 137 | ", user=" + user + 138 | '}'; 139 | } 140 | } -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/impl/OrderItemServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service.impl; 2 | 3 | import com.byh.biyesheji.dao.OrderItemMapper; 4 | import com.byh.biyesheji.pojo.Order; 5 | import com.byh.biyesheji.pojo.OrderItem; 6 | import com.byh.biyesheji.pojo.OrderItemExample; 7 | import com.byh.biyesheji.pojo.Product; 8 | import com.byh.biyesheji.service.OrderItemService; 9 | import com.byh.biyesheji.service.ProductService; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.util.List; 14 | 15 | @Service 16 | public class OrderItemServiceImpl implements OrderItemService { 17 | 18 | @Autowired 19 | OrderItemMapper orderItemMapper; 20 | @Autowired 21 | ProductService productService; 22 | 23 | @Override 24 | public void save(OrderItem c) { 25 | orderItemMapper.insert(c); 26 | } 27 | 28 | @Override 29 | public void del(int id) { 30 | orderItemMapper.deleteByPrimaryKey(id); 31 | } 32 | 33 | @Override 34 | public void update(OrderItem c) { 35 | orderItemMapper.updateByPrimaryKeySelective(c); 36 | } 37 | 38 | @Override 39 | public OrderItem get(int id) { 40 | OrderItem result = orderItemMapper.selectByPrimaryKey(id); 41 | setProduct(result); 42 | return result; 43 | } 44 | 45 | public List list(){ 46 | OrderItemExample example =new OrderItemExample(); 47 | example.setOrderByClause("id asc"); 48 | return orderItemMapper.selectByExample(example); 49 | 50 | } 51 | 52 | @Override 53 | public void fill(List os) { 54 | for (Order o :os){ 55 | fill(o); 56 | } 57 | } 58 | /* 59 | 1. 根据订单id查询出其对应的所有订单项 60 | 2. 通过setProduct为所有的订单项设置Product属性 61 | 3. 遍历所有的订单项,然后计算出该订单的总金额和总数量 62 | 4. 最后再把订单项设置在订单的orderItems属性上。 63 | */ 64 | @Override 65 | public void fill(Order o) { 66 | OrderItemExample example = new OrderItemExample(); 67 | example.createCriteria().andOidEqualTo(o.getId()); 68 | example.setOrderByClause("id asc"); 69 | List ois = orderItemMapper.selectByExample(example);//查出当前订单下的所有订单项 70 | setProduct(ois);//现在当前订单的每个订单项都有商品属性 71 | 72 | float total = 0;//该订单总金额 73 | int totalNumber = 0;//该订单总数 74 | for (OrderItem oi :ois){ 75 | total+=oi.getNumber()*oi.getProduct().getPrice();//数量 * 单价 76 | totalNumber+=oi.getNumber(); 77 | } 78 | o.setTotal(total); //设置总金额 79 | o.setTotalNumber(totalNumber); 80 | o.setOrderItems(ois); //当前订单的订单项 81 | 82 | } 83 | //给当前订单下每个订单项设置商品 84 | private void setProduct(List ois) { 85 | for (OrderItem oi: ois) { 86 | setProduct(oi); 87 | } 88 | } 89 | //给订单项设置商品 90 | private void setProduct(OrderItem oi) { 91 | Product p = productService.get(oi.getPid()); 92 | oi.setProduct(p); 93 | } 94 | 95 | @Override 96 | public List listByCustomer(int cstid) {//根据用户id查询orderitem表中oid为空的集合 97 | OrderItemExample example =new OrderItemExample(); 98 | example.createCriteria().andCstidEqualTo(cstid).andOidIsNull(); 99 | List result = orderItemMapper.selectByExample(example); 100 | setProduct(result); 101 | return result; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/resources/mapper/CategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | and ${criterion.condition} 17 | 18 | 19 | and ${criterion.condition} #{criterion.value} 20 | 21 | 22 | and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} 23 | 24 | 25 | and ${criterion.condition} 26 | 27 | #{listItem} 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | id, name 39 | 40 | 55 | 61 | 62 | delete from category 63 | where id = #{id,jdbcType=INTEGER} 64 | 65 | 66 | insert into category (name) 67 | values (#{name,jdbcType=VARCHAR}) 68 | 69 | 70 | insert into category 71 | 72 | 73 | name, 74 | 75 | 76 | 77 | 78 | #{name,jdbcType=VARCHAR}, 79 | 80 | 81 | 82 | 83 | update category 84 | 85 | 86 | name = #{name,jdbcType=VARCHAR}, 87 | 88 | 89 | where id = #{id,jdbcType=INTEGER} 90 | 91 | 92 | update category 93 | set name = #{name,jdbcType=VARCHAR} 94 | where id = #{id,jdbcType=INTEGER} 95 | 96 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/service/impl/ProductServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.service.impl; 2 | 3 | import com.byh.biyesheji.dao.ProductMapper; 4 | import com.byh.biyesheji.dao.UserMapper; 5 | import com.byh.biyesheji.pojo.*; 6 | import com.byh.biyesheji.service.CategoryService; 7 | import com.byh.biyesheji.service.ProductService; 8 | import com.byh.biyesheji.service.UserService; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.List; 13 | 14 | @Service 15 | public class ProductServiceImpl implements ProductService { 16 | 17 | @Autowired 18 | private ProductMapper productMapper; 19 | @Autowired 20 | private CategoryService categoryService; 21 | @Autowired 22 | private UserService userService; 23 | @Autowired 24 | private UserMapper userMapper; 25 | 26 | @Override 27 | public List list() { 28 | List products = productMapper.selectByExample(null);//获得商品列表 29 | for (Product p:products){ 30 | Category category = categoryService.get(p.getCid()); 31 | p.setCategory(category); 32 | User user = userService.get(p.getBid()); 33 | p.setUser(user); 34 | } 35 | return products; 36 | } 37 | 38 | @Override 39 | public String enableStatus(String name) { 40 | productMapper.enableStatus(name); 41 | return "success"; 42 | } 43 | 44 | @Override 45 | public String stopStatus(String name) { 46 | productMapper.stopStatus(name); 47 | return "success"; 48 | } 49 | 50 | @Override 51 | public void save(Product product) { 52 | product.setStatus(1); 53 | productMapper.insert(product); 54 | } 55 | 56 | @Override 57 | public void setImageURL(ProductVO vo) { 58 | productMapper.setImageUrl(vo); 59 | } 60 | 61 | @Override 62 | public Product get(int id) { 63 | return productMapper.selectByPrimaryKey(id); 64 | } 65 | 66 | @Override 67 | public void del(int id) { 68 | productMapper.deleteByPrimaryKey(id); 69 | } 70 | 71 | @Override 72 | public Category getCategoryByCid(int id) { 73 | Category category = categoryService.get(id); 74 | return category; 75 | } 76 | 77 | @Override 78 | public void update(Product product) { 79 | productMapper.updateByPrimaryKeySelective(product); 80 | } 81 | 82 | @Override 83 | public List getProductsByCid(Integer id) { 84 | ProductExample example = new ProductExample(); 85 | example.createCriteria().andCidEqualTo(id).andStatusEqualTo(1); 86 | return productMapper.selectByExample(example); 87 | } 88 | 89 | @Override 90 | public User getUserByBid(long id) { 91 | return userMapper.selectByPrimaryKey(id); 92 | } 93 | 94 | @Override 95 | public List findByName(String pName) { 96 | ProductExample example = new ProductExample(); 97 | example.createCriteria().andNameLike("%"+pName+"%"); 98 | List products = productMapper.selectByExample(example); 99 | return products; 100 | } 101 | 102 | @Override 103 | public List findByCid(int cid) { 104 | ProductExample example = new ProductExample(); 105 | example.createCriteria().andCidEqualTo(cid); 106 | List products = productMapper.selectByExample(example); 107 | return products; 108 | } 109 | 110 | @Override 111 | public boolean findProByCid(int cid) { 112 | ProductExample example = new ProductExample(); 113 | example.createCriteria().andCidEqualTo(cid); 114 | List products = productMapper.selectByExample(example); 115 | return products.size()>0&&products!=null?true:false; 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/syspage/admin-edit.jsp: -------------------------------------------------------------------------------- 1 | 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: baiyuhong 5 | Date: 2018/10/5 6 | Time: 18:46 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 11 | <%@include file="../../include/publicMeta.jsp"%> 12 | 13 |
14 |
15 |
16 | 17 |
18 | 19 |
20 |
21 |
22 | 23 |
24 | 25 |
26 |
27 |
28 | 29 |
30 | 31 |
32 |
33 |
34 | 35 |
36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | ${r.name}
44 |
45 |
46 | 47 |
48 |
49 | 50 |
51 | 52 |
53 |
54 |
55 | 56 |
57 | 58 |
59 |
60 | 61 |
62 |
63 | 64 |
65 |
66 |
67 |
68 | <%@include file="../../include/publicFooter.jsp"%> 69 | 70 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/productmodule/category-list.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/10/10 5 | Time: 15:26 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | <%@include file="../../include/publicMeta.jsp"%> 12 | <%@include file="../../include/publicHeader.jsp"%> 13 | <%@include file="../../include/publicMenu.jsp"%> 14 | 15 |
16 | 17 |
18 |
19 | 20 |
21 | 22 | 23 | 如果分类无法删除的话,是因为该分类下有商品 24 | 共有数据:${size}
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 45 | 46 | 47 | 48 |
分类列表
ID分类名称操作
${category.id}${category.name} 44 |
49 |
50 |
51 |
52 | 53 | <%@include file="../../include/publicFooter.jsp"%> 54 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/pinglunpage/pinglun.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: baiyuhong 5 | Date: 2018/10/4 6 | Time: 21:20 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | <%@include file="../../include/publicMeta.jsp"%> 12 | <%@include file="../../include/publicHeader.jsp"%> 13 | <%@include file="../../include/publicMenu.jsp"%> 14 | 15 |
16 | 21 |
22 |
23 |
24 | 共有数据:${totals} 25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 61 | 62 | 63 | 64 |
评论列表
ID用户名评论商品评论内容评论时间用户等级操作
${review.id}${review.customer.name}${review.product.name}${review.content}${review.createtime} 52 | 会员 53 | 普通用户 54 | 56 | 58 | 删除 59 | 60 |
65 |
66 |
67 | <%@include file="../adminPage.jsp"%> 68 |
69 |
70 |
71 | 72 | <%@include file="../../include/publicFooter.jsp"%> 73 | 74 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/forepage/foreRegister.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/11/19 5 | Time: 17:22 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | <%@ include file="../../foreinclude/foreHander.jsp"%> 11 | 12 | 15 | 16 | 36 | 37 | 38 | 39 | 42 | 43 |
44 |
45 | 46 |
47 |
48 |
49 |
50 | 51 | 77 | 78 |
79 |
80 |
81 |
82 |
83 | 84 | 85 | 86 | 98 | 99 | <%@ include file="../../foreinclude/foreFooter.jsp"%> 100 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/forepage/forelogin.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/11/19 5 | Time: 17:22 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | 10 | <%@ include file="../../foreinclude/foreHander.jsp"%> 11 | 12 | 15 | 16 | 36 | 37 | 38 | 39 | 42 | 43 |
44 |
45 | 46 |
47 |
48 | 49 | 50 |
51 |
52 | 53 |
54 | 55 | 79 | 80 |
81 |
82 | 83 |
84 |
85 |
86 | 87 | 88 | 89 | 107 | 108 | <%@ include file="../../foreinclude/foreFooter.jsp"%> 109 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/syspage/admin-permission.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: baiyuhong 5 | Date: 2018/10/8 6 | Time: 17:20 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | <%@include file="../../include/publicMeta.jsp"%> 12 | <%@include file="../../include/publicHeader.jsp"%> 13 | <%@include file="../../include/publicMenu.jsp"%> 14 | 15 |
16 | 17 |
18 |
19 |
20 | 21 | 22 | 添加权限节点 23 | 24 | 25 | 共有数据:${perCount}
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 50 | 51 | 52 | 53 |
权限节点
ID权限名称描述路径操作
${permission.id}${permission.name}${permission.desc_}${permission.url} 49 |
54 |
55 |
56 | <%@include file="../adminPage.jsp"%> 57 |
58 |
59 |
60 | 61 | <%@include file="../../include/publicFooter.jsp"%> 62 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /src/main/resources/mapper/RoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | and ${criterion.condition} 18 | 19 | 20 | and ${criterion.condition} #{criterion.value} 21 | 22 | 23 | and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} 24 | 25 | 26 | and ${criterion.condition} 27 | 28 | #{listItem} 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | id, name, desc_ 40 | 41 | 56 | 62 | 63 | delete from role 64 | where id = #{id,jdbcType=BIGINT} 65 | 66 | 67 | insert into role (name, desc_) 68 | values (#{name,jdbcType=VARCHAR}, #{desc_,jdbcType=VARCHAR}) 69 | 70 | 71 | insert into role 72 | 73 | 74 | name, 75 | 76 | 77 | desc_, 78 | 79 | 80 | 81 | 82 | #{name,jdbcType=VARCHAR}, 83 | 84 | 85 | #{desc_,jdbcType=VARCHAR}, 86 | 87 | 88 | 89 | 90 | update role 91 | 92 | 93 | name = #{name,jdbcType=VARCHAR}, 94 | 95 | 96 | desc_ = #{desc_,jdbcType=VARCHAR}, 97 | 98 | 99 | where id = #{id,jdbcType=BIGINT} 100 | 101 | 102 | update role 103 | set name = #{name,jdbcType=VARCHAR}, 104 | desc_ = #{desc_,jdbcType=VARCHAR} 105 | where id = #{id,jdbcType=BIGINT} 106 | 107 | -------------------------------------------------------------------------------- /src/main/resources/mapper/UserRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | and ${criterion.condition} 18 | 19 | 20 | and ${criterion.condition} #{criterion.value} 21 | 22 | 23 | and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} 24 | 25 | 26 | and ${criterion.condition} 27 | 28 | #{listItem} 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | id, uid, rid 40 | 41 | 56 | 62 | 63 | delete from user_role 64 | where id = #{id,jdbcType=BIGINT} 65 | 66 | 67 | insert into user_role (uid, rid) 68 | values (#{uid,jdbcType=BIGINT}, #{rid,jdbcType=BIGINT}) 69 | 70 | 71 | insert into user_role 72 | 73 | 74 | uid, 75 | 76 | 77 | rid, 78 | 79 | 80 | 81 | 82 | #{uid,jdbcType=BIGINT}, 83 | 84 | 85 | #{rid,jdbcType=BIGINT}, 86 | 87 | 88 | 89 | 90 | update user_role 91 | 92 | 93 | uid = #{uid,jdbcType=BIGINT}, 94 | 95 | 96 | rid = #{rid,jdbcType=BIGINT}, 97 | 98 | 99 | where id = #{id,jdbcType=BIGINT} 100 | 101 | 102 | update user_role 103 | set uid = #{uid,jdbcType=BIGINT}, 104 | rid = #{rid,jdbcType=BIGINT} 105 | where id = #{id,jdbcType=BIGINT} 106 | 107 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/productmodule/product-add.jsp: -------------------------------------------------------------------------------- 1 | <%-- 2 | Created by IntelliJ IDEA. 3 | User: baiyuhong 4 | Date: 2018/10/12 5 | Time: 10:18 6 | To change this template use File | Settings | File Templates. 7 | --%> 8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 10 | 11 | <%@include file="../../include/publicMeta.jsp"%> 12 | 13 |
14 |
15 |
16 | 17 |
18 | 19 |
20 |
21 |
22 | 23 |
24 | 25 |
26 |
27 |
28 | 29 |
30 | 31 |
32 |
33 |
34 | 35 |
36 | 37 |
38 |
39 |
40 | 41 |
42 | 43 |
44 |
45 | 46 |
47 | 48 |
49 | 50 |
51 |
52 |
53 | 54 |
55 | 60 | 61 |
62 |
63 | 64 |
65 | 66 |
67 | 72 | 73 |
74 |
75 | 76 |
77 |
78 | 79 |
80 |
81 |
82 |
83 | <%@include file="../../include/publicFooter.jsp"%> 84 | 85 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/ordermodule/order-list.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: baiyuhong 5 | Date: 2018/10/4 6 | Time: 21:20 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | <%@include file="../../include/publicMeta.jsp"%> 12 | <%@include file="../../include/publicHeader.jsp"%> 13 | <%@include file="../../include/publicMenu.jsp"%> 14 | 15 |
16 | 21 |
22 |
23 |
24 | 共有数据:${totals} 25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 61 | 77 | 78 | 79 | 80 |
台后订单列表
ID地址买家总价状态操作
${order.id}${order.address}${order.customer.name}${order.total} 48 | 49 | 未支付 50 | 51 | 52 | 未发货 53 | 54 | 55 | 已发货 56 | 57 | 58 | 已收货 59 | 60 | 62 | 65 | 查看详情 66 | 67 | 68 | 70 | 发货 71 | 72 | 73 | 74 | 已发货 75 | 76 |
81 |
82 |
83 | <%@include file="../adminPage.jsp"%> 84 |
85 |
86 |
87 | 88 | <%@include file="../../include/publicFooter.jsp"%> 89 | 90 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /src/main/resources/mapper/RolePermissionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | and ${criterion.condition} 18 | 19 | 20 | and ${criterion.condition} #{criterion.value} 21 | 22 | 23 | and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} 24 | 25 | 26 | and ${criterion.condition} 27 | 28 | #{listItem} 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | id, rid, pid 40 | 41 | 56 | 62 | 63 | delete from role_permission 64 | where id = #{id,jdbcType=BIGINT} 65 | 66 | 67 | insert into role_permission (rid, pid) 68 | values (#{rid,jdbcType=BIGINT}, #{pid,jdbcType=BIGINT}) 69 | 70 | 71 | insert into role_permission 72 | 73 | 74 | rid, 75 | 76 | 77 | pid, 78 | 79 | 80 | 81 | 82 | #{rid,jdbcType=BIGINT}, 83 | 84 | 85 | #{pid,jdbcType=BIGINT}, 86 | 87 | 88 | 89 | 90 | update role_permission 91 | 92 | 93 | rid = #{rid,jdbcType=BIGINT}, 94 | 95 | 96 | pid = #{pid,jdbcType=BIGINT}, 97 | 98 | 99 | where id = #{id,jdbcType=BIGINT} 100 | 101 | 102 | update role_permission 103 | set rid = #{rid,jdbcType=BIGINT}, 104 | pid = #{pid,jdbcType=BIGINT} 105 | where id = #{id,jdbcType=BIGINT} 106 | 107 | -------------------------------------------------------------------------------- /src/main/java/com/byh/biyesheji/Interceptor/LoginInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.byh.biyesheji.Interceptor; 2 | 3 | import com.byh.biyesheji.pojo.Customer; 4 | import com.byh.biyesheji.service.OrderItemService; 5 | import org.apache.commons.lang.StringUtils; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.servlet.ModelAndView; 8 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import javax.servlet.http.HttpSession; 13 | import java.util.Arrays; 14 | 15 | /** 16 | * 前台登陆状态拦截器 如果访问的请求没有在noNeedAuthPage数组就跳转登陆 17 | */ 18 | public class LoginInterceptor extends HandlerInterceptorAdapter { 19 | @Autowired 20 | OrderItemService orderItemService; 21 | /** 22 | * 在业务处理器处理请求之前被调用 23 | * 如果返回false 24 | * 从当前的拦截器往回执行所有拦截器的afterCompletion(),再退出拦截器链 25 | * 如果返回true 26 | * 执行下一个拦截器,直到所有的拦截器都执行完毕 27 | * 再执行被拦截的Controller 28 | * 然后进入拦截器链, 29 | * 从最后一个拦截器往回执行所有的postHandle() 30 | * 接着再从最后一个拦截器往回执行所有的afterCompletion() 31 | */ 32 | @Override 33 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 34 | /** 35 | * 不需要登录也可以访问的 36 | * 注册,登录,产品,首页,分类,查询等等 37 | * 需要登录才能够访问的 38 | * 购买行为,加入购物车行为,查看购物车,查看我的订单等等 39 | * 不需要登录也可以访问的已经确定了,但是需要登录才能够访问,截止目前为止还不能确定,所以这个过滤器就判断如果不是注册,登录,产品这些,就进行登录校验 40 | * 1. 准备字符串数组 noNeedAuthPage,存放哪些不需要登录也能访问的路径 41 | * 2. 获取uri 42 | * 3. 去掉前缀/fore 43 | * 4. 如果访问的地址是/fore开头 44 | * 4.1 取出fore后面的字符串,比如是forecart,那么就取出cart 45 | * 4.2 判断cart是否是在noNeedAuthPage 46 | * 4.2 如果不在,那么就需要进行是否登录验证 47 | * 4.3 从session中取出"cst"对象 48 | * 4.4 如果对象不存在,就客户端跳转到login.jsp 49 | * 4.5 否则就正常执行 50 | */ 51 | HttpSession session = request.getSession(); 52 | String contextPath=session.getServletContext().getContextPath()+"/fore"; 53 | //准备字符串数组 noNeedAuthPage,存放哪些不需要登录也能访问的路径 54 | String[] noNeedAuthPage = new String[]{ 55 | "Index", //首页 56 | "DetailUI", //商品详情页 57 | "RegisterUI", //注册页 58 | "Register", //注册 59 | "LoginUI", //登陆页 60 | "Login", //登陆 61 | "IsLogin", //判断是否登陆 62 | "MtLogin", //模态登陆验证 63 | "CstLoginOut", //退出 64 | "DelOrderItem",//删除购物车项 65 | "CreateOrder", //提交订单 66 | "Payed", //支付成功 67 | "NameLike", //模糊搜索商品 68 | "FindCategory", //查看分类下的商品 69 | "Zixunadd", //添加资讯 70 | "LoginMsg", //登陆返回信息 71 | }; 72 | //获取uri 73 | String uri = request.getRequestURI(); //访问首页 /fore/foreIndex 74 | //去掉前缀/fore 75 | uri = uri.substring(5,uri.length()); //去掉前缀后 /foreIndex 76 | //如果访问的地址是/fore开头 77 | if(uri.startsWith("/fore")){ 78 | //判断是否是在noNeedAuthPage 79 | String method = StringUtils.substringAfterLast(uri,"/fore" ); // 取出/fore后的字符串:Index 80 | //如果不在,那么就需要进行是否登录验证 81 | if(!Arrays.asList(noNeedAuthPage).contains(method)){ 82 | Customer customer =(Customer) session.getAttribute("cst"); 83 | if(null==customer){ 84 | response.sendRedirect("foreLoginUI"); 85 | return false; 86 | } 87 | } 88 | } 89 | 90 | return true; 91 | 92 | } 93 | 94 | /** 95 | * 在业务处理器处理请求执行完成后,生成视图之前执行的动作 96 | * 可在modelAndView中加入数据,比如当前时间 97 | */ 98 | @Override 99 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { 100 | // super.postHandle(request, response, handler, modelAndView); 101 | } 102 | 103 | /** 104 | * 在DispatcherServlet完全处理完请求后被调用,可用于清理资源等 105 | * 106 | * 当有拦截器抛出异常时,会从当前拦截器往回执行所有的拦截器的afterCompletion() 107 | */ 108 | @Override 109 | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { 110 | // super.afterCompletion(request, response, handler, ex); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/syspage/admin-role.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: baiyuhong 5 | Date: 2018/10/6 6 | Time: 21:25 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | <%@include file="../../include/publicMeta.jsp"%> 11 | <%@include file="../../include/publicHeader.jsp"%> 12 | <%@include file="../../include/publicMenu.jsp"%> 13 | 14 | 15 |
16 | 17 |
18 |
19 |
20 | 21 | 22 | 添加角色 23 | 24 | 25 | 共有数据:${roleSize} 26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 54 | 62 | 63 | 64 | 65 |
角色管理
ID角色名角色描述权限操作
${role.id}${role.name}${role.desc_} 50 | 51 | ${permission.name} 52 | 53 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
66 |
67 |
68 |
69 | <%@include file="../adminPage.jsp"%> 70 |
71 |
72 |
73 | 74 | <%@include file="../../include/publicFooter.jsp"%> 75 | 101 | 102 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/cstpage/zixun-list.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: baiyuhong 5 | Date: 2018/10/4 6 | Time: 21:20 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | <%@include file="../../include/publicMeta.jsp"%> 12 | <%@include file="../../include/publicHeader.jsp"%> 13 | <%@include file="../../include/publicMenu.jsp"%> 14 | 15 |
16 | 21 |
22 |
23 |
24 | 共有数据:${totals} 25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 56 | 72 | 73 | 74 | 75 |
台后资讯列表
ID发布者发布内容发布时间审核状态操作
${z.id}${z.cstid}${z.content}${z.fabudate} 48 | 49 | 未审核 50 | 51 | 52 | 已审核 53 | 54 | 55 | 57 | 58 | 61 | 通过 62 | 63 | 64 | 65 | 已通过 66 | 67 | 69 | 删除 70 | 71 |
76 |
77 |
78 | <%@include file="../adminPage.jsp"%> 79 |
80 |
81 |
82 | 83 | <%@include file="../../include/publicFooter.jsp"%> 84 | 85 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /src/main/resources/mapper/PermissionMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | and ${criterion.condition} 19 | 20 | 21 | and ${criterion.condition} #{criterion.value} 22 | 23 | 24 | and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} 25 | 26 | 27 | and ${criterion.condition} 28 | 29 | #{listItem} 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | id, name, desc_, url 41 | 42 | 57 | 63 | 64 | delete from permission 65 | where id = #{id,jdbcType=BIGINT} 66 | 67 | 68 | insert into permission (name, desc_, url 69 | ) 70 | values (#{name,jdbcType=VARCHAR}, #{desc_,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR} 71 | ) 72 | 73 | 74 | insert into permission 75 | 76 | 77 | name, 78 | 79 | 80 | desc_, 81 | 82 | 83 | url, 84 | 85 | 86 | 87 | 88 | #{name,jdbcType=VARCHAR}, 89 | 90 | 91 | #{desc_,jdbcType=VARCHAR}, 92 | 93 | 94 | #{url,jdbcType=VARCHAR}, 95 | 96 | 97 | 98 | 99 | update permission 100 | 101 | 102 | name = #{name,jdbcType=VARCHAR}, 103 | 104 | 105 | desc_ = #{desc_,jdbcType=VARCHAR}, 106 | 107 | 108 | url = #{url,jdbcType=VARCHAR}, 109 | 110 | 111 | where id = #{id,jdbcType=BIGINT} 112 | 113 | 114 | update permission 115 | set name = #{name,jdbcType=VARCHAR}, 116 | desc_ = #{desc_,jdbcType=VARCHAR}, 117 | url = #{url,jdbcType=VARCHAR} 118 | where id = #{id,jdbcType=BIGINT} 119 | 120 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/syspage/admin-role-edit.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: baiyuhong 5 | Date: 2018/10/8 6 | Time: 15:40 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | <%@include file="../../include/publicMeta.jsp"%> 11 | 12 |
13 |
14 |
15 | 16 | 17 |
18 | 19 |
20 |
21 |
22 | 23 |
24 | 25 |
26 |
27 |
28 | 29 |
30 |
31 |
32 |
33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 44 |
45 |
46 |
47 | 48 |
49 |
50 |
51 |
52 | 53 |
54 |
55 |
56 |
57 | 58 | <%@include file="../../include/publicFooter.jsp"%> 59 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/page/cstpage/cst-list.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%-- 3 | Created by IntelliJ IDEA. 4 | User: baiyuhong 5 | Date: 2018/10/4 6 | Time: 21:20 7 | To change this template use File | Settings | File Templates. 8 | --%> 9 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> 10 | 11 | <%@include file="../../include/publicMeta.jsp"%> 12 | <%@include file="../../include/publicHeader.jsp"%> 13 | <%@include file="../../include/publicMenu.jsp"%> 14 | 15 |
16 | 21 |
22 |
23 |
24 | 共有数据:${totals} 25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 66 | 67 | 68 | 69 |
台后订单列表
ID用户名密码地址手机用户等级操作
${cst.id}${cst.name}${cst.password}${cst.address}${cst.phone} 52 | 会员 53 | 普通用户 54 | 56 | 59 | 设为会员 60 | 61 | 63 | 删除 64 | 65 |
70 |
71 |
72 | <%@include file="../adminPage.jsp"%> 73 |
74 |
75 |
76 | 77 | <%@include file="../../include/publicFooter.jsp"%> 78 | 79 | 123 | 124 | 125 | 126 | --------------------------------------------------------------------------------