【SpringBoot搭建个人博客】- 其他页面显示,kafka架构图

import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**

  • @Description: 分类页面控制器

  • @Date: Created in 10:03 2020/6/24

  • @Author: ONESTAR

  • @QQ群: 530311074

  • @URL: https://onestar.newstar.net.cn/

*/

@Controller

public class TypeShowController {

@Autowired

private TypeService typeService;

@Autowired

private BlogService blogService;

// 分页查询分类

@GetMapping("/types/{id}")

public String types(@RequestParam(defaultValue = “1”,value = “pageNum”) Integer pageNum, @PathVariable Long id, Model model) {

List types = typeService.getAllTypeAndBlog();

//id为-1表示从首页导航栏点击进入分类页面

if (id == -1) {

id = types.get(0).getId();

}

model.addAttribute(“types”, types);

List blogs = blogService.getByTypeId(id);

PageHelper.startPage(pageNum, 10000);

PageInfo pageInfo = new PageInfo<>(blogs);

model.addAttribute(“pageInfo”, pageInfo);

model.addAttribute(“activeTypeId”, id);

return “types”;

}

}

讲解:

{id}:当id为-1时,表示从首页导航栏进入分类页面,默认第一个分类显示颜色

getAllTypeAndBlog:查询分类名称和博客信息,前端统计出该分类下博客数量

getByTypeId:查询博客列表

5. 前后端交互

  • 分类统计

好文

22
  • 分类列表

大圣,此去欲何?

戴上金箍,没法爱你;放下金箍,没法保护你。我知道上天不会给我第二次机会,曾经我们说好的永远,原来也仅仅只有,十二画,而已。“大圣,此去欲何?”“踏南天,碎凌霄。”“若一去不回……”“便一去不回” 其实很多时候,我们都是有机会的,最后真正放弃的,是我们自己。......

2020-01-01

2222

2222

好文

  • 分页显示

上一页

/

下一页

6. 运行访问

运行项目,访问 http://localhost:8080/ ,点击导航栏的分类,可以看到分类信息和分类博客列表

二、时间轴页面显示

时间轴页面显示只要显示博客标题和时间,因此可以直接共用BlogDao中的持久层接口getAllBlog,只需要编写控制层代码即可,在controller包下创建ArchiveShowController类:

package com.star.controller;

import com.star.queryvo.BlogQuery;

import com.star.service.BlogService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.ui.Model;

import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**

  • @Description: 时间轴页面显示控制器

  • @Date: Created in 17:40 2020/6/27

  • @Author: ONESTAR

  • @QQ群: 530311074

  • @URL: https://onestar.newstar.net.cn/

*/

@Controller

public class ArchiveShowController {

@Autowired

private BlogService blogService;

@GetMapping("/archives")

public String archive(Model model){

List blogs = blogService.getAllBlog();

model.addAttribute(“blogs”, blogs);

return “archives”;

}

}

  • 前后端交互
  • 文章标题

    • 运行访问 运行项目,访问 http://localhost:8080/ ,点击导航栏的时间轴,可以看到阶梯状左右分布、按照时间顺序排布的文章列表

    三、音乐盒页面显示

    音乐盒是一个静态页面,直接在控制器中返回页面就可以了

    package com.star.controller;

    import org.springframework.stereotype.Controller;

    import org.springframework.web.bind.annotation.GetMapping;

    /**

    • @Description: 音乐盒页面显示控制器

    • @Date: Created in 20:59 2020/6/27

    • @Author: ONESTAR

    • @QQ群: 530311074

    • @URL: https://onestar.newstar.net.cn/

    */

    @Controller

    public class MusicShowController {

    @GetMapping("/music")

    public String about() {

    return “music”;

    }

    }

    四、友人帐页面显示

    友人帐前端页面显示直接调用持久层的listFriendLink接口,只需编写

    《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》

    【docs.qq.com/doc/DSmxTbFJ1cmN1R2dB】 完整内容开源分享

    控制层代码就可以了,在controller包下创建FriendsShowController类:

    package com.star.controller;

    import com.star.service.FriendLinkService;

    import org.springframework.beans.factory.annotation.Autowired;

    import org.springframework.stereotype.Controller;

    import org.springframework.ui.Model;

    import org.springframework.web.bind.annotation.GetMapping;

    /**

    • @Description: 友链显示控制器

    • @Date: Created in 21:12 2020/6/27

    • @Author: ONESTAR

    • @QQ群: 530311074

    • @URL: https://onestar.newstar.net.cn/

    */

    @Controller

    public class FriendsShowController {

    @Autowired

    private FriendLinkService friendLinkService;

    @GetMapping("/friends")

    public String friends(Model model) {

    model.addAttribute(“friendlinks”,friendLinkService.listFriendLink());

    return “friends”;

    }

    }

    • 前后端交互
    ONESTAR
    • 运行访问

    运行项目,访问 http://localhost:8080/ ,点击导航栏的友人帐,可以查看友链信息:

    五、照片墙页面显示

    照片墙页面显示直接调用持久层的listPicture接口,只需编写控制层代码就可以了,在controller包下创建PictureShowController类:

    package com.star.controller;

    import com.star.service.PictureService;

    import org.springframework.beans.factory.annotation.Autowired;

    import org.springframework.stereotype.Controller;

    import org.springframework.ui.Model;

    import org.springframework.web.bind.annotation.GetMapping;

    /**

    • @Description: 照片墙页面显示控制器

    • @Date: Created in 22:08 2020/6/27

    • @Author: ONESTAR

    • @QQ群: 530311074

    • @URL: https://onestar.newstar.net.cn/

    */

    @Controller

    public class PictureShowController {

    @Autowired

    private PictureService pictureService;

    @GetMapping("/picture")

    public String friends(Model model) {

    model.addAttribute(“pictures”,pictureService.listPicture());

    return “picture”;

    }

    }

    • 前后端交互
    起风了
    起风了
    2020-02-02  深圳

    我曾难自拔于世界之大,也沉迷于其中梦话

    • 运行访问

    运行项目,访问 http://localhost:8080/ ,点击导航栏的照片墙,点击照片,可以查看照片信息:

    六、关于我页面显示

    关于我页面显示是一个静态页面,直接在控制器中返回页面就可以了

    package com.star.controller;

    import org.springframework.stereotype.Controller;

    import org.springframework.web.bind.annotation.GetMapping;

    /**

    • @Description: 关于我界面显示控制器

    • @Date: Created in 23:26 2020/6/27

    • @Author: ONESTAR

    • @QQ群: 530311074

    • @URL: https://onestar.newstar.net.cn/

    */

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值