栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

内容管理系统(BS作业实验四)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

内容管理系统(BS作业实验四)


文章目录
  • 一:作业要求
    • 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 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 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";
    }



}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/830540.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号