|
|
@@ -4,11 +4,10 @@ import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.cyksj.common.constant.WeChatTemplateConst;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.Codec;
|
|
|
+import com.cyksj.common.util.IoKit;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
@@ -19,14 +18,18 @@ import com.cyksj.model.manage.entity.Admin;
|
|
|
import com.cyksj.service.mange.AdminService;
|
|
|
import com.cyksj.service.wechat.WeChatService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.Date;
|
|
|
+import java.util.Enumeration;
|
|
|
import java.util.List;
|
|
|
-
|
|
|
-import static com.cyksj.common.constant.WeChatTemplateConst.EXPIRY_TEMPLATE;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @description
|
|
|
@@ -36,10 +39,13 @@ import static com.cyksj.common.constant.WeChatTemplateConst.EXPIRY_TEMPLATE;
|
|
|
@RestController
|
|
|
@RequestMapping("/manage/admin")
|
|
|
@RequiredArgsConstructor
|
|
|
+@Slf4j
|
|
|
public class AdminController {
|
|
|
|
|
|
private final AdminService adminService;
|
|
|
|
|
|
+ private final HttpServletRequest request;
|
|
|
+
|
|
|
private final WeChatService weChatService;
|
|
|
|
|
|
@PostMapping(value = "/login")
|
|
|
@@ -121,4 +127,46 @@ public class AdminController {
|
|
|
weChatService.sendTemplateMessage(weChatService.getAccessToken(), Jsons.toJson(templateMessage));
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping("/callback")
|
|
|
+ public String youtubeCallback(HttpServletRequest request, @RequestHeader Map<String, String> headers) throws IOException {
|
|
|
+ log.info("----------------打印请求全部消息开始----------------");
|
|
|
+ Enumeration<String> headerNames = request.getHeaderNames();
|
|
|
+ while (headerNames.hasMoreElements()) {
|
|
|
+ String name = headerNames.nextElement();
|
|
|
+ log.info("{} - {}", name, request.getHeader(name));
|
|
|
+ }
|
|
|
+ log.info("----------------打印请求全部消息结束----------------");
|
|
|
+ log.info("-----------------打印请求头消息开始-----------------");
|
|
|
+ headers.forEach((String key, String value) -> log.info(String.format("Header '%s' = %s", key, value)));
|
|
|
+ log.info("-----------------打印请求头消息结束-----------------");
|
|
|
+ Map<String, String[]> parameterMap = request.getParameterMap();
|
|
|
+ log.info("------------------打印全部参数开始------------------");
|
|
|
+ String result = "";
|
|
|
+ if (parameterMap.isEmpty()) {
|
|
|
+ log.info("请求参数为空");
|
|
|
+ }else {
|
|
|
+ parameterMap.forEach((String key, String[] value) -> {
|
|
|
+ for (String s : value) {
|
|
|
+ log.info("Param '{}' = {}", key, s);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ result = parameterMap.get("hub.challenge")[0];
|
|
|
+ }
|
|
|
+ log.info("------------------打印全部参数结束------------------");
|
|
|
+ log.info("-----------------打印Reader数据开始----------------");
|
|
|
+ StringBuilder buffer = new StringBuilder();
|
|
|
+ try (BufferedReader reader = request.getReader()){
|
|
|
+ String line;
|
|
|
+ while ((line = reader.readLine()) != null) {
|
|
|
+ buffer.append(line);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ log.info("reader -> {}", buffer);
|
|
|
+ log.info("-----------------打印Reader数据结束----------------");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|