基于javaweb+mysql的springboot员工管理系统(前后端分离+java+vue+springboot+ssm+mysql+maven)

基于javaweb+mysql的springboot员工管理系统(前后端分离+java+vue+springboot+ssm+mysql+maven)

运行环境

Java≥8、MySQL≥5.7、Node.js≥10

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行

前端:WebStorm/VSCode/HBuilderX等均可

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot员工管理系统(前后端分离+java+vue+springboot+ssm+mysql+maven)

一、项目简述

本系统功能包括:分为前端翻后端部分,包括用户,区分晋通用户以及誉里员用户,包括首页展示,部门管理,人事管理,员工管理三个模块等等。

二、项目运行

环境配置: Jdkl . 8 + Tomcats . 5 + Mysql + HBuilderX ( Webstorm 也行)+ Eclispe ( IntelliJ IDEA,Eclispe , MyEclispe , Sts 都支持)。 项目技术: html + css +js + vue + v 一 charts + electron + springboot + mybatis + Mysql + Maven 等等。


/**
 * 用户登录相关接口
 *
 */
@RestController
@CrossOrigin
public class AuthController {
    @Autowired
    private AuthService authService;

    @PostMapping("/login")
    public Result login(@RequestParam(name = "email") String email,
                        @RequestParam(name = "password") String password) {
        //密码加密
    	System.out.println(MD5Util.getMD5(password, 11));
        return authService.login(email, MD5Util.getMD5(password, 11));
    }

}


/**
 */
@AllArgsConstructor
@RestController
@RequestMapping("/wx/redirect/{appid}")
public class WxRedirectController {
    private final WxMpService wxService;
    @Autowired
    private WebSocketServer webSocketServer;
    @Autowired
    private EmployeeMapper employeeMapper;

    @RequestMapping("/greet")
    public WxMpUser greetUser(@PathVariable String appid, @RequestParam String code, ModelMap map) {
        if (!this.wxService.switchover(appid)) {
            throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
        }
        WxMpUser user = null;
        try {
            WxMpOAuth2AccessToken accessToken = wxService.oauth2getAccessToken(code);
            user = wxService.oauth2getUserInfo(accessToken, null);
            map.put("user", user);
        } catch (WxErrorException e) {
            e.printStackTrace();

/**
 */
@RestController
@RequestMapping("/employee")
@CrossOrigin
@Slf4j
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private JobService jobService;
    @Autowired
    private EduLevelMapper eduLevelMapper;
    @Autowired
    private EmployeeMapper employeeMapper;
    /**
     * 搜索接口
     */
    @GetMapping("/search")
    public Result search(@RequestParam(name = "name", required = false,defaultValue = "") String name,
                         @RequestParam(name = "current", required = false, defaultValue = "1") Integer current,
                         @RequestParam(name = "size", required = false, defaultValue = "10") Integer size) {
        return employeeService.list(current, size, name);
    }

    /**
     * 分页查询接口
     *
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/list")
    public Result list(@RequestParam(name = "current", required = false, defaultValue = "1") Integer current,
                       @RequestParam(name = "size", required = false, defaultValue = "10") Integer size) {
     * @param employee
     * @return
     */
    @PostMapping("/update")
    public Map<String, Object> updateUser(@RequestBody Employee employee) {
        log.info(employee.toString());
        return employeeService.update(employee);
    }

    /**
     * 删除用户
     * @param id
     * @return
     */
    @GetMapping("/delete")
    public Result deleteEmployeeById(@RequestParam(name = "id") Integer id) {
        return employeeService.deleteEmployeeById(id);
    }

    /**
     * 辞退员工
     *
     * @param id
     * @return
     */
    @GetMapping("/dismiss")
    public Map<String, Object> dismissEmployeeById(@RequestParam(name = "id") Integer id) {
        return employeeService.dismissEmployeeById(id);
    }

    /**
     * 得到所以工作,部门,学历信息
     *
     * @return
     */
    @GetMapping("/otherInfo")
    public Result getAllOtherInfo() {
        Map<String, Object> info = new HashMap<>();
        info.put("departments", departmentService.selectAll());
        info.put("jobs", jobService.selectAll());
        info.put("eduLevels", eduLevelMapper.selectList(null));
        return Result.success(info);
    }

    @GetMapping("/map")
    public Result getMap() {
        return employeeService.getMap();
    }
}

        if (!this.wxService.switchover(appid)) {
            throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
        }
        WxMpUser user = null;
        try {
            WxMpOAuth2AccessToken accessToken = wxService.oauth2getAccessToken(code);
            user = wxService.oauth2getUserInfo(accessToken, null);
            map.put("user", user);
        } catch (WxErrorException e) {
            e.printStackTrace();
        }
        System.out.println(user);
        //websocket 开启登录功能
        LambdaQueryWrapper<Employee> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Employee::getOpenid, user.getOpenId());
        Employee employee = employeeMapper.selectOne(wrapper);
        if (employee != null) {
            LoginDTO loginDTO = new LoginDTO();
            loginDTO.setUserId(employee.getId());
            loginDTO.setAvator_url(user.getHeadImgUrl());
            loginDTO.setToken(UUID.randomUUID().toString());
            if (employee.getAuthority() == 1) {
                loginDTO.setSuper(true);
            } else {
                loginDTO.setSuper(false);
            }
            //发送消息给客户端
            try {
                WebSocketServer.sendInfo(loginDTO, "login");
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            try {
                WebSocketServer.sendInfo("用户不存在", "error");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return user;
    }

/**
 */
@AllArgsConstructor
@RestController
@RequestMapping("/wx/redirect/{appid}")
public class WxRedirectController {
    private final WxMpService wxService;
    @Autowired
    private WebSocketServer webSocketServer;
    @Autowired
    private EmployeeMapper employeeMapper;

    @RequestMapping("/greet")
    public WxMpUser greetUser(@PathVariable String appid, @RequestParam String code, ModelMap map) {
        if (!this.wxService.switchover(appid)) {
            throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
        }
        WxMpUser user = null;
        try {
            WxMpOAuth2AccessToken accessToken = wxService.oauth2getAccessToken(code);
            user = wxService.oauth2getUserInfo(accessToken, null);
            map.put("user", user);
        } catch (WxErrorException e) {
            e.printStackTrace();
        }
        System.out.println(user);
        //websocket 开启登录功能
        LambdaQueryWrapper<Employee> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Employee::getOpenid, user.getOpenId());
        Employee employee = employeeMapper.selectOne(wrapper);
        if (employee != null) {
            LoginDTO loginDTO = new LoginDTO();
            loginDTO.setUserId(employee.getId());
            loginDTO.setAvator_url(user.getHeadImgUrl());
            loginDTO.setToken(UUID.randomUUID().toString());
            if (employee.getAuthority() == 1) {
                loginDTO.setSuper(true);
            } else {
                loginDTO.setSuper(false);
            }
            //发送消息给客户端
            try {
     * @param id
     * @return
     */
    @GetMapping("/getEmployeeById")
    public Employee getUserById(@RequestParam(name = "id") Integer id) {
        return employeeMapper.selectById(id);
    }
    /**
     * 增加员工接口
     *
     * @param employee
     * @return
     */
    @PostMapping("/add")
    public Map<String, Object> addUser(@RequestBody Employee employee) {
        log.info(employee.toString());
        return employeeService.add(employee);
    }

    /**
     * 更新用户
     * @param employee
     * @return
     */
    @PostMapping("/update")
    public Map<String, Object> updateUser(@RequestBody Employee employee) {
        log.info(employee.toString());
        return employeeService.update(employee);
    }

    /**
     * 删除用户
     * @param id
     * @return
     */
    @GetMapping("/delete")
    public Result deleteEmployeeById(@RequestParam(name = "id") Integer id) {
        return employeeService.deleteEmployeeById(id);
    }

    /**
     * 辞退员工
/**
 */
@Slf4j
@RestController
@RequestMapping("/department")
@CrossOrigin
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;

    /**
     * 查询所以部门
     * @return
     */
    @GetMapping("/list")
    public Result list() {
        return Result.success(departmentService.selectAll());
    }

    @PostMapping("/add")
    public Map<String, Object> add(@RequestBody Map<String, Object> map) {
        log.info(map.toString());
        return departmentService.add(map);
    }
}

/**
 * 人事管理相关接口
 */
@RestController
@CrossOrigin
@RequestMapping("/personnel")
public class PersonnelController {
    @Autowired
    private PersonnelService personnelService;

    /**
     * 所以人事记录接口
     * @return
     */
    @PostMapping("/update")
    public Map<String, Object> updateUser(@RequestBody Employee employee) {
        log.info(employee.toString());
        return employeeService.update(employee);
    }

    /**
     * 删除用户
     * @param id
     * @return
     */
    @GetMapping("/delete")
    public Result deleteEmployeeById(@RequestParam(name = "id") Integer id) {
        return employeeService.deleteEmployeeById(id);
    }

    /**
     * 辞退员工
     *
     * @param id
     * @return
     */
    @GetMapping("/dismiss")
    public Map<String, Object> dismissEmployeeById(@RequestParam(name = "id") Integer id) {
        return employeeService.dismissEmployeeById(id);
    }

    /**
     * 得到所以工作,部门,学历信息
     *
     * @return
     */
    @GetMapping("/otherInfo")
    public Result getAllOtherInfo() {
        Map<String, Object> info = new HashMap<>();
        info.put("departments", departmentService.selectAll());
        info.put("jobs", jobService.selectAll());
        info.put("eduLevels", eduLevelMapper.selectList(null));
        return Result.success(info);
    }

    }
}

/**
 * 注意: 在 Controller 里面使用属性时需要指定配置文件
 */

@Slf4j
@RestController
@RequestMapping("/wx/portal/{appid}")
@AllArgsConstructor
@PropertySource("classpath:application.yml")
public class WxMessageController {
    private final WxMpService wxService;

    @GetMapping(produces = "text/plain;charset=utf-8")
    public String authGet(@PathVariable String appid,
                          @RequestParam(name = "signature", required = false) String signature,
                          @RequestParam(name = "timestamp", required = false) String timestamp,
                          @RequestParam(name = "nonce", required = false) String nonce,
                          @RequestParam(name = "echostr", required = false) String echostr,
                          @Value("${prop.url}") String url) {

        log.info("\n接收到来自微信服务器的认证消息:[{}, {}, {}, {}]", signature,
                timestamp, nonce, echostr);
        url = url + "wx/redirect/" +appid + "/greet";
        String s = wxService.oauth2buildAuthorizationUrl(url, WxConsts.OAuth2Scope.SNSAPI_USERINFO, null);
        System.out.println(url);
        System.out.println(s);
        if (StringUtils.isAnyBlank(signature, timestamp, nonce, echostr)) {
            throw new IllegalArgumentException("请求参数非法,请核实!");
        }

        if (!this.wxService.switchover(appid)) {
            throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
        }

        if (wxService.checkSignature(timestamp, nonce, signature)) {
            return echostr;
        }


/**
 */
@AllArgsConstructor
@RestController
@RequestMapping("/wx/redirect/{appid}")
public class WxRedirectController {
    private final WxMpService wxService;
    @Autowired
    private WebSocketServer webSocketServer;
    @Autowired
    private EmployeeMapper employeeMapper;

    @RequestMapping("/greet")
    public WxMpUser greetUser(@PathVariable String appid, @RequestParam String code, ModelMap map) {
        if (!this.wxService.switchover(appid)) {
            throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
        }
        WxMpUser user = null;
        try {
            WxMpOAuth2AccessToken accessToken = wxService.oauth2getAccessToken(code);
            user = wxService.oauth2getUserInfo(accessToken, null);
            map.put("user", user);
     * @return
     */
    @GetMapping("/welcome")
    public Result getWelcome() {
        return jobService.welcome();
    }
}

/**
 */
@Slf4j
@RestController
@RequestMapping("/department")
@CrossOrigin
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;

    /**
     * 查询所以部门
     * @return
     */
    @GetMapping("/list")
    public Result list() {
        return Result.success(departmentService.selectAll());
    }

    @PostMapping("/add")
    public Map<String, Object> add(@RequestBody Map<String, Object> map) {
        log.info(map.toString());

@RestController
@RequestMapping("/job")
@CrossOrigin
public class JobController {
    @Autowired
    private JobService jobService;

    @GetMapping("/numbers")
    public Result getJobPersonNumbers() {
        return jobService.getJobPersonNumbers();
    }

    /**
     * 返回欢迎页面数据
     * @return
     */
    @GetMapping("/welcome")
    public Result getWelcome() {
        return jobService.welcome();
    }
}

/**
 */
@Slf4j
@RestController
@RequestMapping("/department")
@CrossOrigin
public class DepartmentController {
     * 分页查询接口
     *
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/list")
    public Result list(@RequestParam(name = "current", required = false, defaultValue = "1") Integer current,
                       @RequestParam(name = "size", required = false, defaultValue = "10") Integer size) {
        return employeeService.list(current, size, null);
    }

    /**
     * 根据id获取员工具体信息
     * @param id
     * @return
     */
    @GetMapping("/getUserById")
    public EmployeeDTO getUserAllInfoById(@RequestParam(name = "id") Integer id) {
        return employeeService.getUserById(id);
    }

    /**
     * 根据员工获取信息
     * @param id
     * @return
     */
    @GetMapping("/getEmployeeById")
    public Employee getUserById(@RequestParam(name = "id") Integer id) {
        return employeeMapper.selectById(id);
    }
    /**
     * 增加员工接口
     *
     * @param employee
     * @return
     */
    @PostMapping("/add")
    public Map<String, Object> addUser(@RequestBody Employee employee) {
        log.info(employee.toString());
        return employeeService.add(employee);
    }

    /**
            WxMpOAuth2AccessToken accessToken = wxService.oauth2getAccessToken(code);
            user = wxService.oauth2getUserInfo(accessToken, null);
            map.put("user", user);
        } catch (WxErrorException e) {
            e.printStackTrace();
        }
        System.out.println(user);
        //websocket 开启登录功能
        LambdaQueryWrapper<Employee> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Employee::getOpenid, user.getOpenId());
        Employee employee = employeeMapper.selectOne(wrapper);
        if (employee != null) {
            LoginDTO loginDTO = new LoginDTO();
            loginDTO.setUserId(employee.getId());
            loginDTO.setAvator_url(user.getHeadImgUrl());
            loginDTO.setToken(UUID.randomUUID().toString());
            if (employee.getAuthority() == 1) {
                loginDTO.setSuper(true);
            } else {
                loginDTO.setSuper(false);
            }
            //发送消息给客户端
            try {
                WebSocketServer.sendInfo(loginDTO, "login");
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            try {
                WebSocketServer.sendInfo("用户不存在", "error");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return user;
    }
}

/**
 * 注意: 在 Controller 里面使用属性时需要指定配置文件
@RequestMapping("/employee")
@CrossOrigin
@Slf4j
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private JobService jobService;
    @Autowired
    private EduLevelMapper eduLevelMapper;
    @Autowired
    private EmployeeMapper employeeMapper;
    /**
     * 搜索接口
     */
    @GetMapping("/search")
    public Result search(@RequestParam(name = "name", required = false,defaultValue = "") String name,
                         @RequestParam(name = "current", required = false, defaultValue = "1") Integer current,
                         @RequestParam(name = "size", required = false, defaultValue = "10") Integer size) {
        return employeeService.list(current, size, name);
    }

    /**
     * 分页查询接口
     *
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/list")
    public Result list(@RequestParam(name = "current", required = false, defaultValue = "1") Integer current,
                       @RequestParam(name = "size", required = false, defaultValue = "10") Integer size) {
        return employeeService.list(current, size, null);
    }

    /**
     * 根据id获取员工具体信息
     * @param id
     * @return
     */
    @GetMapping("/getUserById")
    public EmployeeDTO getUserAllInfoById(@RequestParam(name = "id") Integer id) {
        return employeeService.getUserById(id);
    }

    /**
     * 根据员工获取信息
     * @param id
        log.info(employee.toString());
        return employeeService.add(employee);
    }

    /**
     * 更新用户
     * @param employee
     * @return
     */
    @PostMapping("/update")
    public Map<String, Object> updateUser(@RequestBody Employee employee) {
        log.info(employee.toString());
        return employeeService.update(employee);
    }

    /**
     * 删除用户
     * @param id
     * @return
     */
    @GetMapping("/delete")
    public Result deleteEmployeeById(@RequestParam(name = "id") Integer id) {
        return employeeService.deleteEmployeeById(id);
    }

    /**
     * 辞退员工
     *
     * @param id
     * @return
     */
    @GetMapping("/dismiss")
    public Map<String, Object> dismissEmployeeById(@RequestParam(name = "id") Integer id) {
        return employeeService.dismissEmployeeById(id);
    }

    /**
     * 得到所以工作,部门,学历信息
     *
     * @return
     */
    @GetMapping("/otherInfo")
    public Result getAllOtherInfo() {
        Map<String, Object> info = new HashMap<>();
        info.put("departments", departmentService.selectAll());
        info.put("jobs", jobService.selectAll());
@CrossOrigin
@Slf4j
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private JobService jobService;
    @Autowired
    private EduLevelMapper eduLevelMapper;
    @Autowired
    private EmployeeMapper employeeMapper;
    /**
     * 搜索接口
     */
    @GetMapping("/search")
    public Result search(@RequestParam(name = "name", required = false,defaultValue = "") String name,
                         @RequestParam(name = "current", required = false, defaultValue = "1") Integer current,
                         @RequestParam(name = "size", required = false, defaultValue = "10") Integer size) {
        return employeeService.list(current, size, name);
    }

    /**
     * 分页查询接口
     *
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/list")
    public Result list(@RequestParam(name = "current", required = false, defaultValue = "1") Integer current,
                       @RequestParam(name = "size", required = false, defaultValue = "10") Integer size) {
        return employeeService.list(current, size, null);
    }

    /**
     * 根据id获取员工具体信息
     * @param id
     * @return
     */
    @GetMapping("/getUserById")

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值