後臺權限管理系統(2)——系統基礎數據的展示

1.頁面效果展示

實現效果如下

  • 訂單管理頁面
    在這裏插入圖片描述
  • 產品管理頁面
    在這裏插入圖片描述

2.具體實現

2.1 訂單管理模塊

2.1.1 訂單展示頁面

點擊訂單管理,url跳轉地址如下所示:
在這裏插入圖片描述

  • web層代碼
 //分頁的寫法
    @RequestMapping("/findAll.do")
    @Secured("ROLE_ADMIN")
    public ModelAndView findAll(@RequestParam(name = "page", required = true, defaultValue = "1") Integer page, @RequestParam(name = "size", required = true, defaultValue = "4") Integer size) throws Exception {
        ModelAndView mv = new ModelAndView();
        List<Orders> ordersList = ordersService.findAll(page, size);
        //PageInfo就是一個分頁Bean
        PageInfo pageInfo = new PageInfo(ordersList);
        mv.addObject("pageInfo", pageInfo);
        mv.setViewName("orders-page-list");
        return mv;
    }
  • service層
    @Override
    public List<Orders> findAll(int page,int size) throws Exception {
        //參數PageNum是頁碼值 參數pageSize代表是每頁顯示條數
        PageHelper.startPage(page,size);//這行代碼必須寫在真正調用分頁的代碼之前
        return ordersDao.findAll();
    }
  • dao層
    在這裏插入圖片描述
    由於頁面的數據展示涉及到兩張表的內容,分別是orders表和product表,這兩張表的關係如下圖所示:
    在這裏插入圖片描述
    因此在查詢時需要兩張表聯合查詢:
 @Select("select * from orders")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "orderNum", column = "orderNum"),
            @Result(property = "orderTime", column = "orderTime"),
            @Result(property = "orderStatus", column = "orderStatus"),
            @Result(property = "peopleCount", column = "peopleCount"),
            @Result(property = "payType", column = "payType"),
            @Result(property = "orderDesc", column = "orderDesc"),
            @Result(property = "product", column = "productId", javaType = Product1.class, one = @One(select = "com.GTMStudio.admintelssm.dao.IProductDao.findById"))
    })
    List<Orders> findAll() throws Exception;
    //根據id查詢產品
    @Select("select * from product where id=#{id}")
    public Product1 findById(String id) throws Exception;

2.1.2 訂單詳情頁面

實現效果
在這裏插入圖片描述

在頁面上點擊詳情後的跳轉路徑如下圖所示:
在這裏插入圖片描述

  • web層
  @RequestMapping("/findById.do")
    public ModelAndView findById(@RequestParam(name = "id", required = true) String id) throws Exception {
        ModelAndView mv = new ModelAndView();
        Orders orders = ordersService.findById(id);
        mv.addObject("orders", orders);
        mv.setViewName("orders-show");
        return mv;

    }
  • service層
   @Override
    public Orders findById(String id) throws Exception {
        return ordersDao.findById(id);
    }
  • dao層
    如下圖所示,詳情頁面涉及到了三張表:product表、orders表、travellers表和members表,dao層三表聯合查詢
    在這裏插入圖片描述
    上述三張表的關係如下圖所示:
    在這裏插入圖片描述

dao層代碼

    @Select("select * from orders where id=#{id}")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "orderNum", property = "orderNum"),
            @Result(column = "orderTime", property = "orderTime"),
            @Result(column = "orderStatus", property = "orderStatus"),
            @Result(column = "peopleCount", property = "peopleCount"),
            @Result(column = "payType", property = "payType"),
            @Result(column = "orderDesc", property = "orderDesc"),
            @Result(column = "productId", property = "product", one = @One(select = "com.GTMStudio.admintelssm.dao.IProductDao.findById")),
            @Result(column = "id", property = "travellers", many = @Many(select = "com.GTMStudio.admintelssm.dao.ITravellerDao.findByOrdersId")),
            @Result(column = "memberId", property = "members",    one = @One(select = "com.GTMStudio.admintelssm.dao.IMemberDao.findById"))
    })
    Orders findById(String id);
    //根據id查詢產品
    @Select("select * from product where id=#{id}")
    public Product1 findById(String id) throws Exception;
    @Select("select * from traveller where id in(select travellerId from order_traveller where orderId=#{ordersId})")
    List<Traveller> findByOrdersId(String ordersId) throws Exception;
    @Select("select * from members where id=#{id}")
    Members findById(String id) throws Exception;


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章