yaowanxin
昨天 4c001e8b7efc1383d1cdfc8219538eeaec49c51b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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<RyglAddEmployee> 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<RyglAddEmployee> 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();
//    }
 
}