少数派其中代码

Card:

@Data

public class Card{

private StringimgLink;

private Stringcalled;

private  Stringnumber;

public Card(){

}

public Card(String imgLink,String called,String  number){

this.imgLink=imgLink;

    this.called=called;

    this.number=number;

  }

}

Pai:

@Data

public class Pai {

private Stringtitle;

    private Stringpic;

    private Stringnumber;

    public Pai(){

}

public Pai(String pic,String title,String number){

this.pic=pic;

this.title=title;

this.number=number;

    }

}

Logo:

@Data

public class Logo {

private Stringlogo;

private Stringname;

}



Controller:

@Controller

public class PaiController {

@Resource

    private PaiDaopaiDao;

@GetMapping("pai")

public StringgetAll(ModelMap map) {

List paiList =paiDao.getPais();

    ListcardList=paiDao.getCards();

    User user =paiDao.getUser();

    Logo logo=paiDao.getLogo();

    map.addAttribute("cardList",cardList);

    map.addAttribute("paiList", paiList);

    map.addAttribute("user", user);

    map.addAttribute("logo",logo);

    return  "pai";

}

}



Dao:

@Configuration

@Data

public class PaiDao {

public ListgetPais(){

Pai[] pais={

new Pai("777.png","少数派带你看苹晚 2018","2篇文章"),

                new Pai("3.png","青年居家生活指南","6篇文章"),

                new Pai("2.png","给现代人的护眼小技巧","5篇文章"),

        };

        ListpaiList= Arrays.asList(pais);

        return paiList;

    }

public ListgetCards(){

Card[] cards={

new Card("777.png","少数派带你看苹晚 2018","7篇文章"),

                new Card("12.png","青年生活居家指南","13篇文章"),

                new Card("13.png","国产游戏独立之光","19篇文章"),

                new Card("24.png","Windows美化手册","15篇文章"),

                new Card("17.png","把Mac菜单栏变成工具箱","14篇文章"),

                new Card("14.png","嘿Sir,你能帮我做什么","10篇文章"),

                new Card("15.png","Android玩机指南","15篇文章"),

                new Card("23.png","文件传输,有这些就够了","13篇文章"),

                new Card("16.png","少数派带你看WWDC 2018","28篇文章"),

                new Card("18.png","玩转二维码","16篇文章"),

                new Card("21.png","GIF还能这么玩","11篇文章"),

                new Card("22.png","旧设备换新手机","19篇文章"),

        };

        ListcardList= Arrays.asList(cards);

        return cardList;

    }

public UsergetUser(){

User user=new User();

        user.setAvatar("bai.jpg");

        return user;

    }

public LogogetLogo(){

Logo logo=new Logo();

        logo.setLogo("pai.png");

        logo.setName("少数派");

        return logo;

    }

}

你可能感兴趣的:(少数派其中代码)