package com.song.vhr.controller.Emp;
import com.song.vhr.model.*; import com.song.vhr.service.*; import com.song.vhr.utils.POIUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** * @author song * @data 2020/2/21 */ @RestController @RequestMapping("/emp/basic") public class EmpBasicController {
@Autowired EmployeeService employeeService; @Autowired NationService nationService; @Autowired PoliticsstatusService politicsstatusService; @Autowired PositionService positionService;
@Autowired JobLevelService jobLevelService; @GetMapping("/") public RespPageBean getEmployeeByPage(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10")Integer size,String keywords){ return employeeService.getEmployeeByPage(page,size,keywords); }
@PostMapping("/") public RespBean addEmp(@RequestBody Employee employee){ if(employeeService.addEmp(employee)==1){ return RespBean.ADD_SUCCESS; } return RespBean.ADD_ERROR; }
@GetMapping("/nations") public List<Nation> getAllNations(){ return nationService.getAllNations(); } @GetMapping("/politicsstatus") public List<Politicsstatus> getAllPoliticsstatus(){ return politicsstatusService.getAllPoliticsstatus(); }
@GetMapping("/jobLevels") public List<JobLevel> getAllJobLevel(){ return jobLevelService.getAllJobLevels(); } @GetMapping("/position") public List<Position> getAllPosition(){ return positionService.getAllPositions(); }
@GetMapping("/maxWordID") public RespBean maxWordID(){
return RespBean.ok("",String.format("%08d",employeeService.maxWordID()+1)); }
@DeleteMapping("/{id}") public RespBean deleteEmp(@PathVariable Integer id){ if(employeeService.deleteEmp(id)==1){ return RespBean.DELETE_SUCCESS; } return RespBean.DELETE_ERROR; } @PutMapping("/") public RespBean updateEmp(@RequestBody Employee employee){ if(employeeService.updateEmp(employee)==1){ return RespBean.UPDATE_SUCCESS; } return RespBean.UPDATE_ERROR; }
@GetMapping("/export") public ResponseEntity<byte[]> exportDate(){ List<Employee> list= (List<Employee>) employeeService.getEmployeeByPage(null,null,null).getData();
return POIUtils.employee2Excel(list); }
}
|
|