Search in sources :

Example 1 with TextCard

use of com.jeecg.qywx.api.message.vo.TextCard in project jeecg-boot by jeecgboot.

the class ThirdAppWechatEnterpriseServiceImpl method sendTextCardMessage.

/**
 * 发送文本卡片消息(SysAnnouncement定制)
 *
 * @param announcement
 * @param verifyConfig 是否验证配置(未启用的APP会拒绝发送)
 * @return
 */
public JSONObject sendTextCardMessage(SysAnnouncement announcement, boolean verifyConfig) {
    if (verifyConfig && !thirdAppConfig.isWechatEnterpriseEnabled()) {
        return null;
    }
    String accessToken = this.getAppAccessToken();
    if (accessToken == null) {
        return null;
    }
    TextCard textCard = new TextCard();
    textCard.setAgentid(thirdAppConfig.getWechatEnterprise().getAgentIdInt());
    boolean isToAll = CommonConstant.MSG_TYPE_ALL.equals(announcement.getMsgType());
    String usernameString = "";
    if (!isToAll) {
        // 将userId转为username
        String userId = announcement.getUserIds();
        String[] userIds = null;
        if (oConvertUtils.isNotEmpty(userId)) {
            userIds = userId.substring(0, (userId.length() - 1)).split(",");
        } else {
            LambdaQueryWrapper<SysAnnouncementSend> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(SysAnnouncementSend::getAnntId, announcement.getId());
            SysAnnouncementSend sysAnnouncementSend = sysAnnouncementSendMapper.selectOne(queryWrapper);
            userIds = new String[] { sysAnnouncementSend.getUserId() };
        }
        List<String> usernameList = sysUserService.userIdToUsername(Arrays.asList(userIds));
        usernameString = String.join(",", usernameList);
    }
    textCard.setTouser(this.getTouser(usernameString, isToAll));
    TextCardEntity entity = new TextCardEntity();
    entity.setTitle(announcement.getTitile());
    entity.setDescription(oConvertUtils.getString(announcement.getMsgAbstract(), "空"));
    entity.setUrl(RestUtil.getBaseUrl() + "/sys/annountCement/show/" + announcement.getId());
    textCard.setTextcard(entity);
    return JwMessageAPI.sendTextCardMessage(textCard, accessToken);
}
Also used : TextCardEntity(com.jeecg.qywx.api.message.vo.TextCardEntity) TextCard(com.jeecg.qywx.api.message.vo.TextCard) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 2 with TextCard

use of com.jeecg.qywx.api.message.vo.TextCard in project kykms by mahonelau.

the class ThirdAppWechatEnterpriseServiceImpl method sendTextCardMessage.

/**
 * 发送文本卡片消息(SysAnnouncement定制)
 *
 * @param announcement
 * @param verifyConfig 是否验证配置(未启用的APP会拒绝发送)
 * @return
 */
public JSONObject sendTextCardMessage(SysAnnouncement announcement, boolean verifyConfig) {
    if (verifyConfig && !thirdAppConfig.isWechatEnterpriseEnabled()) {
        return null;
    }
    String accessToken = this.getAppAccessToken();
    if (accessToken == null) {
        return null;
    }
    TextCard textCard = new TextCard();
    textCard.setAgentid(thirdAppConfig.getWechatEnterprise().getAgentIdInt());
    boolean isToAll = CommonConstant.MSG_TYPE_ALL.equals(announcement.getMsgType());
    String usernameString = "";
    if (!isToAll) {
        // 将userId转为username
        String userId = announcement.getUserIds();
        String[] userIds = null;
        if (oConvertUtils.isNotEmpty(userId)) {
            userIds = userId.substring(0, (userId.length() - 1)).split(",");
        } else {
            LambdaQueryWrapper<SysAnnouncementSend> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(SysAnnouncementSend::getAnntId, announcement.getId());
            SysAnnouncementSend sysAnnouncementSend = sysAnnouncementSendMapper.selectOne(queryWrapper);
            userIds = new String[] { sysAnnouncementSend.getUserId() };
        }
        List<String> usernameList = sysUserService.userIdToUsername(Arrays.asList(userIds));
        usernameString = String.join(",", usernameList);
    }
    textCard.setTouser(this.getTouser(usernameString, isToAll));
    TextCardEntity entity = new TextCardEntity();
    entity.setTitle(announcement.getTitile());
    entity.setDescription(oConvertUtils.getString(announcement.getMsgAbstract(), "空"));
    entity.setUrl(RestUtil.getBaseUrl() + "/sys/annountCement/show/" + announcement.getId());
    textCard.setTextcard(entity);
    return JwMessageAPI.sendTextCardMessage(textCard, accessToken);
}
Also used : TextCardEntity(com.jeecg.qywx.api.message.vo.TextCardEntity) TextCard(com.jeecg.qywx.api.message.vo.TextCard) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 3 with TextCard

use of com.jeecg.qywx.api.message.vo.TextCard in project kms by mahonelau.

the class ThirdAppWechatEnterpriseServiceImpl method sendTextCardMessage.

/**
 * 发送文本卡片消息(SysAnnouncement定制)
 *
 * @param announcement
 * @param verifyConfig 是否验证配置(未启用的APP会拒绝发送)
 * @return
 */
public JSONObject sendTextCardMessage(SysAnnouncement announcement, boolean verifyConfig) {
    if (verifyConfig && !thirdAppConfig.isWechatEnterpriseEnabled()) {
        return null;
    }
    String accessToken = this.getAppAccessToken();
    if (accessToken == null) {
        return null;
    }
    TextCard textCard = new TextCard();
    textCard.setAgentid(thirdAppConfig.getWechatEnterprise().getAgentIdInt());
    boolean isToAll = CommonConstant.MSG_TYPE_ALL.equals(announcement.getMsgType());
    String usernameString = "";
    if (!isToAll) {
        // 将userId转为username
        String userId = announcement.getUserIds();
        String[] userIds = null;
        if (oConvertUtils.isNotEmpty(userId)) {
            userIds = userId.substring(0, (userId.length() - 1)).split(",");
        } else {
            LambdaQueryWrapper<SysAnnouncementSend> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(SysAnnouncementSend::getAnntId, announcement.getId());
            SysAnnouncementSend sysAnnouncementSend = sysAnnouncementSendMapper.selectOne(queryWrapper);
            userIds = new String[] { sysAnnouncementSend.getUserId() };
        }
        List<String> usernameList = sysUserService.userIdToUsername(Arrays.asList(userIds));
        usernameString = String.join(",", usernameList);
    }
    textCard.setTouser(this.getTouser(usernameString, isToAll));
    TextCardEntity entity = new TextCardEntity();
    entity.setTitle(announcement.getTitile());
    entity.setDescription(oConvertUtils.getString(announcement.getMsgAbstract(), "空"));
    entity.setUrl(RestUtil.getBaseUrl() + "/sys/annountCement/show/" + announcement.getId());
    textCard.setTextcard(entity);
    return JwMessageAPI.sendTextCardMessage(textCard, accessToken);
}
Also used : TextCardEntity(com.jeecg.qywx.api.message.vo.TextCardEntity) TextCard(com.jeecg.qywx.api.message.vo.TextCard) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Aggregations

LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)3 TextCard (com.jeecg.qywx.api.message.vo.TextCard)3 TextCardEntity (com.jeecg.qywx.api.message.vo.TextCardEntity)3