首页接口完善

This commit is contained in:
zhh 2019-01-29 10:05:33 +08:00
parent 7d80b4329a
commit 25cc88c64e
3 changed files with 78 additions and 11 deletions

View File

@ -1,6 +1,8 @@
package com.macro.mall.portal.dao; package com.macro.mall.portal.dao;
import com.macro.mall.model.CmsSubject;
import com.macro.mall.model.PmsBrand; import com.macro.mall.model.PmsBrand;
import com.macro.mall.model.PmsProduct;
import com.macro.mall.portal.domain.FlashPromotionProduct; import com.macro.mall.portal.domain.FlashPromotionProduct;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -15,9 +17,24 @@ public interface HomeDao {
/** /**
* 获取推荐品牌 * 获取推荐品牌
*/ */
List<PmsBrand> getRecommendBrand(); List<PmsBrand> getRecommendBrandList(@Param("offset") Integer offset,@Param("limit") Integer limit);
/** /**
* 获取秒杀商品 * 获取秒杀商品
*/ */
List<FlashPromotionProduct> getFlashProductList(@Param("flashPromotionId") Long flashPromotionId, @Param("sessionId") Long sessionId); List<FlashPromotionProduct> getFlashProductList(@Param("flashPromotionId") Long flashPromotionId, @Param("sessionId") Long sessionId);
/**
* 获取新品推荐
*/
List<PmsProduct> getNewProductList(@Param("offset") Integer offset,@Param("limit") Integer limit);
/**
* 获取人气推荐
*/
List<PmsProduct> getHotProductList(@Param("offset") Integer offset,@Param("limit") Integer limit);
/**
* 获取推荐专题
*/
List<CmsSubject> getRecommendSubjectList(@Param("offset") Integer offset, @Param("limit") Integer limit);
} }

View File

@ -38,9 +38,15 @@ public class HomeServiceImpl implements HomeService {
//获取首页广告 //获取首页广告
result.setAdvertiseList(getHomeAdvertiseList()); result.setAdvertiseList(getHomeAdvertiseList());
//获取推荐品牌 //获取推荐品牌
result.setBrandList(homeDao.getRecommendBrand()); result.setBrandList(homeDao.getRecommendBrandList(0,4));
//获取秒杀信息 //获取秒杀信息
result.setHomeFlashPromotion(getHomeFlashPromotion()); result.setHomeFlashPromotion(getHomeFlashPromotion());
//获取新品推荐
result.setNewProductList(homeDao.getNewProductList(0,4));
//获取人气推荐
result.setHotProductList(homeDao.getHotProductList(0,4));
//获取推荐专题
result.setSubjectList(homeDao.getRecommendSubjectList(0,4));
return result; return result;
} }

View File

@ -1,21 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.macro.mall.portal.dao.HomeDao"> <mapper namespace="com.macro.mall.portal.dao.HomeDao">
<resultMap id="flashPromotionProduct" type="com.macro.mall.portal.domain.FlashPromotionProduct" extends="com.macro.mall.mapper.PmsProductMapper.BaseResultMap"> <resultMap id="flashPromotionProduct" type="com.macro.mall.portal.domain.FlashPromotionProduct"
<result column="flash_promotion_price" property="flashPromotionPrice" /> extends="com.macro.mall.mapper.PmsProductMapper.BaseResultMap">
<result column="flash_promotion_count" property="flashPromotionCount" /> <result column="flash_promotion_price" property="flashPromotionPrice"/>
<result column="flash_promotion_limit" property="flashPromotionLimit" /> <result column="flash_promotion_count" property="flashPromotionCount"/>
<result column="flash_promotion_limit" property="flashPromotionLimit"/>
</resultMap> </resultMap>
<select id="getRecommendBrand" resultMap="com.macro.mall.mapper.PmsBrandMapper.BaseResultMap">
SELECT <select id="getRecommendBrandList" resultMap="com.macro.mall.mapper.PmsBrandMapper.BaseResultMap">
pb.* SELECT b.*
FROM FROM
sms_home_brand hb sms_home_brand hb
LEFT JOIN pms_brand pb ON hb.brand_id = pb.id LEFT JOIN pms_brand b ON hb.brand_id = b.id
AND recommend_status = 1 WHERE
hb.recommend_status = 1
AND b.show_status = 1
ORDER BY ORDER BY
hb.sort DESC hb.sort DESC
LIMIT #{offset}, #{limit}
</select> </select>
<select id="getFlashProductList" resultMap="flashPromotionProduct"> <select id="getFlashProductList" resultMap="flashPromotionProduct">
SELECT SELECT
pr.flash_promotion_price, pr.flash_promotion_price,
@ -29,4 +34,43 @@
pr.flash_promotion_id = #{flashPromotionId} pr.flash_promotion_id = #{flashPromotionId}
AND pr.flash_promotion_session_id = #{sessionId} AND pr.flash_promotion_session_id = #{sessionId}
</select> </select>
<select id="getNewProductList" resultMap="com.macro.mall.mapper.PmsProductMapper.BaseResultMap">
SELECT p.*
FROM
sms_home_new_product hp
LEFT JOIN pms_product p ON hp.product_id = p.id
WHERE
hp.recommend_status = 1
AND p.publish_status = 1
ORDER BY
hp.sort DESC
LIMIT #{offset}, #{limit};
</select>
<select id="getHotProductList" resultMap="com.macro.mall.mapper.PmsProductMapper.BaseResultMap">
SELECT p.*
FROM
sms_home_recommend_product hp
LEFT JOIN pms_product p ON hp.product_id = p.id
WHERE
hp.recommend_status = 1
AND p.publish_status = 1
ORDER BY
hp.sort DESC
LIMIT #{offset}, #{limit};
</select>
<select id="getRecommendSubjectList" resultMap="com.macro.mall.mapper.CmsSubjectMapper.BaseResultMap">
SELECT s.*
FROM
sms_home_recommend_subject hs
LEFT JOIN cms_subject s ON hs.subject_id = s.id
WHERE
hs.recommend_status = 1
AND s.show_status = 1
ORDER BY
hs.sort DESC
LIMIT #{offset}, #{limit};
</select>
</mapper> </mapper>