| | |
| | | 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.EmpResign; |
| | | import cc.mrbird.febs.server.hr.entity.EmpUnemployment; |
| | | import cc.mrbird.febs.server.hr.service.IEmpUnemploymentService; |
| | | 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.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * name:EmpUnemployment |
| | | * package:cc.mrbird.febs.server.hr.controller |
| | | * description:失业金领取表控制器 |
| | | * |
| | | * @author luoyibo |
| | | * @date 2021-02-01 00:22:28 |
| | | * @since JDK1.8 |
| | | */ |
| | | * name:EmpUnemployment |
| | | * package:cc.mrbird.febs.server.hr.controller |
| | | * description:失业金领取表控制器 |
| | | * |
| | | * @author luoyibo |
| | | * @date 2021-02-01 00:22:28 |
| | | * @since JDK1.8 |
| | | */ |
| | | @Api(tags = "人员失业金领取信息录入接口") |
| | | @Slf4j |
| | | @Validated |
| | |
| | | @RequiredArgsConstructor |
| | | public class EmpUnemploymentController { |
| | | |
| | | private final IEmpUnemploymentService empUnemploymentService; |
| | | private final IEmpUnemploymentService empUnemploymentService; |
| | | |
| | | @GetMapping |
| | | @PreAuthorize("hasAuthority('empUnemployment:list')") |
| | | public FebsResponse getAllEmpUnemployments(EmpUnemployment empUnemployment) { |
| | | return new FebsResponse().data(empUnemploymentService.findEmpUnemployments(empUnemployment)); |
| | | } |
| | | @GetMapping |
| | | @PreAuthorize("hasAuthority('empUnemployment:list')") |
| | | public FebsResponse getAllEmpUnemployments(EmpUnemployment empUnemployment) { |
| | | return new FebsResponse().data(empUnemploymentService.findEmpUnemployments(empUnemployment)); |
| | | } |
| | | |
| | | @GetMapping("list") |
| | | @PreAuthorize("hasAuthority('empUnemployment:list')") |
| | | public FebsResponse empUnemploymentList(QueryRequest request, EmpUnemployment empUnemployment) { |
| | | Map<String, Object> dataTable = FebsUtil.getDataTable(this.empUnemploymentService.findEmpUnemployments(request, empUnemployment)); |
| | | return new FebsResponse().data(dataTable); |
| | | } |
| | | @GetMapping("list") |
| | | @PreAuthorize("hasAuthority('empUnemployment:list')") |
| | | public FebsResponse empUnemploymentList(QueryRequest request, EmpUnemployment empUnemployment) { |
| | | Map<String, Object> dataTable = FebsUtil.getDataTable(this.empUnemploymentService.findEmpUnemployments(request, empUnemployment)); |
| | | return new FebsResponse().data(dataTable); |
| | | } |
| | | @ApiOperation(value = "导出员工") |
| | | @RequestMapping(value = "export",method= RequestMethod.POST) |
| | | @ControllerEndpoint(operation = "导出用户数据", exceptionMessage = "导出Excel失败") |
| | | public void export(QueryRequest request, EmpUnemployment empBaseinfo, HttpServletResponse response) { |
| | | request.setPageSize(this.empUnemploymentService.count()); |
| | | List<EmpUnemployment> records = this.empUnemploymentService.findEmpUnemployments(request, empBaseinfo).getRecords(); |
| | | ExcelKit.$Export(EmpUnemployment.class, response).downXlsx(records, false); |
| | | } |
| | | @PostMapping |
| | | @PreAuthorize("hasAuthority('empUnemployment:add')") |
| | | public void addEmpUnemployment(@Valid EmpUnemployment empUnemployment) throws FebsException { |
| | | try { |
| | | this.empUnemploymentService.createEmpUnemployment(empUnemployment); |
| | | } catch (Exception e) { |
| | | String message = "新增失业金领取表失败"; |
| | | if (StrUtil.equals(e.getMessage(), MyConstant.MESSAGE)){ |
| | | message = e.getMessage(); |
| | | } |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | |
| | | @PostMapping |
| | | @PreAuthorize("hasAuthority('empUnemployment:add')") |
| | | public void addEmpUnemployment(@Valid EmpUnemployment empUnemployment) throws FebsException { |
| | | try { |
| | | this.empUnemploymentService.createEmpUnemployment(empUnemployment); |
| | | } catch (Exception e) { |
| | | String message = "新增失业金领取表失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | @DeleteMapping |
| | | @PreAuthorize("hasAuthority('empUnemployment:delete')") |
| | | public void deleteEmpUnemployment(EmpUnemployment empUnemployment) throws FebsException { |
| | | try { |
| | | this.empUnemploymentService.deleteEmpUnemployment(empUnemployment); |
| | | } catch (Exception e) { |
| | | String message = "删除失业金领取表失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @PreAuthorize("hasAuthority('empUnemployment:delete')") |
| | | public void deleteEmpUnemployment(EmpUnemployment empUnemployment) throws FebsException { |
| | | try { |
| | | this.empUnemploymentService.deleteEmpUnemployment(empUnemployment); |
| | | } catch (Exception e) { |
| | | String message = "删除失业金领取表失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | @DeleteMapping("{ids}") |
| | | @PreAuthorize("hasAuthority('empUnemployment:delete')") |
| | | public void logicDeleteEmpUnemployment(@PathVariable("ids") String ids) throws FebsException { |
| | | try { |
| | | this.empUnemploymentService.logicDelEmpUnemployment(ids); |
| | | } catch (Exception e) { |
| | | String message = "逻辑删除失业金领取表失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | |
| | | @DeleteMapping("{ids}") |
| | | @PreAuthorize("hasAuthority('empUnemployment:delete')") |
| | | public void logicDeleteEmpUnemployment(@PathVariable("ids") String ids) throws FebsException { |
| | | try { |
| | | this.empUnemploymentService.logicDelEmpUnemployment(ids); |
| | | } catch (Exception e) { |
| | | String message = "逻辑删除失业金领取表失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | @PutMapping |
| | | @PreAuthorize("hasAuthority('empUnemployment:update')") |
| | | public void updateEmpUnemployment(EmpUnemployment empUnemployment) throws FebsException { |
| | | try { |
| | | this.empUnemploymentService.updateEmpUnemployment(empUnemployment); |
| | | } 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('empUnemployment:update')") |
| | | public void updateEmpUnemployment(EmpUnemployment empUnemployment) throws FebsException { |
| | | try { |
| | | this.empUnemploymentService.updateEmpUnemployment(empUnemployment); |
| | | } catch (Exception e) { |
| | | String message = "修改失业金领取表失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | @ApiOperation(value = "失业金领取信息提交") |
| | | @DeleteMapping("toNormal/{ids}") |
| | | @PreAuthorize("hasAuthority('empUnemployment:delete')") |
| | | public void momentToNormal(@NotBlank(message = "{required}") @PathVariable("ids") String ids) throws FebsException { |
| | | try { |
| | | this.empUnemploymentService.momentToNormal(ids); |
| | | } catch (Exception e) { |
| | | String message = "失业金领取信息提交失败"; |
| | | log.error(message, e); |
| | | throw new FebsException(message); |
| | | } |
| | | } |
| | | } |