内容管理系统

内容管理系统,第1张


文章目录
  • 一:作业要求
    • 1:要求
    • 2:提炼功能
    • 3.数据库设计
    • 4:前端展示
  • 二:功能展示
    • 1:登录
    • 2:登录首页
    • 3:文章类别管理
      • (1):修改
      • (2):添加
  • 三:核心代码
    • controller


一:作业要求 1:要求

完成内容管理系统后台部分的基本功能 *** 作。要求jdbc连接数据库,数据库自行设计。具体功能如下:
1、文章分类的管理,包括文章分类的列表显示(含删除、修改、查询的功能)、添加。
2、文章的管理,包括文章的列表显示(含删除、修改、查询的功能)、添加。
3、用户的管理,包括用户的列表显示(含删除、修改、查询的功能)、添加。
4、用户登录及退出、修改个人信息功能。

2:提炼功能
  • 完成用户登录功能,利用spring安全框架实现密码加密加盐处理
  • 完成拦截器功能(自定义拦截器)
  • 主页面菜单栏分为三个部分
    • 文章分类管理(CRUD)
    • 文章管理(CRUD)
    • 用户管理(CRUD)
3.数据库设计
  • 3个表 文章类别表 文章表 用户表
  • 其中在文章类别中将 类别设置成主键 在文章表中将类别设置成外键
  • 文章类别表的字段为:id, 类别,代表人物,盛行时间
  • 文章表中的字段为:id,文章名称,类别,作者
  • 用户表:id,姓名,密码
4:前端展示
  • 前端找模板
  • 一个是后台管理
  • 一个是登录模板
    模板之家网址
二:功能展示 1:登录

2:登录首页


3:文章类别管理

(1):修改

(2):添加

三:核心代码 controller
package com.wyj.Controller;

import com.wyj.Pojo.Category;
import com.wyj.Service.CateGoryService;
import com.wyj.Service.Imp.CateGoryListImp;
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 org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class CommonController {

    @Autowired
    CateGoryListImp cateGoryListImp;

    //欢迎页
    @GetMapping("/")
    public String login() {
        return "login";
    }


    @RequestMapping("/errors")
    public String error () {
        return "error/404";
    }

    @RequestMapping("/cateGoryList")
    public String getCateGoryList(Model model) {

        List<Category> list = cateGoryListImp.getCateGoryList();
        model.addAttribute("cateGoryList",list);
        return "category/category";
    }

    @RequestMapping("/addCateShow")
    public String showAddCAte() {
        return "category/addCateGory";
    }

    @RequestMapping("/updateCate")
    public String updateCate (String id,Model model) {

        if (id != null){
            int i = Integer.parseInt(id);

            Category cate = cateGoryListImp.getCate(i);

            model.addAttribute("cate",cate);
        }

        return "category/updateCote";
    }


}

package com.wyj.Controller;

import com.wyj.Pojo.User;
import com.wyj.Service.Imp.UserServiceImp;
import com.wyj.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class loginController {

    @Autowired
    UserServiceImp userServiceImp;

    @RequestMapping("/index")
    public String getIndex() {
        return "index";
    }

    @RequestMapping("/login")
    public String login(@RequestParam("username") String name,
                        @RequestParam("password") String password) {

        List<User> list = userServiceImp.getUserList();

        for (User user : list) {
            if(user.getName().equals(name) && user.getPassword().equals(password)) {
                return "/index";
            }
        }

        return "redirect: /errors";
    }

}

package com.wyj.Controller;

import com.wyj.Pojo.Category;
import com.wyj.Service.Imp.CateGoryListImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class cateGoryController {

    @Autowired
    CateGoryListImp cateGoryListImp;

    @RequestMapping("/addCateGory")
    public String addCategory(Category category) {

        int i = cateGoryListImp.addCateCoryList(category);

        System.out.println(category.toString()  );
        System.out.println("==========="+i+"=============");

        return "redirect:cateGoryList";
    }


    @RequestMapping("/deleteCateGeory")
    public String deleteCate(String id) {

        if (id != null) {
            int a = Integer.parseInt(id);

            int i = cateGoryListImp.deleteCateGory(a);
        }

        return "redirect:cateGoryList";
    }



}

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/723225.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-26
下一篇 2022-04-26

发表评论

登录后才能评论

评论列表(0条)

保存