Search in sources :

Example 1 with MessageDTO

use of org.jeecg.common.api.dto.message.MessageDTO in project jeecg-boot by jeecgboot.

the class ThirdAppController method sendMessageTest.

/**
 * 发送消息测试
 *
 * @return
 */
@PostMapping("/sendMessageTest")
public Result sendMessageTest(@RequestBody JSONObject params, HttpServletRequest request) {
    /* 获取前台传递的参数 */
    // 第三方app的类型
    String app = params.getString("app");
    // 是否发送给全部人
    boolean sendAll = params.getBooleanValue("sendAll");
    // 消息接收者,传sys_user表的username字段,多个用逗号分割
    String receiver = params.getString("receiver");
    // 消息内容
    String content = params.getString("content");
    String fromUser = JwtUtil.getUserNameByToken(request);
    String title = "第三方APP消息测试";
    MessageDTO message = new MessageDTO(fromUser, receiver, title, content);
    message.setToAll(sendAll);
    if (ThirdAppConfig.WECHAT_ENTERPRISE.equals(app)) {
        if (thirdAppConfig.isWechatEnterpriseEnabled()) {
            JSONObject response = wechatEnterpriseService.sendMessageResponse(message, false);
            return Result.OK(response);
        }
        return Result.error("企业微信已被禁用");
    } else if (ThirdAppConfig.DINGTALK.equals(app)) {
        if (thirdAppConfig.isDingtalkEnabled()) {
            Response<String> response = dingtalkService.sendMessageResponse(message, false);
            return Result.OK(response);
        }
        return Result.error("钉钉已被禁用");
    }
    return Result.error("不识别的第三方APP");
}
Also used : Response(com.jeecg.dingtalk.api.core.response.Response) MessageDTO(org.jeecg.common.api.dto.message.MessageDTO) JSONObject(com.alibaba.fastjson.JSONObject)

Example 2 with MessageDTO

use of org.jeecg.common.api.dto.message.MessageDTO in project kms by mahonelau.

the class ThirdAppController method sendMessageTest.

/**
 * 发送消息测试
 *
 * @return
 */
@PostMapping("/sendMessageTest")
public Result sendMessageTest(@RequestBody JSONObject params, HttpServletRequest request) {
    /* 获取前台传递的参数 */
    // 第三方app的类型
    String app = params.getString("app");
    // 是否发送给全部人
    boolean sendAll = params.getBooleanValue("sendAll");
    // 消息接收者,传sys_user表的username字段,多个用逗号分割
    String receiver = params.getString("receiver");
    // 消息内容
    String content = params.getString("content");
    String fromUser = JwtUtil.getUserNameByToken(request);
    String title = "第三方APP消息测试";
    MessageDTO message = new MessageDTO(fromUser, receiver, title, content);
    message.setToAll(sendAll);
    if (ThirdAppConfig.WECHAT_ENTERPRISE.equals(app)) {
        if (thirdAppConfig.isWechatEnterpriseEnabled()) {
            JSONObject response = wechatEnterpriseService.sendMessageResponse(message, false);
            return Result.OK(response);
        }
        return Result.error("企业微信已被禁用");
    } else if (ThirdAppConfig.DINGTALK.equals(app)) {
        if (thirdAppConfig.isDingtalkEnabled()) {
            Response<String> response = dingtalkService.sendMessageResponse(message, false);
            return Result.OK(response);
        }
        return Result.error("钉钉已被禁用");
    }
    return Result.error("不识别的第三方APP");
}
Also used : Response(com.jeecg.dingtalk.api.core.response.Response) MessageDTO(org.jeecg.common.api.dto.message.MessageDTO) JSONObject(com.alibaba.fastjson.JSONObject)

Example 3 with MessageDTO

use of org.jeecg.common.api.dto.message.MessageDTO in project kykms by mahonelau.

the class ThirdAppController method sendMessageTest.

/**
 * 发送消息测试
 *
 * @return
 */
@PostMapping("/sendMessageTest")
public Result sendMessageTest(@RequestBody JSONObject params, HttpServletRequest request) {
    /* 获取前台传递的参数 */
    // 第三方app的类型
    String app = params.getString("app");
    // 是否发送给全部人
    boolean sendAll = params.getBooleanValue("sendAll");
    // 消息接收者,传sys_user表的username字段,多个用逗号分割
    String receiver = params.getString("receiver");
    // 消息内容
    String content = params.getString("content");
    String fromUser = JwtUtil.getUserNameByToken(request);
    String title = "第三方APP消息测试";
    MessageDTO message = new MessageDTO(fromUser, receiver, title, content);
    message.setToAll(sendAll);
    if (ThirdAppConfig.WECHAT_ENTERPRISE.equals(app)) {
        if (thirdAppConfig.isWechatEnterpriseEnabled()) {
            JSONObject response = wechatEnterpriseService.sendMessageResponse(message, false);
            return Result.OK(response);
        }
        return Result.error("企业微信已被禁用");
    } else if (ThirdAppConfig.DINGTALK.equals(app)) {
        if (thirdAppConfig.isDingtalkEnabled()) {
            Response<String> response = dingtalkService.sendMessageResponse(message, false);
            return Result.OK(response);
        }
        return Result.error("钉钉已被禁用");
    }
    return Result.error("不识别的第三方APP");
}
Also used : Response(com.jeecg.dingtalk.api.core.response.Response) MessageDTO(org.jeecg.common.api.dto.message.MessageDTO) JSONObject(com.alibaba.fastjson.JSONObject)

Aggregations

JSONObject (com.alibaba.fastjson.JSONObject)3 Response (com.jeecg.dingtalk.api.core.response.Response)3 MessageDTO (org.jeecg.common.api.dto.message.MessageDTO)3