首页模块设计(个人博客)

首页模块设计(个人博客)

首页模块设计(个人博客)
首页模块设计(个人博客)

一、编写dao层

二、绑定mapper配置文件

三、编写service层

四、编写controller层

@RequestMapping("/")
public String index(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum, Model model) {
    PageHelper.startPage(pageNum,4);
    List<Article> articles = articleService.queryArticles();
    PageInfo<Article> pageInfo = new PageInfo<>(articles);
    model.addAttribute("pageInfo",pageInfo);
    List<Category> categories = categoryService.allCategories();
    model.addAttribute("types",categories);
    model.addAttribute("count",articleService.countArt());
    return "index";
}

五、绑定前端页面

					<div class="ui attached segment">

                        <div class="ui vertical m-padded-wide-mini m-padded-tb-large segment">
                            <div class="ui mobile reversed stackable grid" th:each="article:${pageInfo.list}">
                                <div class="eleven wide column">
                                    <h3 class="ui header" th:text="${article.title}">我真的放下了吗?</h3>
                                    <p class="m-text" th:text="${article.content}">说实话已经一个月过去了,我还是会想起很多的事情,内心无比的压抑,也还是会半夜醒来,我知道我应该走出来,高兴一天是一天难过一天也是一天,但是真的很难做到....</p>
                                    <div class="ui grid">
                                        <div class="eleven wide column">
                                            <div class="ui mini horizontal link list">
                                                <div class="item">
                                                    <img src="https://picsum.photos/100/100?image=1005" alt="" class="ui avatar image">
                                                    <div class="content"><a href="#" class="header" th:text="${article.author.getNickname()}">B先生</a></div>
                                                </div>
                                                <div class="item">
                                                    <i class="calendar alternate icon"></i> [[${article.createdAt}]]
                                                </div>
                                                <div class="item">
                                                    <i class="eye icon"></i> [[${article.viewCount}]]
                                                </div>
                                            </div>
                                        </div>
                                        <div class="right aligned five wide column">
                                            <a th:href="@{/detail/{id}(id=${article.id})}" target="_blank" class="ui teal basic label m-padded-tiny m-text-thin">认知升级</a>
                                        </div>
                                    </div>
                                </div>
                                <div class="five wide column">
                                    <a href="#" target="_blank">
                                        <img src="https://picsum.photos//800/450?image=1005" alt="" class="ui rounded image">
                                    </a>
                                </div>

                            </div>
                        </div>

                    </div>
上一篇:Mybatis之应用场景


下一篇:PageHelper Springboot