| | |
| | | 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.EmpAccidentCases; |
| | | import cc.mrbird.febs.server.hr.entity.EmpBaseInfo; |
| | | import cc.mrbird.febs.server.hr.service.IEmpAccidentCasesService; |
| | | 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 lombok.RequiredArgsConstructor; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | 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.io.IOException; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * name:EmpAccidentcases |
| | | * package:cc.mrbird.febs.server.hr.controller |
| | | * description:员工意外险案件控制器 |
| | | * |
| | | * @author luoyibo |
| | | * @date 2021-01-24 20:36:10 |
| | | * @since JDK1.8 |
| | | */ |
| | | * name:EmpAccidentcases |
| | | * package:cc.mrbird.febs.server.hr.controller |
| | | * description:员工意外险案件控制器 |
| | | * |
| | | * @author luoyibo |
| | | * @date 2021-01-31 11:26:27 |
| | | * @since JDK1.8 |
| | | */ |
| | | @Api(tags = "人员意外险案件录入接口") |
| | | @Slf4j |
| | | @Validated |
| | | @RestController |
| | | @RequestMapping("empAccidentcases") |
| | | @RequestMapping("empAccidentCases") |
| | | @RequiredArgsConstructor |
| | | public class EmpAccidentCasesController { |
| | | |
| | | private final IEmpAccidentCasesService empAccidentcasesService; |
| | | private final IEmpAccidentCasesService empAccidentCasesService; |
| | | |
| | | @GetMapping |
| | | @PreAuthorize("hasAuthority('empAccidentcases:list')") |
| | | public FebsResponse getAllEmpAccidentcasess(EmpAccidentCases empAccidentcases) { |
| | | return new FebsResponse().data(empAccidentcasesService.findEmpAccidentcasess(empAccidentcases)); |
| | | } |
| | | @GetMapping |
| | | @PreAuthorize("hasAuthority('empAccidentcases:list')") |
| | | public FebsResponse getAllEmpAccidentCases(EmpAccidentCases empAccidentcases) { |
| | | return new FebsResponse().data(empAccidentCasesService.findEmpAccidentcasess(empAccidentcases)); |
| | | } |
| | | |
| | | @GetMapping("list") |
| | | @PreAuthorize("hasAuthority('empAccidentcases:list')") |
| | | public FebsResponse empAccidentcasesList(QueryRequest request, EmpAccidentCases empAccidentcases) { |
| | | Map<String, Object> dataTable = FebsUtil.getDataTable(this.empAccidentcasesService.findEmpAccidentcasess(request, empAccidentcases)); |
| | | return new FebsResponse().data(dataTable); |
| | | } |
| | | @GetMapping("list") |
| | | @PreAuthorize("hasAuthority('empAccidentcases:list')") |
| | | public FebsResponse empAccidentCasesList(QueryRequest request, EmpAccidentCases empAccidentcases) { |
| | | Map<String, Object> dataTable = FebsUtil.getDataTable(this.empAccidentCasesService.findEmpAccidentcasess(request, empAccidentcases)); |
| | | return new FebsResponse().data(dataTable); |
| | | } |
| | | |
| | | @PostMapping |
| | | @PreAuthorize("hasAuthority('empAccidentcases:add')") |
| | | public void addEmpAccidentcases(@Valid EmpAccidentCases empAccidentcases) throws FebsException { |
| | | try { |
| | | this.empAccidentcasesService.createEmpAccidentcases(empAccidentcases); |
| | | } catch (Exception e) { |
| | | String message = "新增EmpAccidentcases失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | @ApiOperation(value = "导出员工") |
| | | @RequestMapping(value = "export", method = RequestMethod.POST) |
| | | @ControllerEndpoint(operation = "导出用户数据", exceptionMessage = "导出Excel失败") |
| | | public void export(QueryRequest request, EmpAccidentCases empBaseinfo, HttpServletResponse response) { |
| | | request.setPageSize(this.empAccidentCasesService.count()); |
| | | List<EmpAccidentCases> records = this.empAccidentCasesService.findEmpAccidentcasess(request, empBaseinfo).getRecords(); |
| | | ExcelKit.$Export(EmpAccidentCases.class, response).downXlsx(records, false); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @PreAuthorize("hasAuthority('empAccidentcases:delete')") |
| | | public void deleteEmpAccidentcases(EmpAccidentCases empAccidentcases) throws FebsException { |
| | | try { |
| | | this.empAccidentcasesService.deleteEmpAccidentcases(empAccidentcases); |
| | | } catch (Exception e) { |
| | | String message = "删除EmpAccidentcases失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | @PostMapping |
| | | @PreAuthorize("hasAuthority('empAccidentcases:add')") |
| | | public void addEmpAccidentCases(@Valid EmpAccidentCases empAccidentcases) throws FebsException { |
| | | try { |
| | | this.empAccidentCasesService.createEmpAccidentcases(empAccidentcases); |
| | | } catch (Exception e) { |
| | | String message = "新增员工意外险案件失败"; |
| | | if (StrUtil.equals(e.getMessage(), MyConstant.MESSAGE)){ |
| | | message = e.getMessage(); |
| | | } |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | |
| | | @PutMapping |
| | | @PreAuthorize("hasAuthority('empAccidentcases:update')") |
| | | public void updateEmpAccidentcases(EmpAccidentCases empAccidentcases) throws FebsException { |
| | | try { |
| | | this.empAccidentcasesService.updateEmpAccidentcases(empAccidentcases); |
| | | } catch (Exception e) { |
| | | String message = "修改EmpAccidentcases失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | @DeleteMapping |
| | | @PreAuthorize("hasAuthority('empAccidentcases:delete')") |
| | | public void deleteEmpAccidentCases(EmpAccidentCases empAccidentcases) throws FebsException { |
| | | try { |
| | | this.empAccidentCasesService.deleteEmpAccidentcases(empAccidentcases); |
| | | } catch (Exception e) { |
| | | String message = "删除员工意外险案件失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | |
| | | @DeleteMapping("{ids}") |
| | | @PreAuthorize("hasAuthority('empAccidentcases:delete')") |
| | | public void logicDeleteEmpAccidentCases(@PathVariable("ids") String ids) throws FebsException { |
| | | try { |
| | | this.empAccidentCasesService.logicDelEmpAccidentCases(ids); |
| | | } catch (Exception e) { |
| | | String message = "逻辑删除员工意外险案件失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | |
| | | @PutMapping |
| | | @PreAuthorize("hasAuthority('empAccidentcases:update')") |
| | | public void updateEmpAccidentCases(EmpAccidentCases empAccidentcases) throws FebsException { |
| | | try { |
| | | this.empAccidentCasesService.updateEmpAccidentcases(empAccidentcases); |
| | | } catch (Exception e) { |
| | | String message = "修改员工意外险案件失败"; |
| | | if (StrUtil.equals(e.getMessage(), MyConstant.MESSAGE)){ |
| | | message = e.getMessage(); |
| | | } |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "意外险案件信息提交") |
| | | @DeleteMapping("toNormal/{ids}") |
| | | @PreAuthorize("hasAuthority('empAccidentcases:delete')") |
| | | public void momentToNormal(@NotBlank(message = "{required}") @PathVariable("ids") String ids) throws FebsException { |
| | | try { |
| | | this.empAccidentCasesService.momentToNormal(ids); |
| | | } catch (Exception e) { |
| | | String message = "意外险案件信息提交失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | } |