SendMsgUseFeiShu.java 1.43 KB
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();
    }
}