欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

一、項(xiàng)目簡述功能

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

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

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

項(xiàng)目技術(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)計(jì)信息");
        //產(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)計(jì)信息");
        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)計(jì)數(shù)組
        int[] orderUnpaidArray = new int[7];
        //未發(fā)貨訂單數(shù)統(tǒng)計(jì)叔祖
        int[] orderNotShippedArray = new int[7];
        //未確認(rèn)訂單數(shù)統(tǒng)計(jì)數(shù)組
        int[] orderUnconfirmedArray = new int[7];
        //交易成功訂單數(shù)統(tǒng)計(jì)數(shù)組
        int[] orderSuccessArray = new int[7];
        //總交易訂單數(shù)統(tǒng)計(jì)數(shù)組
        int[] orderTotalArray = new int[7];
        logger.info("從數(shù)據(jù)庫中獲取統(tǒng)計(jì)的訂單集合數(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)計(jì)結(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)計(jì)的訂單總數(shù)存入總交易訂單數(shù)統(tǒng)計(jì)數(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)) {
            //查詢一級分類列表中第一個實(shí)體的所有二級分類
            List<GoodsCategory> secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(firstLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel());
            if (!CollectionUtils.isEmpty(secondLevelCategories)) {
                //查詢二級分類列表中第一個實(shí)體的所有三級分類
                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)) {
                //查詢一級分類列表中第一個實(shí)體的所有二級分類
                List<GoodsCategory> secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(firstLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel());
                if (!CollectionUtils.isEmpty(secondLevelCategories)) {
                    //查詢二級分類列表中第一個實(shí)體的所有三級分類
                    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);
        //既不是一級分類也不是二級分類則為不返回?cái)?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ù)下的所有三級分類列表
            //查詢一級分類列表中第一個實(shí)體的所有二級分類
            List<GoodsCategory> secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(categoryId), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel());
            if (!CollectionUtils.isEmpty(secondLevelCategories)) {
                //查詢二級分類列表中第一個實(shí)體的所有三級分類
                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)的實(shí)現(xiàn)流程的文章就介紹到這了,更多相關(guān)Java 女裝商城系統(tǒng)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • SpringBoot中的自動配置原理詳解

    SpringBoot中的自動配置原理詳解

    這篇文章主要介紹了SpringBoot中的自動配置原理詳解,springboot的自動配置類直觀的表現(xiàn)就是通過一系列的注解,使得springboot項(xiàng)目在啟動的時候從配置文件中加載需要自動配置的類,注入容器中,需要的朋友可以參考下
    2024-01-01
  • mybatis if test 不為空字符串且不為null的問題

    mybatis if test 不為空字符串且不為null的問題

    這篇文章主要介紹了mybatis if test 不為空字符串且不為null的問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-03-03
  • Java中String的JdbcTemplate連接SQLServer數(shù)據(jù)庫的方法

    Java中String的JdbcTemplate連接SQLServer數(shù)據(jù)庫的方法

    這篇文章主要介紹了Java中String的JdbcTemplate連接SQLServer數(shù)據(jù)庫的方法,在研發(fā)過程中我們需要與其他系統(tǒng)對接的場景,連接SQLServer拉取數(shù)據(jù),所以就用jdbc連接數(shù)據(jù)庫的方式連接外部數(shù)據(jù)源,需要的朋友可以參考下
    2021-10-10
  • SpringMVC中常用參數(shù)校驗(yàn)類注解使用示例教程

    SpringMVC中常用參數(shù)校驗(yàn)類注解使用示例教程

    這篇文章主要介紹了SpringMVC中常用參數(shù)校驗(yàn)類注解使用示例教程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-03-03
  • 使用dom4j解析xml文件問題

    使用dom4j解析xml文件問題

    這篇文章主要介紹了使用dom4j解析xml文件問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-09-09
  • 解決JMap抓取heap使用統(tǒng)計(jì)信息報(bào)錯的問題

    解決JMap抓取heap使用統(tǒng)計(jì)信息報(bào)錯的問題

    這篇文章主要介紹了解決JMap抓取heap使用統(tǒng)計(jì)信息報(bào)錯的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-12-12
  • Spring連接Mysql數(shù)據(jù)庫全過程

    Spring連接Mysql數(shù)據(jù)庫全過程

    這篇文章主要介紹了Spring連接Mysql數(shù)據(jù)庫全過程,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-11-11
  • mybatis?@InsertProvider報(bào)錯問題及解決

    mybatis?@InsertProvider報(bào)錯問題及解決

    這篇文章主要介紹了mybatis?@InsertProvider報(bào)錯的解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • Java 可視化垃圾回收_動力節(jié)點(diǎn)Java學(xué)院整理

    Java 可視化垃圾回收_動力節(jié)點(diǎn)Java學(xué)院整理

    Ben Evans是一名資深培訓(xùn)師兼顧問,他在演講可視化垃圾回收中從基礎(chǔ)談起討論了垃圾回收。以下是對其演講的簡短總結(jié)。感興趣的朋友一起學(xué)習(xí)吧
    2017-05-05
  • java基礎(chǔ)之類初始化順序示例解析

    java基礎(chǔ)之類初始化順序示例解析

    這篇文章主要為大家介紹了java基礎(chǔ)之類初始化順序示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-10-10

最新評論