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);
}
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);
}
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);
}
Aggregations