zhanghua
2025-08-22 89ad0fa748b1773d58822290e4822a4bbbb1d9f9
添加蓉政通登陆接口
5个文件已修改
1个文件已添加
165 ■■■■■ 已修改文件
doc/运维文档.md 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/pom.xml 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/org/dromara/web/utils/RZTHttpUtils.java 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-dev.yml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-prod.yml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
doc/ÔËάÎĵµ.md
@@ -33,12 +33,18 @@
密码:QyqkwwjtbxtWersdf01
```
连接上VPN后,输入 https://192.168.50.17
堡垒机账号密码(即运维客户端登录账号密码):
```
账号:qyqkwwjtbxt01
密码:QyqkwwjtbxtWersdf@02
密码:QyqkwwjtbxtWersdf@06
```
## ææ–™
@@ -170,6 +176,16 @@
## åŽç«¯æœåŠ¡
# æ‰“包生产环境
mvn clean package -Pprod
# å¯åŠ¨æœåŠ¡
systemctl stop java-server
systemctl start java-server
```bash
nohup java -jar &
```
ruoyi-admin/pom.xml
@@ -126,6 +126,14 @@
                    </execution>
                </executions>
            </plugin>
            <!-- è·³è¿‡Test测试打包 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java
@@ -3,7 +3,9 @@
import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.dingtalkcontact_1_0.models.GetUserHeaders;
import com.aliyun.dingtalkcontact_1_0.models.GetUserResponseBody;
import com.aliyun.dingtalkoauth2_1_0.models.GetUserTokenRequest;
@@ -14,9 +16,7 @@
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.*;
import com.dingtalk.api.response.OapiUserGetbyunionidResponse;
import com.dingtalk.api.response.OapiUserGetuserinfoResponse;
import com.dingtalk.api.response.OapiV2UserGetResponse;
import com.dingtalk.api.response.OapiV2UserGetuserinfoResponse;
import com.taobao.api.ApiException;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
@@ -33,6 +33,7 @@
import org.dromara.common.core.utils.MessageUtils;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.social.config.properties.SocialLoginConfigProperties;
import org.dromara.common.social.config.properties.SocialProperties;
import org.dromara.common.social.utils.SocialUtils;
@@ -50,12 +51,16 @@
import org.dromara.web.service.IAuthStrategy;
import org.dromara.web.service.SysLoginService;
import org.dromara.web.service.SysRegisterService;
import org.dromara.web.utils.RZTHttpUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.aliyun.teaopenapi.models.Config;
import java.net.URL;
import java.time.Duration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * è®¤è¯
@@ -79,6 +84,7 @@
    private final ISysClientService clientService;
    private final ISysUserService userService;
    private final SysUserMapper userMapper;
    private final RZTHttpUtils rzthttpUtils;
    /**
@@ -315,4 +321,55 @@
        return rsp.getResult();
    }
    final String redisKey = "RZT_TOKEN";
    @RequestMapping(value = "/rztLogin", method = RequestMethod.GET)
    public String getRztAccessToken(@RequestParam(value = "code") String code) {
        try {
            log.info("code值:{}", code);
            String accessToken = getRztToken();
            if (StrUtil.isNotBlank(accessToken)) {
                Map<String, String> hashMap = new HashMap<>();
                hashMap.put("code", code);
                hashMap.put("token", accessToken);
                String userJson = rzthttpUtils.sendGetRequest("/login/info", hashMap);
                log.info("用户信息:{}", userJson);
                JSONObject userObject = JSON.parseObject(userJson);
                if (userObject.getIntValue("errcode") == 0) {
                    return userObject.getString("userid");
                } else {
                    log.error("获取用户信息失败:{}", userObject.getString("errmsg"));
                }
            }
        } catch (Exception e) {
            log.error("获取用户信息异常:{}", e.getMessage());
        }
        return "";
    }
    private String getRztToken() throws Exception {
        String token = RedisUtils.getCacheObject(redisKey);
        if (StrUtil.isEmpty(token)) {
            String corpId = "ww9904fd98c1b0df9e";
            String corpSecret = "mZdTP-ULDWHEPgFCpl62OwudbP3bODgqN9lC-rUtNSA";
            String accessJson = rzthttpUtils.sendGetRequest("/gettoken?corpId=" + corpId + "&corpsecret=" + corpSecret, null);
            JSONObject jsonObject = JSON.parseObject(accessJson);
            if (jsonObject.getIntValue("errcode") == 0) {
                String accessToken = jsonObject.getString("access_token");
                Integer expiresIn = jsonObject.getIntValue("expires_in");
                RedisUtils.setCacheObject(redisKey, accessToken, Duration.ofSeconds(expiresIn));
                return accessToken;
            } else {
                log.error("获取token失败:{},{}", jsonObject.getIntValue("errcode"), jsonObject.getString("errmsg"));
                return null;
            }
        } else {
            return token;
        }
    }
}
ruoyi-admin/src/main/java/org/dromara/web/utils/RZTHttpUtils.java
New file
@@ -0,0 +1,57 @@
package org.dromara.web.utils;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.utils.RandomUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.security.MessageDigest;
import java.util.Map;
@Component
@Slf4j
public class RZTHttpUtils {
    @Value("${rzt.url}")
    private String url;
    @Value("${rzt.paasid}")
    private String paasid;
    @Value("${rzt.paastoken}")
    private String paastoken;
    public String sendGetRequest(String urlPath, Map<String, String> params) throws Exception {
        //获取时间戳:
        String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
        String nonce = RandomUtil.randomString(20);
        //获取签名:
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        byte[] hash = digest.digest((timestamp + paastoken + nonce + timestamp).getBytes());
        StringBuffer hexString = new StringBuffer();
        for (int i = 0; i < hash.length; i++) {
            String hex = Integer.toHexString(0xff & hash[i]);
            if (hex.length() == 1) {
                hexString.append('0');
            }
            hexString.append(hex);
        }
        String signature = hexString.toString().toUpperCase();
        HttpRequest request = HttpRequest.get(url + urlPath)
            .header("x-rio-paasid", paasid)
            .header("x-rio-timestamp", timestamp)
            .header("x-rio-nonce", nonce)
            .header("x-rio-signature", signature);
        if (params != null) {
            request.formStr(params);
        }
        log.info(request.toString());
        return request.execute().body();
    }
}
ruoyi-admin/src/main/resources/application-dev.yml
@@ -43,9 +43,9 @@
          driverClassName: com.mysql.cj.jdbc.Driver
          # jdbc æ‰€æœ‰å‚数配置参考 https://lionli.blog.csdn.net/article/details/122018562
          # rewriteBatchedStatements=true æ‰¹å¤„理优化 å¤§å¹…提升批量插入更新删除性能(对数据库有性能损耗 ä½¿ç”¨æ‰¹é‡æ“ä½œåº”考虑性能问题)
          url: jdbc:mysql://127.0.0.1:3306/qysp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
          url: jdbc:mysql://42.193.1.25:3306/qysp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
          username: root
          password: 123456
          password: 321$YcYl@1970!
        # ä»Žåº“数据源
        slave:
          lazy: true
@@ -95,11 +95,10 @@
--- # redis å•机配置(单机与集群只能开启一个另一个需要注释掉)
spring.data:
  redis:
    # åœ°å€
    host: 127.0.0.1
    # ç«¯å£ï¼Œé»˜è®¤ä¸º6379
    host: 42.193.1.25
    port: 6379
#    password: 234#Wersdf!
    password: ycl2018
    #    password: 234#Wersdf!
    # æ•°æ®åº“索引
    database: 0
    # å¯†ç (如没有密码请注释掉)
@@ -250,3 +249,8 @@
      client-id: 10**********6
      client-secret: 1f7d08**********5b7**********29e
      redirect-uri: ${justauth.address}/social-callback?source=gitlab
rzt:
  url: https://rio.rztcd.com:10443/ebus/dzptcs
  paasid: dzptcs
  paastoken: 69b986d3c2450454c22d99a9653c97d2
ruoyi-admin/src/main/resources/application-prod.yml
@@ -272,3 +272,8 @@
  username: admin          #本机:ftpup
  passwd: 234#Wersdf!
  path: /
rzt:
  url: https://rio.rztcd.com:10443/ebus/dzpt
  paasid: dzpt
  paastoken: 69b986d3c2450454c22d99a9653c97d2