package com.ruoyi.staff_management.controller; import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.staff_management.domain.RyglAddEmployee; import com.ruoyi.staff_management.service.RyglAddEmployeeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("/staff_management") public class RyglAddEmployeeController extends BaseController { @Autowired private RyglAddEmployeeService ryglAddEmployeeService; /** * 获取人员列表 */ // @PreAuthorize("@ss.hasPermi('system:dept:list')") @GetMapping("/list") public AjaxResult list() { List allEmployees = ryglAddEmployeeService.getAllEmployees(); return success(allEmployees); } /** * 根据 ID 获取员工信息 * @param id 员工 ID * @return 员工信息 */ @GetMapping("/{id}") public AjaxResult getInfo(@PathVariable Long id) { RyglAddEmployee employee = ryglAddEmployeeService.getById(id); return success(employee); } /** * 根据姓名查询员工信息 * @param name 员工姓名 * @return 员工信息列表 */ @GetMapping("/search") public AjaxResult searchByName(@RequestParam String name) { List employees = ryglAddEmployeeService.searchByName(name); return success(employees); } /** * 添加员工信息 * @param employee 员工信息 * @return 操作结果 */ @PostMapping public AjaxResult add(@RequestBody RyglAddEmployee employee) { boolean result = ryglAddEmployeeService.save(employee); return result ? success() : error(); } /** * 修改员工信息 * @param employee 员工信息 * @return 操作结果 */ @PutMapping public AjaxResult update(@RequestBody RyglAddEmployee employee) { boolean result = ryglAddEmployeeService.updateById(employee); return result ? success() : error(); } /** * 删除员工信息 * @param id 员工 ID * @return 操作结果 */ @DeleteMapping("/{id}") public AjaxResult delete(@PathVariable Long id) { boolean result = ryglAddEmployeeService.removeById(id); return result ? success() : error(); } /** * 导出员工信息 * @return 操作结果 (Excel 文件) */ // @GetMapping("/export") // public AjaxResult export() { // // 调用导出方法 // ryglAddEmployeeService.export(); // return success(); // } }