luoyb
2021-02-02 a6c5984b2347a368e4e9ea7dbfdb95d199d6d4f4
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
95
96
97
package cc.mrbird.febs.server.hr.controller;
 
import cc.mrbird.febs.server.hr.entity.EmpResign;
import cc.mrbird.febs.server.hr.service.IEmpResignService;
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:EmpResign
* package:cc.mrbird.febs.server.hr.controller
* description:员工辞职申请控制器
*
* @author luoyibo
* @date 2021-01-31 11:26:18
* @since JDK1.8
*/
@Slf4j
@Validated
@RestController
@RequestMapping("empResign")
@RequiredArgsConstructor
public class EmpResignController {
 
private final IEmpResignService empResignService;
 
@GetMapping
@PreAuthorize("hasAuthority('empResign:list')")
public FebsResponse getAllEmpResigns(EmpResign empResign) {
return new FebsResponse().data(empResignService.findEmpResigns(empResign));
}
 
@GetMapping("list")
@PreAuthorize("hasAuthority('empResign:list')")
public FebsResponse empResignList(QueryRequest request, EmpResign empResign) {
Map<String, Object> dataTable = FebsUtil.getDataTable(this.empResignService.findEmpResigns(request, empResign));
return new FebsResponse().data(dataTable);
}
 
@PostMapping
@PreAuthorize("hasAuthority('empResign:add')")
public void addEmpResign(@Valid EmpResign empResign) throws FebsException {
try {
this.empResignService.createEmpResign(empResign);
} catch (Exception e) {
String message = "新增员工辞职申请失败";
log.error(message, e);
throw new FebsException(message);
}
}
 
@DeleteMapping
@PreAuthorize("hasAuthority('empResign:delete')")
public void deleteEmpResign(EmpResign empResign) throws FebsException {
try {
this.empResignService.deleteEmpResign(empResign);
} catch (Exception e) {
String message = "删除员工辞职申请失败";
log.error(message, e);
throw new FebsException(message);
}
}
 
@DeleteMapping("{ids}")
@PreAuthorize("hasAuthority('empResign:delete')")
public void logicDeleteEmpResign(@PathVariable("ids") String ids) throws FebsException {
try {
this.empResignService.logicDelEmpResign(ids);
} catch (Exception e) {
String message = "逻辑删除员工辞职申请失败";
log.error(message, e);
throw new FebsException(message);
}
}
 
@PutMapping
@PreAuthorize("hasAuthority('empResign:update')")
public void updateEmpResign(EmpResign empResign) throws FebsException {
try {
this.empResignService.updateEmpResign(empResign);
} catch (Exception e) {
String message = "修改员工辞职申请失败";
log.error(message, e);
throw new FebsException(message);
}
}
}