package cc.mrbird.febs.server.hr.controller; import cc.mrbird.febs.server.hr.entity.EmpBaseinfo; import cc.mrbird.febs.server.hr.service.IEmpBaseInfoService; 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:EmpBaseinfo * package:cc.mrbird.febs.server.hr.controller * description:人员基本信息控制器 * * @author luoyibo * @date 2021-01-24 20:35:50 * @since JDK1.8 */ @Slf4j @Validated @RestController @RequestMapping("empBaseinfo") @RequiredArgsConstructor public class EmpBaseInfoController { private final IEmpBaseInfoService empBaseinfoService; @GetMapping @PreAuthorize("hasAuthority('empBaseinfo:list')") public FebsResponse getAllEmpBaseinfos(EmpBaseinfo empBaseinfo) { return new FebsResponse().data(empBaseinfoService.findEmpBaseinfos(empBaseinfo)); } @GetMapping("list") @PreAuthorize("hasAuthority('empBaseinfo:list')") public FebsResponse empBaseinfoList(QueryRequest request, EmpBaseinfo empBaseinfo) { Map dataTable = FebsUtil.getDataTable(this.empBaseinfoService.findEmpBaseinfos(request, empBaseinfo)); return new FebsResponse().data(dataTable); } @PostMapping @PreAuthorize("hasAuthority('empBaseinfo:add')") public void addEmpBaseinfo(@Valid EmpBaseinfo empBaseinfo) throws FebsException { try { this.empBaseinfoService.createEmpBaseinfo(empBaseinfo); } catch (Exception e) { String message = "新增EmpBaseinfo失败"; log.error(message, e); throw new FebsException(message); } } @DeleteMapping @PreAuthorize("hasAuthority('empBaseinfo:delete')") public void deleteEmpBaseinfo(EmpBaseinfo empBaseinfo) throws FebsException { try { this.empBaseinfoService.deleteEmpBaseinfo(empBaseinfo); } catch (Exception e) { String message = "删除EmpBaseinfo失败"; log.error(message, e); throw new FebsException(message); } } @PutMapping @PreAuthorize("hasAuthority('empBaseinfo:update')") public void updateEmpBaseinfo(EmpBaseinfo empBaseinfo) throws FebsException { try { this.empBaseinfoService.updateEmpBaseinfo(empBaseinfo); } catch (Exception e) { String message = "修改EmpBaseinfo失败"; log.error(message, e); throw new FebsException(message); } } }