| | |
| | | package cc.mrbird.febs.server.hr.controller; |
| | | |
| | | import cc.mrbird.febs.server.hr.annotation.ControllerEndpoint; |
| | | import cc.mrbird.febs.server.hr.constant.MyConstant; |
| | | import cc.mrbird.febs.server.hr.entity.EmpLeaveInfo; |
| | | import cc.mrbird.febs.server.hr.entity.EmpOccupational; |
| | | import cc.mrbird.febs.server.hr.service.IEmpOccupationalService; |
| | | import cc.mrbird.febs.common.core.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.core.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.core.exception.FebsException; |
| | | import cc.mrbird.febs.common.core.utils.FebsUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.wuwenze.poi.ExcelKit; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | Map<String, Object> dataTable = FebsUtil.getDataTable(this.empOccupationalService.findEmpOccupationals(request, empOccupational)); |
| | | return new FebsResponse().data(dataTable); |
| | | } |
| | | |
| | | @ApiOperation(value = "导出员工") |
| | | @RequestMapping(value = "export",method= RequestMethod.POST) |
| | | @ControllerEndpoint(operation = "导出用户数据", exceptionMessage = "导出Excel失败") |
| | | public void export(QueryRequest request, EmpOccupational empBaseinfo, HttpServletResponse response) { |
| | | request.setPageSize(this.empOccupationalService.count()); |
| | | List<EmpOccupational> records = this.empOccupationalService.findEmpOccupationals(request, empBaseinfo).getRecords(); |
| | | ExcelKit.$Export(EmpOccupational.class, response).downXlsx(records, false); |
| | | } |
| | | @PostMapping |
| | | @PreAuthorize("hasAuthority('empOccupational:add')") |
| | | public void addEmpOccupational(@Valid EmpOccupational empOccupational) throws FebsException { |
| | |
| | | this.empOccupationalService.createEmpOccupational(empOccupational); |
| | | } catch (Exception e) { |
| | | String message = "新增员工工伤案件失败"; |
| | | if (StrUtil.equals(e.getMessage(), MyConstant.MESSAGE)){ |
| | | message = e.getMessage(); |
| | | } |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |