|
|
@ -6,7 +6,13 @@ import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
import jakarta.annotation.security.PermitAll; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import me.chanjar.weixin.common.bean.WxJsapiSignature; |
|
|
|
import me.chanjar.weixin.common.error.WxErrorException; |
|
|
|
import me.chanjar.weixin.cp.api.WxCpMessageService; |
|
|
|
import me.chanjar.weixin.cp.api.WxCpUserService; |
|
|
|
import me.chanjar.weixin.cp.bean.WxCpAgentJsapiSignature; |
|
|
|
import me.chanjar.weixin.cp.bean.WxCpUser; |
|
|
|
import me.chanjar.weixin.cp.bean.message.WxCpMessage; |
|
|
|
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult; |
|
|
|
import me.chanjar.weixin.mp.api.WxMpService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
@ -23,6 +29,7 @@ import java.nio.charset.StandardCharsets; |
|
|
|
import java.security.MessageDigest; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
import java.util.Formatter; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
@ -62,4 +69,52 @@ public class JsSdkController { |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
@GetMapping("/sendMessage") |
|
|
|
@PermitAll |
|
|
|
@TenantIgnore |
|
|
|
public void sendMessage(@RequestParam(required = false) String data) { |
|
|
|
|
|
|
|
|
|
|
|
WxCpMessageService messageService = wxCpService.getMessageService(); |
|
|
|
String title = "解锁完成"; |
|
|
|
String description = "<div class=\"gray\">2025年8月7日</div>" + |
|
|
|
"<div class=\"normal\">下午3:00解锁完成</div>" + |
|
|
|
"<div class=\"highlight\">请停止作业</div>"; |
|
|
|
String url = "https://example.com/meeting/details/123"; |
|
|
|
String btnText = " "; |
|
|
|
|
|
|
|
WxCpMessage message = WxCpMessage.TEXTCARD() |
|
|
|
.agentId(1000002) |
|
|
|
.toUser("@all") |
|
|
|
.title(title) |
|
|
|
.description(description) |
|
|
|
.url(url) |
|
|
|
.btnTxt(btnText) |
|
|
|
.build(); |
|
|
|
// 3. 调用 send 方法发送消息
|
|
|
|
try { |
|
|
|
WxCpMessageSendResult sendResult = messageService.send(message); |
|
|
|
// 你可以根据 sendResult 的内容进行后续处理
|
|
|
|
System.out.println("消息发送成功: " + sendResult); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
// 异常处理,例如记录日志、发送告警等
|
|
|
|
System.err.println("消息发送失败: " + e.getError().getErrorMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
@GetMapping("/call/action") |
|
|
|
@PermitAll |
|
|
|
@TenantIgnore |
|
|
|
public void action(@RequestParam(required = false) String data) { |
|
|
|
|
|
|
|
System.out.println(data); |
|
|
|
log.info(data); |
|
|
|
} |
|
|
|
@GetMapping("/call/data") |
|
|
|
@PermitAll |
|
|
|
@TenantIgnore |
|
|
|
public void data(@RequestParam(required = false) String data) { |
|
|
|
|
|
|
|
System.out.println(data); |
|
|
|
log.info(data); |
|
|
|
} |
|
|
|
} |
|
|
|