package cc.mrbird.febs.server.hr.controller; import cc.mrbird.febs.server.hr.entity.EmpPhysicalExam; import cc.mrbird.febs.server.hr.service.IEmpPhysicalExamService; 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 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.validation.Valid; import java.util.Map; /** * * name:EmpPhysicalexam * package:cc.mrbird.febs.server.hr.controller * description:员工体检信息控制器 * * @author luoyibo * @date 2021-01-24 20:35:19 * @since JDK1.8 */ @Slf4j @Validated @RestController @RequestMapping("empPhysicalexam") @RequiredArgsConstructor public class EmpPhysicalExamController { private final IEmpPhysicalExamService empPhysicalexamService; @GetMapping @PreAuthorize("hasAuthority('empPhysicalexam:list')") public FebsResponse getAllEmpPhysicalexams(EmpPhysicalExam empPhysicalexam) { return new FebsResponse().data(empPhysicalexamService.findEmpPhysicalexams(empPhysicalexam)); } @GetMapping("list") @PreAuthorize("hasAuthority('empPhysicalexam:list')") public FebsResponse empPhysicalexamList(QueryRequest request, EmpPhysicalExam empPhysicalexam) { Map dataTable = FebsUtil.getDataTable(this.empPhysicalexamService.findEmpPhysicalexams(request, empPhysicalexam)); return new FebsResponse().data(dataTable); } @PostMapping @PreAuthorize("hasAuthority('empPhysicalexam:add')") public void addEmpPhysicalexam(@Valid EmpPhysicalExam empPhysicalexam) throws FebsException { try { this.empPhysicalexamService.createEmpPhysicalexam(empPhysicalexam); } catch (Exception e) { String message = "新增EmpPhysicalexam失败"; log.error(message, e); throw new FebsException(message); } } @DeleteMapping @PreAuthorize("hasAuthority('empPhysicalexam:delete')") public void deleteEmpPhysicalexam(EmpPhysicalExam empPhysicalexam) throws FebsException { try { this.empPhysicalexamService.deleteEmpPhysicalexam(empPhysicalexam); } catch (Exception e) { String message = "删除EmpPhysicalexam失败"; log.error(message, e); throw new FebsException(message); } } @PutMapping @PreAuthorize("hasAuthority('empPhysicalexam:update')") public void updateEmpPhysicalexam(EmpPhysicalExam empPhysicalexam) throws FebsException { try { this.empPhysicalexamService.updateEmpPhysicalexam(empPhysicalexam); } catch (Exception e) { String message = "修改EmpPhysicalexam失败"; log.error(message, e); throw new FebsException(message); } } }