xinyb
2024-07-18 80430d52f7716e3eb3e517dc96f94c4a6f9657bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.yc.sdk.shopping.service;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
import org.springframework.context.annotation.Scope;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
 
import com.yc.action.grid.GridUtils;
import com.yc.sdk.shopping.entity.BannerEntity;
import com.yc.service.BaseService;
 
@Service("BannerImpl")
@Scope("prototype")
public class BannerImpl extends BaseService implements BannerIfc {
 
    @Override
    public List<BannerEntity> getBanners(String shopCcCode,String authorizationAppid) {
        String sql = " set nocount on ; \n"
                + " declare @ShopCcCode varchar(50) = "+GridUtils.prossSqlParm(shopCcCode)+" ,@AuthorizationAppid varchar(50) = "+GridUtils.prossSqlParm(authorizationAppid)+" \n"
                + " select a.BannerId,a.Title,a.Link,a.Image,a.ImageUrl,a.PathCode,b.PathUrl, \n"
                + " case when exists(select 1 from t720123 y where a.pathcode = y.pathcode and y.AuthorizationAppid = @AuthorizationAppid) then 1 else 0 end as isTabBarButton , \n"
                + " a.CoverImg,a.CoverImgUrl,a.isVideoFile \n"
                + " from t710306 a left join t730117 b on a.PathCode = b.PathCode \n "
                + " where ISNULL(a.Status,0) = 1 \n "
                + " and (isnull(@ShopCcCode,'') = '' or a.ShopCcCode = @ShopCcCode ) \n"
                + " order by a.SortOrder asc,a.BannerId asc ;" ;
        
        List<Map<String,Object>> list = null ;
        try {
            list = this.jdbcTemplate.queryForList(sql) ;
            List<BannerEntity> bannerList = new ArrayList<BannerEntity>() ;
            for (int i = 0 ; list != null && i < list.size();i++) {
                Map<String,Object> map = list.get(i) ;
                BannerEntity banner = new BannerEntity(); 
                banner.setBannerId(map.get("BannerId") == null ? null: (Integer)map.get("BannerId"));
                banner.setTitle(map.get("Title") == null ? "": (String)map.get("Title"));
                banner.setLink(map.get("Link") == null ? "": (String)map.get("Link"));
                banner.setImage(map.get("Image") == null ? "": (String)map.get("Image"));
                banner.setImageUrl(map.get("ImageUrl") == null ? "": (String)map.get("ImageUrl"));
                banner.setPathCode(map.get("PathCode") == null ? "": (String)map.get("PathCode"));
                banner.setPathUrl(map.get("PathUrl") == null ? "": (String)map.get("PathUrl"));
                banner.setTabBarButton(map.get("isTabBarButton")!=null&&map.get("isTabBarButton").equals(1)?true:false);
                banner.setCoverImg(map.get("CoverImg") == null ? "": (String)map.get("CoverImg"));
                banner.setCoverImgUrl(map.get("CoverImgUrl") == null ? "": (String)map.get("CoverImgUrl"));
                banner.setVideoFile(map.get("isVideoFile")!=null&&map.get("isVideoFile").equals(1)?true:false);
                bannerList.add(banner);
            }
        return bannerList;
        }catch(DataAccessException e ) {
            if (e instanceof EmptyResultDataAccessException){
                return null ;
            }else {
                e.printStackTrace();
                 throw e;
            }
        }catch(Exception e){
            e.printStackTrace();
            throw e;
        }
    }
 
}