功能介绍:
登录、新增、修改、离职
部门控制层:
@RequestMapping("/Department")
@RestController
public class DepartmentController {
@Autowired
IDepartmentService departmentService;
@Autowired
private HttpServletRequest request;
@PostMapping("/addDepartment")
public Result addDepartment(@RequestParam("departmentNumber") String departmentNumber, @RequestParam("departmentName") String departmentName,
@RequestParam("departmentHead") String departmentHead, @RequestParam("departmentAddress") String departmentAddress,
@RequestParam("departmentTel") String departmentTel, @RequestParam("departmentFax") String departmentFax)throws ParseException {
SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Department department = new Department();
department.setDepartmentName(departmentName);
department.setDepartmentNumber(departmentNumber);
department.setDepartmentAddress(departmentAddress);
department.setDepartmentHead(departmentHead);
department.setDepartmentTel(departmentTel);
department.setDepartmentFax(departmentFax);
return departmentService.addDepartment(department);
}
@GetMapping("/getAllDepartments")
public ModelAndView getAllDepartments(){
departmentService.getAllDepartments();
// System.out.println("就是"+request.getSession().getAttribute("departmentPage"));
return new ModelAndView("department");
}
@PostMapping("/deleteDepartment")
public Result deleteDepartment(@RequestParam("ids") String ids){
return departmentService.deleteDepartment(ids);
}
@PostMapping("/modifyDepartment")
public Result modifyDepartment(@RequestParam("departmentNumber") String departmentNumber, @RequestParam("departmentName") String departmentName,
@RequestParam("departmentHead") String departmentHead, @RequestParam("departmentAddress") String departmentAddress,
@RequestParam("departmentTel") String departmentTel, @RequestParam("departmentFax") String departmentFax,
@RequestParam("id") long id)throws ParseException{
Department department = new Department();
department.setDepartmentName(departmentName);
department.setDepartmentNumber(departmentNumber);
department.setDepartmentAddress(departmentAddress);
department.setDepartmentHead(departmentHead);
department.setDepartmentTel(departmentTel);
department.setDepartmentFax(departmentFax);
department.setId(id);
// System.out.println("department修改: "+ department);
return departmentService.modifyDepartment(department);
}
@GetMapping("/getPage")
public ModelAndView getPage(@RequestParam("currentPage") Integer currentPage){
departmentService.getPageDatas(currentPage);
// System.out.println("currentPage: "+currentPage);
return new ModelAndView("department");
}
@GetMapping("/getDepartmentById")
public Result getDepartmentById(@RequestParam("id") long id){
return departmentService.getDepartmentById(id);
}
@GetMapping("/getDepartmentByDepartmentNumber")
public ModelAndView getDepartmentByDepartmentNumber(@RequestParam("departmentNumber") String departmentNumber)throws ParseException{
departmentService.getDepartmentByDepartmentNumber(departmentNumber);
return new ModelAndView("department");
}
@PostMapping("/getDepartmentNumberByDepartmentName")
public Result getDepartmentNumberByDepartmentName(@RequestParam("departmentName") String departmentName)throws ParseException{
return departmentService.getDepartmentNumberByDepartmentName(departmentName);
}
}
员工控制层:
package com.lut.controller;
import com.lut.entity.Employee;
import com.lut.entity.Result;
import com.lut.service.IEmployeeService;
import com.lut.service.impl.EmployeeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
@Controller
@RequestMapping("/employee")
public class EmployeeController {
@Autowired
private IEmployeeService employeeService;
@Autowired
private EmployeeServiceImpl employeeServiceImpl;
@PostMapping("/login")
public ModelAndView login(Employee employee, HttpServletRequest request){
Result result = employeeService.login(employee);
if (result.getCode()==0){
return new ModelAndView("redirect:/page/index");
}
request.setAttribute("pageMsg",result.getMsg());
return new ModelAndView("forward:/page/login");
}
@PostMapping("/del_employees")
@ResponseBody
public ModelAndView deleteEmployees(@RequestParam("ids") String ids){
employeeService.deleteEmployees(ids);
return new ModelAndView("employeeInfo");
}
@GetMapping("/getPage")
public ModelAndView getPage(@RequestParam("currentPage") Integer currentPage){
employeeService.getPageDatas(currentPage);
return new ModelAndView("employeeInfo");
}
@PostMapping("/addEmployee")
@ResponseBody
public Result addEmployee(Employee employee){
return employeeService.addEmployee(employee);
}
@GetMapping("/getUpdateEmployeeInfo")
public ModelAndView getUpdateEmployeeInfo(){
employeeServiceImpl.updateAllEmployeeToSession();
return new ModelAndView("employeeInfo");
}
@GetMapping("/getMyAccount")
public ModelAndView getMyAccount(){
return new ModelAndView("myAccount");
}
@GetMapping("/getEmployee")
@ResponseBody
public Result getEmployee(@RequestParam("id") long id){
Employee employee = new Employee();
employee.setId(id);
return employeeService.getEmployee(employee);
}
@PostMapping("/updateEmployeeById")
@ResponseBody
public Result updateEmployeeById(Employee employee){
return employeeService.updateEmployeeById(employee);
}
@PostMapping("/getEmployeeByNumber")
@ResponseBody
public Result getEmployeeByNumber(Employee employee){
return employeeService.getEmployeeByNumber(employee.getEmployeeNumber());
}
@PostMapping("/updateEmployeeByNumber")
@ResponseBody
public Result updateEmployeeByNumber(Employee employee){
return employeeService.updateEmployeeByNumber(employee);
}
@PostMapping("/uploadMyImage")
@ResponseBody
public Result upLoadMyImage(){
return employeeService.upLoadMyImage();
}
@GetMapping("/clearLogin")
@ResponseBody
public Result clearLogin(){
return employeeServiceImpl.clearLogin();
}
@PostMapping("/modifyPwd")
@ResponseBody
public Result modifyPwd(@RequestParam("oldPwd") String oldPwd,@RequestParam("newPwd") String newPwd){
return employeeService.modifyPwd(oldPwd,newPwd);
}
@GetMapping("/loginYesOrNo")
@ResponseBody
public Result loginYesOrNo(){
employeeServiceImpl.getEmployeeLoginInfo();
return new Result(0,"已登录",null);
}
@GetMapping("/getEmployeeByEmployeeNumber")
@ResponseBody
public Result getEmployeeByEmployeeNumber(@RequestParam("employeeNumber") String employeeNumber)throws ParseException {
Employee employee = new Employee();
employee.setEmployeeNumber(employeeNumber);
return employeeService.getEmployeeByEmployeeNumber(employee);
}
@PostMapping("/getEmployeeByName")
@ResponseBody
public Result getEmployeeByName(Employee employee)throws ParseException{
return employeeService.getEmployeeByName(employee.getEmployeeName());
}
@GetMapping("/getPersonByEmployeeNumber")
@ResponseBody
public ModelAndView getPersonByEmployeeNumber(@RequestParam("employeeNumber") String employeeNumber){
Employee employee = new Employee();
employee.setEmployeeNumber(employeeNumber);
employeeServiceImpl.getPersonByEmployeeNumber(employee);
return new ModelAndView("employeeInfo");
}
}
证书控制层:
@RequestMapping("/Certificate")
@RestController
public class CertificateController {
@Autowired
ICertificateService certificateService;
@Autowired
private HttpServletRequest request;
@PostMapping("/addCertificate")
public Result addCertificate(@RequestParam("name") String name,
@RequestParam("happenTime") String happenTime,
@RequestParam("organization") String organization,
@RequestParam("certificateNumber") String certificateNumber,
@RequestParam("employeeNumber") String employeeNumber)throws ParseException {
// SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Certificate certificate = new Certificate();
certificate.setName(name);
certificate.setCertificateNumber(certificateNumber);
certificate.setHappenTime(happenTime);
certificate.setOrganization(organization);
certificate.setEmployeeNumber(employeeNumber);
return certificateService.addCertificate(certificate);
}
@GetMapping("/getAllCertificates")
public ModelAndView getAllCertificates(){
certificateService.getAllCertificates();
// System.out.println("就是"+request.getSession().getAttribute("certificatePage"));
return new ModelAndView("certificate");
}
@PostMapping("/deleteCertificate")
public Result deleteCertificate(@RequestParam("ids") String ids){
return certificateService.deleteCertificate(ids);
}
@PostMapping("/modifyCertificate")
public Result modifyCertificate(@RequestParam("name") String name,
@RequestParam("happenTime") String happenTime,
@RequestParam("organization") String organization,
@RequestParam("certificateNumber") String certificateNumber,
@RequestParam("employeeNumber") String employeeNumber,
@RequestParam("id") long id)throws ParseException{
// SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Certificate certificate = new Certificate();
certificate.setName(name);
certificate.setCertificateNumber(certificateNumber);
certificate.setHappenTime(happenTime);
certificate.setOrganization(organization);
certificate.setEmployeeNumber(employeeNumber);
certificate.setId(id);
// System.out.println("certificate修改: "+ certificate);
return certificateService.modifyCertificate(certificate);
}
@GetMapping("/getPage")
public ModelAndView getPage(@RequestParam("currentPage") Integer currentPage){
certificateService.getPageDatas(currentPage);
// System.out.println("currentPage: "+currentPage);
return new ModelAndView("certificate");
}
@GetMapping("/getCertificateById")
public Result getCertificateById(@RequestParam("id") long id){
return certificateService.getCertificateById(id);
}
@GetMapping("/getCertificateByEmployeeNumber")
public ModelAndView getCertificateByEmployeeNumber(@RequestParam("employeeNumber") String employeeNumber)throws ParseException{
certificateService.getCertificateByEmployeeNumber(employeeNumber);
return new ModelAndView("certificate");
}
@PostMapping("/getEmployeeNumberByEmployeeName")
public Result getEmployeeNumberByEmployeeName(@RequestParam("employeeName") String employeeName)throws ParseException{
return certificateService.getEmployeeNumberByEmployeeName(employeeName);
}
}