2026-08-10 9fceeaad9af96bc58ba714560814c6e94f8af406
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
package cn.iocoder.yudao.module.hrm.controller.admin.employee;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.hrm.controller.admin.employee.vo.HrmEmployeeContractPageReqVO;
import cn.iocoder.yudao.module.hrm.controller.admin.employee.vo.HrmEmployeeContractRespVO;
import cn.iocoder.yudao.module.hrm.controller.admin.employee.vo.HrmEmployeeContractSaveReqVO;
import cn.iocoder.yudao.module.hrm.controller.admin.employee.vo.HrmEmployeeContractTerminateReqVO;
import cn.iocoder.yudao.module.hrm.service.employee.HrmEmployeeContractService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@Tag(name = "管理后台 - HRM 员工合同")
@RestController
@RequestMapping("/hrm/employee-contract")
@Validated
public class HrmEmployeeContractController {
 
    @Resource
    private HrmEmployeeContractService contractService;
 
    @PostMapping("/create")
    @Operation(summary = "创建员工合同")
    @PreAuthorize("@ss.hasPermission('hrm:employee-contract:create')")
    public CommonResult<Long> createContract(@Valid @RequestBody HrmEmployeeContractSaveReqVO createReqVO) {
        return success(contractService.createContract(createReqVO));
    }
 
    @PutMapping("/update")
    @Operation(summary = "更新员工合同")
    @PreAuthorize("@ss.hasPermission('hrm:employee-contract:update')")
    public CommonResult<Boolean> updateContract(@Valid @RequestBody HrmEmployeeContractSaveReqVO updateReqVO) {
        contractService.updateContract(updateReqVO);
        return success(true);
    }
 
    @PutMapping("/terminate")
    @Operation(summary = "解除/终止员工合同")
    @PreAuthorize("@ss.hasPermission('hrm:employee-contract:update')")
    public CommonResult<Boolean> terminateContract(@Valid @RequestBody HrmEmployeeContractTerminateReqVO reqVO) {
        contractService.terminateContract(reqVO);
        return success(true);
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除员工合同")
    @Parameter(name = "id", description = "合同ID", required = true)
    @PreAuthorize("@ss.hasPermission('hrm:employee-contract:delete')")
    public CommonResult<Boolean> deleteContract(@RequestParam("id") Long id) {
        contractService.deleteContract(id);
        return success(true);
    }
 
    @GetMapping("/get")
    @Operation(summary = "获得员工合同详情")
    @Parameter(name = "id", description = "合同ID", required = true)
    @PreAuthorize("@ss.hasPermission('hrm:employee-contract:query')")
    public CommonResult<HrmEmployeeContractRespVO> getContract(@RequestParam("id") Long id) {
        return success(contractService.getContract(id));
    }
 
    @GetMapping("/page")
    @Operation(summary = "获得员工合同分页")
    @PreAuthorize("@ss.hasPermission('hrm:employee-contract:query')")
    public CommonResult<PageResult<HrmEmployeeContractRespVO>> getContractPage(@Valid HrmEmployeeContractPageReqVO pageReqVO) {
        return success(contractService.getContractPage(pageReqVO));
    }
 
    @GetMapping("/expiring-count")
    @Operation(summary = "获得即将到期合同数量", description = "供 HRM 待办/首页提醒使用")
    @PreAuthorize("@ss.hasPermission('hrm:employee-contract:query')")
    public CommonResult<Long> getExpiringCount() {
        return success(contractService.getExpiringCount());
    }
 
}