xuhy
2024-08-24 e05cfc5d409491235f73418e916e2c5e18031f2f
Merge remote-tracking branch 'origin/master'
14个文件已修改
147 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TAppUserSign.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/OrderFallbackFactory.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TNotice.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/service/RedisService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/RequestParamGlobalFilter.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/filter/AuthFilter.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/CarBrandUtil.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/SSLCipherSuiteUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/filter/AuthFilter.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/filter/AuthFilter.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/filter/AuthFilter.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TAppUserSign.java
@@ -3,6 +3,7 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.web.domain.BasePojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -39,6 +40,7 @@
    @ApiModelProperty(value = "签到天")
    @TableField("sign_day")
    @JsonFormat(pattern = "dd", timezone = "GMT+8")
    private LocalDate signDay;
    @ApiModelProperty(value = "奖励积分")
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/OrderFallbackFactory.java
@@ -55,6 +55,11 @@
                return R.fail("订单创建" + cause.getMessage());
            }
            @Override
            public R callBack(String code, String outTradeNo) {
                return R.fail("支付回调" + cause.getMessage());
            }
            @Override
            public R<TActivityVO> activityStatistics(TActivityStatisticsQuery dto) {
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/TNotice.java
@@ -12,6 +12,7 @@
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
@@ -40,13 +41,13 @@
    @ApiModelProperty(value = "开始时间")
    @TableField("start_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime startTime;
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private LocalDate startTime;
    @ApiModelProperty(value = "结束时间")
    @TableField("end_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime endTime;
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private LocalDate endTime;
ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/service/RedisService.java
@@ -195,6 +195,14 @@
        }
    }
    public <T> void setCacheMap(final String key, final Map<String, T> dataMap, long timeout)
    {
        if (dataMap != null) {
            redisTemplate.opsForHash().putAll(key, dataMap);
            redisTemplate.expire(key, timeout, TimeUnit.SECONDS);
        }
    }
    /**
     * 获得缓存的Map
     *
ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java
@@ -39,7 +39,7 @@
    // 排除过滤的 uri 地址,nacos自行添加
    @Autowired
    private IgnoreWhiteProperties ignoreWhite;
    @Autowired
    private RedisService redisService;
    
@@ -100,7 +100,7 @@
    }
    
    private Mono<Void> unauthorizedResponse(ServerWebExchange exchange, String msg) {
        log.error("[鉴权异常处理]请求路径:{}", exchange.getRequest().getPath());
        log.error("[鉴权异常处理]请求路径:{}", exchange.getRequest().getPath() + "\n" + msg);
        return ServletUtils.webFluxResponseWriter(exchange.getResponse(), msg, HttpStatus.UNAUTHORIZED);
    }
    
@@ -146,7 +146,7 @@
        if(null == cacheMap){
            cacheMap = new HashMap<>();
            cacheMap.put(url, timestamp);
            redisService.setCacheMap(client, cacheMap);
            redisService.setCacheMap(client, cacheMap, 5L);
        }else{
            Object o = cacheMap.get(url);
            if(null == o){
@@ -155,13 +155,13 @@
                Long old_timestamp = Long.valueOf(o.toString());
                Long new_timestamp = Long.valueOf(timestamp);
                //两个请求时间差小于1秒,判定为重复提交
                if((new_timestamp - old_timestamp) <= 1000){
                if((new_timestamp - old_timestamp) <= 500){
                    throw new RuntimeException("重复提交");
                }else{
                    cacheMap.put(url, timestamp);
                }
            }
            redisService.setCacheMap(client, cacheMap);
            redisService.setCacheMap(client, cacheMap, 5L);
        }
    }
    
@@ -181,14 +181,8 @@
        if (claims == null) {
            throw new RuntimeException("令牌已过期或验证不正确!");
        }
//        String userkey = JwtUtils.getUserKey(claims);
//        boolean islogin = redisService.hasKey(getTokenKey(userkey));
//        if (!islogin) {
//            throw new RuntimeException("登录状态已过期");
//        }
        String userid = JwtUtils.getUserId(claims);
        String username = JwtUtils.getUserName(claims);
        if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
        if (StringUtils.isEmpty(userid)) {
            throw new RuntimeException("令牌验证失败");
        }
    }
ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/RequestParamGlobalFilter.java
@@ -52,13 +52,13 @@
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        ServerHttpRequest request = exchange.getRequest();
        ServerHttpRequest.Builder mutate = request.mutate();
        HttpMethod method = request.getMethod();
        if(method != HttpMethod.POST){
            return chain.filter(exchange.mutate().request(mutate.build()).build());
        }
        // 跳过不需要验证的路径
        String url = request.getURI().getPath();
        if (StringUtils.matches(url, ignoreWhite.getWhites())) {
            return chain.filter(exchange);
        }
        HttpMethod method = request.getMethod();
        if(method != HttpMethod.POST){
            return chain.filter(exchange);
        }
        ServerHttpRequestDecorator httpRequestDecorator = requestDecorator(exchange);
@@ -104,6 +104,6 @@
    
    @Override
    public int getOrder() {
        return HIGHEST_PRECEDENCE;
        return -500;
    }
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
@@ -805,9 +805,19 @@
    @ApiOperation(value = "获取车辆品牌", tags = {"小程序-个人中心-车辆"})
    @GetMapping(value = "/user/car/getBrands")
    public R getBrands() throws Exception {
    public R getBrands(String name) throws Exception {
        String brand = CarBrandUtil.getBrand();
        return R.ok(brand);
        JSONObject jsonObject = JSON.parseObject(brand);
        JSONArray data = jsonObject.getJSONArray("data");
        return R.ok(data);
    }
    @ApiOperation(value = "根据品牌获取车型", tags = {"小程序-个人中心-车辆"})
    @GetMapping(value = "/user/car/getModel")
    public R getModel(String id) throws Exception {
        String modelById = CarBrandUtil.getModelById(id);
        return R.ok(modelById);
    }
}
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/filter/AuthFilter.java
@@ -1,16 +1,13 @@
package com.ruoyi.account.filter;
import com.alibaba.fastjson.JSON;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.TAppUser;
import com.ruoyi.account.service.TAppUserService;
import com.ruoyi.common.core.constant.TokenConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.JwtUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import io.jsonwebtoken.Claims;
import org.apache.logging.log4j.core.config.Order;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,16 +32,16 @@
@Component
public class AuthFilter implements Filter {
    private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
    @Lazy
    @Resource
    private TAppUserService appUserService;
    @Lazy
    @Resource
    private SysUserClient sysUserClient;
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/CarBrandUtil.java
@@ -49,9 +49,64 @@
            // Print the body of the response.
            HttpEntity resEntity = response.getEntity();
            if (resEntity != null) {
                LOGGER.info("Processing Body with name: {} and value: {}", System.getProperty("line.separator"),
                        EntityUtils.toString(resEntity, "UTF-8"));
//                LOGGER.info("Processing Body with name: {} and value: {}", System.getProperty("line.separator"),
//                        EntityUtils.toString(resEntity, "UTF-8"));
                String string = EntityUtils.toString(resEntity, "UTF-8");
                return string;
            }
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
        } finally {
            if (client != null) {
                client.close();
            }
        }
        return "";
    }
    public static   String getModelById(String brandId) throws Exception {
        // Create a new request.
        Request httpClientRequest = new Request();
        try {
            // Set the request parameters.
            // AppKey, AppSecrect, Method and Url are required parameters.
            // Directly writing AK/SK in code is risky. For security, encrypt your AK/SK and store them in the configuration file or environment variables.
            // In this example, the AK/SK are stored in environment variables for identity authentication.
            // Before running this example, set environment variables HUAWEICLOUD_SDK_AK and HUAWEICLOUD_SDK_SK.
            httpClientRequest.setKey("9a4a2b69afe141718f6843c5d39961ec");
            httpClientRequest.setSecret("541845f206324bbc933065b44fc98c47");
            httpClientRequest.setMethod("POST");
            // Set a request URL in the format of https://{Endpoint}/{URI}.
            httpClientRequest.setUrl("https://vehiclequery.apistore.huaweicloud.com/vehicle/query/series");
            httpClientRequest.addHeader("Content-Type", "text/plain");
            httpClientRequest.addQueryStringParam("brandId",brandId);
            // Set a body for http request.
//            httpClientRequest.setBody("put your request body here");
        } catch (Exception e) {
//            LOGGER.error(e.getMessage());
            return "";
        }
        CloseableHttpClient client = null;
        try {
            // Sign the request.
            HttpRequestBase signedRequest = Client.sign(httpClientRequest, Constant.SIGNATURE_ALGORITHM_SDK_HMAC_SHA256);
            if (Constant.DO_VERIFY) {
                // creat httpClient and verify ssl certificate
                HostName.setUrlHostName(httpClientRequest.getHost());
                client = (CloseableHttpClient) SSLCipherSuiteUtil.createHttpClientWithVerify(Constant.INTERNATIONAL_PROTOCOL);
            } else {
                // creat httpClient and do not verify ssl certificate
                client = (CloseableHttpClient) SSLCipherSuiteUtil.createHttpClient(Constant.INTERNATIONAL_PROTOCOL);
            }
            HttpResponse response = client.execute(signedRequest);
            // Print the body of the response.
            HttpEntity resEntity = response.getEntity();
            if (resEntity != null) {
//                LOGGER.info("Processing Body with name: {} and value: {}", System.getProperty("line.separator"),
//                        EntityUtils.toString(resEntity, "UTF-8"));
                String string = EntityUtils.toString(resEntity, "UTF-8");
                return string;
            }
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/util/carBrand/SSLCipherSuiteUtil.java
@@ -4,7 +4,6 @@
package com.ruoyi.account.util.carBrand;
import okhttp3.OkHttpClient;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
@@ -15,6 +14,7 @@
import org.openeuler.BGMProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import okhttp3.OkHttpClient;
import javax.net.ssl.*;
import java.net.HttpURLConnection;
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/filter/AuthFilter.java
@@ -5,11 +5,9 @@
import com.ruoyi.account.api.model.TAppUser;
import com.ruoyi.common.core.constant.TokenConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.JwtUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import io.jsonwebtoken.Claims;
import org.apache.logging.log4j.core.config.Order;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -25,7 +23,6 @@
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
/**
 * @author zhibing.pu
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/filter/AuthFilter.java
@@ -5,11 +5,9 @@
import com.ruoyi.account.api.model.TAppUser;
import com.ruoyi.common.core.constant.TokenConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.JwtUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import io.jsonwebtoken.Claims;
import org.apache.logging.log4j.core.config.Order;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TVipController.java
@@ -130,7 +130,7 @@
                        .last("LIMIT 1")));
            case 2:
                return R.ok(vipService.getOne(Wrappers.lambdaQuery(TVip.class)
                        .eq(TVip::getReveal,1)
                        .eq(TVip::getReveal,1).eq(TVip::getType,1)
                        .orderByAsc(TVip::getMonthlyCard)
                        .last("LIMIT 1")));
            default:
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/filter/AuthFilter.java
@@ -5,11 +5,9 @@
import com.ruoyi.account.api.model.TAppUser;
import com.ruoyi.common.core.constant.TokenConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.JwtUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import io.jsonwebtoken.Claims;
import org.apache.logging.log4j.core.config.Order;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;