current position:Home>Java project: OA management system (java + SSM + bootstrap + MySQL + JSP)

Java project: OA management system (java + SSM + bootstrap + MySQL + JSP)

2022-01-27 05:07:14 qq_ one billion three hundred and thirty-four million six hundr

Spring+SpringMVC+Mybatis Realized OA Management system , The front end uses Bootstrap frame , The form uses BootstrapTables Paging table plug-in , This framework is only suitable for consolidating SSM Learn from , The functions inside are very complex , It may be a little difficult for novices , But the first mock exam is one of the consolidation of one SSM Framework best practices , The main configuration is mailbox , The system can have the function of receiving and sending e-mail , So the mailbox must be configured , Especially the authorization code . The main functions of this system are : The information center 、 Document management 、 Personnel management 、 Process CITIC 、 Mailbox Management 、 Utilities 、 System management 、 Schedule management 、 Asset management 、 Leave management, etc .mapper The file in entity In the entity class, it is hereby explained here , In case you can't find the file when you get the source code .

Running environment :Mysql5.7、Tomcat7.0、jdk1.7/1.8、eclipse.

 

 

 

 

Role control layer :

/**
 * @author yy
 */
@Controller
@RequestMapping("/role")
public class RoleController extends BaseController{
    private String prefix = "system/role/";


    @Autowired
    IUserService iUserService;

    @Autowired
    IRoleService iRoleService;

    @Autowired
    IPermissionService iPermissionService;

    /**
     *
     * @ describe   Page Jump 
     *
     * @date 2018/9/16 10:59
     */
    @RequestMapping("/tolist")
    @RequiresPermissions("role:list")
    public String tolist()
    {
        return prefix + "role";
    }


    /**
     *
     * @ describe  ajax Ask for all 
     *
     * @date 2018/9/16 10:48
     */
    @RequestMapping("/ajaxlist")
    @ResponseBody
    public List<Role> list(Role role)
    {
        List<Role> roles = iRoleService.selectRoleList(role);
        return roles;
    }

    /**
     *
     * @ describe   list 
     *
     * @date 2018/9/16 10:52
     */
    @RequestMapping("/tableList")
    @ResponseBody
    public TableDataInfo listPag(Role role)
    {
        // Open paging 
        startPage();
        List<Role> roles = iRoleService.selectRoleList(role);
        return getDataTable(roles);
    }


    /**
     *
     * @ describe   New page 
     *
     * @date 2018/9/16 11:37
     */
    @RequestMapping("/toAdd")
    @RequiresPermissions("role:add")
    public String toAdd(Model model)
    {
        return prefix + "add";
    }


    /**
     *
     * @ describe   Batch deletion 
     *
     * @date 2018/9/16 11:53
     */
    @RequestMapping("/del")
    @RequiresPermissions("role:del")
    @Operlog(modal = " Role management ",descr = " Delete the role ")
    @ResponseBody
    public AjaxResult del(Integer[] ids)
    {
        try
        {
            iRoleService.deleteByPrimaryKeys(ids);
        }
        catch (Exception e)
        {
            return error(e.getMessage());
        }
        return success();
    }


    /**
     *
     * @ describe   Add save 
     *
     * @date 2018/9/16 11:54
     */

    @RequestMapping("/addSave")
    @RequiresPermissions("role:update")
    @Operlog(modal = " Role management ",descr = " Adding roles ")
    @ResponseBody
    public AjaxResult addRole(Role role, Integer[] ids)
    {
        role.setCreateTime(new Date());
        int insert = 0;
        try
        {
            if (StringUtils.isEmpty(ids))
            {
                ids = new Integer[0];
            }
            insert = iRoleService.insert(role, ids);
        }
        catch (Exception e)
        {
            return error(e.getMessage());
        }
        // Empty cache 
        ShiroUtils.clearCachedAuthorizationInfo();
        return  result(insert);
    }


    /**
     *
     * @ describe :  according to ID  obtain u All his authority   Do echo 
     *
     * @params: roleId  role Id
     * @return:
     * @date: 2018/9/27 14:04
     */
    @RequestMapping("/selectById/{roleId}")
    @ResponseBody
    public Role selectById(@PathVariable("roleId") Integer roleId)
    {
        Role role = iRoleService.selectByPrimaryKey(roleId);
        return role;
    }


    /**
     *
     * @ describe   Edit and modify the page 
     *
     * @date 2018/9/16 14:06
     */
    @RequestMapping("/edit/{id}")
    @RequiresPermissions("role:update")
    public String edit(@PathVariable("id") Integer id, Model model)
    {
        Role role = iRoleService.selectByPrimaryKey(id);
        model.addAttribute("Role", role);
        return prefix + "edit";
    }

    /**
     *
     * @ describe   Edit and modify permission page 
     *
     * @date 2018/9/16 14:06
     */
    @RequestMapping("/editPower/{id}")
    @RequiresPermissions("role:update")
    public String editPower(@PathVariable("id") Integer id, Model model)
    {
        Role role = iRoleService.selectByPrimaryKey(id);
        model.addAttribute("Role", role);
        return prefix + "editPower";
    }


    /**
     *
     * @ describe   Modify role information and save 
     *
     * @date 2018/9/16 16:12
     */
    @RequestMapping("/editSave")
    @RequiresPermissions("role:update")
    @Operlog(modal = " Role management ",descr = " Modify role information ")
    @ResponseBody
    public AjaxResult save(Role role)
    {
        int i = 0;
        try
        {
            i = iRoleService.updateByPrimaryKeySelective(role);
        }
        catch (Exception e)
        {
            return error(e.getMessage());
        }
        return result(i);
    }


    /**
     *
     * @ describe   Modify role permission information and save 
     *
     * @date 2018/9/16 16:12
     */
    @RequestMapping("/editPowerSave")
    @RequiresPermissions("role:update")
    @Operlog(modal = " Role management ",descr = " Modify role permissions ")
    @ResponseBody
    public AjaxResult editPowerSave(Role role, Integer[] ids)
    {
        int i = 0;
        try
        {
            if (StringUtils.isEmpty(ids))
            {
                ids = new Integer[0];
            }
            i = iRoleService.updateByPrimaryKeyPowerSelective(role, ids);
        }
        catch (Exception e)
        {
            return error(e.getMessage());
        }
        // Empty cache 
        ShiroUtils.clearCachedAuthorizationInfo();
        // If the user is modifying the role id  Is the role of the current user id  Then refresh  subject Of User Information 
        if (role.getRoleId().equals(getRoleId()))
        {
            ShiroUtils.reloadUser(iUserService.selectByPrimaryKey(getUserId()));
        }
        return result(i);
    }


    /**
     *  The verification name is unique 
     */
    @PostMapping("/checkRoleNameUnique")
    @ResponseBody
    public String checkDeptNameUnique(Role role)
    {
        String uniqueFlag = "0";
        if (role != null)
        {
            uniqueFlag = iRoleService.checkRoleNameUnique(role);
        }
        return uniqueFlag;
    }
}

User login control layer :

@org.springframework.stereotype.Controller
@RequestMapping("/oa")
public class LoginController extends BaseController{
    private static final Logger logger = LoggerFactory.getLogger(LoginController.class);

    private String prefix = "system/user/";

    @Autowired
    LoginService loginService;


    @Autowired
    IUserService userService;



    /**
     *
     * @ describe :  Perform login operation 
     *
     * @params: user: User login information ;
     *          validateCode: Verification Code 
     * @return:
     * @date: 2018/9/29 21:20
     */
    @RequestMapping("/login")
    @Operlog(descr = " The user login ", modal = " Login module ")
    @ResponseBody
    public AjaxResult Logining(User user, String validateCode, Boolean rememberMe, HttpServletRequest request)
    {
        HttpSession session = ServletUtils.getSession();

        UsernamePasswordToken token = new UsernamePasswordToken(user.getName(), user.getPwd());
        token.setRememberMe(rememberMe);
        Subject subject = SecurityUtils.getSubject();

        // Verify user name and password   Verification code problem 
        try
        {
            loginService.checkLogin(user.getName(), user.getPwd(), validateCode);
        }
        catch (Exception e)
        {
            session.setAttribute(Constants.LOGIN_ERROR, e.getMessage());
            return error(e.getMessage());
        }
        try
        {
            if (!subject.isAuthenticated())
            {
                subject.login(token);
            }
        }
        catch (IncorrectCredentialsException e)
        {
            session.setAttribute(Constants.LOGIN_ERROR," Wrong password ");
            return error(" Wrong password !");
        }
        catch (UnknownAccountException e)
        {
            session.setAttribute(Constants.LOGIN_ERROR,e.getMessage());
            return error(e.getMessage());
        }
        catch (LockedAccountException e)
        {
            session.setAttribute("login",e.getMessage());
            return error(e.getMessage());
        }
        catch (AuthenticationException e)
        {
//            String msg = " Wrong user name or password !";
//            if (!StringUtils.isEmpty(e.getMessage()))
//            {
//                msg = e.getMessage();
//            }
            session.setAttribute(Constants.LOGIN_ERROR,e.getMessage());
            return error(" System exception !");
        }

        return success();
    }


    /**
 s sl
       *
     * @ describe :  The login page 
     *
     * @params:
     * @return:
     * @date: 2018/9/29 21:20
     */
    @RequestMapping("/toLogin")
    public String toLogin()
    {
        return "login";
    }


}

Department management control :

/**
 * @author yy
 */
@Controller
@RequestMapping("/dept")
public class DeptController extends BaseController{

    private String prefix = "system/dept/";

    @Autowired
    IDeptService iDeptService;

    @Autowired
    IUserService iUserService;


    /**
     *
     * @ describe   The page jumps to the Department 
     *
     * @date 2018/9/16 10:59
     */

    @RequestMapping("/tolist")
    @RequiresPermissions("dept:list")
    public String tolist()
    {
        return prefix + "dept";
    }


    /**
     *
     * @ describe  ajax All departments requested 
     *
     * @date 2018/9/16 10:48
     */
    @RequestMapping("/ajaxlist")
    @ResponseBody
    public List<Dept> list(Dept dept)
    {
        List<Dept> depts = iDeptService.selectDeptList(dept);
        return depts;
    }

    /**
     *
     * @ describe   Department list page 
     *
     * @date 2018/9/16 10:52
     */
    @RequestMapping("/tableList")
    @ResponseBody
    public TableDataInfo listPag(Dept dept)
    {
        // Open paging 
        startPage();
        List<Dept> depts = iDeptService.selectDeptList(dept);
        return getDataTable(depts);
    }


    /**
     *
     * @ describe   New page 
     *
     * @date 2018/9/16 11:37
     */
    @RequiresPermissions("dept:add")
    @RequestMapping("/toAdd")
    public String toAdd(Model model)
    {
        List<User> users = iUserService.selectByUser(new User());
        model.addAttribute("users", users);
        return prefix + "add";
    }


    /**
     *
     * @ describe :  Query all users under all departments   User classification   Tree data 
     *
     * @date: 2018/9/27 11:25
     */
    @RequestMapping("/getDeptAndUserTreeData")
    @ResponseBody
    public List<Object> DeptAndUserTreeData()
    {
        List<Dept> depts = iDeptService.selectDeptAndUser();

        List<User> users=new ArrayList<>();
        LinkedList<Object> deptList = new LinkedList<>();
        for (Dept dept : depts)
        {
            Map<String, Object> deptMap = new HashMap();
            deptMap.put("name", dept.getDeptName());
            deptMap.put("id", null);
            users = dept.getUsers();
            LinkedList<Object> userlist = new LinkedList<>();
            for (User user : users)
            {
                Map<String, Object> userMap = new HashMap();
                userMap.put("name",user.getName());
                userMap.put("id",user.getUid());
                userMap.put("icon","/img/timg.jpg");
                userlist.add(userMap);
            }
            deptMap.put("children",userlist);
            deptList.add(deptMap);
        }

        return deptList;
    }


    /**
     *
     * @ describe   Batch deletion 
     *
     * @date 2018/9/16 11:53
     */
    @RequestMapping("/del")
    @RequiresPermissions("dept:del")
    @ResponseBody
    @Operlog(modal = " Department of management ",descr = " Delete Department ")
    public AjaxResult del(String[] ids)
    {
        try
        {
            iDeptService.deleteByPrimaryKeys(ids);
        }
        catch (Exception e)
        {
            return error(e.getMessage());
        }
        return success();
    }


    /**
     *
     * @ describe   Perform save operation 
     *
     * @date 2018/9/16 11:54
     */

    @RequestMapping("/addSave")
    @Operlog(modal = " Department of management ",descr = " Add Department ")
    @RequiresPermissions("dept:add")
    @ResponseBody
    public AjaxResult addDept(Dept dept)
    {
        dept.setCreateTime(new Date());
        return  result(iDeptService.insertSelective(dept));
    }


    /**
     *
     * @ describe   Edit and modify the page 
     *
     * @date 2018/9/16 14:06
     */
    @RequestMapping("/edit/{id}")
    @RequiresPermissions("dept:update")
    public String edit(@PathVariable("id") String id, Model model)
    {
        Dept dept = iDeptService.selectByPrimaryKey(id);
        List<User> users = iUserService.selectByUser(new User());
        model.addAttribute("users", users);

        model.addAttribute("Dept", dept);
        return prefix + "edit";

    }

    /**
     *
     * @ describe   Changes to save 
     *
     * @date 2018/9/16 16:12
     */
    @RequestMapping("/editSave")
    @RequiresPermissions("dept:update")
    @Operlog(modal = " Department of management ",descr = " Modify the information ")
    @ResponseBody
    public AjaxResult save(Dept dept)
    {
        int i = 0;
        try
        {
            i = iDeptService.updateByPrimaryKeySelective(dept);
        }
        catch (Exception e)
        {
            return error(e.getMessage());
        }
        return result(i);
    }


    /**
     *  Name of verification department 
     */
    @PostMapping("/checkDeptNameUnique")
    @ResponseBody
    public String checkDeptNameUnique(Dept dept)
    {
        String uniqueFlag = "0";
        if (dept != null)
        {
            uniqueFlag = iDeptService.checkDeptNameUnique(dept);
        }
        return uniqueFlag;
    }
}

copyright notice
author[qq_ one billion three hundred and thirty-four million six hundr],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270507128071.html

The sidebar is recommended

guess what you like

Random recommended