Java 實(shí)戰(zhàn)項(xiàng)目之家居購物商城系統(tǒng)詳解流程
一、項(xiàng)目簡述
功能: Java Web精品項(xiàng)目源碼,家居商城分類展示,商品展示, 商品下單,購物車,個(gè)人中心,后臺管理,用戶管理,商品管理,分類管理等等。
二、項(xiàng)目運(yùn)行
環(huán)境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
項(xiàng)目技術(shù): Jdbc+ Servlert + html+ css + JavaScript + JQuery + Ajax + Fileupload






打開訂單列表頁面代碼:
@Controller
@RequestMapping("/order")
public class OrderController {
@Autowired
private OrderService orderService;
/**
* 打開訂單列表頁面
*
* @return
*/
@RequestMapping("/toList.html")
public String toOrderList() {
return "mall/order/list";
}
/**
* 查詢用戶訂單列表
*
* @param request
* @return
*/
@RequestMapping("/list.do")
@ResponseBody
public ResultBean<List<Order>> listData(HttpServletRequest request) {
List<Order> orders = orderService.findUserOrder(request);
return new ResultBean<>(orders);
}
/**
* 查詢訂單詳情
*
* @param orderId
* @return
*/
@RequestMapping("/getDetail.do")
@ResponseBody
public ResultBean<List<OrderItem>> getDetail(int orderId) {
List<OrderItem> orderItems = orderService.findItems(orderId);
return new ResultBean<>(orderItems);
}
/**
* 提交訂單
*
* @param name
* @param phone
* @param addr
* @param request
* @param response
*/
@RequestMapping("/submit.do")
public void submit(String name,
String phone,
String addr,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
orderService.submit(name, phone, addr, request, response);
}
/**
* 支付方法
*
* @param orderId
*/
@RequestMapping("pay.do")
@ResponseBody
public ResultBean<Boolean> pay(int orderId, HttpServletResponse response) throws IOException {
orderService.pay(orderId);
return new ResultBean<>(true);
}
/**
* 確認(rèn)收貨
* @param orderId
* @param response
* @return
* @throws IOException
*/
@RequestMapping("receive.do")
@ResponseBody
public ResultBean<Boolean> receive(int orderId, HttpServletResponse response) throws IOException {
orderService.receive(orderId);
return new ResultBean<>(true);
}
}
商品信息操作代碼:
@Controller
@RequestMapping("/product")
public class ProductController {
@Autowired
private ProductService productService;
@Autowired
private ClassificationService classificationService;
@Autowired
private ShopCartService shopCartService;
/**
* 獲取商品信息
*
* @param id
* @return
*/
@RequestMapping("/get.do")
public ResultBean<Product> getProduct(int id) {
Product product = productService.findById(id);
return new ResultBean<>(product);
}
/**
* 打開商品詳情頁面
*
* @param id
* @param map
* @return
*/
@RequestMapping("/get.html")
public String toProductPage(int id, Map<String, Object> map) {
Product product = productService.findById(id);
map.put("product", product);
return "mall/product/info";
}
/**
* 查找熱門商品
*
* @return
*/
@ResponseBody
@RequestMapping("/hot.do")
public ResultBean<List<Product>> getHotProduct() {
List<Product> products = productService.findHotProduct();
return new ResultBean<>(products);
}
/**
* 查找最新商品
*
* @param pageNo
* @param pageSize
* @return
*/
@ResponseBody
@RequestMapping("/new.do")
public ResultBean<List<Product>> getNewProduct(int pageNo, int pageSize) {
Pageable pageable = new PageRequest(pageNo, pageSize);
List<Product> products = productService.findNewProduct(pageable);
return new ResultBean<>(products);
}
/**
* 打開分類查看商品頁面
*
* @return
*/
@RequestMapping("/category.html")
public String toCatePage(int cid, Map<String, Object> map) {
Classification classification = classificationService.findById(cid);
map.put("category", classification);
return "mall/product/category";
}
@RequestMapping("/toCart.html")
public String toCart(){
return "mall/product/cart";
}
/**
* 按一級分類查找商品
*
* @param cid
* @param pageNo
* @param pageSize
* @return
*/
@ResponseBody
@RequestMapping("/category.do")
public ResultBean<List<Product>> getCategoryProduct(int cid, int pageNo, int pageSize) {
Pageable pageable = new PageRequest(pageNo, pageSize);
List<Product> products = productService.findByCid(cid, pageable);
return new ResultBean<>(products);
}
/**
* 按二級分類查找商品
*
* @param csId
* @param pageNo
* @param pageSize
* @return
*/
@ResponseBody
@RequestMapping("/categorySec.do")
public ResultBean<List<Product>> getCategorySecProduct(int csId, int pageNo, int pageSize) {
Pageable pageable = new PageRequest(pageNo, pageSize);
List<Product> products = productService.findByCsid(csId, pageable);
return new ResultBean<>(products);
}
/**
* 根據(jù)一級分類查詢它所有的二級分類
* @param cid
* @return
*/
@ResponseBody
@RequestMapping("/getCategorySec.do")
public ResultBean<List<Classification>> getCategorySec(int cid){
List<Classification> list = classificationService.findByParentId(cid);
return new ResultBean<>(list);
}
/**
* 加購物車
*
* @param productId
* @param request
* @return
*/
@ResponseBody
@RequestMapping("/addCart.do")
public ResultBean<Boolean> addToCart(int productId, HttpServletRequest request) throws Exception {
shopCartService.addCart(productId, request);
return new ResultBean<>(true);
}
/**
* 移除購物車
*
* @param productId
* @param request
* @return
*/
@ResponseBody
@RequestMapping("/delCart.do")
public ResultBean<Boolean> delToCart(int productId, HttpServletRequest request) throws Exception {
shopCartService.remove(productId, request);
return new ResultBean<>(true);
}
/**
* 查看購物車商品
* @param request
* @return
*/
@ResponseBody
@RequestMapping("/listCart.do")
public ResultBean<List<OrderItem>> listCart(HttpServletRequest request) throws Exception {
List<OrderItem> orderItems = shopCartService.listCart(request);
return new ResultBean<>(orderItems);
}
}
以上就是Java 實(shí)戰(zhàn)項(xiàng)目之家居購物商城系統(tǒng)詳解流程的詳細(xì)內(nèi)容,更多關(guān)于Java 家居購物商城系統(tǒng)的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Java獲取年月日(格式:xxxx年xx月xx日)的方法詳解
在開發(fā)應(yīng)用程序時(shí),經(jīng)常需要獲取當(dāng)前的年、月、日,并以特定格式進(jìn)行展示或處理,本文將介紹如何獲取年月日,并將其格式化為“xxxx年xx月xx日”的形式,幫助你在應(yīng)用程序中處理日期信息,需要的朋友可以參考下2023-10-10
java:無法訪問org.springframework.boot.SpringApplication問題
這篇文章主要介紹了java:無法訪問org.springframework.boot.SpringApplication問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-08-08
Spring Cloud Eureka服務(wù)治理的實(shí)現(xiàn)
服務(wù)治理是微服務(wù)框架中最為核心和基礎(chǔ)的模塊,它主要是用來實(shí)現(xiàn)各個(gè)微服務(wù)實(shí)例的自動化注冊與發(fā)現(xiàn)。這篇文章主要介紹了Spring Cloud Eureka服務(wù)治理的實(shí)現(xiàn),感興趣的小伙伴們可以參考一下2018-06-06
Java實(shí)現(xiàn)向數(shù)組里添加元素
這篇文章主要介紹了Java實(shí)現(xiàn)向數(shù)組里添加元素方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-11
Maven打包所有依賴到一個(gè)可執(zhí)行jar中遇到的問題
這篇文章主要給大家介紹了關(guān)于Maven打包所有依賴到一個(gè)可執(zhí)行jar中遇到的問題,將依賴打入jar包,由于maven管理了所有的依賴,所以將項(xiàng)目的代碼和依賴打成一個(gè)包對它來說是順理成章的功能,需要的朋友可以參考下2023-10-10
mybatis-plus的SafetyEncryptProcessor安全加密處理示例解析
這篇文章主要為大家介紹了mybatis-plus的SafetyEncryptProcessor安全加密處理示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08

