BAOLH
2026-01-28 f79bb90c66de4468019ef0dfeffb9581867258bb
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
package me.zhengjie.modules.temp;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.annotation.rest.AnonymousGetMapping;
import me.zhengjie.annotation.rest.AnonymousPostMapping;
import me.zhengjie.annotation.rest.AnonymousPutMapping;
import me.zhengjie.modules.project.domain.Project;
import me.zhengjie.modules.project.repository.ProjectRepository;
import me.zhengjie.modules.project.service.dto.ProjectQueryCriteria;
import me.zhengjie.modules.temp.service.WechatRobotService;
import me.zhengjie.modules.temp.service.WechatSendHistoryService;
import me.zhengjie.utils.QueryHelp;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
@RestController
@RequiredArgsConstructor
@Api(tags = "临时接口")
@RequestMapping("/api/temp")
public class Temp {
 
    private final ProjectRepository projectRepository;
    private final WechatSendHistoryService wechatSendHistoryService;
    private final WechatRobotService wechatRobotService;
 
    @AnonymousPutMapping(value = "/updateProjectLiableUserId")
    @Log("修改项目责任人ID")
    @ApiOperation("修改项目责任人ID")
    public ResponseEntity<Object> updateProjectLiableUserId(){
        ProjectQueryCriteria criteria = new ProjectQueryCriteria();
        List<Project> projectList = projectRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
 
        for (int i = 0; i < projectList.size(); i ++) {
            Project project = projectList.get(i);
            if (project.getLiableUserId() != null && !"".equals(project.getLiableUserId())) {
                project.setLiableUserId("-" + project.getLiableUserId() + "-");
                projectRepository.save(project);
            }
        }
 
        return new ResponseEntity<>("", HttpStatus.OK);
    }
 
    @AnonymousGetMapping(value = "/wechat/approval/backUrl")
    @Log("企业微信验证回调URL")
    @ApiOperation("企业微信验证回调URL")
    public void approvalBack(@RequestParam(value = "msg_signature") String msgSignature, @RequestParam(value = "timestamp") String timestamp,
                                               @RequestParam(value = "nonce") String nonce, @RequestParam(value = "echostr") String echostr, HttpServletResponse response){
        wechatSendHistoryService.approvalBack(msgSignature, timestamp, nonce, echostr, response);
    }
 
    @AnonymousPostMapping(value = "/wechat/approval/backUrl")
    @Log("处理企业微信审批回调事件")
    @ApiOperation("处理企业微信审批回调事件")
    public ResponseEntity<Object> handleApprovalCallback(@RequestParam(value = "msg_signature") String msgSignature, @RequestParam(value = "timestamp") String timestamp,
                                                  @RequestParam(value = "nonce") String nonce, HttpServletRequest request, HttpServletResponse response){
        wechatSendHistoryService.handleApprovalCallback(msgSignature, timestamp, nonce, request, response);
        return new ResponseEntity<>(HttpStatus.OK);
    }
 
    @AnonymousGetMapping(value = "/wechat/robot/backUrl")
    @Log("企业微信智能机器人验证回调URL")
    @ApiOperation("企业微信智能机器人验证回调URL")
    public void robotBack(@RequestParam(value = "msg_signature") String msgSignature, @RequestParam(value = "timestamp") String timestamp,
                             @RequestParam(value = "nonce") String nonce, @RequestParam(value = "echostr") String echostr, HttpServletResponse response){
        wechatRobotService.robotBack(msgSignature, timestamp, nonce, echostr, response);
    }
 
    @AnonymousPostMapping(value = "/wechat/robot/backUrl")
    @Log("处理企业微信智能机器人回调事件")
    @ApiOperation("处理企业微信智能机器人回调事件")
    public ResponseEntity<Object> handleRobotCallback(@RequestParam(value = "msg_signature") String msgSignature, @RequestParam(value = "timestamp") String timestamp,
                                                         @RequestParam(value = "nonce") String nonce, HttpServletRequest request, HttpServletResponse response){
        return new ResponseEntity<>(wechatRobotService.handleRobotCallback(msgSignature, timestamp, nonce, request, response), HttpStatus.OK);
    }
}