Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
mall
Commits
25cc88c6
Commit
25cc88c6
authored
Jan 29, 2019
by
zhh
Browse files
首页接口完善
parent
7d80b432
Changes
3
Hide whitespace changes
Inline
Side-by-side
mall-portal/src/main/java/com/macro/mall/portal/dao/HomeDao.java
View file @
25cc88c6
package
com.macro.mall.portal.dao
;
import
com.macro.mall.model.CmsSubject
;
import
com.macro.mall.model.PmsBrand
;
import
com.macro.mall.model.PmsProduct
;
import
com.macro.mall.portal.domain.FlashPromotionProduct
;
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
<
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
);
}
mall-portal/src/main/java/com/macro/mall/portal/service/impl/HomeServiceImpl.java
View file @
25cc88c6
...
...
@@ -38,9 +38,15 @@ public class HomeServiceImpl implements HomeService {
//获取首页广告
result
.
setAdvertiseList
(
getHomeAdvertiseList
());
//获取推荐品牌
result
.
setBrandList
(
homeDao
.
getRecommendBrand
(
));
result
.
setBrandList
(
homeDao
.
getRecommendBrand
List
(
0
,
4
));
//获取秒杀信息
result
.
setHomeFlashPromotion
(
getHomeFlashPromotion
());
//获取新品推荐
result
.
setNewProductList
(
homeDao
.
getNewProductList
(
0
,
4
));
//获取人气推荐
result
.
setHotProductList
(
homeDao
.
getHotProductList
(
0
,
4
));
//获取推荐专题
result
.
setSubjectList
(
homeDao
.
getRecommendSubjectList
(
0
,
4
));
return
result
;
}
...
...
mall-portal/src/main/resources/dao/HomeDao.xml
View file @
25cc88c6
<?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">
<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"
>
<result
column=
"flash_promotion_price"
property=
"flashPromotionPrice"
/>
<result
column=
"flash_promotion_count"
property=
"flashPromotionCount"
/>
<result
column=
"flash_promotion_limit"
property=
"flashPromotionLimit"
/>
<resultMap
id=
"flashPromotionProduct"
type=
"com.macro.mall.portal.domain.FlashPromotionProduct"
extends=
"com.macro.mall.mapper.PmsProductMapper.BaseResultMap"
>
<result
column=
"flash_promotion_price"
property=
"flashPromotionPrice"
/>
<result
column=
"flash_promotion_count"
property=
"flashPromotionCount"
/>
<result
column=
"flash_promotion_limit"
property=
"flashPromotionLimit"
/>
</resultMap>
<select
id=
"getRecommendBrand"
resultMap=
"com.macro.mall.mapper.PmsBrandMapper.BaseResultMap"
>
SELECT
p
b.*
<select
id=
"getRecommendBrandList"
resultMap=
"com.macro.mall.mapper.PmsBrandMapper.BaseResultMap"
>
SELECT
b.*
FROM
sms_home_brand hb
LEFT JOIN pms_brand pb ON hb.brand_id = pb.id
AND recommend_status = 1
LEFT JOIN pms_brand b ON hb.brand_id = b.id
WHERE
hb.recommend_status = 1
AND b.show_status = 1
ORDER BY
hb.sort DESC
LIMIT #{offset}, #{limit}
</select>
<select
id=
"getFlashProductList"
resultMap=
"flashPromotionProduct"
>
SELECT
pr.flash_promotion_price,
...
...
@@ -29,4 +34,43 @@
pr.flash_promotion_id = #{flashPromotionId}
AND pr.flash_promotion_session_id = #{sessionId}
</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>
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment