作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
本系统是一个个人博客的管理系统,用户可以注册账号并登陆系统查看发布的文章并进行阅读评论等
本系统主要有三种用户:
1、游客角色主要功能:
没有登陆的用户,可以查询文章,但是无法进行评论,系统中的所有文章可以通过内容搜索,可以通过分类搜索也可以通过标签就行搜索
2、注册用户主要功能
可以对所有的文章进行阅读以及评论等功能,可以对文章进行赞赏(支付宝或者微信付钱)
3、管理员主要功能:
拥有注册用户的所有权限,管理分类以及发布文章和管理标签等,友链管理,时间轴管理等
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7版本;
5.是否Maven项目:是;
SpringBoot+SpringSecurity+Mybatis+Mysql+Redis+Thymeleaf+JQuery
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,项目运行成功后,访问地址localhost:8080
管理员账号密码:zhangpeng98@aliyun.com/mt2680324
用户账号密码:zhangpeng@aliyun.com/mt2680324
- @Controller("adminUserController")
- @RequestMapping("/admin/user")
- public class AdminUserController {
- @Autowired
- private UserService userService;
-
- @Autowired
- private RoleService roleService;
-
- @RequestMapping("/showAll")
- public String showAll(@RequestParam(name = "pageNum", required = false, defaultValue = "1") Integer pageNum,
- @RequestParam(name = "pageSize", required = false, defaultValue = "2") Integer pageSize,
- @RequestParam(name = "email", required = false, defaultValue = "") String email, Model model) {
-
- show (pageNum, pageSize, email, model);
- return "admin/users";
- }
-
- public void show(Integer pageNum, Integer pageSize, String email, Model model){
- List<UserInfo> userInfos = userService.selectAll (pageNum, pageSize, email);
- PageInfo<UserInfo> pageInfo = new PageInfo<> (userInfos,8);
- model.addAttribute ("pageInfo",pageInfo);
- model.addAttribute ("email",email);
- }
-
- @RequestMapping("/showAll/search")
- public String search(@RequestParam(name = "pageNum", required = false, defaultValue = "1") Integer pageNum,
- @RequestParam(name = "pageSize", required = false, defaultValue = "2") Integer pageSize,
- @RequestParam(name = "email", required = false, defaultValue = "") String email, Model model) {
-
- show (pageNum, pageSize, email, model);
- return "admin/users :: userList";
- }
-
- @RequestMapping("/updateStatus")
- public String updateStatus(String email, RedirectAttributes attributes) {
- UserInfo userInfo = userService.findByEmail (email);
- Boolean status = userInfo.getStatus ();
-
- try {
- userService.updateStatus (email, !status);
- attributes.addFlashAttribute ("message","状态修改成功!");
- } catch (Exception e) {
- attributes.addFlashAttribute ("message","状态修改失败,服务器异常!");
- e.printStackTrace ();
- }
-
- return "redirect:showAll";
- }
- }
- @Controller
- @RequestMapping("/admin/type")
- public class AdminTypeController {
-
- @Autowired
- private TypeService typeService;
-
- @RequestMapping("/showAll")
- public ModelAndView showAll(@RequestParam(name = "pageNum", required = false, defaultValue = "1") Integer pageNum,
- @RequestParam(name = "pageSize", required = false, defaultValue = "5") Integer pageSize,
- @RequestParam(name = "name", required = false, defaultValue = "") String name){
- ModelAndView mv = new ModelAndView ();
-
- //调用service层获取数据
- List<Type> types = typeService.selectAllByLikeName (pageNum, pageSize, name);
- //使用pageInfo包装查询后的结果,封装了详细的查询数据,其中参数5是页码导航连续显示的页数
- PageInfo<Type> pageInfo = new PageInfo<> (types,5);
-
- mv.addObject ("pageInfo",pageInfo);
- mv.addObject ("name",name);
- mv.setViewName ("admin/types");
-
- return mv;
- }
-
- @RequestMapping("/toAdd")
- public String toAdd(Model model){
- model.addAttribute ("type",new Type ());
- return "admin/types-input";
- }
-
- @RequestMapping("/add")
- public String add(@Valid Type type, BindingResult result, RedirectAttributes attributes){
-
- Type type1 = typeService.selectByName (type.getName ());
- if (type1 != null){
- result.rejectValue ("name","nameError","不能添加重复的类别名称");
- }
-
- if (result.hasErrors ()){
- return "admin/types-input";
- }
-
- //调用service层保存类别
- Boolean save = typeService.save (type);
-
- if (save){
- attributes.addFlashAttribute ("message","添加成功!");
- } else {
- attributes.addFlashAttribute ("message","添加失败!");
- }
-
- return "redirect:showAll";
- }
-
-
- @RequestMapping("/toUpdate")
- public ModelAndView toUpdate(Integer id){
- ModelAndView mv = new ModelAndView ();
-
- Type type = typeService.selectById (id);
-
- mv.addObject ("type",type);
- mv.setViewName ("admin/types-update");
- return mv;
- }
-
- @RequestMapping("/update")
- public String update(@Valid Type type, BindingResult result, RedirectAttributes attributes){
-
- Type type1 = typeService.selectByName (type.getName ());
- if (type1 != null){
- result.rejectValue ("name","nameError","该类别名称已存在,不能修改!");
- }
-
- if (result.hasErrors ()){
- return "admin/types-update";
- }
-
- Boolean update = typeService.update (type);
- if (update){
- attributes.addFlashAttribute ("message","修改成功!");
- } else {
- attributes.addFlashAttribute ("message","修改失败!");
- }
-
- return "redirect:showAll";
- }
-
-
- @RequestMapping("/deleteById")
- public String deleteById(Integer id, RedirectAttributes attributes){
-
- //调用service层删除类别
- Boolean aBoolean = typeService.deleteById (id);
- if (aBoolean){
- attributes.addFlashAttribute ("message","删除成功!");
- } else {
- attributes.addFlashAttribute ("message","删除失败,有博客是该类别!");
- }
-
- return "redirect:showAll";
- }
- }
如果也想学习本系统,下面领取。回复:098springboot