JavaWeb General Authority Management System Based on SSM Framework

View more systems: System Encyclopedia, Course Design, Graduation Design, please click here to view

01 Overview

This is a general permission management system project, developed based on the SSM (Spring + Spring-MVC + Mybatis) framework. Its SQL statements are persisted in Hibernate, and it has better support for native SQL. The original intention of making this system is to help JavaWeb developers or beginners learn and learn from the needs. Readers can introduce other technologies on the basis of this system or completely rely on this system technology for functional expansion to develop projects with actual application requirements, eliminating the trouble of "authorization design" in the application system.

02 Technology

Jsp, SSM (Spring + Spring-MVC + Mybatis), Shiro, Mvc, Jdbc, MySQL, DWZ rich client framework + Jquery + Ajax

03 Environment

JDK:JDK1.6+ 、WEB:Tomcat6.0+ 、DB:MySQL5+ 、IDE: MyEclipse8.5+/Eclipse4.4+

04 Engineering structure

Insert picture description here

05 Run screenshot

login interface

Insert picture description here

Staff management interface

Insert picture description here

Department Management Interface

Insert picture description here

Role management interface

Insert picture description here

06 main code

Staff department management

package com.kzfire.portal.action.user;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.kzfire.portal.base.BaseAction;
import com.kzfire.portal.entiy.SysDept;
import com.kzfire.portal.service.DeptService;
import com.kzfire.portal.service.UserService;
import com.kzfire.portal.utils.JSONUtils;
import com.kzfire.portal.utils.VoFactory;
import com.kzfire.portal.vo.ConditionVo;

@RequestMapping("/user/dept")
@Controller
public class DeptAction extends BaseAction{
    @Autowired
    DeptService deptService;
    @Autowired
    UserService userService;

    /**
     * 设置员工部门
     * @param model
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/setUserDept")
    public String setUserDept(Model model,HttpServletRequest request,HttpServletResponse response) {

        String userId=request.getParameter("userId");
        model.addAttribute("userId", userId);
        //设置部门树
        List<SysDept> list=deptService.getAllDept();
        model.addAttribute("data", JSONUtils.parseList(list));
        return VIEW+"user/dept/setUserDept";
    }

    @RequestMapping("/saveUserdept")
    public ModelAndView saveUserdept(Model model, HttpServletRequest request,
            HttpServletResponse response) {
        try {
            Integer userId=Integer.parseInt(request.getParameter("userId"));
            Integer deptId=Integer.parseInt(request.getParameter("deptId"));
            deptService.saveUserdept(userId,deptId);
        } catch (Exception e) {
            e.printStackTrace();
            return ajaxDoneError("操作失败:"+e.getMessage());
        }
        return ajaxDoneSuccess("操作成功");
    }

    @RequestMapping("/main")
    public String list(Model model,HttpServletRequest request,HttpServletResponse response) {
        //设置部门树
        List<SysDept> list=deptService.getAllDept();
        System.out.println("json格式----->"    + JSONUtils.parseList(list).toString() );
        model.addAttribute("data", JSONUtils.parseList(list));
        return VIEW+"user/dept/dept";
    }

    @RequestMapping("/userList")
    public String userList(Model model,HttpServletRequest request,HttpServletResponse response) {
        ConditionVo cvo=VoFactory.getConditionVo(request);
        String deptId=request.getParameter("deptId");
        if("1".equals(deptId))
        {
            cvo.setText4("1");
        }else
        {
            cvo.setText3(request.getParameter("deptId"));
        }
        request.setAttribute("deptId", deptId);
        cvo.setTotalCount(userService.getUserCount(cvo));
        model.addAttribute("vo", cvo);
        model.addAttribute("list", userService.getList(cvo));
        return VIEW+"user/dept/userList";
    }

    @RequestMapping("/add")
    public String add(Model model,HttpServletRequest request,HttpServletResponse response) {
        SysDept dept=new SysDept();
        dept.setPid(Integer.parseInt(request.getParameter("selDept")));
        model.addAttribute("dept", dept);
        return VIEW+"user/dept/deptEdit";
    }
    @RequestMapping("/edit")
    public String edit(Model model,HttpServletRequest request,HttpServletResponse response) {
        SysDept dept=deptService.getDeptById(Integer.parseInt(request.getParameter("selDept")));
        model.addAttribute("dept", dept);
        return VIEW+"user/dept/deptEdit";
    }

    @RequestMapping("/del")
    public ModelAndView del(Model model, HttpServletRequest request)
    {
        try {
            String deptId=request.getParameter("selDept");
            deptService.delDeptById(Integer.parseInt(deptId));
        } catch (Exception e) {
            e.printStackTrace();
            return ajaxDoneError("操作失败:"+e.getMessage());
        }
        return ajaxDoneSuccess("操作成功");
    }

    @RequestMapping("/save")
    public ModelAndView save(SysDept dept,Model model, HttpServletRequest request,
            HttpServletResponse response) {
        try {
            if(dept!=null)
            {
                deptService.saveDept(dept);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return ajaxDoneError("操作失败:"+e.getMessage());
        }
        return ajaxDoneSuccess("操作成功");
    }
}

Role management

package com.kzfire.portal.action.user;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.kzfire.portal.base.BaseAction;
import com.kzfire.portal.entiy.SysRole;
import com.kzfire.portal.service.RoleService;
import com.kzfire.portal.utils.VoFactory;
import com.kzfire.portal.vo.ConditionVo;
import com.kzfire.portal.vo.PerGroupVo;

@RequestMapping("/user/role")
@Controller
public class RoleAction extends BaseAction{
    @Autowired
    RoleService roleService;

    @RequestMapping("/list")
    public String list(Model model,HttpServletRequest request,HttpServletResponse response) {
        ConditionVo cvo=VoFactory.getConditionVo(request);
        cvo.setTotalCount(roleService.getTableCount("sys_role"));
        model.addAttribute("vo", cvo);
        model.addAttribute("list", roleService.getList(cvo));
        return VIEW+"permission/role/list";
    }

    /**
     * 权限编辑页面
     * @param model
     * @param request
     * @return
     */
    @RequestMapping("/editPermission")
    public String editPermission(Model model, HttpServletRequest request)
    {
        String roleId=request.getParameter("roleId");
        //获取角色权限
        List<PerGroupVo> group=roleService.getPerGroupVoByUserId(Integer.parseInt(roleId));
        model.addAttribute("group", group);
        model.addAttribute("roleId", roleId);
        return VIEW+"permission/role/editPermission";
    }

    @RequestMapping("/savePer")
    public ModelAndView savePer(Model model, HttpServletRequest request,
            HttpServletResponse response) {
        try {
            String[] perIds=request.getParameterValues("perId");
            roleService.savePermission(perIds,Integer.parseInt(request.getParameter("roleId")));
        } catch (Exception e) {
            e.printStackTrace();
            return ajaxDoneError("操作失败");
        }

        return ajaxDoneSuccess("操作成功");
    }

    @RequestMapping("/add")
    public String add(Model model, HttpServletRequest request)
    {
        model.addAttribute("role", new SysRole());
        return VIEW+"permission/role/roleEdit";
    }

    @RequestMapping("/edit")
    public String edit(Model model, HttpServletRequest request)
    {
        String roleId=request.getParameter("roleId");
        SysRole role=roleService.getRoleById(Integer.parseInt(roleId));
        model.addAttribute("role", role);
        return VIEW+"permission/role/roleEdit";
    }

    @RequestMapping("/del")
    public ModelAndView del(Model model, HttpServletRequest request)
    {
        try {
            String roleId=request.getParameter("roleId");
            roleService.delRoleById(Integer.parseInt(roleId));
        } catch (Exception e) {
            e.printStackTrace();
            return ajaxDoneError("操作失败");
        }
        return ajaxDoneSuccess("操作成功");
    }

    @RequestMapping("/save")
    public ModelAndView save(SysRole role,Model model, HttpServletRequest request,
            HttpServletResponse response) {
        if(role!=null)
        {
            roleService.saveShop(role);
        }
        return ajaxDoneSuccess("操作成功");
    }

}

07 Other

1. MySQL database account

MySQL database default port: "3306", database name: "kzfire", account name: "root", password: empty.

2. SQL file

The SQL file is placed in the "MySQL database SQL file" directory, and the SQL file needs to be executed through the "Navicat for MySQL" tool.

3. System startup files

The system startup file is "login.jsp" in the "webroot" directory

4. System login user name and password

After "login.jsp" is started (running), enter the login interface under normal circumstances, enter "admin" for the user name and "123456" for the password. If you cannot log in, it may be caused by a problem with the database parameter configuration. Please check the database parameter configuration file.

08 Download the source code

Follow the public account [C you again] and reply to "JavaWeb Universal Authority Management System Based on SSM Framework" to receive it for free.
You can also directly scan the QR code on the homepage to follow and reply to "JavaWeb Universal Permission Management System Based on SSM Framework" to receive it for free, click here to open the personal homepage

Note: This source code comes from the Internet, if there is any infringement, please contact to delete it! !

Author: C you again, engaged in software development efforts moving bricks on the road in IT technology white
public number: [ C you again ], share a computer class graduation project source code, IT technical articles, game source code, web templates, program of life and so on. No public reply [ fans ] into the group of bloggers technology, communication and chiefs, receive learning materials dry goods
on reprint : Bloggers welcome to reprint the article, reproduced indicate the source when
seeking praise links : creation is not easy, remember thumbs + + comments forwarded Thank you All the way support

Guess you like

Origin blog.51cto.com/15107850/2657816