Browse Source

微信小程序banner生成

XMTT 7 years ago
parent
commit
a9f136b1f4

+ 29 - 3
src/main/java/com/ekexiu/console/system/service/DiscoverBannerService.java

@ -115,6 +115,30 @@ public class DiscoverBannerService {
115 115
            "    <div class=\"mui-indicator\"></div>\n" +
116 116
            "    <div class=\"mui-indicator\"></div>\n" +
117 117
            "</div>";
118
    private String templateWx = "{\n" +
119
            "  \"success\": true,\n" +
120
            "  \"data\": [\n" +
121
            "    <#list banner as banner>\n" +
122
            "    <#if banner_has_next>\n" +
123
            "    {\n" +
124
            "      \"articleId\": \"${banner.articleId}\",\n" +
125
            "      \"title\": \"${banner.title}\",\n" +
126
            "      \"image\": \"${banner.image}\",\n" +
127
            "      \"banner\":\"${banner.banner}\",\n" +
128
            "      \"bannerId\":\"${banner.bannerId}\"\n" +
129
            "    },\n" +
130
            "    <#else>\n" +
131
            "    {\n" +
132
            "      \"articleId\": \"${banner.articleId}\",\n" +
133
            "      \"title\": \"${banner.title}\",\n" +
134
            "      \"image\": \"${banner.image}\",\n" +
135
            "      \"banner\":\"${banner.banner}\",\n" +
136
            "      \"bannerId\":\"${banner.bannerId}\"\n" +
137
            "    }\n" +
138
            "    </#if>\n" +
139
            "    </#list>\n" +
140
            "  ]\n" +
141
            "}";
118 142
    @Autowrie
119 143
    private DiscoverBannerDao discoverBannerDao;
120 144
    @Autowrie
@ -252,6 +276,7 @@ public class DiscoverBannerService {
252 276
        StringTemplateLoader stringLoader = new StringTemplateLoader();
253 277
        stringLoader.putTemplate("slideTab.html", templatePc);
254 278
        stringLoader.putTemplate("appfound.html", templateApp);
279
        stringLoader.putTemplate("wxfound",templateWx);
255 280
        Configuration cfg = templateService.getCfg();
256 281
        cfg.setTemplateLoader(stringLoader);
257 282
        this.discoverBannerDao.end(con);
@ -269,6 +294,7 @@ public class DiscoverBannerService {
269 294
            //this.genCnt("appfound.html", new File(generatePath+"/col_bannerApp.html"), root);
270 295
            templateService.genCnt(cfg,"slideTab.html", new File(generatePath+"/col_banner.html"), root);
271 296
            templateService.genCnt(cfg,"appfound.html", new File(generatePath+"/col_bannerApp.html"), root);
297
            templateService.genCnt(cfg,"wxfound", new File(generatePath+"/col_bannerApp.json"), root);
272 298
        } catch (IOException | TemplateException e) {
273 299
            e.printStackTrace();
274 300
        }
@ -298,15 +324,15 @@ public class DiscoverBannerService {
298 324
        if (Objects.equals(banner, 1) || Objects.equals(banner, 2)) {
299 325
            return "原创";
300 326
        } else if (Objects.equals(banner, 3)) {
301
            return "前沿";
327
            return "科研";
302 328
        } else if (Objects.equals(banner, 4)) {
303
            return "经验";
329
            return "智库";
304 330
        } else if (Objects.equals(banner, 5)) {
305 331
            return "检测";
306 332
        } else if (Objects.equals(banner, 6)) {
307 333
            return "会议";
308 334
        } else if (Objects.equals(banner, 7)) {
309
            return "访谈";
335
            return "企业";
310 336
        } else if (Objects.equals(banner, 8)) {
311 337
            return "招聘";
312 338
        } else if (Objects.equals(banner, 9)) {