lvzhiqiang 2 年之前
父节点
当前提交
a92974fc41

+ 6 - 29
pom.xml

@@ -25,28 +25,6 @@
         <version>2.1.9.RELEASE</version>
     </parent>
 
-    <!--配置不同的profile,对应不同的运行环境-->
-    <profiles>
-        <profile>
-            <!-- 开发 -->
-            <id>dev</id>
-            <activation>
-                <!--默认开发环境-->
-                <activeByDefault>true</activeByDefault>
-            </activation>
-            <properties>
-                <activatedProperties>dev</activatedProperties>
-            </properties>
-        </profile>
-        <profile>
-            <!-- 测试 -->
-            <id>test</id>
-            <properties>
-                <activatedProperties>test</activatedProperties>
-            </properties>
-        </profile>
-    </profiles>
-
     <dependencies>
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -126,12 +104,6 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.httpcomponents</groupId>
-            <artifactId>httpclient</artifactId>
-            <version>4.5.8</version>
-        </dependency>
-
-        <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-configuration-processor</artifactId>
             <version>2.7.0</version>
@@ -139,7 +111,12 @@
         <dependency>
             <groupId>com.github.binarywang</groupId>
             <artifactId>weixin-java-cp</artifactId>
-            <version>4.4.0</version>
+            <version>4.5.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.13</version>
         </dependency>
 
 

+ 8 - 1
src/main/java/top/lvzhiqiang/config/InitRunner.java

@@ -1,5 +1,6 @@
 package top.lvzhiqiang.config;
 
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.ApplicationArguments;
 import org.springframework.boot.ApplicationRunner;
 import org.springframework.core.annotation.Order;
@@ -30,8 +31,14 @@ public class InitRunner implements ApplicationRunner {
     @Resource
     private CoinService coinService;
 
+    @Value("${spring.profiles.active}")
+    private String env;
+
     @Override
     public void run(ApplicationArguments args) {
-        coinService.monitorJob();
+
+        if (!"dev".equals(env)) {
+            coinService.monitorJob();
+        }
     }
 }

+ 0 - 6
src/main/java/top/lvzhiqiang/controller/BgController.java

@@ -63,12 +63,6 @@ public class BgController {
         return "success";
     }
 
-    @RequestMapping("/ftlIndex")
-    public String ftlIndex(Model model) {
-
-        return "ftlIndex";
-    }
-
     /**
      * 上传识别码文件
      *

+ 0 - 326
src/main/java/top/lvzhiqiang/util/HttpUtils.java

@@ -1,326 +0,0 @@
-package top.lvzhiqiang.util;
-
-import com.alibaba.fastjson.JSONException;
-import com.alibaba.fastjson.JSONObject;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.*;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.client.utils.URLEncodedUtils;
-import org.apache.http.conn.ConnectionKeepAliveStrategy;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.EntityUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URISyntaxException;
-import java.util.*;
-
-/**
- * HTTP工具类
- *
- * @author shiyong
- * 2019-12-17 16:08
- */
-public class HttpUtils {
-
-    // 编码格式。发送编码格式统一用UTF-8
-    private static final String ENCODING = "UTF-8";
-
-    // 设置连接超时时间,单位毫秒。ConnectTimeoutException
-    private static final int CONNECT_TIMEOUT = 60000;
-
-    // 请求获取数据的超时时间(即响应时间),单位毫秒。如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。SocketTimeoutException
-    private static final int SOCKET_TIMEOUT = 30000;
-
-    // 设置从connect Manager获取Connection 超时时间,单位毫秒。这个属性是新加的属性,因为目前版本是可以共享连接池的。ConnectionPoolTimeout
-    private static final int CONNECTION_REQUEST_TIMEOUT = 60000;
-
-    private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
-
-    private static CloseableHttpClient httpClient = null;
-
-    /**
-     * 自己构建httpclient连接池。通过享元模式来解决该问题来解决HttpClient引起的TCP连接数高问题
-     *
-     * @return
-     */
-    public static synchronized CloseableHttpClient getHttpClient() {
-        if (httpClient == null) {
-            PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
-            // 连接池最大连接数,默认为20
-            cm.setMaxTotal(2000);
-            // 单条链路最大连接数(一个ip+一个端口是一个链路),即每个主机的最大连接数,默认为2
-            cm.setDefaultMaxPerRoute(1000);
-
-            ConnectionKeepAliveStrategy kaStrategy = new DefaultConnectionKeepAliveStrategy() {
-                @Override
-                public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
-                    long keepAlive = super.getKeepAliveDuration(response, context);
-                    if (keepAlive == -1) {
-                        keepAlive = 60000;
-                    }
-                    return keepAlive;
-                }
-            };
-
-            httpClient = HttpClients.custom().setConnectionManager(cm).setKeepAliveStrategy(kaStrategy).build();
-        }
-
-        return httpClient;
-    }
-
-    /**
-     * 发送get请求,返回字符串
-     *
-     * @param url 请求地址
-     * @return java.lang.String
-     * @author shiyong
-     * 2020/4/15 10:54
-     */
-    public static String doGetToStr(String url) throws IOException, URISyntaxException {
-        return doGetToStr(url, new HashMap<>());
-    }
-
-    /**
-     * 发送get请求,返回字符串
-     *
-     * @param url    请求地址
-     * @param params 请求参数
-     * @return java.lang.String
-     * @author shiyong
-     * 2020/4/15 10:58
-     */
-    public static String doGetToStr(String url, Map<String, String> params) throws IOException, URISyntaxException {
-        return doGetToStr(url, new HashMap<>(), params);
-    }
-
-    /**
-     * 发送get请求,返回字符串
-     *
-     * @param url     请求地址
-     * @param headers 请求头
-     * @param params  请求参数
-     * @return java.lang.String
-     * @author shiyong
-     * 2020/4/15 10:59
-     */
-    public static String doGetToStr(String url, Map<String, String> headers, Map<String, String> params) throws IOException, URISyntaxException {
-        // 创建httpClient对象
-        // CloseableHttpClient httpClient = HttpClients.createDefault();
-        CloseableHttpClient httpClient = getHttpClient();
-
-        // 创建httpResponse对象
-        CloseableHttpResponse httpResponse = null;
-        HttpGet httpGet = null;
-        try {
-            // 创建访问的地址
-            URIBuilder uriBuilder = new URIBuilder(url);
-
-            if (params != null) {
-                Set<Map.Entry<String, String>> entrySet = params.entrySet();
-
-                for (Map.Entry<String, String> entry : entrySet) {
-                    uriBuilder.setParameter(entry.getKey(), entry.getValue());
-                }
-            }
-
-            // 创建http对象
-            httpGet = new HttpGet(uriBuilder.build());
-
-            RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT).setSocketTimeout(SOCKET_TIMEOUT).build();
-            httpGet.setConfig(requestConfig);
-
-            // 设置请求头
-            packageHeader(headers, httpGet);
-
-            // 执行请求
-            httpResponse = httpClient.execute(httpGet);
-
-            if (null == httpResponse || null == httpResponse.getStatusLine() || null == httpResponse.getEntity() || httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
-                return "";
-            }
-
-            return EntityUtils.toString(httpResponse.getEntity(), ENCODING);
-        } catch (JSONException e) {
-            throw new JSONException(e.getMessage());
-        } catch (IOException e) {
-            throw new IOException(e);
-        } finally {
-            // 释放资源
-            if (httpGet != null) {
-                httpGet.abort();
-                httpGet.releaseConnection();
-            }
-            release(httpResponse, httpClient);
-        }
-    }
-
-
-    /**
-     * 发送post请求,返回字符串
-     *
-     * @param url     请求地址
-     * @param headers 请求头
-     * @param params  请求参数
-     * @return java.lang.String
-     * @author shiyong
-     * 2020/4/15 11:35
-     */
-    public static String doPostToStr(String url, Map<String, String> headers, Map<String, String> params) throws IOException, JSONException {
-        // 创建httpClient对象
-        // CloseableHttpClient httpClient = HttpClients.createDefault();
-        CloseableHttpClient httpClient = getHttpClient();
-
-        // 创建httpResponse对象
-        CloseableHttpResponse httpResponse = null;
-        HttpPost httpPost = null;
-        try {
-            // 创建http对象
-            httpPost = new HttpPost(url);
-
-            RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT).setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT).setSocketTimeout(SOCKET_TIMEOUT).build();
-            httpPost.setConfig(requestConfig);
-            //httpPost.setHeader(HttpHeaders.CONNECTION, "close");
-
-            packageHeader(headers, httpPost);
-
-            // 封装请求参数
-            packageParam(params, httpPost);
-
-            // 执行请求
-            httpResponse = httpClient.execute(httpPost);
-
-            if (null == httpResponse || null == httpResponse.getStatusLine() || null == httpResponse.getEntity() || httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
-                return "";
-            }
-
-            return EntityUtils.toString(httpResponse.getEntity(), ENCODING);
-        } catch (JSONException e) {
-            throw new JSONException(e.getMessage());
-        } catch (IOException e) {
-            throw new IOException(e);
-        } finally {
-            // 释放资源
-            if (httpPost != null) {
-                httpPost.abort();
-                httpPost.releaseConnection();
-            }
-            release(httpResponse, httpClient);
-        }
-    }
-
-    /**
-     * 发送post请求,返回JSONObject
-     *
-     * @param url    请求地址
-     * @param params 参数集合
-     * @return com.alibaba.fastjson.JSONObject
-     * @author shiyong
-     * 2019/11/23 18:39
-     */
-    public static JSONObject doPost(String url, Map<String, String> params) throws IOException {
-        return doPost(url, new HashMap<String, String>(), params);
-    }
-
-    /**
-     * 发送post请求,返回JSONObject
-     *
-     * @param url     请求地址
-     * @param headers 请求头
-     * @param params  请求参数
-     * @return com.alibaba.fastjson.JSONObject
-     * @author shiyong
-     * 2019/11/23 18:35
-     */
-    public static JSONObject doPost(String url, Map<String, String> headers, Map<String, String> params) throws IOException {
-        String content = doPostToStr(url, headers, params);
-
-        if (StringUtils.isEmpty(content)) {
-            return new JSONObject();
-        }
-
-        return JSONObject.parseObject(content);
-    }
-
-    /**
-     * 封装请求头
-     *
-     * @param params     请求头
-     * @param httpMethod 请求方式
-     * @author shiyong
-     * 2019/11/23 19:21
-     */
-    private static void packageHeader(Map<String, String> params, HttpRequestBase httpMethod) {
-        if (params != null) {
-            Set<Map.Entry<String, String>> entrySet = params.entrySet();
-
-            for (Map.Entry<String, String> entry : entrySet) {
-                // 设置到请求头到HttpRequestBase对象中
-                httpMethod.setHeader(entry.getKey(), entry.getValue());
-            }
-        }
-    }
-
-    /**
-     * 封装请求参数
-     *
-     * @param params     请求参数
-     * @param httpMethod 请求方式
-     * @author shiyong
-     * 2019/11/23 19:22
-     */
-    private static void packageParam(Map<String, String> params, HttpEntityEnclosingRequestBase httpMethod) throws UnsupportedEncodingException {
-        if (params != null) {
-            List<NameValuePair> nvps = new ArrayList<>();
-
-            Set<Map.Entry<String, String>> entrySet = params.entrySet();
-
-            for (Map.Entry<String, String> entry : entrySet) {
-                nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
-            }
-
-            UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nvps, ENCODING);
-            formEntity.setContentType(URLEncodedUtils.CONTENT_TYPE);
-
-            // 设置到请求的http对象中
-            httpMethod.setEntity(formEntity);
-        }
-    }
-
-    /**
-     * 释放资源
-     *
-     * @param httpResponse HTTP响应
-     * @param httpClient   HTTP客户端
-     * @author shiyong
-     * 2019/11/23 19:28
-     */
-    private static void release(CloseableHttpResponse httpResponse, CloseableHttpClient httpClient) {
-        try {
-            if (httpResponse != null) {
-                httpResponse.close();
-            }
-
-            // 连接池使用的时候不能关闭连接,否则下次使用会抛异常 java.lang.IllegalStateException: Connection pool shut down
-            // 选择使用连接池,就是将连接全部交由连接池管理,而我们在程序中使用了httpClient.close()就破坏了这以规则
-            /*if (httpClient != null) {
-                httpClient.close();
-            }*/
-        } catch (IOException e) {
-            log.error("释放HTTP请求资源失败!", e);
-        }
-
-    }
-
-}

+ 1 - 1
src/main/resources/application.yml

@@ -3,7 +3,7 @@ spring:
     name: jav
   # 指定运行环境
   profiles:
-    active: @activatedProperties@
+    active: dev
   # freemarker
   freemarker:
     allow-request-override: false

+ 0 - 109
src/main/resources/templates/ftlIndex.ftl

@@ -1,109 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-    <title>影片列表</title>
-
-    <meta http-equiv="pragma" content="no-cache">
-    <meta http-equiv="cache-control" content="no-cache">
-    <meta http-equiv="expires" content="0">
-    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
-    <meta http-equiv="description" content="This is my page">
-    <meta http-equiv="content-type" content="text/html;charset=utf-8">
-    <link href="css/main.css?1649066400" type="text/css" rel="stylesheet">
-    <style type="text/css">
-        #waterfall-zdy{
-            display: flex;
-            flex-direction: row;
-            flex-wrap: wrap;
-            width: 100%;
-            margin: 0 auto;
-            transition: .5s;
-        }
-        #waterfall-zdy .item-b{
-            padding: 5px;
-            width: 25%;
-            transition: .5s;
-            animation: fadeInUp .5s ease-out;
-        }
-        #waterfall-zdy .item-tag {
-            display: inline-block;
-            white-space: nowrap;
-        }
-        #waterfall-zdy div{
-            box-sizing: border-box;
-        }
-        #waterfall-zdy .movie-box-b{
-            border-radius: 5px;
-            background-color: white;
-            border: 1px solid rgba(0,0,0,0.2);
-            box-shadow: 0 2px 3px 0 rgba(0,0,0,0.1);
-            overflow: hidden;
-        }
-        #waterfall-zdy .movie-box-b .photo-frame-b{
-            text-align: center;
-        }
-        #waterfall-zdy .movie-box-b a:link{
-            color: black;
-        }
-        #waterfall-zdy .movie-box-b .photo-info-b{
-            padding: 7px;
-        }
-        #waterfall-zdy .movie-box-b .photo-info-b a{
-            display: block;
-        }
-        #waterfall-zdy span.svg-span{
-            cursor: pointer;
-            opacity: .3;
-        }
-        #waterfall-zdy .copy-svg{
-            vertical-align: middle;
-            display: inline-block;
-        }
-        #waterfall-zdy .info-bottom, .info-bottom-two{
-            display: flex;
-            justify-content: space-between;
-            align-items: center;
-            flex-wrap: wrap;
-        }
-    </style>
-</head>
-
-<body>
-<div class="textbox">
-    <div class="boxtitle">筛选</div>
-    <div class="genreitem"><a href="vl_genre.php?g=amjq">极致·性高潮</a></div>
-    <div class="genreitem"><a href="vl_genre.php?g=da">出轨</a></div>
-    <div class="genreitem"><a href="vl_genre.php?g=azba">亚洲</a></div>
-    <div class="genreitem"><a href="vl_genre.php?g=ba">洗澡</a></div>
-    <div class="genreitem"><a href="vl_genre.php?g=ia">美容院</a></div>
-</div>
-<div id="rightcolumn">
-    <div class="boxtitle">最近讨论的影片</div>
-    <div class="videothumblist">
-        <div class="videos">
-            <#if videoInfoList?? && videoInfoList?size gt 0>
-            <#list videoInfoList as videoInfo>
-                <div class="video" id="vid_javme2lx4y">
-                    <a href="./?v=javme2lx4y" title="PFES-029 料理研究家の湿ったパンスト 辻井ほのか">
-                        <div class="id">${videoInfo.identificationCode}</div>
-                        <img src="image/${videoInfo.imgUrl}" width="147" height="200" border="0"
-                             onerror="ThumbError(this, 'https://t69.pixhost.to/thumbs/87/271717403_t517591.jpg');">
-                        <div class="title">${videoInfo.name}</div>
-                    </a>
-                    <div class="toolbar" style="display: none;">
-                        <a id="javme2lx4y" class="icn_want" title="我想要"></a>
-                        <a id="javme2lx4y" class="icn_seen" title="看过了"></a>
-                        <a id="javme2lx4y" class="icn_have" title="已拥有"></a>
-                    </div>
-                </div>
-            </#list>
-            </#if>
-        </div>
-    </div>
-    <div class="page_selector"><span class="page first">|&lt;&lt;</span><span class="page prev">上一页</span><span class="page current">1</span><a class="page" href="/cn/vl_mostwanted.php?&amp;mode=&amp;page=2">2</a><a class="page" href="/cn/vl_mostwanted.php?&amp;mode=&amp;page=3">3</a><a class="page" href="/cn/vl_mostwanted.php?&amp;mode=&amp;page=4">4</a><a class="page" href="/cn/vl_mostwanted.php?&amp;mode=&amp;page=5">5</a><a class="page" href="/cn/vl_mostwanted.php?&amp;mode=&amp;page=6">6</a><a class="page" href="/cn/vl_mostwanted.php?&amp;mode=&amp;page=7">7</a><a class="page" href="/cn/vl_mostwanted.php?&amp;mode=&amp;page=8">8</a><a class="page" href="/cn/vl_mostwanted.php?&amp;mode=&amp;page=9">9</a><a class="page next" href="/cn/vl_mostwanted.php?&amp;mode=&amp;page=2">下一页</a><a class="page next10" href="/cn/vl_mostwanted.php?&amp;mode=&amp;page=11">下十页</a><a class="page last" href="/cn/vl_mostwanted.php?&amp;mode=&amp;page=25">&gt;&gt;|</a></div>
-</div>
-</body>
-</html>
-
-
-

+ 28 - 6
src/test/java/Test4.java

@@ -18,6 +18,11 @@
  * 3、刷票。很多投票的网页一个IP只允许投票一次,如果我们借助大量代理IP去投票,结果可想而知....
  */
 
+import me.chanjar.weixin.common.error.WxErrorException;
+import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
+import me.chanjar.weixin.cp.bean.message.WxCpMessage;
+import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
+import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
 import top.lvzhiqiang.util.DateUtils;
 
 import java.time.LocalDateTime;
@@ -30,12 +35,29 @@ import java.util.stream.Collectors;
  */
 public class Test4 {
     public static void main(String[] args) {
-        Map<String, String> paramMap = new LinkedHashMap<>();
-        paramMap.put("productType", "umcbl");
-        paramMap.put("startTime", String.valueOf(DateUtils.localDateTimeToMilliseconds(LocalDateTime.now().minusMonths(1))));
-        paramMap.put("endTime", String.valueOf(System.currentTimeMillis()));
-        paramMap.put("pageSize","100");
+        String title = "监控告警明细";
+        String content = "LEVERUSDT 上穿(Crossing Up) 0.001550";
+        String logUrl = "";
+        String btnTxt = "日志详情";
 
-        String signQueryString = paramMap.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining("&"));
+        WxCpMessage wxCpMessage = WxCpMessage.TEXTCARD().agentId(1000002)
+                .toUser("LvZhiQiang")
+                .toParty("")
+                .toTag("")
+                .title(title).description(content)
+                .url("https://lvzhiqiang.top").btnTxt(btnTxt)
+                .build();
+
+        WxCpDefaultConfigImpl wxCpDefaultConfig = new WxCpDefaultConfigImpl();
+        wxCpDefaultConfig.setCorpId("ww95a4adba56acb55f");
+        wxCpDefaultConfig.setAgentId(1000002);
+        wxCpDefaultConfig.setCorpSecret("tqWepGSe91U2Cc2SDf2EGt6M2KaEy2PbvdEauGWywxs");
+        WxCpServiceImpl wxCpService = new WxCpServiceImpl();
+        wxCpService.setWxCpConfigStorage(wxCpDefaultConfig);
+        try {
+            WxCpMessageSendResult sendResult = wxCpService.getMessageService().send(wxCpMessage);
+            System.out.println(sendResult);
+        } catch (WxErrorException e) {
+        }
     }
 }