src/action/cart/CartAction.java

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package action.cart;

import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.List;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;

import service.CartService;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

import entity.AllCartItem;
import entity.CartItem;
import entity.User;

public class CartAction extends ActionSupport
{
	private AllCartItem allCartItem; // 用户购物车
	private String goodsId;// 商品id
	private int quantity;// 商品数量
	private String singalCartId; // 加减操作时的单个购物项

	private List<String> cartId; // 实行批量删除的购物id

	@Autowired
	private CartService cartService;

	// 查询出用户所有购物
	public String cartItems() throws Exception
	{
		HttpSession session = ServletActionContext.getRequest().getSession();
		User user = (User) session.getAttribute("user");
		allCartItem = cartService.selectByUId(user.getUid());
		allCartItem.setUser(user);
		return Action.SUCCESS;
	}

	// 用户添加购物
	public String addCartItem() throws Exception
	{
		HttpSession session = ServletActionContext.getRequest().getSession();
		User user = (User) session.getAttribute("user");
		allCartItem = cartService.addCartItem(user.getUid(), quantity,goodsId );
		return Action.SUCCESS;
	}

	// 实现批量删除购物车项
	public String deleteCartItem() throws Exception
	{
		HttpSession session = ServletActionContext.getRequest().getSession();
		User user = (User) session.getAttribute("user");
		
		allCartItem = cartService.deleteCartItem(user.getUid(), cartId);
		return Action.SUCCESS;
后面还有 89 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。