SendMsgUseFeiShu.java
1.43 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
package com.pipihelper.project.controller;
import com.alibaba.fastjson.JSONObject;
import com.pipihelper.project.core.Result;
import com.pipihelper.project.core.ResultGenerator;
import com.pipihelper.project.feishu.dto.FeiShuConfig;
import com.pipihelper.project.feishu.enums.SendMsgBusinessType;
import com.pipihelper.project.feishu.service.FeiShuApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Description: TODO
* @author: charles
* @date: 2022年07月20日 14:50
*/
@RestController
@RequestMapping("/pipitest")
public class SendMsgUseFeiShu {
@Autowired
private FeiShuApiService feiShuApiService;
@Autowired
private FeiShuConfig feiShuConfig;
@PostMapping("/send-msg")
public Result sendMsg(String receiveId, String msg, String receiveIdType){
JSONObject sendMsg = new JSONObject();
sendMsg.put("receive_id", receiveId);
sendMsg.put("msg_type", "text");
JSONObject content = new JSONObject();
content.put("text", msg);
sendMsg.put("content", content.toString());
feiShuApiService.sendMsg(SendMsgBusinessType.TALK.getBusinessType(), receiveIdType, sendMsg, feiShuConfig.getTestHelperApp());
return ResultGenerator.genSuccessResult();
}
}