• shop--10.前端展示系统--首页展示(后台)


     初始的首页

     首先获取首页中头条展示内容的List

    然后还要获取一级店铺类别,用来将店铺分类展示

    Dao层

    获取头条信息

    /**
         * 通过传入的查询条件,查询头条信息
         * @param headLineCondition
         * @return
         */
        List<HeadLine> queryHeadLine(@Param( "headLineCondition" ) HeadLine headLineCondition);
    

      

    <select id="queryHeadLine" resultType="com.shop.bean.HeadLine">
            SELECT
            line_id,
            line_name,
            line_link,
            line_img,
            priority,
            status,
            create_time,
            last_edit_time
            FROM
            head_line
            <where>
                <if test="headLineCondition.status != null">
                    and status=#{headLineCondition.status}
                </if>
            </where>
            ORDER BY
            priority DESC
        </select>
    

      

    获取店铺类别信息

    /**
         * 获取店铺类别
         * @param shopCategoryCondition
         * @return
         */
        List<ShopCategory> queryShopCategory(@Param("shopCategoryCondition") ShopCategory shopCategoryCondition);
    

      

    <select id="queryShopCategory" resultType="com.shop.bean.ShopCategory">
            SELECT
            shop_category_id,
            shop_category_name,
            shop_category_desc,
            shop_category_img,
            priority,
            create_time,
            last_edit_time,
            parent_id
            FROM shop_category
            <where>
                <if test="shopCategoryCondition == null">
                    AND parent_id IS NULL
                </if>
                <if test="shopCategoryCondition != null">
                    AND parent_id IS NOT NULL
                </if>
                <if test="shopCategoryCondition != null and shopCategoryCondition.parent != null">
                    AND parent_id = #{shopCategoryCondition.parent.shopCategoryId}
                </if>
            </where>
            ORDER BY
            priority DESC
        </select>
    

      

    Service层

    头条信息

    /**
         * 根据查询条件返回头条列表
         * @param headLineCondition
         * @return
         */
        List<HeadLine> getHeadLineList(HeadLine headLineCondition);
    

      

    public List<HeadLine> getHeadLineList(HeadLine headLineCondition) {
            return headLineDao.queryHeadLine( headLineCondition );
        }
    

      

    店铺类别

    /**
         * 根据查询条件获取店铺类别列表
         * @param shopCategoryCondition
         * @return
         */
        List<ShopCategory>getShopCategoryList(ShopCategory shopCategoryCondition);
    

      

    public List<ShopCategory> getShopCategoryList(ShopCategory shopCategoryCondition) {
            return shopCategoryDao.queryShopCategory( shopCategoryCondition );
        }
    

      

    Controller层

    /**
         * 初始化前端展示系统信息,包括一级店铺类别列表信息和头条列表
         * @return
         */
        @RequestMapping(value="/listmainpageinfo", method= RequestMethod.GET)
        @ResponseBody
        private Map<String, Object> listMainPageInfo(){
            Map<String, Object> modelMap = new HashMap<>();
    
            List<ShopCategory> shopCategoryList = new ArrayList<>();
    
            try{
                //传入null时(parentId为null),获取的时一级店铺类别
                shopCategoryList = shopCategoryService.getShopCategoryList( null );
                modelMap.put( "shopCategoryList", shopCategoryList );
            }catch(Exception e){
                modelMap.put( "success", false );
                modelMap.put( "errMsg", e.toString() );
                return modelMap;
            }
    
            List<HeadLine> headLineList = new ArrayList<>(  );
            try{
                //获取 status == 1 的头条列表,用于在首页的头条展示
                HeadLine headLineCondition = new HeadLine();
                headLineCondition.setStatus( 1 );
                headLineList = headLineService.getHeadLineList( headLineCondition );
                modelMap.put( "headLineList", headLineList );
            } catch(Exception e){
                modelMap.put( "success", false );
                modelMap.put( "errMsg", e.toString() );
                return modelMap;
            }
    
            modelMap.put( "success", true );
            return modelMap;
        }
    

      

  • 相关阅读:
    centos6.x 配置bond
    Js学习(2)
    Js学习(1)
    Java源码阅读计划(1) String<II>
    【461】汉明距离
    【617】合并二叉树
    Java源码阅读计划(1) String<I>
    Dubbo的高可用性
    Dubbo SpringBoot配置方法
    Dubbo基本配置属性
  • 原文地址:https://www.cnblogs.com/SkyeAngel/p/9010864.html
Copyright © 2020-2023  润新知