最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Java 仿天貓服裝商城系統(tǒng)的實(shí)現(xiàn)流程

 更新時(shí)間:2021年11月23日 14:47:54   作者:qq_1334611189  
讀萬(wàn)卷書(shū)不如行萬(wàn)里路,只學(xué)書(shū)上的理論是遠(yuǎn)遠(yuǎn)不夠的,只有在實(shí)戰(zhàn)中才能獲得能力的提升,本篇文章手把手帶你用java+SSM+jsp+mysql+maven實(shí)現(xiàn)一個(gè)仿天貓服裝商城系統(tǒng),大家可以在過(guò)程中查缺補(bǔ)漏,提升水平

一、項(xiàng)目簡(jiǎn)述

功能:網(wǎng)上商城系統(tǒng),前臺(tái)+后臺(tái)管理,用戶注冊(cè),登錄, 上哦展示,分組展示,搜索,收貨地址管理,購(gòu)物車管 理,添加,購(gòu)買,個(gè)人信息修改。訂單查詢等等,后臺(tái)商 品管理,分類管理,庫(kù)存管理,訂單管理,用戶管理,信 息、修改等等。

二、項(xiàng)目運(yùn)行

環(huán)境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)

項(xiàng)目技術(shù): JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。

權(quán)限控制代碼:

 
/**
 * 產(chǎn)品詳情頁(yè)
 */
@Controller
public class ForeProductDetailsController extends BaseController {
    @Resource(name = "productService")
    private ProductService productService;
    @Resource(name = "userService")
    private UserService userService;
    @Resource(name = "productImageService")
    private ProductImageService productImageService;
    @Resource(name = "categoryService")
    private CategoryService categoryService;
    @Resource(name = "propertyValueService")
    private PropertyValueService propertyValueService;
    @Resource(name = "propertyService")
    private PropertyService propertyService;
    @Resource(name = "reviewService")
    private ReviewService reviewService;
    @Resource(name = "productOrderItemService")
    private ProductOrderItemService productOrderItemService;
 
    //轉(zhuǎn)到前臺(tái)天貓-產(chǎn)品詳情頁(yè)
    @RequestMapping(value = "product/{pid}", method = RequestMethod.GET)
    public String goToPage(HttpSession session, Map<String, Object> map,
                           @PathVariable("pid") String pid /*產(chǎn)品ID*/) {
        logger.info("檢查用戶是否登錄");
        Object userId = checkUser(session);
        if (userId != null) {
            logger.info("獲取用戶信息");
            User user = userService.get(Integer.parseInt(userId.toString()));
            map.put("user", user);
        }
        logger.info("獲取產(chǎn)品ID");
        Integer product_id = Integer.parseInt(pid);
        logger.info("獲取產(chǎn)品信息");
        Product product = productService.get(product_id);
        if (product == null || product.getProduct_isEnabled() == 1) {
            return "redirect:/404";
        }
        logger.info("獲取產(chǎn)品子信息-分類信息");
        product.setProduct_category(categoryService.get(product.getProduct_category().getCategory_id()));
        logger.info("獲取產(chǎn)品子信息-預(yù)覽圖片信息");
        List<ProductImage> singleProductImageList = productImageService.getList(product_id, (byte) 0, null);
        product.setSingleProductImageList(singleProductImageList);
        logger.info("獲取產(chǎn)品子信息-詳情圖片信息");
        List<ProductImage> detailsProductImageList = productImageService.getList(product_id, (byte) 1, null);
        product.setDetailProductImageList(detailsProductImageList);
        logger.info("獲取產(chǎn)品子信息-產(chǎn)品屬性值信息");
        List<PropertyValue> propertyValueList = propertyValueService.getList(new PropertyValue().setPropertyValue_product(product), null);
        logger.info("獲取產(chǎn)品子信息-分類信息對(duì)應(yīng)的屬性列表");
        List<Property> propertyList = propertyService.getList(new Property().setProperty_category(product.getProduct_category()), null);
        logger.info("屬性列表和屬性值列表合并");
        for (Property property : propertyList) {
            for (PropertyValue propertyValue : propertyValueList) {
                if (property.getProperty_id().equals(propertyValue.getPropertyValue_property().getProperty_id())) {
                    List<PropertyValue> property_value_item = new ArrayList<>(1);
                    property_value_item.add(propertyValue);
                    property.setPropertyValueList(property_value_item);
                    break;
                }
            }
        }
        logger.info("獲取產(chǎn)品子信息-產(chǎn)品評(píng)論信息");
        product.setReviewList(reviewService.getListByProductId(product_id, null));
        if (product.getReviewList() != null) {
            for (Review review : product.getReviewList()) {
                review.setReview_user(userService.get(review.getReview_user().getUser_id()));
            }
        }
 
        logger.info("獲取猜你喜歡列表");
        Integer category_id = product.getProduct_category().getCategory_id();
        Integer total = productService.getTotal(new Product().setProduct_category(new Category().setCategory_id(category_id)), new Byte[]{0, 2});
        logger.info("分類ID為{}的產(chǎn)品總數(shù)為{}條", category_id, total);
        //生成隨機(jī)數(shù)
        int i = new Random().nextInt(total);
        if (i + 2 >= total) {
            i = total - 3;
        }
        if (i < 0) {
            i = 0;
        }
        List<Product> loveProductList = productService.getList(new Product().setProduct_category(
                new Category().setCategory_id(category_id)),
                new Byte[]{0, 2},
                null,
                new PageUtil().setCount(3).setPageStart(i)
        );
        if (loveProductList != null) {
            logger.info("獲取產(chǎn)品列表的相應(yīng)的一張預(yù)覽圖片");
            for (Product loveProduct : loveProductList) {
                loveProduct.setSingleProductImageList(productImageService.getList(loveProduct.getProduct_id(), (byte) 0, new PageUtil(0, 1)));
            }
        }
        logger.info("獲取分類列表");
        List<Category> categoryList = categoryService.getList(null, new PageUtil(0, 3));
 
        map.put("loveProductList", loveProductList);
        map.put("categoryList", categoryList);
        map.put("propertyList", propertyList);
        map.put("product", product);
        map.put("guessNumber", i);
        map.put("pageUtil", new PageUtil(0, 10).setTotal(product.getProduct_review_count()));
        logger.info("轉(zhuǎn)到前臺(tái)-產(chǎn)品詳情頁(yè)");
        return "fore/productDetailsPage";
    }
 
    //按產(chǎn)品ID加載產(chǎn)品評(píng)論列表-ajax
    @Deprecated
    @ResponseBody
    @RequestMapping(value = "review/{pid}", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public String loadProductReviewList(@PathVariable("pid") String pid/*產(chǎn)品ID*/,
                                        @RequestParam Integer index/* 頁(yè)數(shù) */,
                                        @RequestParam Integer count/* 行數(shù) */) {
        logger.info("獲取產(chǎn)品ID");
        Integer product_id = Integer.parseInt(pid);
        logger.info("獲取產(chǎn)品評(píng)論列表");
        List<Review> reviewList = reviewService.getListByProductId(product_id, new PageUtil(index, count));
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("reviewList", JSONArray.parseArray(JSON.toJSONString(reviewList)));
 
        return jsonObject.toJSONString();
    }
 
    //按產(chǎn)品ID加載產(chǎn)品屬性列表-ajax
    @Deprecated
    @ResponseBody
    @RequestMapping(value = "property/{pid}", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public String loadProductPropertyList(@PathVariable("pid") String pid/*產(chǎn)品ID*/) {
        logger.info("獲取產(chǎn)品ID");
        Integer product_id = Integer.parseInt(pid);
 
        logger.info("獲取產(chǎn)品詳情-屬性值信息");
        Product product = new Product();
        product.setProduct_id(product_id);
        List<PropertyValue> propertyValueList = propertyValueService.getList(new PropertyValue().setPropertyValue_product(product), null);
 
        logger.info("獲取產(chǎn)品詳情-分類信息對(duì)應(yīng)的屬性列表");
        List<Property> propertyList = propertyService.getList(new Property().setProperty_category(product.getProduct_category()), null);
 
        logger.info("屬性列表和屬性值列表合并");
        for (Property property : propertyList) {
            for (PropertyValue propertyValue : propertyValueList) {
                if (property.getProperty_id().equals(propertyValue.getPropertyValue_property().getProperty_id())) {
                    List<PropertyValue> property_value_item = new ArrayList<>(1);
                    property_value_item.add(propertyValue);
                    property.setPropertyValueList(property_value_item);
                    break;
                }
            }
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("propertyList", JSONArray.parseArray(JSON.toJSONString(propertyList)));
 
        return jsonObject.toJSONString();
    }
 
    //加載猜你喜歡列表-ajax
    @ResponseBody
    @RequestMapping(value = "guess/{cid}", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public String guessYouLike(@PathVariable("cid") Integer cid, @RequestParam Integer guessNumber) {
        logger.info("獲取猜你喜歡列表");
        Integer total = productService.getTotal(new Product().setProduct_category(new Category().setCategory_id(cid)), new Byte[]{0, 2});
        logger.info("分類ID為{}的產(chǎn)品總數(shù)為{}條", cid, total);
        //生成隨機(jī)數(shù)
        int i = new Random().nextInt(total);
        if (i + 2 >= total) {
            i = total - 3;
        }
        if (i < 0) {
            i = 0;
        }
        while (i == guessNumber) {
            i = new Random().nextInt(total);
            if (i + 2 >= total) {
                i = total - 3;
            }
            if (i < 0) {
                i = 0;
                break;
            }
        }
 
        logger.info("guessNumber值為{},新guessNumber值為{}", guessNumber, i);
        List<Product> loveProductList = productService.getList(new Product().setProduct_category(
                new Category().setCategory_id(cid)),
                new Byte[]{0, 2},
                null,
                new PageUtil().setCount(3).setPageStart(i)
        );
        if (loveProductList != null) {
            logger.info("獲取產(chǎn)品列表的相應(yīng)的一張預(yù)覽圖片");
            for (Product loveProduct : loveProductList) {
                loveProduct.setSingleProductImageList(productImageService.getList(loveProduct.getProduct_id(), (byte) 0, new PageUtil(0, 1)));
            }
        }
 
        JSONObject jsonObject = new JSONObject();
        logger.info("獲取數(shù)據(jù)成功!");
        jsonObject.put("success", true);
        jsonObject.put("loveProductList", JSONArray.parseArray(JSON.toJSONString(loveProductList)));
        jsonObject.put("guessNumber", i);
        return jsonObject.toJSONString();
    }
}

用戶信息管理控制層:

/**
 * 用戶信息管理
 */
@Controller
public class ForeUserController extends BaseController{
    @Resource(name = "addressService")
    private AddressService addressService;
    @Resource(name="userService")
    private UserService userService;
 
    //轉(zhuǎn)到前臺(tái)天貓-用戶詳情頁(yè)
    @RequestMapping(value = "userDetails", method = RequestMethod.GET)
    public String goToUserDetail(HttpSession session, Map<String,Object> map){
        logger.info("檢查用戶是否登錄");
        Object userId = checkUser(session);
        if (userId != null) {
            logger.info("獲取用戶信息");
            User user = userService.get(Integer.parseInt(userId.toString()));
            map.put("user", user);
 
            logger.info("獲取用戶所在地區(qū)級(jí)地址");
            String districtAddressId = user.getUser_address().getAddress_areaId();
            Address districtAddress = addressService.get(districtAddressId);
            logger.info("獲取市級(jí)地址信息");
            Address cityAddress = addressService.get(districtAddress.getAddress_regionId().getAddress_areaId());
            logger.info("獲取其他地址信息");
            List<Address> addressList = addressService.getRoot();
            List<Address> cityList = addressService.getList(
                    null,cityAddress.getAddress_regionId().getAddress_areaId()
            );
            List<Address> districtList = addressService.getList(null,cityAddress.getAddress_areaId());
 
            map.put("addressList", addressList);
            map.put("cityList", cityList);
            map.put("districtList", districtList);
            map.put("addressId", cityAddress.getAddress_regionId().getAddress_areaId());
            map.put("cityAddressId", cityAddress.getAddress_areaId());
            map.put("districtAddressId", districtAddressId);
            return  "fore/userDetails";
        } else {
            return "redirect:/login";
        }
    }
    //前臺(tái)天貓-用戶更換頭像
    @ResponseBody
    @RequestMapping(value = "user/uploadUserHeadImage", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public  String uploadUserHeadImage(@RequestParam MultipartFile file, HttpSession session
    ){
        String originalFileName = file.getOriginalFilename();
        logger.info("獲取圖片原始文件名:{}", originalFileName);
        String extension = originalFileName.substring(originalFileName.lastIndexOf('.'));
        String fileName = UUID.randomUUID() + extension;
        String filePath = session.getServletContext().getRealPath("/") + "res/images/item/userProfilePicture/" + fileName;
        logger.info("文件上傳路徑:{}", filePath);
        JSONObject jsonObject = new JSONObject();
        try {
            logger.info("文件上傳中...");
            file.transferTo(new File(filePath));
            logger.info("文件上傳成功!");
            jsonObject.put("success", true);
            jsonObject.put("fileName", fileName);
        } catch (IOException e) {
            logger.warn("文件上傳失??!");
            e.printStackTrace();
            jsonObject.put("success", false);
        }
        return jsonObject.toJSONString();
    }
    //前臺(tái)天貓-用戶詳情更新
    @RequestMapping(value="user/update",method=RequestMethod.POST,produces ="application/json;charset=utf-8")
    public String userUpdate(HttpSession session, Map<String,Object> map,
                             @RequestParam(value = "user_nickname") String user_nickname  /*用戶昵稱 */,
                             @RequestParam(value = "user_realname") String user_realname  /*真實(shí)姓名*/,
                             @RequestParam(value = "user_gender") String user_gender  /*用戶性別*/,
                             @RequestParam(value = "user_birthday") String user_birthday /*用戶生日*/,
                             @RequestParam(value = "user_address") String user_address  /*用戶所在地 */,
                             @RequestParam(value = "user_profile_picture_src", required = false)
                                         String user_profile_picture_src /* 用戶頭像*/,
                             @RequestParam(value = "user_password") String user_password/* 用戶密碼 */
    ) throws ParseException, UnsupportedEncodingException {
        logger.info("檢查用戶是否登錄");
        Object userId = checkUser(session);
        if (userId != null) {
            logger.info("獲取用戶信息");
            User user = userService.get(Integer.parseInt(userId.toString()));
            map.put("user", user);
        } else {
            return "redirect:/login";
        }
        logger.info("創(chuàng)建用戶對(duì)象");
        if (user_profile_picture_src != null && "".equals(user_profile_picture_src)) {
            user_profile_picture_src = null;
        }
        User userUpdate = new User()
                .setUser_id(Integer.parseInt(userId.toString()))
                .setUser_nickname(user_nickname)
                .setUser_realname(user_realname)
                .setUser_gender(Byte.valueOf(user_gender))
                .setUser_birthday(new SimpleDateFormat("yyyy-MM-dd").parse(user_birthday))
                .setUser_address(new Address().setAddress_areaId(user_address))
                .setUser_profile_picture_src(user_profile_picture_src)
                .setUser_password(user_password);
        logger.info("執(zhí)行修改");
        if (userService.update(userUpdate)){
             logger.info("修改成功!跳轉(zhuǎn)到用戶詳情頁(yè)面");
             return "redirect:/userDetails";
         }
         throw new RuntimeException();
    }
}

地址信息管理控制層:

/**
 * 地址信息管理
 */
@RestController
public class ForeAddressController extends BaseController {
    @Resource(name = "addressService")
    private AddressService addressService;
 
    //根據(jù)address_areaId獲取地址信息-ajax
    @RequestMapping(value = "address/{areaId}", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    protected String getAddressByAreaId(@PathVariable String areaId) {
        JSONObject object = new JSONObject();
        logger.info("獲取AreaId為{}的地址信息");
        List<Address> addressList = addressService.getList(null, areaId);
        if (addressList == null || addressList.size() <= 0) {
            object.put("success", false);
            return object.toJSONString();
        }
        logger.info("獲取該地址可能的子地址信息");
        List<Address> childAddressList = addressService.getList(null, addressList.get(0).getAddress_areaId());
        object.put("success", true);
        object.put("addressList", addressList);
        object.put("childAddressList", childAddressList);
        return object.toJSONString();
    }
}

到此這篇關(guān)于Java 仿天貓服裝商城系統(tǒng)的實(shí)現(xiàn)流程的文章就介紹到這了,更多相關(guān)Java 商城系統(tǒng)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • sql查詢返回值使用map封裝多個(gè)key和value實(shí)例

    sql查詢返回值使用map封裝多個(gè)key和value實(shí)例

    這篇文章主要介紹了sql查詢返回值使用map封裝多個(gè)key和value實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-07-07
  • Java Spring詳解如何配置數(shù)據(jù)源注解開(kāi)發(fā)以及整合Junit

    Java Spring詳解如何配置數(shù)據(jù)源注解開(kāi)發(fā)以及整合Junit

    Spring 是目前主流的 Java Web 開(kāi)發(fā)框架,是 Java 世界最為成功的框架。該框架是一個(gè)輕量級(jí)的開(kāi)源框架,具有很高的凝聚力和吸引力,本篇文章帶你了解如何配置數(shù)據(jù)源、注解開(kāi)發(fā)以及整合Junit
    2021-10-10
  • Java中的Null到底是什么

    Java中的Null到底是什么

    null是沒(méi)有地址,""是有地址但是里面的內(nèi)容是空的,好比做飯 null說(shuō)明連鍋都沒(méi)有 而""則是有鍋沒(méi)米,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,下面我們來(lái)詳細(xì)學(xué)習(xí)一下它吧
    2019-06-06
  • Spring項(xiàng)目接入DeepSeek的兩種超簡(jiǎn)單的方式分享

    Spring項(xiàng)目接入DeepSeek的兩種超簡(jiǎn)單的方式分享

    DeepSeek?作為一款卓越的國(guó)產(chǎn)?AI?模型,越來(lái)越多的公司考慮在自己的應(yīng)用中集成,本文為大家?分享了Spring項(xiàng)目接入DeepSeek的兩種超簡(jiǎn)單的方式,希望對(duì)大家有所幫助
    2025-02-02
  • SpringBoot配置文件格式詳細(xì)介紹

    SpringBoot配置文件格式詳細(xì)介紹

    這篇文章主要為大家詳細(xì)介紹了SpringBoot配置文件格式,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)SpringBoot有一定幫助,需要的可以參考一下
    2022-09-09
  • Java contains用法示例

    Java contains用法示例

    這篇文章主要介紹了Java contains的用法示例,幫助大家更好的理解和學(xué)習(xí)Java,感興趣的朋友可以了解下
    2020-11-11
  • 如何實(shí)現(xiàn)java8 list按照元素的某個(gè)字段去重

    如何實(shí)現(xiàn)java8 list按照元素的某個(gè)字段去重

    這篇文章主要介紹了如何實(shí)現(xiàn)java8 list按照元素的某個(gè)字段去重,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,,需要的朋友可以參考下
    2019-06-06
  • 詳解JAVA中的OPTIONAL

    詳解JAVA中的OPTIONAL

    從Java 8引入的一個(gè)很有趣的特性是Optional類。Optional類主要解決的問(wèn)題是臭名昭著的空指針異常(NullPointerException)
    2021-06-06
  • Java @GlobalLock注解詳細(xì)分析講解

    Java @GlobalLock注解詳細(xì)分析講解

    這篇文章主要介紹了Java @GlobalLock注解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧
    2022-11-11
  • spring boot環(huán)境抽象的實(shí)現(xiàn)方法

    spring boot環(huán)境抽象的實(shí)現(xiàn)方法

    在實(shí)際開(kāi)發(fā)中,開(kāi)發(fā)人員在編寫(xiě)springboot的時(shí)候通常要在本地環(huán)境測(cè)試然后再部署到Production環(huán)境,這兩種環(huán)境一般來(lái)講是不同的,最主要的區(qū)別就是數(shù)據(jù)源的不同。本文主要介紹了這兩種,感興趣的可以了解一下
    2019-04-04

最新評(píng)論

潞西市| 沛县| 丰都县| 武安市| 吐鲁番市| 镇沅| 嵊州市| 和林格尔县| 武汉市| 来安县| 望江县| 金乡县| 夏河县| 内乡县| 碌曲县| 黎川县| 荔波县| 通山县| 宁陵县| 济阳县| 佛冈县| 上饶市| 图们市| 宾川县| 福鼎市| 辽中县| 乡城县| 沙湾县| 望江县| 扶余县| 开封县| 贵港市| 苍梧县| 陆川县| 安达市| 丹棱县| 井研县| 西城区| 荥经县| 郓城县| 沙湾县|