package com.zhongzheng.controller.staff; import java.util.List; import java.util.Arrays; import lombok.RequiredArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.zhongzheng.common.annotation.Log; import com.zhongzheng.common.core.controller.BaseController; import com.zhongzheng.common.core.domain.AjaxResult; import com.zhongzheng.common.enums.BusinessType; import com.zhongzheng.modules.staff.vo.StaffEmergencyContactVo; import com.zhongzheng.modules.staff.bo.StaffEmergencyContactQueryBo; import com.zhongzheng.modules.staff.bo.StaffEmergencyContactAddBo; import com.zhongzheng.modules.staff.bo.StaffEmergencyContactEditBo; import com.zhongzheng.modules.staff.service.IStaffEmergencyContactService; import com.zhongzheng.common.utils.poi.ExcelUtil; import com.zhongzheng.common.core.page.TableDataInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; /** * 员工紧急联系人Controller * * @author ruoyi * @date 2024-03-21 */ @Api(value = "员工紧急联系人控制器", tags = {"员工紧急联系人管理"}) @RequiredArgsConstructor(onConstructor_ = @Autowired) @RestController @RequestMapping("/system/contact") public class StaffEmergencyContactController extends BaseController { private final IStaffEmergencyContactService iStaffEmergencyContactService; /** * 查询员工紧急联系人列表 */ @ApiOperation("查询员工紧急联系人列表") @PreAuthorize("@ss.hasPermi('system:contact:list')") @GetMapping("/list") public TableDataInfo list(StaffEmergencyContactQueryBo bo) { startPage(); List list = iStaffEmergencyContactService.queryList(bo); return getDataTable(list); } /** * 导出员工紧急联系人列表 */ @ApiOperation("导出员工紧急联系人列表") @PreAuthorize("@ss.hasPermi('system:contact:export')") @Log(title = "员工紧急联系人", businessType = BusinessType.EXPORT) @GetMapping("/export") public AjaxResult export(StaffEmergencyContactQueryBo bo) { List list = iStaffEmergencyContactService.queryList(bo); ExcelUtil util = new ExcelUtil(StaffEmergencyContactVo.class); return util.exportExcel(list, "员工紧急联系人"); } /** * 获取员工紧急联系人详细信息 */ @ApiOperation("获取员工紧急联系人详细信息") @PreAuthorize("@ss.hasPermi('system:contact:query')") @GetMapping("/{contactId}") public AjaxResult getInfo(@PathVariable("contactId" ) Long contactId) { return AjaxResult.success(iStaffEmergencyContactService.queryById(contactId)); } /** * 新增员工紧急联系人 */ @ApiOperation("新增员工紧急联系人") @PreAuthorize("@ss.hasPermi('system:contact:add')") @Log(title = "员工紧急联系人", businessType = BusinessType.INSERT) @PostMapping() public AjaxResult add(@RequestBody StaffEmergencyContactAddBo bo) { return toAjax(iStaffEmergencyContactService.insertByAddBo(bo) ? 1 : 0); } /** * 修改员工紧急联系人 */ @ApiOperation("修改员工紧急联系人") @PreAuthorize("@ss.hasPermi('system:contact:edit')") @Log(title = "员工紧急联系人", businessType = BusinessType.UPDATE) @PutMapping() public AjaxResult edit(@RequestBody StaffEmergencyContactEditBo bo) { return toAjax(iStaffEmergencyContactService.updateByEditBo(bo) ? 1 : 0); } /** * 删除员工紧急联系人 */ @ApiOperation("删除员工紧急联系人") @PreAuthorize("@ss.hasPermi('system:contact:remove')") @Log(title = "员工紧急联系人" , businessType = BusinessType.DELETE) @DeleteMapping("/{contactIds}") public AjaxResult remove(@PathVariable Long[] contactIds) { return toAjax(iStaffEmergencyContactService.deleteWithValidByIds(Arrays.asList(contactIds), true) ? 1 : 0); } }