Commit a762a89e5de1b81322ac75763c979833d254eb09

Authored by qinkelan@diligrp.com
1 parent d46a5bd4

返回参数新增链接内容

etrade-admin/src/main/java/com/diligrp/etrade/admin/api/BannerApi.java
1 1 package com.diligrp.etrade.admin.api;
2 2  
3 3 import com.diligrp.etrade.admin.domain.req.BannerQuery;
4   -import com.diligrp.etrade.admin.model.Banner;
  4 +import com.diligrp.etrade.admin.domain.resp.BannerVo;
5 5 import com.diligrp.etrade.admin.service.BannerService;
6 6 import com.diligrp.etrade.admin.type.BannerDeleted;
7 7 import com.diligrp.etrade.admin.type.BannerState;
8 8 import com.diligrp.etrade.core.domain.Message;
9   -import kotlin.collections.EmptyList;
10 9 import org.slf4j.Logger;
11 10 import org.slf4j.LoggerFactory;
12 11 import org.springframework.beans.factory.annotation.Autowired;
13 12 import org.springframework.util.CollectionUtils;
14   -import org.springframework.web.bind.annotation.*;
  13 +import org.springframework.web.bind.annotation.GetMapping;
  14 +import org.springframework.web.bind.annotation.RequestMapping;
  15 +import org.springframework.web.bind.annotation.RequestParam;
  16 +import org.springframework.web.bind.annotation.RestController;
15 17  
16   -import java.util.Collections;
17 18 import java.util.List;
18 19  
19 20 /** 【小程序/APP】--轮播图接口
... ... @@ -36,14 +37,14 @@ public class BannerApi {
36 37 * @return: com.diligrp.etrade.core.domain.Message<?>
37 38 **/
38 39 @GetMapping(value = "/listByMarketId.api")
39   - public Message<List<Banner>> listByMarketId(@RequestParam Long marketId, Long bannerTypeId) {
  40 + public Message<List<BannerVo>> listByMarketId(@RequestParam Long marketId, Long bannerTypeId) {
40 41 try {
41 42 BannerQuery bannerQuery = new BannerQuery();
42 43 bannerQuery.setMarketId(marketId);
43 44 bannerQuery.setState(BannerState.ENABLE.getCode());
44 45 bannerQuery.setDeleted(BannerDeleted.NO.getCode());
45 46 bannerQuery.setBannerTypeId(bannerTypeId);
46   - List<Banner> bannerList = bannerService.listByMarketId(bannerQuery);
  47 + List<BannerVo> bannerList = bannerService.listByMarketId(bannerQuery);
47 48 return Message.success(bannerList);
48 49 }catch (Exception e){
49 50 LOG.error("获取轮播图失败:{}", e.getMessage());
... ... @@ -59,17 +60,17 @@ public class BannerApi {
59 60 * @return: com.diligrp.etrade.core.domain.Message<?>
60 61 **/
61 62 @GetMapping(value = "/listByMarketIdLimitTwo.api")
62   - public Message<List<Banner>> listByMarketIdLimitTwo(@RequestParam Long marketId, Long bannerTypeId) {
  63 + public Message<List<BannerVo>> listByMarketIdLimitTwo(@RequestParam Long marketId, Long bannerTypeId) {
63 64 try {
64 65 BannerQuery bannerQuery = new BannerQuery();
65 66 bannerQuery.setMarketId(marketId);
66 67 bannerQuery.setState(BannerState.ENABLE.getCode());
67 68 bannerQuery.setDeleted(BannerDeleted.NO.getCode());
68 69 bannerQuery.setBannerTypeId(bannerTypeId);
69   - List<Banner> bannerList = bannerService.listByMarketId(bannerQuery);
  70 + List<BannerVo> bannerList = bannerService.listByMarketId(bannerQuery);
70 71 if (!CollectionUtils.isEmpty(bannerList) && bannerList.size()>2){
71 72 //如果轮播图大于2张,就取前2张;
72   - List<Banner> bannerTwo = bannerList.subList(0, 2);
  73 + List<BannerVo> bannerTwo = bannerList.subList(0, 2);
73 74 return Message.success(bannerTwo);
74 75 }else {
75 76 return Message.success(bannerList);
... ...
etrade-admin/src/main/java/com/diligrp/etrade/admin/dao/BannerMapper.java
1 1 package com.diligrp.etrade.admin.dao;
2 2  
3 3 import com.diligrp.etrade.admin.domain.req.BannerQuery;
  4 +import com.diligrp.etrade.admin.domain.resp.BannerVo;
4 5 import com.diligrp.etrade.admin.model.Banner;
5 6 import com.diligrp.etrade.core.mybatis.MybatisMapperSupport;
6 7 import org.springframework.stereotype.Repository;
... ... @@ -28,5 +29,5 @@ public interface BannerMapper extends MybatisMapperSupport {
28 29 **/
29 30 List<Banner> listPage(BannerQuery bannerQuery);
30 31  
31   - List<Banner> listByMarketId(BannerQuery bannerQuery);
  32 + List<BannerVo> listByMarketId(BannerQuery bannerQuery);
32 33 }
33 34 \ No newline at end of file
... ...
etrade-admin/src/main/java/com/diligrp/etrade/admin/service/BannerService.java
... ... @@ -28,7 +28,7 @@ public interface BannerService {
28 28 * @param: [bannerQuery]
29 29 * @return: java.util.List<com.diligrp.etrade.admin.domain.resp.BannerVo>
30 30 **/
31   - List<Banner> listByMarketId(BannerQuery bannerQuery);
  31 + List<BannerVo> listByMarketId(BannerQuery bannerQuery);
32 32  
33 33 /**
34 34 * @description: 通过ID查询记录
... ...
etrade-admin/src/main/java/com/diligrp/etrade/admin/service/impl/BannerServiceImpl.java
... ... @@ -81,8 +81,8 @@ public class BannerServiceImpl implements BannerService {
81 81 }
82 82  
83 83 @Override
84   - public List<Banner> listByMarketId(BannerQuery bannerQuery) {
85   - List<Banner> bannerList = bannerMapper.listByMarketId(bannerQuery);
  84 + public List<BannerVo> listByMarketId(BannerQuery bannerQuery) {
  85 + List<BannerVo> bannerList = bannerMapper.listByMarketId(bannerQuery);
86 86 if (CollectionUtils.isEmpty(bannerList)) {
87 87 return Collections.emptyList();
88 88 }
... ...
etrade-admin/src/main/resources/com/diligrp/etrade/dao/mapper/BannerMapper.xml
... ... @@ -268,20 +268,24 @@
268 268 </select>
269 269  
270 270 <!-- 根据市场查询 -->
271   - <select id="listByMarketId" resultType="com.diligrp.etrade.admin.model.Banner">
272   - select <include refid="Base_Column_List"/>
273   - from banner
  271 + <select id="listByMarketId" resultType="com.diligrp.etrade.admin.domain.resp.BannerVo">
  272 + select
  273 + b.id, b.created_time, b.modified_time, b.creater_id, b.creater, b.modifier_id, b.modifier, b.sort,
  274 + b.banner_type_id, b.title, b.pic_url, b.link_type, b.link, b.remark, b.`state`, b.market_id, b.deleted, b.version,
  275 + bc.content, bc.pic_url as linkPicUrl
  276 + from banner b
  277 + left join banner_content bc on b.id = bc.banner_id
274 278 where 1=1
275 279 <if test="state != null">
276   - and state = #{state}
  280 + and b.state = #{state}
277 281 </if>
278 282 <if test="deleted != null">
279   - and deleted = #{deleted}
  283 + and b.deleted = #{deleted}
280 284 </if>
281 285 <if test="bannerTypeId != null">
282   - and banner_type_id = #{bannerTypeId}
  286 + and b.banner_type_id = #{bannerTypeId}
283 287 </if>
284   - and market_id=#{marketId,jdbcType=BIGINT}
  288 + and b.market_id=#{marketId,jdbcType=BIGINT}
285 289 ORDER BY sort ASC
286 290 </select>
287 291  
... ...