基于SSM的网上商城(中)

上一篇已经大致介绍了该项目的结构以及后台部分的管理和界面
具体链接如下:
基于SSM的网上商城(上)
代码链接

这篇来讲讲前台管理和界面的一些内容:

一:前台的展示界面:

1.common公共界面
(1).common/header.jsp头部的界面
头部
(2).common/error.jsp错误404界面
(3).common/footer.jsp底部界面
底部界面
(4).common/user_menu.jsp用户使用管理界面
管理界面

2.index主界面
(1).index/login.jsp登陆界面
登陆界面
(2).index/index.jsp显示的主界面
主界面
(3).index/register.jsp注册信息界面
注册界面
3.user用户信息界面
(1).user/info.jsp用户基本信息界面
用户基本信息
(2).user/update_pwd.jsp修改用户密码界面
修改密码
4.product产品信息界面
(1).product/detail.jsp商品详情界面
商品详情界面
(2).product/list.jsp侧边栏推荐商品
侧边栏推荐商品
(3).product/search.jsp搜索商品界面
搜索商品界面
5.order评论界面
(1).order/list.jsp评论界面
评论主界面
(2).order/list.jsp订单列表界面
订单列表界面
6.favorite收藏界面
(1).favorite/list.jsp收藏列表界面
收藏界面
7.commont评价列表
(1).commont/list.jsp评价列表界面
我的评价列表
8.cart购物车界面
(1).cart/list.jsp空购物车界面
空购物车界面
(2).cart/list_2.jsp有内容购物车界面
有内容的界面
(3).cart/order_success.jsp下单成功界面
下单成功界面
9.address管理收货地址
(1).address/list.jsp管理收货地址界面
管理收货界面

二:前台的控制器:

1.AddressController前台收获地址控制器

@RequestMapping("/address")
@Controller
public class AddressController {
	@Autowired
	private AccountService accountService;
	@Autowired
	private ProductCategoryService productCategoryService;
	@Autowired
	private ProductService productService;
	@Autowired
	private AddressService addressService;

2.CartController前台购物车控制器

@RequestMapping("/cart")
@Controller
public class CartController {
	@Autowired
	private AccountService accountService;
	@Autowired
	private ProductCategoryService productCategoryService;
	@Autowired
	private ProductService productService;
	@Autowired
	private CartService cartService;
	@Autowired
	private AddressService addressService;

3.FavoriteController前台收藏控制器

@RequestMapping("/favorite")
@Controller
public class FavoriteController {
	@Autowired
	private AccountService accountService;
	@Autowired
	private ProductCategoryService productCategoryService;
	@Autowired
	private ProductService productService;
	@Autowired
	private FavoriteService favoriteService;

4.HomeCommenController前台评价控制器

@RequestMapping("/comment")
@Controller
public class HomeCommentController {
	@Autowired
	private AccountService accountService;
	@Autowired
	private ProductCategoryService productCategoryService;
	@Autowired
	private ProductService productService;
	@Autowired
	private CommentService commentService;

5.HomeOrderController前台订单控制器

@RequestMapping("/order")
@Controller
public class HomeOrderController {
	@Autowired
	private AccountService accountService;
	@Autowired
	private ProductCategoryService productCategoryService;
	@Autowired
	private ProductService productService;
	@Autowired
	private OrderService orderService;
	@Autowired
	private CartService cartService;
	@Autowired
	private AddressService addressService;

6.HomeProductController前台商品控制器

@RequestMapping("/product")
@Controller
public class HomeProductController {
	@Autowired
	private AccountService accountService;
	@Autowired
	private ProductCategoryService productCategoryService;
	@Autowired
	private ProductService productService;
	@Autowired
	private CommentService commentService;

7.HomeUserController前台用户中心控制器

@RequestMapping("/user")
@Controller
public class HomeUserController {
	@Autowired
	private AccountService accountService;
	@Autowired
	private ProductCategoryService productCategoryService;
	@Autowired
	private ProductService productService;
	@Autowired
	private OrderService orderService;
	@Autowired
	private CartService cartService;
	@Autowired
	private AddressService addressService;

8.IndexController前台首页控制器

@RequestMapping("/home")
@Controller
public class IndexController {
	@Autowired
	private AccountService accountService;
	@Autowired
	private ProductCategoryService productCategoryService;
	@Autowired
	private ProductService productService;

三:前台的dao层:

1.addressDao收货地址dao层
收货
2.CartDao购物车dao层
购物车
3.FavoriteDao收藏dao层
收藏

四:前台的实体entity:

1.Address收货地址实体

@Component
public class Address {
	private Long id;//id
	private Long userId;//用户id
	private String name;//收货人姓名
	private String address;//详细地址
	private String phone;//手机号码
	private Date createTime;//添加时间

2.Cart购物车实体

@Component
public class Cart {
	private Long id;//id
	private Long productId;//商品id
	private Long userId;//用户id
	private String name;//商品名称
	private String imageUrl;//商品主图
	private Double price;//商品价格
	private int num;//商品数量
	private Double money;//商品价格
	private Date createTime;//添加时间

3.Favorite收藏实体

@Component
public class Favorite {
	private Long id;//id
	private Long productId;//商品id
	private Long userId;//用户id
	private String name;//商品名称
	private String imageUrl;//商品主图
	private Double price;//商品价格
	private Date createTime;//添加时间

五:前台的interceptor拦截器:

LoginInterceptor拦截器

/**
 * 前台登录拦截器
 * @author llq
 *
 */
public class LoginInterceptor implements HandlerInterceptor {
	@Override
	public void afterCompletion(HttpServletRequest arg0,
			HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {
		// TODO Auto-generated method stub
	}
	@Override
	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1,
			Object arg2, ModelAndView arg3) throws Exception {
		// TODO Auto-generated method stub
	}
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
			Object arg2) throws Exception {
		// TODO Auto-generated method stub
		String requestURI = request.getRequestURI();
		Object account = request.getSession().getAttribute("account");
		if(account == null){
			//表示未登录或者登录失效
			System.out.println("链接"+requestURI+"进入拦截器!");
			String header = request.getHeader("X-Requested-With");
			//判断是否是ajax请求
			if("XMLHttpRequest".equals(header)){
				//表示是ajax请求
				Map<String, String> ret = new HashMap<String, String>();
				ret.put("type", "error");
				ret.put("msg", "登录会话超时或还未登录,请重新登录!");
				response.getWriter().write(JSONObject.fromObject(ret).toString());
				return false;
			}
			//表示是普通链接跳转,直接重定向到登录页面
			response.sendRedirect(request.getServletContext().getContextPath() + "/home/login");
			return false;
		}
		return true;
	}
}

六:前台的service以及serviceImpl:

收货地址接口AddressService
Service接口
AddressServiceimpl实现类
实现
Service方法同上面的dao层方法
ServiceImpl实现方法类似上面,这里不再赘述!!

七:前台的mapper映射文件:

1.AddressMapper.xml收货映射文件
收货
2.CartMapper.xml购物车映射文件
购物车
3.FavoriteMapper.xml收藏映射文件
收藏

至此,前台的界面和管理系统的大致已经介绍完毕!

下面会再写一篇该项目所用的一些知识点,想看上一篇的请点击这里!!

基于SSM的网上商城(上)

发布了36 篇原创文章 · 获赞 26 · 访问量 7587

猜你喜欢

转载自blog.csdn.net/weixin_43566977/article/details/103418309