源码获取:博客首页 "资源" 里下载!
项目介绍
ssm ERP报销系统。主要分4个角色,总经理、部门经理、财务、普通员工,普通员工填写报销单后需要提交给部门经理审核,再由财务支付,如果金额大于5000,还需要总经理审核。
总经理拥有 部门管理 和 员工管理 功能
部门经理拥有 员工管理 功能
其他职务没有
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7版本;
技术栈
1. 后端:Spring SpringMVC MyBatis
2. 前端:JSP+LayUI+jQuery
主要技术
- Spring Ioc
- Mybatis+Spring整合
- 声明式事务
- Spring标签库
- Spring拦截器
软件架构
三层架构
- 持久层--Mybatis
- 表现层--Spring MVC
- 控制器--Spring Controller
基于MVC模式
- 视图--Jsp
- 模型--JavaBean
- 业务层--JavaBean
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
3. 将项目中spring-dao.xml配置文件中的数据库配置改为自己的配置
4. 运行项目,在浏览器中输入http://localhost:8080/ 登录
账户说明
系统默认用户里有四个,分别对应10001(总经理),10002(部门经理),10003(财务),10004(普通员工)
密码为000000
员工填写报销单后需要提交给部门经理审核,再由财务支付,
如果金额大于5000,还需要总经理审核。
总经理拥有 部门管理 和 员工管理 功能
部门经理拥有 员工管理 功能
其他职务没有
员工管理控制层:
@Controller
@RequestMapping("/employee")
public class EmployeeController {
@Autowired
private EmployeeService employeeService;
/**
* 获取雇员全部信息
*
* @param request
* @return
*/
@RequestMapping("/getEmployeeAll")
@ResponseBody
public JSONObject getEmployeeAll(HttpServletRequest request) {
return employeeService.getEmployeeAll(request);
}
/**
* 添加雇员
*
* @param request
* @return
*/
@RequestMapping("/addEmployee")
@ResponseBody
public JSONObject addEmployee(HttpServletRequest request) {
return employeeService.addEmployee(request);
}
/**
* 修改雇员信息
*
* @param request
* @return
*/
@RequestMapping("/updateEmployee")
@ResponseBody
public JSONObject updateEmployee(HttpServletRequest request) {
return employeeService.updateEmployee(request);
}
/**
* 删除雇员
*
* @param request
* @return
*/
@RequestMapping("/deleteEmployee")
@ResponseBody
public JSONObject deleteEmployee(HttpServletRequest request) {
return employeeService.deleteEmployee(request);
}
/**
* 修改角色
*
* @param request
* @return
*/
@RequestMapping("/updateRole")
@ResponseBody
public JSONObject updateRole(HttpServletRequest request) {
return employeeService.updateRole(request);
}
/**
* 修改部门
*
* @param request
* @return
*/
@RequestMapping("/updateDepartment")
@ResponseBody
public JSONObject updateDepartment(HttpServletRequest request) {
return employeeService.updateDepartment(request);
}
/**
* 重置密码
*
* @param request
* @return
*/
@RequestMapping("/resetPassword")
@ResponseBody
public JSONObject resetPassword(HttpServletRequest request) {
return employeeService.resetPassword(request);
}
/**
* 获取个人信息
* @param request
* @return
*/
@RequestMapping("/getEmployeeInformation")
@ResponseBody
public Employee getEmployeeInformation(HttpServletRequest request){
String employeeNumber = SecurityUtils.getSubject().getPrincipal().toString(); //获取自身工号
return employeeService.getEmployeeNumber(employeeNumber);
}
/**
* 个人信息修改
* @param request
* @return
*/
@RequestMapping("/personageUpdateEmployee")
@ResponseBody
public JSONObject personageUpdateEmployee(HttpServletRequest request){
return employeeService.personageUpdateEmployee(request);
}
/**
* 修改密码
* @param request
* @return
*/
@RequestMapping("/updateEmployeePassword")
@ResponseBody
public JSONObject updateEmployeePassword(HttpServletRequest request){
return employeeService.updateEmployeePassword(request);
}
}
角色管理控制层:
@Controller
@RequestMapping("/role")
public class RoleController {
@Autowired
private RoleService roleService;
/**
* 页面跳转
*
* @param request
* @return
*/
@RequestMapping("/toPage")
public String toPage(HttpServletRequest request) {
String url = "sys/role/role";
String page = request.getParameter("page");
if (page != null) {
url = page;
}
return url;
}
/**
* 添加角色
*
* @param request
* @return
*/
@RequestMapping("/addRole")
@ResponseBody
public JSONObject addRole(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
Role role = JSONObject.parseObject(request.getParameter("role"), Role.class);
if (roleService.verifyRoleTitle(role) > 0) {
json.put("type", "error");
json.put("msg", "角色名称已重复,请使用别的角色名称");
return json;
}
if (roleService.addRole(role) > 0) {
json.put("type", "success");
json.put("msg", "添加角色成功!");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "添加角色失败!");
return json;
}
/**
* 修改角色
*
* @param request
* @return
*/
@RequestMapping("/updateRole")
@ResponseBody
public JSONObject updateRole(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
Role role = JSONObject.parseObject(request.getParameter("role"), Role.class);
if (roleService.verifyRoleTitle(role) > 0) {
json.put("type", "error");
json.put("msg", "角色名称已重复,请使用别的角色名称");
return json;
}
if (roleService.updateRole(role) > 0) {
json.put("type", "success");
json.put("msg", "修改角色成功!");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "修改角色失败!");
return json;
}
/**
* 删除角色
*
* @param request
* @return
*/
@RequestMapping("/deleteRole")
@ResponseBody
public JSONObject deleteRole(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String roleId = request.getParameter("roleId");
if (roleService.deleteRole(Integer.parseInt(roleId)) > 0) {
json.put("type", "success");
json.put("msg", "删除角色成功!");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "删除角色失败!");
return json;
}
/**
* 获取全部角色
*
* @return
*/
@RequestMapping("/getRoleAll")
@ResponseBody
public JSONObject getRoleAll() {
JSONObject json = new JSONObject();
List<Role> roles = roleService.selectRoleAll();
json.put("code", 0);
json.put("msg", "");
json.put("count", roles.size());
json.put("data", roles);
return json;
}
/**
* 设置角色菜单
*
* @param request
* @return
*/
@RequestMapping("/setRoleJurisdiction")
@ResponseBody
public JSONObject setRoleJurisdiction(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
/** 角色ID*/
String roleId = request.getParameter("roleId");
/** 菜单ID数组*/
Integer[] menuIds = JSONObject.parseObject(request.getParameter("menuIdList"), Integer[].class);
roleService.batchDeleteRoleByMenu(Integer.parseInt(roleId)); //先删除
if (roleService.batchAddRoleByMenu(Integer.parseInt(roleId), menuIds) > 0) { // 后添加
json.put("type", "success");
json.put("msg", "设置角色菜单成功");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", "系统错误!请联系管理员");
System.out.println(e.getMessage());
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //回滚
}
json.put("type", "error");
json.put("msg", "设置角色菜单失败!");
return json;
}
/**
* 设置角色权限
*
* @param request
* @return
*/
@RequestMapping("/setRolePermissions")
@ResponseBody
public JSONObject setRolePermissions(HttpServletRequest request) {
return roleService.setPermissions(request);
}
}
部门管理控制层:
@Controller
@RequestMapping("/department")
public class DepartmentController {
@Autowired
private DepartmentService departmentService;
/**
* 获取部门全部数据
* @return
*/
@RequestMapping("/getDepartmentAll")
@ResponseBody
public JSONObject getDepartmentAll(){
return departmentService.selectDepartmentAll();
}
/**
* 添加部门
* @param request
* @return
*/
@RequestMapping("/addDepartment")
@ResponseBody
public JSONObject addDepartment(HttpServletRequest request){
JSONObject json = new JSONObject();
try{
Department department = JSONObject.parseObject(request.getParameter("department"), Department.class);
if(departmentService.verifyDepartmentTitle(department) > 0){
json.put("type","error");
json.put("msg","部门名称重复,请使用别的部门名称");
return json;
}
if(departmentService.addDepartment(department) > 0){
json.put("type","success");
json.put("msg","添加成功");
return json;
}
}catch (Exception e){
json.put("type","success");
json.put("msg",MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
}
return json;
}
/**
* 修改部门
* @param request
* @return
*/
@RequestMapping("/updateDepartment")
@ResponseBody
public JSONObject updateDepartment(HttpServletRequest request){
JSONObject json = new JSONObject();
try{
Department department = JSONObject.parseObject(request.getParameter("department"), Department.class);
if(departmentService.verifyDepartmentTitle(department) > 0){
json.put("type","error");
json.put("msg","部门名称重复,请使用别的部门名称");
return json;
}
if(departmentService.updateDepartment(department) > 0){
json.put("type","success");
json.put("msg","修改成功");
return json;
}
}catch (Exception e){
json.put("type","success");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
}
return json;
}
/**
* 删除部门
* @param request
* @return
*/
@RequestMapping("/deleteDepartment")
@ResponseBody
public JSONObject deleteDepartment(HttpServletRequest request){
JSONObject json = new JSONObject();
try{
String departmentId = request.getParameter("departmentId");
if(departmentService.verifyDepartmentByEmployee(Integer.parseInt(departmentId)) > 0){
json.put("type","error");
json.put("msg","该部门还含有雇员存在,无法删除");
return json;
}
if(departmentService.deleteDepartment(Integer.parseInt(departmentId)) > 0){
json.put("type","success");
json.put("msg","删除成功");
return json;
}
}catch (Exception e){
json.put("type","success");
json.put("msg",MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
}
return json;
}
@RequestMapping("/updateDepartmentPrincipal")
@ResponseBody
public JSONObject updateDepartmentPrincipal(HttpServletRequest request){
return departmentService.updateDepartmentPrincipal(request);
}
}
源码获取:博客首页 "资源" 里下载!