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

Java女裝商城系統(tǒng)的實現(xiàn)流程

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

一、項目簡述功能

javaweb 網(wǎng)上商城系統(tǒng),前臺+后臺管理,用戶注冊,登錄,上哦展示,分組展示,搜索,收貨地址管理,購物車管理,添加,購買,個人信息修改。訂單查詢等等,后臺商品管理,分類管理,庫存管理,訂單管理,用戶管理,信息修改等等.

二、項目運行

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

項目技術(shù): JSP + Spring + SpringMVC + MyBatis + html + cSS + Javascript + JQuery + Ajax + layui + maven 等等。

后臺管理平臺登錄代碼:

/**
 * 后臺管理-主頁
 */
@Controller
public class AdminHomeController extends BaseController {
    @Resource(name = "adminService")
    private AdminService adminService;
    @Resource(name = "productOrderService")
    private ProductOrderService productOrderService;
    @Resource(name = "productService")
    private ProductService productService;
    @Resource(name = "userService")
    private UserService userService;
 
    /**
     * 轉(zhuǎn)到后臺管理-主頁
     * @param session session對象
     * @param map 前臺傳入的Map
     * @return 響應(yīng)數(shù)據(jù)
     * @throws ParseException 轉(zhuǎn)換異常
     */
    @RequestMapping(value = "admin", method = RequestMethod.GET)
    public String goToPage(HttpSession session, Map<String, Object> map) throws ParseException {
        logger.info("獲取管理員信息");
        Object adminId = checkAdmin(session);
        if (adminId == null) {
            return "redirect:/admin/login";
        }
        Admin admin = adminService.get(null, Integer.parseInt(adminId.toString()));
        map.put("admin", admin);
        logger.info("獲取統(tǒng)計信息");
        //產(chǎn)品總數(shù)
        Integer productTotal = productService.getTotal(null, new Byte[]{0, 2});
        //用戶總數(shù)
        Integer userTotal = userService.getTotal(null);
        //訂單總數(shù)
        Integer orderTotal = productOrderService.getTotal(null, new Byte[]{3});
        logger.info("獲取圖表信息");
        map.put("jsonObject", getChartData(null,null,7));
        map.put("productTotal", productTotal);
        map.put("userTotal", userTotal);
        map.put("orderTotal", orderTotal);
 
        logger.info("轉(zhuǎn)到后臺管理-主頁");
        return "admin/homePage";
    }
 
    /**
     * 轉(zhuǎn)到后臺管理-主頁(ajax方式)
     * @param session session對象
     * @param map 前臺傳入的Map
     * @return 響應(yīng)數(shù)據(jù)
     * @throws ParseException 轉(zhuǎn)換異常
     */
    @RequestMapping(value = "admin/home", method = RequestMethod.GET)
    public String goToPageByAjax(HttpSession session, Map<String, Object> map) throws ParseException {
        logger.info("獲取管理員信息");
        Object adminId = checkAdmin(session);
        if (adminId == null) {
            return "admin/include/loginMessage";
        }
        Admin admin = adminService.get(null, Integer.parseInt(adminId.toString()));
        map.put("admin", admin);
        logger.info("獲取統(tǒng)計信息");
        Integer productTotal = productService.getTotal(null, new Byte[]{0, 2});
        Integer userTotal = userService.getTotal(null);
        Integer orderTotal = productOrderService.getTotal(null, new Byte[]{3});
        logger.info("獲取圖表信息");
        map.put("jsonObject", getChartData(null, null,7));
        logger.info("獲取圖表信息");
        map.put("jsonObject", getChartData(null,null,7));
        map.put("productTotal", productTotal);
        map.put("userTotal", userTotal);
        map.put("orderTotal", orderTotal);
        logger.info("轉(zhuǎn)到后臺管理-主頁-ajax方式");
        return "admin/homeManagePage";
    }
 
    /**
     * 按日期查詢圖表數(shù)據(jù)(ajax方式)
     * @param beginDate 開始日期
     * @param endDate 結(jié)束日期
     * @return 響應(yīng)數(shù)據(jù)
     * @throws ParseException 轉(zhuǎn)換異常
     */
    @ResponseBody
    @RequestMapping(value = "admin/home/charts", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public String getChartDataByDate(@RequestParam(required = false) String beginDate, @RequestParam(required = false) String endDate) throws ParseException {
        if (beginDate != null && endDate != null) {
            //轉(zhuǎn)換日期格式
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            return getChartData(simpleDateFormat.parse(beginDate), simpleDateFormat.parse(endDate),7).toJSONString();
        } else {
            return getChartData(null, null,7).toJSONString();
        }
    }
 
    /**
     * 按日期獲取圖表數(shù)據(jù)
     * @param beginDate 開始日期
     * @param endDate 結(jié)束日期
     * @param days 天數(shù)
     * @return 圖表數(shù)據(jù)的JSON對象
     * @throws ParseException 轉(zhuǎn)換異常
     */
    private JSONObject getChartData(Date beginDate,Date endDate,int days) throws ParseException {
        JSONObject jsonObject = new JSONObject();
        SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd", Locale.UK);
        SimpleDateFormat time2 = new SimpleDateFormat("MM/dd", Locale.UK);
        SimpleDateFormat timeSpecial = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.UK);
        //如果沒有指定開始和結(jié)束日期
        if (beginDate == null || endDate == null) {
            //指定一周前的日期為開始日期
            Calendar cal = Calendar.getInstance();
            cal.add(Calendar.DATE, 1-days);
            beginDate = time.parse(time.format(cal.getTime()));
            //指定當(dāng)前日期為結(jié)束日期
            cal = Calendar.getInstance();
            endDate = cal.getTime();
        } else {
            beginDate = time.parse(time.format(beginDate));
            endDate = timeSpecial.parse(time.format(endDate) + " 23:59:59");
        }
        logger.info("根據(jù)訂單狀態(tài)分類");
        //未付款訂單數(shù)統(tǒng)計數(shù)組
        int[] orderUnpaidArray = new int[7];
        //未發(fā)貨訂單數(shù)統(tǒng)計叔祖
        int[] orderNotShippedArray = new int[7];
        //未確認(rèn)訂單數(shù)統(tǒng)計數(shù)組
        int[] orderUnconfirmedArray = new int[7];
        //交易成功訂單數(shù)統(tǒng)計數(shù)組
        int[] orderSuccessArray = new int[7];
        //總交易訂單數(shù)統(tǒng)計數(shù)組
        int[] orderTotalArray = new int[7];
        logger.info("從數(shù)據(jù)庫中獲取統(tǒng)計的訂單集合數(shù)據(jù)");
        List<OrderGroup> orderGroupList = productOrderService.getTotalByDate(beginDate, endDate);
        //初始化日期數(shù)組
        JSONArray dateStr = new JSONArray(days);
        //按指定的天數(shù)進(jìn)行循環(huán)
        for (int i = 0; i < days; i++) {
            //格式化日期串(MM/dd)并放入日期數(shù)組中
            Calendar cal = Calendar.getInstance();
            cal.setTime(beginDate);
            cal.add(Calendar.DATE, i);
            String formatDate = time2.format(cal.getTime());
            dateStr.add(formatDate);
            //該天的訂單總數(shù)
            int orderCount = 0;
            //循環(huán)訂單集合數(shù)據(jù)的結(jié)果集
            for(int j = 0; j < orderGroupList.size(); j++){
                OrderGroup orderGroup = orderGroupList.get(j);
                //如果該訂單日期與當(dāng)前日期一致
                if(orderGroup.getProductOrder_pay_date().equals(formatDate)){
                    //從結(jié)果集中移除數(shù)據(jù)
                    orderGroupList.remove(j);
                    //根據(jù)訂單狀態(tài)將統(tǒng)計結(jié)果存入對應(yīng)的訂單狀態(tài)數(shù)組中
                    switch (orderGroup.getProductOrder_status()) {
                        case 0:
                            //未付款訂單
                            orderUnpaidArray[i] = orderGroup.getProductOrder_count();
                            break;
                        case 1:
                            //未發(fā)貨訂單
                            orderNotShippedArray[i] = orderGroup.getProductOrder_count();
                            break;
                        case 2:
                            //未確認(rèn)訂單
                            orderUnconfirmedArray[i] = orderGroup.getProductOrder_count();
                            break;
                        case 3:
                            //交易成功訂單
                            orderSuccessArray[i] = orderGroup.getProductOrder_count();
                            break;
                    }
                    //累加當(dāng)前日期的訂單總數(shù)
                    orderCount += orderGroup.getProductOrder_count();
                }
            }
            //將統(tǒng)計的訂單總數(shù)存入總交易訂單數(shù)統(tǒng)計數(shù)組
            orderTotalArray[i] = orderCount;
        }
        logger.info("返回結(jié)果集map");
        jsonObject.put("orderTotalArray", orderTotalArray);
        jsonObject.put("orderUnpaidArray", orderUnpaidArray);
        jsonObject.put("orderNotShippedArray", orderNotShippedArray);
        jsonObject.put("orderUnconfirmedArray", orderUnconfirmedArray);
        jsonObject.put("orderSuccessArray", orderSuccessArray);
        jsonObject.put("dateStr",dateStr);
        return jsonObject;
    }
}

商品信息控制層:

/**
 * @author yy
 */
@Controller
@RequestMapping("/admin")
public class NewBeeMallGoodsController {
 
    @Resource
    private NewBeeMallGoodsService newBeeMallGoodsService;
    @Resource
    private NewBeeMallCategoryService newBeeMallCategoryService;
 
    @GetMapping("/goods")
    public String goodsPage(HttpServletRequest request) {
        request.setAttribute("path", "newbee_mall_goods");
        return "admin/newbee_mall_goods";
    }
 
    @GetMapping("/goods/edit")
    public String edit(HttpServletRequest request) {
        request.setAttribute("path", "edit");
        //查詢所有的一級分類
        List<GoodsCategory> firstLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(0L), NewBeeMallCategoryLevelEnum.LEVEL_ONE.getLevel());
        if (!CollectionUtils.isEmpty(firstLevelCategories)) {
            //查詢一級分類列表中第一個實體的所有二級分類
            List<GoodsCategory> secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(firstLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel());
            if (!CollectionUtils.isEmpty(secondLevelCategories)) {
                //查詢二級分類列表中第一個實體的所有三級分類
                List<GoodsCategory> thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(secondLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel());
                request.setAttribute("firstLevelCategories", firstLevelCategories);
                request.setAttribute("secondLevelCategories", secondLevelCategories);
                request.setAttribute("thirdLevelCategories", thirdLevelCategories);
                request.setAttribute("path", "goods-edit");
                return "admin/newbee_mall_goods_edit";
            }
        }
        return "error/error_5xx";
    }
 
    @GetMapping("/goods/edit/{goodsId}")
    public String edit(HttpServletRequest request, @PathVariable("goodsId") Long goodsId) {
        request.setAttribute("path", "edit");
        NewBeeMallGoods newBeeMallGoods = newBeeMallGoodsService.getNewBeeMallGoodsById(goodsId);
        if (newBeeMallGoods == null) {
            return "error/error_400";
        }
        if (newBeeMallGoods.getGoodsCategoryId() > 0) {
            if (newBeeMallGoods.getGoodsCategoryId() != null || newBeeMallGoods.getGoodsCategoryId() > 0) {
                //有分類字段則查詢相關(guān)分類數(shù)據(jù)返回給前端以供分類的三級聯(lián)動顯示
                GoodsCategory currentGoodsCategory = newBeeMallCategoryService.getGoodsCategoryById(newBeeMallGoods.getGoodsCategoryId());
                //商品表中存儲的分類id字段為三級分類的id,不為三級分類則是錯誤數(shù)據(jù)
                if (currentGoodsCategory != null && currentGoodsCategory.getCategoryLevel() == NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel()) {
                    //查詢所有的一級分類
                    List<GoodsCategory> firstLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(0L), NewBeeMallCategoryLevelEnum.LEVEL_ONE.getLevel());
                    //根據(jù)parentId查詢當(dāng)前parentId下所有的三級分類
                    List<GoodsCategory> thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(currentGoodsCategory.getParentId()), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel());
                    //查詢當(dāng)前三級分類的父級二級分類
                    GoodsCategory secondCategory = newBeeMallCategoryService.getGoodsCategoryById(currentGoodsCategory.getParentId());
                    if (secondCategory != null) {
                        //根據(jù)parentId查詢當(dāng)前parentId下所有的二級分類
                        List<GoodsCategory> secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(secondCategory.getParentId()), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel());
                        //查詢當(dāng)前二級分類的父級一級分類
                        GoodsCategory firestCategory = newBeeMallCategoryService.getGoodsCategoryById(secondCategory.getParentId());
                        if (firestCategory != null) {
                            //所有分類數(shù)據(jù)都得到之后放到request對象中供前端讀取
                            request.setAttribute("firstLevelCategories", firstLevelCategories);
                            request.setAttribute("secondLevelCategories", secondLevelCategories);
                            request.setAttribute("thirdLevelCategories", thirdLevelCategories);
                            request.setAttribute("firstLevelCategoryId", firestCategory.getCategoryId());
                            request.setAttribute("secondLevelCategoryId", secondCategory.getCategoryId());
                            request.setAttribute("thirdLevelCategoryId", currentGoodsCategory.getCategoryId());
                        }
                    }
                }
            }
        }
        if (newBeeMallGoods.getGoodsCategoryId() == 0) {
            //查詢所有的一級分類
            List<GoodsCategory> firstLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(0L), NewBeeMallCategoryLevelEnum.LEVEL_ONE.getLevel());
            if (!CollectionUtils.isEmpty(firstLevelCategories)) {
                //查詢一級分類列表中第一個實體的所有二級分類
                List<GoodsCategory> secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(firstLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel());
                if (!CollectionUtils.isEmpty(secondLevelCategories)) {
                    //查詢二級分類列表中第一個實體的所有三級分類
                    List<GoodsCategory> thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(secondLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel());
                    request.setAttribute("firstLevelCategories", firstLevelCategories);
                    request.setAttribute("secondLevelCategories", secondLevelCategories);
                    request.setAttribute("thirdLevelCategories", thirdLevelCategories);
                }
            }
        }
        request.setAttribute("goods", newBeeMallGoods);
        request.setAttribute("path", "goods-edit");
        return "admin/newbee_mall_goods_edit";
    }
 
    /**
     * 列表
     */
    @RequestMapping(value = "/goods/list", method = RequestMethod.GET)
    @ResponseBody
    public Result list(@RequestParam Map<String, Object> params) {
        if (StringUtils.isEmpty(params.get("page")) || StringUtils.isEmpty(params.get("limit"))) {
            return ResultGenerator.genFailResult("參數(shù)異常!");
        }
        PageQueryUtil pageUtil = new PageQueryUtil(params);
        return ResultGenerator.genSuccessResult(newBeeMallGoodsService.getNewBeeMallGoodsPage(pageUtil));
    }
 
    /**
     * 添加
     */
    @RequestMapping(value = "/goods/save", method = RequestMethod.POST)
    @ResponseBody
    public Result save(@RequestBody NewBeeMallGoods newBeeMallGoods) {
        if (StringUtils.isEmpty(newBeeMallGoods.getGoodsName())
                || StringUtils.isEmpty(newBeeMallGoods.getGoodsIntro())
                || StringUtils.isEmpty(newBeeMallGoods.getTag())
                || Objects.isNull(newBeeMallGoods.getOriginalPrice())
                || Objects.isNull(newBeeMallGoods.getGoodsCategoryId())
                || Objects.isNull(newBeeMallGoods.getSellingPrice())
                || Objects.isNull(newBeeMallGoods.getStockNum())
                || Objects.isNull(newBeeMallGoods.getGoodsSellStatus())
                || StringUtils.isEmpty(newBeeMallGoods.getGoodsCoverImg())
                || StringUtils.isEmpty(newBeeMallGoods.getGoodsDetailContent())) {
            return ResultGenerator.genFailResult("參數(shù)異常!");
        }
        String result = newBeeMallGoodsService.saveNewBeeMallGoods(newBeeMallGoods);
        if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
            return ResultGenerator.genSuccessResult();
        } else {
            return ResultGenerator.genFailResult(result);
        }
    }
 
 
    /**
     * 修改
     */
    @RequestMapping(value = "/goods/update", method = RequestMethod.POST)
    @ResponseBody
    public Result update(@RequestBody NewBeeMallGoods newBeeMallGoods) {
        if (Objects.isNull(newBeeMallGoods.getGoodsId())
                || StringUtils.isEmpty(newBeeMallGoods.getGoodsName())
                || StringUtils.isEmpty(newBeeMallGoods.getGoodsIntro())
                || StringUtils.isEmpty(newBeeMallGoods.getTag())
                || Objects.isNull(newBeeMallGoods.getOriginalPrice())
                || Objects.isNull(newBeeMallGoods.getSellingPrice())
                || Objects.isNull(newBeeMallGoods.getGoodsCategoryId())
                || Objects.isNull(newBeeMallGoods.getStockNum())
                || Objects.isNull(newBeeMallGoods.getGoodsSellStatus())
                || StringUtils.isEmpty(newBeeMallGoods.getGoodsCoverImg())
                || StringUtils.isEmpty(newBeeMallGoods.getGoodsDetailContent())) {
            return ResultGenerator.genFailResult("參數(shù)異常!");
        }
        String result = newBeeMallGoodsService.updateNewBeeMallGoods(newBeeMallGoods);
        if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
            return ResultGenerator.genSuccessResult();
        } else {
            return ResultGenerator.genFailResult(result);
        }
    }
 
    /**
     * 詳情
     */
    @GetMapping("/goods/info/{id}")
    @ResponseBody
    public Result info(@PathVariable("id") Long id) {
        NewBeeMallGoods goods = newBeeMallGoodsService.getNewBeeMallGoodsById(id);
        if (goods == null) {
            return ResultGenerator.genFailResult(ServiceResultEnum.DATA_NOT_EXIST.getResult());
        }
        return ResultGenerator.genSuccessResult(goods);
    }
 
    /**
     * 批量修改銷售狀態(tài)
     */
    @RequestMapping(value = "/goods/status/{sellStatus}", method = RequestMethod.PUT)
    @ResponseBody
    public Result delete(@RequestBody Long[] ids, @PathVariable("sellStatus") int sellStatus) {
        if (ids.length < 1) {
            return ResultGenerator.genFailResult("參數(shù)異常!");
        }
        if (sellStatus != Constants.SELL_STATUS_UP && sellStatus != Constants.SELL_STATUS_DOWN) {
            return ResultGenerator.genFailResult("狀態(tài)異常!");
        }
        if (newBeeMallGoodsService.batchUpdateSellStatus(ids, sellStatus)) {
            return ResultGenerator.genSuccessResult();
        } else {
            return ResultGenerator.genFailResult("修改失敗");
        }
    }
 
}

商品分類控制器:

/**
 * @author yy
 */
@Controller
@RequestMapping("/admin")
public class NewBeeMallGoodsCategoryController {
 
    @Resource
    private NewBeeMallCategoryService newBeeMallCategoryService;
 
    @GetMapping("/categories")
    public String categoriesPage(HttpServletRequest request, @RequestParam("categoryLevel") Byte categoryLevel, @RequestParam("parentId") Long parentId, @RequestParam("backParentId") Long backParentId) {
        if (categoryLevel == null || categoryLevel < 1 || categoryLevel > 3) {
            return "error/error_5xx";
        }
        request.setAttribute("path", "newbee_mall_category");
        request.setAttribute("parentId", parentId);
        request.setAttribute("backParentId", backParentId);
        request.setAttribute("categoryLevel", categoryLevel);
        return "admin/newbee_mall_category";
    }
 
    /**
     * 列表
     */
    @RequestMapping(value = "/categories/list", method = RequestMethod.GET)
    @ResponseBody
    public Result list(@RequestParam Map<String, Object> params) {
        if (StringUtils.isEmpty(params.get("page")) || StringUtils.isEmpty(params.get("limit"))) {
            return ResultGenerator.genFailResult("參數(shù)異常!");
        }
        PageQueryUtil pageUtil = new PageQueryUtil(params);
        return ResultGenerator.genSuccessResult(newBeeMallCategoryService.getCategorisPage(pageUtil));
    }
 
    /**
     * 列表
     */
    @RequestMapping(value = "/categories/listForSelect", method = RequestMethod.GET)
    @ResponseBody
    public Result listForSelect(@RequestParam("categoryId") Long categoryId) {
        if (categoryId == null || categoryId < 1) {
            return ResultGenerator.genFailResult("缺少參數(shù)!");
        }
        GoodsCategory category = newBeeMallCategoryService.getGoodsCategoryById(categoryId);
        //既不是一級分類也不是二級分類則為不返回數(shù)據(jù)
        if (category == null || category.getCategoryLevel() == NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel()) {
            return ResultGenerator.genFailResult("參數(shù)異常!");
        }
        Map categoryResult = new HashMap(2);
        if (category.getCategoryLevel() == NewBeeMallCategoryLevelEnum.LEVEL_ONE.getLevel()) {
            //如果是一級分類則返回當(dāng)前一級分類下的所有二級分類,以及二級分類列表中第一條數(shù)據(jù)下的所有三級分類列表
            //查詢一級分類列表中第一個實體的所有二級分類
            List<GoodsCategory> secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(categoryId), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel());
            if (!CollectionUtils.isEmpty(secondLevelCategories)) {
                //查詢二級分類列表中第一個實體的所有三級分類
                List<GoodsCategory> thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(secondLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel());
                categoryResult.put("secondLevelCategories", secondLevelCategories);
                categoryResult.put("thirdLevelCategories", thirdLevelCategories);
            }
        }
        if (category.getCategoryLevel() == NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel()) {
            //如果是二級分類則返回當(dāng)前分類下的所有三級分類列表
            List<GoodsCategory> thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(categoryId), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel());
            categoryResult.put("thirdLevelCategories", thirdLevelCategories);
        }
        return ResultGenerator.genSuccessResult(categoryResult);
    }
 
    /**
     * 添加
     */
    @RequestMapping(value = "/categories/save", method = RequestMethod.POST)
    @ResponseBody
    public Result save(@RequestBody GoodsCategory goodsCategory) {
        if (Objects.isNull(goodsCategory.getCategoryLevel())
                || StringUtils.isEmpty(goodsCategory.getCategoryName())
                || Objects.isNull(goodsCategory.getParentId())
                || Objects.isNull(goodsCategory.getCategoryRank())) {
            return ResultGenerator.genFailResult("參數(shù)異常!");
        }
        String result = newBeeMallCategoryService.saveCategory(goodsCategory);
        if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
            return ResultGenerator.genSuccessResult();
        } else {
            return ResultGenerator.genFailResult(result);
        }
    }
 
 
    /**
     * 修改
     */
    @RequestMapping(value = "/categories/update", method = RequestMethod.POST)
    @ResponseBody
    public Result update(@RequestBody GoodsCategory goodsCategory) {
        if (Objects.isNull(goodsCategory.getCategoryId())
                || Objects.isNull(goodsCategory.getCategoryLevel())
                || StringUtils.isEmpty(goodsCategory.getCategoryName())
                || Objects.isNull(goodsCategory.getParentId())
                || Objects.isNull(goodsCategory.getCategoryRank())) {
            return ResultGenerator.genFailResult("參數(shù)異常!");
        }
        String result = newBeeMallCategoryService.updateGoodsCategory(goodsCategory);
        if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
            return ResultGenerator.genSuccessResult();
        } else {
            return ResultGenerator.genFailResult(result);
        }
    }
 
    /**
     * 詳情
     */
    @GetMapping("/categories/info/{id}")
    @ResponseBody
    public Result info(@PathVariable("id") Long id) {
        GoodsCategory goodsCategory = newBeeMallCategoryService.getGoodsCategoryById(id);
        if (goodsCategory == null) {
            return ResultGenerator.genFailResult("未查詢到數(shù)據(jù)");
        }
        return ResultGenerator.genSuccessResult(goodsCategory);
    }
 
    /**
     * 分類刪除
     */
    @RequestMapping(value = "/categories/delete", method = RequestMethod.POST)
    @ResponseBody
    public Result delete(@RequestBody Integer[] ids) {
        if (ids.length < 1) {
            return ResultGenerator.genFailResult("參數(shù)異常!");
        }
        if (newBeeMallCategoryService.deleteBatch(ids)) {
            return ResultGenerator.genSuccessResult();
        } else {
            return ResultGenerator.genFailResult("刪除失敗");
        }
    }
 
 
}

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

相關(guān)文章

  • 如何測試Spring MVC應(yīng)用

    如何測試Spring MVC應(yīng)用

    這篇文章主要介紹了如何測試Spring MVC應(yīng)用,幫助大家更好的理解和使用spring框架,感興趣的朋友可以了解下
    2020-10-10
  • java實現(xiàn)多線程賣票功能

    java實現(xiàn)多線程賣票功能

    這篇文章主要為大家詳細(xì)介紹了java實現(xiàn)多線程賣票功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-07-07
  • springSecurity自定義登錄接口和JWT認(rèn)證過濾器的流程

    springSecurity自定義登錄接口和JWT認(rèn)證過濾器的流程

    這篇文章主要介紹了springSecurity自定義登陸接口和JWT認(rèn)證過濾器的相關(guān)資料,本文給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧
    2024-12-12
  • 詳解SpringBoot和SpringBatch 使用

    詳解SpringBoot和SpringBatch 使用

    Spring Batch 是一個輕量級的、完善的批處理框架,旨在幫助企業(yè)建立健壯、高效的批處理應(yīng)用。這篇文章主要介紹了詳解SpringBoot和SpringBatch 使用,需要的朋友可以參考下
    2018-07-07
  • Java設(shè)計模式之命令模式_動力節(jié)點Java學(xué)院整理

    Java設(shè)計模式之命令模式_動力節(jié)點Java學(xué)院整理

    命令模式就是對命令的封裝,下文中給大家介紹了命令模式類圖中的基本結(jié)構(gòu),對java設(shè)計模式之命令模式相關(guān)知識感興趣的朋友一起看看吧
    2017-08-08
  • javaweb圖書商城設(shè)計之購物車模塊(3)

    javaweb圖書商城設(shè)計之購物車模塊(3)

    這篇文章主要為大家詳細(xì)介紹了javaweb圖書商城設(shè)計之購物車模塊的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Spring?@Autowired注解超詳細(xì)示例

    Spring?@Autowired注解超詳細(xì)示例

    @Autowired注解可以用在類屬性,構(gòu)造函數(shù),setter方法和函數(shù)參數(shù)上,該注解可以準(zhǔn)確地控制bean在何處如何自動裝配的過程。在默認(rèn)情況下,該注解是類型驅(qū)動的注入
    2022-08-08
  • 一文帶你了解Java排序算法

    一文帶你了解Java排序算法

    這篇文章主要為大家詳細(xì)介紹了Java中常見的三個排序算法:選擇排序,冒泡排序和插入排序,文中的示例代碼講解詳細(xì),感興趣的可以了解一下
    2022-08-08
  • Java中的synchronized有幾種加鎖方式(實例詳解)

    Java中的synchronized有幾種加鎖方式(實例詳解)

    在Java中,synchronized關(guān)鍵字提供了內(nèi)置的支持來實現(xiàn)同步訪問共享資源,以避免并發(fā)問題,這篇文章主要介紹了java的synchronized有幾種加鎖方式,需要的朋友可以參考下
    2024-05-05
  • Javaweb EL自定義函數(shù)開發(fā)及代碼實例

    Javaweb EL自定義函數(shù)開發(fā)及代碼實例

    這篇文章主要介紹了Javaweb EL自定義函數(shù)開發(fā)及代碼實例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-06-06

最新評論

辽宁省| 大化| 双桥区| 蚌埠市| 京山县| 丰台区| 阳曲县| 唐海县| 平凉市| 双桥区| 邹城市| 尼木县| 大足县| 九江县| 滨海县| 宁河县| 平利县| 三台县| 安庆市| 探索| 富民县| 祁东县| 天门市| 仪陇县| 延寿县| 琼结县| 白城市| 五寨县| 紫金县| 英山县| 西贡区| 建宁县| 德江县| 武强县| 商城县| 四子王旗| 开江县| 商都县| 连云港市| 汉中市| 台北县|