Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the system of Women's clothing Mall by Java

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how Java implements the women's wear mall system. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

First, the project brief function

Javaweb online mall system, foreground + background management, user registration, login, display, group display, search, receiving address management, shopping cart management, add, purchase, personal information modification. Order inquiry, background commodity management, classification management, inventory management, order management, user management, information modification and so on.

II. Project operation

Environment configuration: Jdk1.8 + Tomcats. 5 + mysql + Eclispe (IntelliJ IDEA, Eclispe, MyEclispe, sts all support)

Project technology: JSP + Spring + SpringMVC + MyBatis + html + cSS + Javascript + JQuery + Ajax + layui + maven and so on.

Login code for background management platform: / * background management-Home page * / @ Controllerpublic 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 / * go to background management-Home page * @ param session session object * @ param map Map * @ return response data passed from the foreground * @ throws ParseException conversion exception * / @ RequestMapping (value = "admin", method = RequestMethod.GET) public String goToPage (HttpSession session, Map map) throws ParseException {logger.info ("get administrator information") 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 ("get Statistics") / / Total number of products Integer productTotal = productService.getTotal (null, new Byte [] {0,2}); / / Total number of users Integer userTotal = userService.getTotal (null); / / Total order Integer orderTotal = productOrderService.getTotal (null, new Byte [] {3}); logger.info ("get Chart Information"); map.put ("jsonObject", getChartData (null,null,7)) Map.put ("productTotal", productTotal); map.put ("userTotal", userTotal); map.put ("orderTotal", orderTotal); logger.info ("go to background Management-Home Page"); return "admin/homePage" } / * go to background Management-Home Page (ajax method) * @ param session session object * @ param map Map * @ return response data passed in from the foreground * @ throws ParseException conversion exception * / @ RequestMapping (value = "admin/home", method = RequestMethod.GET) public String goToPageByAjax (HttpSession session) Map map) throws ParseException {logger.info ("get administrator information") 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 ("get Statistics"); Integer productTotal = productService.getTotal (null, new Byte [] {0,2}) Integer userTotal = userService.getTotal (null); Integer orderTotal = productOrderService.getTotal (null, new Byte [] {3}); logger.info ("get chart information"); map.put ("jsonObject", getChartData (null,null,7)); logger.info ("get chart information"); map.put ("jsonObject", getChartData (null,null,7)); map.put ("productTotal", productTotal) Map.put ("userTotal", userTotal); map.put ("orderTotal", orderTotal); logger.info ("go to background management-home page-ajax mode"); return "admin/homeManagePage" } / * query chart data by date (ajax method) * @ param beginDate start date * @ param endDate end date * @ return response data * @ throws ParseException conversion exception * / @ 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) {/ / convert date format SimpleDateFormat simpleDateFormat = new SimpleDateFormat (" yyyy-MM-dd "); return getChartData (simpleDateFormat.parse (beginDate), simpleDateFormat.parse (endDate), 7) .toJSONString () } else {return getChartData (null, null,7) .toJSONString () }} / * get chart data by date * @ param beginDate start date * @ param endDate end date * @ param days days * @ JSON object of return chart data * @ throws ParseException conversion exception * / 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) / / if no start and end dates are specified if (beginDate = = null | | endDate = = null) {/ / specify the date one week ago as the start date Calendar cal = Calendar.getInstance (); cal.add (Calendar.DATE, 1-days); beginDate = time.parse (time.format (cal.getTime () / / specify the current date as the end date cal = Calendar.getInstance (); endDate = cal.getTime ();} else {beginDate = time.parse (time.format (beginDate)); endDate = timeSpecial.parse (time.format (endDate) + "23:59:59");} logger.info ("classified by order status") / / unpaid orders statistics array int [] orderUnpaidArray = new int [7]; / Uncle int [] orderNotShippedArray = new int [7]; / / unconfirmed orders statistics array int [] orderUnconfirmedArray = new int [7]; / / transactions successful orders statistics array int [] orderSuccessArray = new int [7] / / Total transaction order statistics array int [] orderTotalArray = new int [7]; logger.info ("get statistical order collection data from database"); List orderGroupList = productOrderService.getTotalByDate (beginDate, endDate); / / initialization date array JSONArray dateStr = new JSONArray (days); / / cycle for according to the specified number of days (int I = 0; I)

< days; i++) { //格式化日期串(MM/dd)并放入日期数组中 Calendar cal = Calendar.getInstance(); cal.setTime(beginDate); cal.add(Calendar.DATE, i); String formatDate = time2.format(cal.getTime()); dateStr.add(formatDate); //该天的订单总数 int orderCount = 0; //循环订单集合数据的结果集 for(int j = 0; j < orderGroupList.size(); j++){ OrderGroup orderGroup = orderGroupList.get(j); //如果该订单日期与当前日期一致 if(orderGroup.getProductOrder_pay_date().equals(formatDate)){ //从结果集中移除数据 orderGroupList.remove(j); //根据订单状态将统计结果存入对应的订单状态数组中 switch (orderGroup.getProductOrder_status()) { case 0: //未付款订单 orderUnpaidArray[i] = orderGroup.getProductOrder_count(); break; case 1: //未发货订单 orderNotShippedArray[i] = orderGroup.getProductOrder_count(); break; case 2: //未确认订单 orderUnconfirmedArray[i] = orderGroup.getProductOrder_count(); break; case 3: //交易成功订单 orderSuccessArray[i] = orderGroup.getProductOrder_count(); break; } //累加当前日期的订单总数 orderCount += orderGroup.getProductOrder_count(); } } //将统计的订单总数存入总交易订单数统计数组 orderTotalArray[i] = orderCount; } logger.info("返回结果集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 firstLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(0L), NewBeeMallCategoryLevelEnum.LEVEL_ONE.getLevel()); if (!CollectionUtils.isEmpty(firstLevelCategories)) { //查询一级分类列表中第一个实体的所有二级分类 List secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(firstLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel()); if (!CollectionUtils.isEmpty(secondLevelCategories)) { //查询二级分类列表中第一个实体的所有三级分类 List 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() >

< 1) { return ResultGenerator.genFailResult("参数异常!"); } if (sellStatus != Constants.SELL_STATUS_UP && sellStatus != Constants.SELL_STATUS_DOWN) { return ResultGenerator.genFailResult("状态异常!"); } 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" } / * list * / @ RequestMapping (value = "/ categories/list", method = RequestMethod.GET) @ ResponseBody public Result list (@ RequestParam Map params) {if (StringUtils.isEmpty (params.get ("page")) | | StringUtils.isEmpty (params.get ("limit") {return ResultGenerator.genFailResult ("Parameter exception!") ;} PageQueryUtil pageUtil = new PageQueryUtil (params); return ResultGenerator.genSuccessResult (newBeeMallCategoryService.getCategorisPage (pageUtil)) } / * list * / @ RequestMapping (value = "/ categories/listForSelect", method = RequestMethod.GET) @ ResponseBody public Result listForSelect (@ RequestParam ("categoryId") Long categoryId) {if (categoryId = = null | | categoryId < 1) {return ResultGenerator.genFailResult ("missing parameter!") ;} GoodsCategory category = newBeeMallCategoryService.getGoodsCategoryById (categoryId); / / data if (category = = null | | category.getCategoryLevel () = = NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel ()) {return ResultGenerator.genFailResult ("parameter exception!") is not returned if it is neither primary nor secondary. ;} Map categoryResult = new HashMap (2) If (category.getCategoryLevel () = = NewBeeMallCategoryLevelEnum.LEVEL_ONE.getLevel ()) {/ / if it is a first-level classification, it returns all second-level classifications under the current first-level classification. And all the third-level classification list under the first item in the secondary classification list / / query all secondary classification List secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber (Collections.singletonList (categoryId), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel ()) of the first entity in the first-level classification list. If (! CollectionUtils.isEmpty (secondLevelCategories)) {/ / query all third-level classifications of the first entity in the secondary classification list List 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 ()) {/ / if it is a second-level classification, return a list of all third-level categories under the current category List thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber (Collections.singletonList (categoryId), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel ()); categoryResult.put ("thirdLevelCategories", thirdLevelCategories) } return ResultGenerator.genSuccessResult (categoryResult) } / * * add * / @ 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 ("abnormal parameter!") ;} String result = newBeeMallCategoryService.saveCategory (goodsCategory); if (ServiceResultEnum.SUCCESS.getResult (). Equals (result)) {return ResultGenerator.genSuccessResult ();} else {return ResultGenerator.genFailResult (result) }} / * modify * / @ 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 ("Parameter exception!") ;} String result = newBeeMallCategoryService.updateGoodsCategory (goodsCategory); if (ServiceResultEnum.SUCCESS.getResult (). Equals (result)) {return ResultGenerator.genSuccessResult ();} else {return ResultGenerator.genFailResult (result) }} / * details * / @ GetMapping ("/ categories/info/ {id}") @ ResponseBody public Result info (@ PathVariable ("id") Long id) {GoodsCategory goodsCategory = newBeeMallCategoryService.getGoodsCategoryById (id); if (goodsCategory = = null) {return ResultGenerator.genFailResult ("data not found");} return ResultGenerator.genSuccessResult (goodsCategory) } / * Category deletion * / @ RequestMapping (value = "/ categories/delete", method = RequestMethod.POST) @ ResponseBody public Result delete (@ RequestBody Integer [] ids) {if (ids.length < 1) {return ResultGenerator.genFailResult ("Parameter exception!") ;} if (newBeeMallCategoryService.deleteBatch (ids)) {return ResultGenerator.genSuccessResult ();} else {return ResultGenerator.genFailResult ("deletion failed") This is the end of the article on "how to realize the Women's clothing Mall system in Java". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report