OtherController.java
3.78 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package cn.fw.dalaran.server.controller.app;
import cn.fw.common.web.annotation.ControllerMethod;
import cn.fw.common.web.auth.LoginAuthBean;
import cn.fw.common.web.auth.annotation.CurrentUser;
import cn.fw.dalaran.domain.param.LiveCheckParams;
import cn.fw.dalaran.domain.vo.LiveCheckVo;
import cn.fw.dalaran.service.Common;
import cn.fw.dalaran.service.biz.OtherBizService;
import cn.fw.data.base.domain.common.Message;
import cn.fw.security.auth.client.annotation.Authorization;
import cn.fw.security.auth.client.annotation.IgnoreAuth;
import cn.fw.security.auth.client.enums.AuthType;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.File;
import java.util.Objects;
import static cn.fw.common.web.util.ResultBuilder.success;
/**
* @author wmy3969
* @version 1.0
* @date 2022/6/7 10:56
* @Description
*/
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@Authorization(AuthType.ERP)
@RequestMapping("/other")
@IgnoreAuth
public class OtherController {
private final OtherBizService otherBizService;
private final Common common;
//private final TodoTask todoTask;// 定时任务
/**
* 获取直播审计页面
*
* @param user 当前登录用户
* @param dataId 待办id
* @return
*/
@GetMapping("/getLiveCheckPage")
public Message<LiveCheckVo> getLiveCheck(@CurrentUser LoginAuthBean user, @NotNull(message = "请必须指定待办id") Long dataId) {
return success(otherBizService.getLiveCheck(user.getUserId(), dataId));
}
/**
* 保存审核结果
*
* @param param 审计结果封装
* @return
*/
@PostMapping("/saveCheckResult")
public Message<Boolean> saveCheckResult(@CurrentUser LoginAuthBean user, @RequestBody @Valid LiveCheckParams param) {
return success(otherBizService.saveCheckResult(user.getUserId(), param));
}
/**
* 获取某条审计详情
*
* @param id 某条记录id
* @return
*/
@GetMapping("/getLiveCheckDetails")
@ControllerMethod("获取某条审计详情")
public Message<LiveCheckVo.LiveSummary> getLiveCheckDetails(@NotNull(message = "请必须指定数据id") Long id) {
return success(otherBizService.getLiveCheckDetails(id));
}
/**
* 操作指定目录
*
* @param dir 目录
* @param type 操作类型
* @return
*/
@GetMapping("/processDir")
public Message<Boolean> processDir(@NotBlank(message = "请必须指定路径") String dir, @NotNull(message = "请必须指定操作类型") Integer type) {
File file = new File(dir);
Boolean result = null;
String handleType = "";
if (Objects.equals(type, 1)) {
handleType = "创建";
if (!file.exists())
result = file.mkdirs();
} else {
handleType = "删除";
if (file.isDirectory())
result = common.deleteAllFile(dir, file);
else if (file.isFile())
result = file.delete();
}
log.info(String.format("%s文件或文件夹, 路径为: %s, 结果为: %s", handleType, dir, Objects.isNull(result) ? "未执行" : (result ? "成功" : "失败")));
return success(result);
}
/**
* 重发直播审计待办
*
* @param timestamp 时间戳
* @return
*/
/*@GetMapping("/resendLiveCheckBacklog")
public Message<Void> test(@NotNull(message = "请必须指定时间戳") Long timestamp) {
todoTask.sendLiveCheckBacklog(timestamp);
return Message.success();
}*/
}