Quellcode durchsuchen

Merge branch 'master' of http://adicom-hxx.natapp1.cc/CQ_ADI/airopt-manager

tangjunhao vor 3 Monaten
Ursprung
Commit
941f61ed0d

+ 13 - 0
adi-admin/pom.xml

@@ -61,6 +61,19 @@
             <artifactId>adi-generator</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpcore</artifactId>
+            <version>4.4.3</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.13</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
     <build>

+ 8 - 0
adi-admin/src/main/java/com/adi/airopt/controller/ProjectController.java

@@ -0,0 +1,8 @@
+package com.adi.airopt.controller;
+/**
+ *  ariopt 项目数据数据查询
+ *
+ * @author adi
+ */
+public class ProjectController {
+}

+ 152 - 0
adi-admin/src/main/java/com/adi/airopt/controller/UserController.java

@@ -0,0 +1,152 @@
+package com.adi.airopt.controller;
+
+import com.adi.common.config.AdiConfig;
+import com.adi.common.constant.CacheConstants;
+import com.adi.common.core.controller.BaseController;
+import com.adi.common.core.domain.AjaxResult;
+import com.adi.common.core.domain.entity.SysUser;
+import com.adi.common.core.page.PageDomain;
+import com.adi.common.core.page.TableDataInfo;
+import com.adi.common.core.page.TableSupport;
+import com.adi.common.core.redis.RedisCache;
+import com.adi.common.utils.PageUtils;
+import com.adi.config.AiroptHttpConfig;
+import com.adi.framework.web.domain.server.Sys;
+import com.adi.system.domain.SysUserOnline;
+import com.adi.util.HttpUtils;
+import com.alibaba.fastjson2.JSONObject;
+import com.github.pagehelper.PageHelper;
+import org.apache.http.HttpResponse;
+import org.apache.http.util.EntityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.IOException;
+import java.util.*;
+
+/**
+ *  ariopt 用户数据数据查询
+ *
+ * @author adi
+ */
+@RestController
+@RequestMapping("/buss/user")
+public class UserController extends BaseController {
+    public final static String UserKeyPre = "USER_";
+    /** 系统基础配置 */
+    @Autowired
+    private AiroptHttpConfig airConfig;
+    @Autowired
+    private RedisCache redisCache;
+    /**
+     * 获取在线用户
+     */
+    @RequestMapping("/online")
+    public AjaxResult online() throws IOException
+    {
+        Collection<String> keys = redisCache.keys(airConfig.getUserKeyPre() + "*");
+        Map<String, Object> result = new HashMap<>(2);
+        result.put("count", keys.size());
+        List<String> uids = new ArrayList<>();
+        for (String key : keys)
+        {
+            String uid = key.replace(airConfig.getUserKeyPre(),"");
+            uids.add(uid);
+        }
+        result.put("uids", uids);
+        return AjaxResult.success(result);
+    }
+    /**
+     * 获取用户信息
+     */
+    @RequestMapping("/detail/{uid}")
+    public AjaxResult userdetil(@PathVariable String uid) throws IOException
+    {
+        String host =airConfig.getUrl();
+        Map<String, String> bodys =new HashMap<>();
+        bodys.put("channelNo",airConfig.getChannelNo());
+        bodys.put("clientToken",airConfig.getClientToken());
+        bodys.put("transCode","B00031");
+        bodys.put("userId",airConfig.getUserId());
+        bodys.put("uid",uid);
+        try {
+            HttpResponse response= HttpUtils.doPost(host,bodys);
+            int stat = response.getStatusLine().getStatusCode();
+            if (stat != 200) {
+                return AjaxResult.error("业务服务链接失败");
+            }
+            String res = EntityUtils.toString(response.getEntity());
+            JSONObject res_obj = JSONObject.parseObject(res);
+            return AjaxResult.success(res_obj);
+        } catch (Exception e) {
+            e.printStackTrace();
+           return AjaxResult.error("业务服务链接失败");
+        }
+
+    }
+
+    /**
+     * 获取用户信息
+     */
+    @RequestMapping("/list")
+    public AjaxResult userlist(@RequestParam String searchtag) throws IOException
+    {
+        PageDomain pageDomain = TableSupport.buildPageRequest();
+        Integer pageNum = pageDomain.getPageNum();
+        Integer pageSize = pageDomain.getPageSize();
+        String host =airConfig.getUrl();
+        Map<String, String> bodys =new HashMap<>();
+        bodys.put("channelNo",airConfig.getChannelNo());
+        bodys.put("clientToken",airConfig.getClientToken());
+        bodys.put("transCode","B00030");
+        bodys.put("userId",airConfig.getUserId());
+        bodys.put("searchtag",searchtag);
+        bodys.put("count", pageSize.toString());
+        bodys.put("page",pageNum.toString());
+        try {
+            HttpResponse response= HttpUtils.doPost(host,bodys);
+            int stat = response.getStatusLine().getStatusCode();
+            if (stat != 200) {
+                return AjaxResult.error("业务服务链接失败");
+            }
+            String res = EntityUtils.toString(response.getEntity());
+            JSONObject res_obj = JSONObject.parseObject(res);
+            return AjaxResult.success(res_obj);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return AjaxResult.error("业务服务链接失败");
+        }
+
+    }
+    /**
+     * 重置密码
+     */
+    @RequestMapping("repwd/{uid}")
+    public AjaxResult repwd(@PathVariable String uid) throws IOException
+    {
+        String host =airConfig.getUrl();
+        Map<String, String> bodys =new HashMap<>();
+        bodys.put("channelNo",airConfig.getChannelNo());
+        bodys.put("clientToken",airConfig.getClientToken());
+        bodys.put("transCode","B00032");
+        bodys.put("userId",airConfig.getUserId());
+        bodys.put("uid",uid);
+        try {
+            HttpResponse response= HttpUtils.doPost(host,bodys);
+            int stat = response.getStatusLine().getStatusCode();
+            if (stat != 200) {
+                return AjaxResult.error("业务服务链接失败");
+            }
+            String res = EntityUtils.toString(response.getEntity());
+            JSONObject res_obj = JSONObject.parseObject(res);
+            return AjaxResult.success(res_obj);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return AjaxResult.error("业务服务链接失败");
+        }
+
+    }
+}
+
+

+ 55 - 0
adi-admin/src/main/java/com/adi/config/AiroptHttpConfig.java

@@ -0,0 +1,55 @@
+package com.adi.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "airopthttp")
+public class AiroptHttpConfig {
+    private String url;
+    private String channelNo;
+    private String clientToken;
+    private String userId;
+    private String UserKeyPre;
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getChannelNo() {
+        return channelNo;
+    }
+
+    public void setChannelNo(String channelNo) {
+        this.channelNo = channelNo;
+    }
+
+    public String getClientToken() {
+        return clientToken;
+    }
+
+    public void setClientToken(String clientToken) {
+        this.clientToken = clientToken;
+    }
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getUserKeyPre() {
+        return UserKeyPre;
+    }
+
+    public void setUserKeyPre(String userKeyPre) {
+        UserKeyPre = userKeyPre;
+    }
+}

+ 323 - 0
adi-admin/src/main/java/com/adi/util/HttpUtils.java

@@ -0,0 +1,323 @@
+package com.adi.util;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.message.BasicNameValuePair;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class HttpUtils {
+
+    /**
+     * get
+     *
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doGet(String host, String path, String method,
+                                     Map<String, String> headers,
+                                     Map<String, String> querys)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpGet request = new HttpGet(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        return httpClient.execute(request);
+    }
+    public static HttpResponse doPost(String host, Map<String, String> bodys)
+            throws Exception {
+        String path="";
+        String method="";
+        Map<String, String> headers= new HashMap<>();
+        Map<String, String> querys= new HashMap<>();
+        return doPost(host,path,method,headers,querys,bodys);
+    }
+    /**
+     * post form
+     *
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @param bodys
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPost(String host, String path, String method,
+                                      Map<String, String> headers,
+                                      Map<String, String> querys,
+                                      Map<String, String> bodys)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpPost request = new HttpPost(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (bodys != null) {
+            List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
+
+            for (String key : bodys.keySet()) {
+                nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
+            }
+            UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
+            formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
+            request.setEntity(formEntity);
+        }
+
+        return httpClient.execute(request);
+    }
+
+    /**
+     * Post String
+     *
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @param body
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPost(String host, String path, String method,
+                                      Map<String, String> headers,
+                                      Map<String, String> querys,
+                                      String body)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpPost request = new HttpPost(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (StringUtils.isNotBlank(body)) {
+            request.setEntity(new StringEntity(body, "utf-8"));
+        }
+
+        return httpClient.execute(request);
+    }
+
+    /**
+     * Post stream
+     *
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @param body
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPost(String host, String path, String method,
+                                      Map<String, String> headers,
+                                      Map<String, String> querys,
+                                      byte[] body)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpPost request = new HttpPost(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (body != null) {
+            request.setEntity(new ByteArrayEntity(body));
+        }
+
+        return httpClient.execute(request);
+    }
+
+    /**
+     * Put String
+     *
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @param body
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPut(String host, String path, String method,
+                                     Map<String, String> headers,
+                                     Map<String, String> querys,
+                                     String body)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpPut request = new HttpPut(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (StringUtils.isNotBlank(body)) {
+            request.setEntity(new StringEntity(body, "utf-8"));
+        }
+
+        return httpClient.execute(request);
+    }
+
+    /**
+     * Put stream
+     *
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @param body
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doPut(String host, String path, String method,
+                                     Map<String, String> headers,
+                                     Map<String, String> querys,
+                                     byte[] body)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpPut request = new HttpPut(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        if (body != null) {
+            request.setEntity(new ByteArrayEntity(body));
+        }
+
+        return httpClient.execute(request);
+    }
+
+    /**
+     * Delete
+     *
+     * @param host
+     * @param path
+     * @param method
+     * @param headers
+     * @param querys
+     * @return
+     * @throws Exception
+     */
+    public static HttpResponse doDelete(String host, String path, String method,
+                                        Map<String, String> headers,
+                                        Map<String, String> querys)
+            throws Exception {
+        HttpClient httpClient = wrapClient(host);
+
+        HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
+        for (Map.Entry<String, String> e : headers.entrySet()) {
+            request.addHeader(e.getKey(), e.getValue());
+        }
+
+        return httpClient.execute(request);
+    }
+
+    private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
+        StringBuilder sbUrl = new StringBuilder();
+        sbUrl.append(host);
+        if (!StringUtils.isBlank(path)) {
+            sbUrl.append(path);
+        }
+        if (null != querys) {
+            StringBuilder sbQuery = new StringBuilder();
+            for (Map.Entry<String, String> query : querys.entrySet()) {
+                if (0 < sbQuery.length()) {
+                    sbQuery.append("&");
+                }
+                if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
+                    sbQuery.append(query.getValue());
+                }
+                if (!StringUtils.isBlank(query.getKey())) {
+                    sbQuery.append(query.getKey());
+                    if (!StringUtils.isBlank(query.getValue())) {
+                        sbQuery.append("=");
+                        sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
+                    }
+                }
+            }
+            if (0 < sbQuery.length()) {
+                sbUrl.append("?").append(sbQuery);
+            }
+        }
+
+        return sbUrl.toString();
+    }
+
+    private static HttpClient wrapClient(String host) {
+        HttpClient httpClient = new DefaultHttpClient();
+        if (host.startsWith("https://")) {
+            sslClient(httpClient);
+        }
+
+        return httpClient;
+    }
+
+    private static void sslClient(HttpClient httpClient) {
+        try {
+            SSLContext ctx = SSLContext.getInstance("TLS");
+            X509TrustManager tm = new X509TrustManager() {
+                public X509Certificate[] getAcceptedIssuers() {
+                    return null;
+                }
+
+                public void checkClientTrusted(X509Certificate[] xcs, String str) {
+
+                }
+
+                public void checkServerTrusted(X509Certificate[] xcs, String str) {
+
+                }
+            };
+            ctx.init(null, new TrustManager[]{tm}, null);
+            SSLSocketFactory ssf = new SSLSocketFactory(ctx);
+            ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+            ClientConnectionManager ccm = httpClient.getConnectionManager();
+            SchemeRegistry registry = ccm.getSchemeRegistry();
+            registry.register(new Scheme("https", 443, ssf));
+        } catch (KeyManagementException ex) {
+            throw new RuntimeException(ex);
+        } catch (NoSuchAlgorithmException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+}

+ 9 - 2
adi-admin/src/main/resources/application.yml

@@ -1,3 +1,10 @@
+# buss 业务访问
+airopthttp:
+  url: http://localhost:8188/TransServlet
+  channelNo: service
+  clientToken: e47b87eec69545559d1e81e56626da68
+  userId: 5f06c8bc77234f969d13e160b54c27e3
+  UserKeyPre: USER_
 # 项目相关配置
 adi:
   # 名称
@@ -7,7 +14,7 @@ adi:
   # 版权年份
   copyrightYear: 2025
   # 文件路径 示例( Windows配置D:/adi/uploadPath,Linux配置 /home/adi/uploadPath)
-  profile: D:/adi/uploadPath
+  profile: /cephfs/airoptm
   # 获取ip地址开关
   addressEnabled: false
   # 验证码类型 math 数字计算 char 字符验证
@@ -16,7 +23,7 @@ adi:
 # 开发环境配置
 server:
   # 服务器的HTTP端口,默认为8080
-  port: 8080
+  port: 1880
   servlet:
     # 应用的访问路径
     context-path: /

+ 1 - 1
adi-ui/vue.config.js

@@ -9,7 +9,7 @@ const CompressionPlugin = require('compression-webpack-plugin')
 
 const name = process.env.VUE_APP_TITLE || '后端管理系统' // 网页标题
 
-const baseUrl = 'https://www.adicn.com/airoptms'  // 后端接口
+const baseUrl = 'http://192.168.0.131/airoptms'  // 后端接口
 
 const port = process.env.port || process.env.npm_config_port || 80 // 端口