零食商城|基于springboot的零食商城(一)https://developer.aliyun.com/article/1423361
品牌管理
商品管理
订单管理
销售统计
四,核心代码展示
package com.yw.eshop.controller.admin; import com.yw.eshop.domain.Product; import com.yw.eshop.domain.TongjiVo; import com.yw.eshop.mapper.ProductMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import java.util.ArrayList; import java.util.List; @Controller @RequestMapping("/echart") public class AdminTongjiController { @Autowired private ProductMapper productMapper; /*得到所有已被销售商品的销售情况*/ @RequestMapping(value = "/adminEachartzhu") @ResponseBody public List<TongjiVo> getAllXiaoshou(){ System.out.println("柱状图数据统计请求"); return productMapper.tongjiBing(); } /*管理员权限查询近日订单金额*/ @RequestMapping(value = "/getAllOrdersComeInByDate") @ResponseBody public List<TongjiVo> getAllOrdersComeInByDate(){ System.out.println("管理员权限查询近日订单金额"); return productMapper.tongjiZhu(); } /*跳转到销售柱状图页面*/ @RequestMapping(value = "/toadminEachartzhu") public String toAdminEchart(){ return "/admin/echart/xiaoshouZhu"; } /*跳转到销售饼状图页面*/ @RequestMapping(value = "/toadminEachartBin") public String toadminEachartzhu2(){ return "/admin/echart/xiaoshouBin"; } }
package com.yw.eshop.controller.admin; import com.yw.eshop.domain.Brand; import com.yw.eshop.domain.ProductType; import com.yw.eshop.service.BrandService; import com.yw.eshop.service.ProductTypeService; import com.yw.eshop.utils.PageModel; import com.yw.eshop.service.BrandService; import com.yw.eshop.service.ProductTypeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import java.util.List; @Controller @RequestMapping("/admin/brand") public class BrandController { @Autowired private BrandService brandService; @Autowired private ProductTypeService productTypeService; @RequestMapping("/list") public String list( @RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "5")Integer pageSize, Model model){ try { PageModel<Brand> brandPages = brandService.queryBrandPages(pageNo, pageSize); model.addAttribute("brandPages", brandPages); } catch (Exception e) { e.printStackTrace(); model.addAttribute("errMessage", "查询失败:"+e.getMessage()); return "500"; } return "admin/brand/list"; } @RequestMapping("addPage") public String addPage(Model model){ List<ProductType> productTypes= productTypeService.queryProductTypeAll(); model.addAttribute("productTypes",productTypes); return "admin/brand/add"; } @RequestMapping("/add") private String addBrand(Brand brand,Model model){ try { int i = brandService.addBrand(brand); if (i==0){ model.addAttribute("errMessage","服务器繁忙操作失败"); return "500"; } }catch (Exception e){ model.addAttribute("errMessage",e.getMessage()); return "500"; } model.addAttribute("url", "admin/brand/list"); return "success"; } @RequestMapping("updatePage") public String updatePage(String id,Model model){ Brand brand= brandService.queryBrandById(id); List<ProductType> productTypes= productTypeService.queryProductTypeAll(); model.addAttribute("productTypes",productTypes); model.addAttribute("brand",brand); return "admin/brand/update"; } @RequestMapping("/update") private String update(Brand brand,Model model){ try { int i = brandService.updateBrand(brand); if (i==0){ model.addAttribute("errMessage","服务器繁忙操作失败"); return "500"; } }catch (Exception e){ model.addAttribute("errMessage",e.getMessage()); return "500"; } model.addAttribute("url", "admin/brand/list"); return "success"; } @RequestMapping("deletePage") public String deletePage(String id,Model model){ model.addAttribute("id",id); return "admin/carousel/delete"; } @RequestMapping("/delete") public String delete(String id, Model model){ try { int i = brandService.delete(id); if (i==0){ model.addAttribute("errMessage","服务器繁忙操作失败"); return "500"; } }catch (Exception e){ model.addAttribute("errMessage",e.getMessage()); return "500"; } model.addAttribute("url", "admin/brand/list"); return "success"; } @RequestMapping("batchDel") @ResponseBody public String batchDel(String[] ids) { System.out.println("进来了"); brandService.batchProductTypeDel(ids); return "/admin/brand/list"; } }
零食商城|基于springboot的零食商城(三)https://developer.aliyun.com/article/1423363