Files
wxSend/src/main/java/cn/van333/wxsend/business/controller/DCController.java
2025-01-20 17:36:03 +08:00

50 lines
1.7 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cn.van333.wxsend.business.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.van333.wxsend.aop.annotation.RateLimiter;
import cn.van333.wxsend.business.model.R;
import cn.van333.wxsend.business.service.LogService;
import cn.van333.wxsend.enums.WXMessageType;
import cn.van333.wxsend.util.SourceForQLUtil;
import cn.van333.wxsend.util.TokenUtil;
import cn.van333.wxsend.util.WxSendUtil;
import cn.van333.wxsend.util.request.MessageRequest;
import com.alibaba.fastjson2.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* @author Leo
* @version 1.0
* @create 2023/10/07 0007 下午 02:25
* @description
*/
@RestController
@RequestMapping("/dc")
public class DCController {
private static final Logger logger = LoggerFactory.getLogger(LogService.class);
@RequestMapping(value = "/send/ty")
@ResponseBody
@RateLimiter(time = 10, count = 60)
public R sendToTY(@RequestBody MessageRequest message) throws Exception {
logger.info(message.toString());
if (!TokenUtil.checkToken(message.getVanToken())) {
return R.error("vanToken无效");
}
if (!StrUtil.isAllNotEmpty(message.getTitle(), message.getText())) {
return R.error("缺少标题和内容");
}
String result = WxSendUtil.sendNotify(message.getTitle(), message.getText(), message.getTouser(), WXMessageType.TY);
return R.ok(result);
}
}