wzy
2020-12-26 2cf928a22b6cf8ea7a29f29127ffc333c73b0bca
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
package com.matrix.component.dingding;
 
 
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
 
/**
 * @author jiangyouyao
 * @description 钉钉对外接口
 */
@Controller
@RequestMapping(value = "/dingding")
public class DingdingAction {
 
 
    /**
     * 列表显示
     */
    @RequestMapping(value = "/getDingdingConfig")
    public @ResponseBody
    AjaxResult getDingdingConfig() {
        AjaxResult result = AjaxResult.buildSuccessInstance("success");
        result.setMapInfo(AuthHelper.getConfig());
        return result;
    }
 
 
    /**
     * @Description:检查是否绑定账号
     * @author:dingchuan
     * @param code
     * @return
     * @throws Exception
     *             返回类型 AjaxResult
     * @date 2016年11月27日
     */
    @RequestMapping(value = "/getDdUserId/{code}")
    public @ResponseBody
    AjaxResult checkIsBinding(@PathVariable String code) {
        LogUtil.debug(code);
        String ddUserId="";
        try {
            String accessToken = AuthHelper.getAccessToken();
            LogUtil.info(accessToken);
            // 用户基本信息
             ddUserId = UserHelper.getUserInfo(accessToken, code);
             LogUtil.info(ddUserId);
        } catch (Exception e) {
            LogUtil.error("获取ddUserId错误",e);
        }
        return AjaxResult.buildSuccessInstance(ddUserId);
    }
 
 
    @RequestMapping(value = "/sendOAMsg/{userId}")
    public @ResponseBody
    AjaxResult sendOAMsg(@PathVariable String userId) throws OApiException {
        // 循环发送OA消息
        // 获取accessToken
        String accessToken = AuthHelper.getAccessToken();
        OapiMessageCorpconversationAsyncsendV2Request.Msg msg = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
        msg.setMsgtype("link");
        msg.setLink(new OapiMessageCorpconversationAsyncsendV2Request.Link());
        msg.getLink().setTitle("审批通知");
        msg.getLink().setText("你还有几个流程需要审核请尽快处理"+ StringUtils.getRandomString(10));
        msg.getLink().setMessageUrl(DDEnvConfig.FUNCTION_URL);
        msg.getLink().setPicUrl(DDEnvConfig.LOGO_IMG);
        MessageSendUtil.sendOAMsg(accessToken, userId, msg);
        return AjaxResult.buildSuccessInstance("发送成功");
    }
 
 
 
}