少数派

作者: 不知所措的STRANGER | 来源:发表于2018-10-20 17:33 被阅读0次

少数派

1、整体效果

3.png

2、entity

@Data
public class Article {
    private String avatar;
    private String nickname;
    private String time;
    private String title;
    private String infoMessage;
    private String articleImg;
    private String attentionCount;
    private String messageCount;

    public Article() {

    }

    public Article(String avatar, String time,String nickname, String title, String infoMessage, String articleImg, String attentionCount, String messageCount) {
        this.avatar = avatar;
        this.time = time;
        this.nickname = nickname;
        this.title = title;
        this.infoMessage = infoMessage;
        this.articleImg = articleImg;
        this.attentionCount = attentionCount;
        this.messageCount = messageCount;
    }
}

3、dao

@Configuration
public class ArticleDAO {

    public  List<Article> getArticles(){
        Article[] articles = {
                new Article(
                        "https://cdn.sspai.com/user/136_1488222798404.jpg",
                        "09月03日",
                        "文刀漢三",
                        "成为身边人中「懂设计」的那一个",
                        "如果你没有接触过设计,想要提高点儿设计感,懂得一些「性价比高」的设计常识。这套教程将会是一个很好的开始。",
                        "https://cdn.sspai.com/article/eabe4534-26f9-a927-5b04-5d1f39cecbd9.jpg","137","39"),
                new Article(
                        "https://cdn.sspai.com/2017/12/26/18f38bad2b0724b4419b7e8bae24bd6e.jpg",
                        "两天前",
                        "少数派编辑部",
                        "一派 | 苹果秋季发布会你最期待什么新产品?",
                        "这一期的一派,少数派编辑们对下周的苹果秋季发布会谈了谈自己最期待的产品以及购置计划。同时我们也想听听大家的想法。",
                        "https://cdn.sspai.com/article/2dc0061b-a251-e8df-a24c-31c66204a981.jpg","25","250"),
                new Article(
                        "https://cdn.sspai.com/attachment/origin/2014/07/14/82455.jpg",
                        "两天前",
                        "化学性情下2",
                        "工作日让家中电脑不再闲置,其实你可以遥控它做很多事",
                        "如果打个小算盘你就会发现家中电脑的利用率低到令人发指的地步,那么怎么才能在工作日的时候让家中的电脑也能被充分利用起来呢?",
                        "https://cdn.sspai.com/article/0e1c925b-a32f-f056-d7d1-861f67226eca.jpg","65","42"),
                new Article(
                        "https://cdn.sspai.com/2018/06/07/ad1a9afa20cdbcf093680131480932d2.jpg",
                        "2天前",
                        "Adventure",
                        "5 种方法,在电脑和手机上告别百度搜索里的广告",
                        "百度上各种广告对用户搜索体验造成的不良影响已不是什么新鲜事。在这篇文章中,我将向大家介绍一些在电脑和手机上减少百度推广广告出现的方法,还你干净快捷的搜索体验。",
                        "https://cdn.sspai.com/article/4b52f103-4493-69f4-07c7-2feab9a4c70f.jpg","155","59"),
                new Article(
                        "https://cdn.sspai.com/avatar/f0a995804d04cc8a064e21110cb04210.jpg",
                        "09月05日",
                        "洛世",
                        "Chrome 在 10 周年之际发布了新版,除了好看还更安全",
                        "Google 在 Chrome 十周年之际向全平台推送了 Chrome 69 正式版的更新,为我们带来了采用全新设计的 Google material theme 主题,同时还新增了许多新功能,特别在安全性方面做出了很大的提升。",
                        "https://cdn.sspai.com/article/6adffdd2-2a2c-d67a-bd3c-a27e7268cd95.jpg","65","76")
        };

        List<Article> articleList = Arrays.asList(articles);
        return articleList;
    }

    public List<Topic> getTopics(){
        Topic[] topics = {
                new Topic(
                        "https://cdn.sspai.com/other/136_1490237571570.jpg",
                        "玩转 Workflow",
                        "Workflow是IOS上一款被称为[效率神器]的APP,它以直观的卡片形式..",
                        "2019"),
                new Topic(
                        "https://cdn.sspai.com/other/705956_1490770613690.jpg",
                        "提升效率之路",
                        "一个优秀的工具,能让你在提升效率之路上事半功倍。你是如何通过这些工具,技..",
                        "1548"),
                new Topic(
                        "https://cdn.sspai.com/other/718855_1493173455255.png",
                        "装了啥",
                        "你的手机装了哪些常见或小众的APP,他们如何帮你提高效率,给生活带来更多..",
                        "1238"),
                new Topic(
                        "https://cdn.sspai.com/article/e0ec4294-bbc4-fa76-39a8-4b12164a63c0.jpg",
                        "除了课本,你还可以在这些 App 中「涨姿势」",
                        "正值开学季,我为你们收集了一些应用,希望能让你无论在校园内外,都能再体验一次知识的趣味。",
                        "232"),
        };
        List<Topic> topicList = Arrays.asList(topics);
        return topicList;
    }
}

4、controller

@Controller
public class ArticleController {

    @Resource
    private ArticleDAO articleDAO;

    @GetMapping("article")
    public String getArticles(ModelMap map){
        List<Article> articles = articleDAO.getArticles();
        List<Topic> topics = articleDAO.getTopics();
        map.addAttribute("articles",articles);
        map.addAttribute("topics",topics);
        return "articles";
    }
}

相关文章

网友评论

    本文标题:少数派

    本文链接:https://www.haomeiwen.com/subject/mtnloftx.html