自定义企业微信消息推送( 2.2.3及以上版本支持版本)

sdk

message服务提供的sdk接口 WeWorkRpcService

父类

子类:

文字消息

卡片消息

`@Autowired
private WeWorkRpcService weWorkRpcService;

@ResponseBody
@RequestMapping(value = "/doTest", method = RequestMethod.POST)
public List<Map<String, Object>> doTest(HttpServletRequest request, ActionDataSourceVo actionDataSourceVo) {

    List<String> userIds = new ArrayList<>();
    userIds.add("bb12c805b147492c83eaab8aa5184983");

    WeWorkTextNotice weWorkTextNotice = new WeWorkTextNotice();
    weWorkTextNotice.setContent("测试消息:" + new Date().getTime());
    weWorkTextNotice.setAgentid("1000002");
    weWorkTextNotice.setTouser(userIds);
    weWorkRpcService.sendTextMsg(weWorkTextNotice);


    WeWorkActionCardNotice weWorkActionCardNotice = new WeWorkActionCardNotice();
    weWorkActionCardNotice.setTouser(userIds);
    weWorkActionCardNotice.setTitle("标题-打开表单");
    weWorkActionCardNotice.setBtntxt("点击查看");
    weWorkActionCardNotice.setDescription("测试打开表单111:" + new Date().getTime());
    StringBuffer url = new StringBuffer();
    url.append("{@CONFIG_DOMAIN@}");
    url.append("/je/rbac/wechat/redirectToWechat");
    url.append("?agentId=" + 1000002);
    url.append("&funcCode=" + "JE_RBAC_WECHAT_APP");
    url.append("&pkValue=" + "1d4398f3ad644c569a2ebdd4a495e030");
    url.append("&type=form");
    weWorkActionCardNotice.setUrl(url.toString());
    logger.info("-----------------------" + url.toString());
    weWorkRpcService.sendCardMsg(weWorkActionCardNotice);


    WeWorkActionCardNotice weWorkActionCardNotice2 = new WeWorkActionCardNotice();
    weWorkActionCardNotice2.setTouser(userIds);
    weWorkActionCardNotice2.setTitle("标题-打开功能列表");
    weWorkActionCardNotice2.setBtntxt("点击查看");
    weWorkActionCardNotice2.setDescription("测试打开功能列表111:" + new Date().getTime());
    StringBuffer url2 = new StringBuffer();
    url2.append("{@CONFIG_DOMAIN@}");
    url2.append("/je/rbac/wechat/redirectToWechat");
    url2.append("?agentId=" + 1000002);
    url2.append("&funcCode=" + "JE_RBAC_WECHAT_APP");
    url2.append("&type=func");
    weWorkActionCardNotice2.setUrl(url2.toString());
    logger.info("-----------------------" + url2.toString());
    weWorkRpcService.sendCardMsg(weWorkActionCardNotice2);


    WeWorkActionCardNotice weWorkActionCardNotice4 = new WeWorkActionCardNotice();
    weWorkActionCardNotice4.setTouser(userIds);
    weWorkActionCardNotice4.setTitle("标题-打开功能列表,main方式");
    weWorkActionCardNotice4.setBtntxt("点击查看");
    weWorkActionCardNotice4.setDescription("测试打开功能列表,main方式,111:" + new Date().getTime());
    StringBuffer url4 = new StringBuffer();
    url4.append("{@CONFIG_DOMAIN@}");
    url4.append("/je/rbac/wechat/redirectToWechat");
    url4.append("?agentId=" + 1000002);
    url4.append("&funcCode=" + "JE_RBAC_WECHAT_APP");
    url4.append("&pcOpenType=" + "2");
    url4.append("&type=func");
    weWorkActionCardNotice4.setUrl(url4.toString());
    logger.info("-----------------------" + url4.toString());
    weWorkRpcService.sendCardMsg(weWorkActionCardNotice4);


    WeWorkActionCardNotice weWorkActionCardNotice3 = new WeWorkActionCardNotice();
    weWorkActionCardNotice3.setTouser(userIds);
    weWorkActionCardNotice3.setTitle("标题-打开指定的url");
    weWorkActionCardNotice3.setBtntxt("点击查看");
    weWorkActionCardNotice3.setDescription("测试打开指定的url111:" + new Date().getTime());
    StringBuffer url3 = new StringBuffer();
    url3.append("{@CONFIG_DOMAIN@}");
    url3.append("/je/rbac/wechat/redirectToWechat");
    url3.append("?agentId=" + 1000002);
    url3.append("&cutomerWxUrl=" + "/#/je/main/KwVOaU2b7MFgHHFjNtM");
    url3.append("&type=cutomerUrl");
    weWorkActionCardNotice3.setUrl(url3.toString());
    logger.info("-----------------------" + url3.toString());
    weWorkRpcService.sendCardMsg(weWorkActionCardNotice3);

    return null;
}`
最后编辑: 于春辉  文档更新时间: 2024-11-08 17:00   作者:于春辉