puzhibing
2026-02-06 96e1427a4f0876db0c5b37cd42d33752d293fa31
添加国际化配置
65个文件已添加
12个文件已修改
1948 ■■■■■ 已修改文件
xp-api/src/main/java/com/xiaopeng/api/vo/vehicleConvoy/VehicleStateVo.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-api/src/main/java/com/xiaopeng/api/vo/vehicleConvoy/VehicleTemperatureVo.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-api/src/main/java/com/xiaopeng/api/vo/vehicleConvoy/VehiclesCommandCallbackVo.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-api/src/main/java/com/xiaopeng/api/vo/vehicleConvoy/VehiclesCommandEnum.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-api/src/main/java/com/xiaopeng/api/vo/vehicleConvoy/VehiclesCommandParamVo.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-api/src/main/java/com/xiaopeng/api/vo/vehicleConvoy/VehiclesCommandVo.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-common/xp-common-core/src/main/java/com/xiaopeng/common/core/utils/MessageUtils.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-gateway/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-account/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-account/src/main/java/com/xiaopeng/account/config/MessageLocalConfig.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-account/src/main/java/com/xiaopeng/account/config/MyLocaleResolver.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-account/src/main/resources/i18n/messages.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-account/src/main/resources/i18n/messages_en_US.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-account/src/main/resources/i18n/messages_zh_CN.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-automaticPilot/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-automaticPilot/src/main/java/com/xiaopeng/automaticPilot/config/MessageLocalConfig.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-automaticPilot/src/main/java/com/xiaopeng/automaticPilot/config/MyLocaleResolver.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-automaticPilot/src/main/resources/i18n/messages.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-automaticPilot/src/main/resources/i18n/messages_en_US.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-automaticPilot/src/main/resources/i18n/messages_zh_CN.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-itinerary/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-itinerary/src/main/java/com/xiaopeng/itinerary/config/MessageLocalConfig.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-itinerary/src/main/java/com/xiaopeng/itinerary/config/MyLocaleResolver.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-itinerary/src/main/resources/i18n/messages.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-itinerary/src/main/resources/i18n/messages_en_US.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-itinerary/src/main/resources/i18n/messages_zh_CN.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-maintenance/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-maintenance/src/main/java/com/xiaopeng/maintenance/config/MessageLocalConfig.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-maintenance/src/main/java/com/xiaopeng/maintenance/config/MyLocaleResolver.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-maintenance/src/main/resources/i18n/messages.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-maintenance/src/main/resources/i18n/messages_en_US.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-maintenance/src/main/resources/i18n/messages_zh_CN.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-map/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-map/src/main/java/com/xiaopeng/map/config/MessageLocalConfig.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-map/src/main/java/com/xiaopeng/map/config/MyLocaleResolver.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-map/src/main/resources/i18n/messages.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-map/src/main/resources/i18n/messages_en_US.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-map/src/main/resources/i18n/messages_zh_CN.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-operation/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-operation/src/main/java/com/xiaopeng/operation/config/MessageLocalConfig.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-operation/src/main/java/com/xiaopeng/operation/config/MyLocaleResolver.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-operation/src/main/resources/i18n/messages.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-operation/src/main/resources/i18n/messages_en_US.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-operation/src/main/resources/i18n/messages_zh_CN.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-order/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-order/src/main/java/com/xiaopeng/order/config/MessageLocalConfig.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-order/src/main/java/com/xiaopeng/order/config/MyLocaleResolver.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-order/src/main/resources/i18n/messages.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-order/src/main/resources/i18n/messages_en_US.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-order/src/main/resources/i18n/messages_zh_CN.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-payment/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-payment/src/main/java/com/xiaopeng/payment/config/MessageLocalConfig.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-payment/src/main/java/com/xiaopeng/payment/config/MyLocaleResolver.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-payment/src/main/resources/i18n/messages.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-payment/src/main/resources/i18n/messages_en_US.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-payment/src/main/resources/i18n/messages_zh_CN.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-pushMessage/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-pushMessage/src/main/java/com/xiaopeng/pushMessage/config/MessageLocalConfig.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-pushMessage/src/main/java/com/xiaopeng/pushMessage/config/MyLocaleResolver.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-pushMessage/src/main/resources/i18n/messages.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-pushMessage/src/main/resources/i18n/messages_en_US.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-pushMessage/src/main/resources/i18n/messages_zh_CN.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-remoteDriving/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-remoteDriving/src/main/java/com/xiaopeng/remoteDriving/config/MessageLocalConfig.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-remoteDriving/src/main/java/com/xiaopeng/remoteDriving/config/MyLocaleResolver.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-remoteDriving/src/main/resources/i18n/messages.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-remoteDriving/src/main/resources/i18n/messages_en_US.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-remoteDriving/src/main/resources/i18n/messages_zh_CN.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-vehicleConvoy/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-vehicleConvoy/src/main/java/com/xiaopeng/vehicleConvoy/config/MessageLocalConfig.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-vehicleConvoy/src/main/java/com/xiaopeng/vehicleConvoy/config/MyLocaleResolver.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-vehicleConvoy/src/main/java/com/xiaopeng/vehicleConvoy/controller/VehiclesController.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-vehicleConvoy/src/main/java/com/xiaopeng/vehicleConvoy/util/HMACSHA1.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-vehicleConvoy/src/main/java/com/xiaopeng/vehicleConvoy/util/VehicleControlUtil.java 146 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-vehicleConvoy/src/main/resources/i18n/messages.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-vehicleConvoy/src/main/resources/i18n/messages_en_US.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-vehicleConvoy/src/main/resources/i18n/messages_zh_CN.properties 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-api/src/main/java/com/xiaopeng/api/vo/vehicleConvoy/VehicleStateVo.java
New file
@@ -0,0 +1,18 @@
package com.xiaopeng.api.vo.vehicleConvoy;
import lombok.Data;
/**
 * 车辆状态响应
 */
@Data
public class VehicleStateVo {
    /**
     * 更新时间
     */
    private Long timestamp;
    /**
     * 状态值
     */
    private Object value;
}
xp-api/src/main/java/com/xiaopeng/api/vo/vehicleConvoy/VehicleTemperatureVo.java
New file
@@ -0,0 +1,21 @@
package com.xiaopeng.api.vo.vehicleConvoy;
import lombok.Data;
import java.util.Map;
/**
 * 车内温度响应
 */
@Data
public class VehicleTemperatureVo {
    /**
     * 车辆vin
     */
    private String vin;
    /**
     * 车辆状态数据
     */
    private Map<String, VehicleStateVo> stateMap;
}
xp-api/src/main/java/com/xiaopeng/api/vo/vehicleConvoy/VehiclesCommandCallbackVo.java
New file
@@ -0,0 +1,40 @@
package com.xiaopeng.api.vo.vehicleConvoy;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
/**
 * 车辆控制消息回调
 */
@Data
public class VehiclesCommandCallbackVo {
    /**
     * 车端响应的原始内容,JSON形式
     */
    private JSONObject msgContent;
    /**
     * 车控指令执行,车端返回MsgId
     */
    private String msg_id;
    /**
     * 车控指令执行的MsgId,从/api/v1/vehicles/command接口获取,业务方自管
     */
    private String msg_ref;
    /**
     * 消息类型
     */
    private Integer msg_type;
    /**
     * 服务类型
     */
    private Integer service_type;
    /**
     * 响应内容
     */
    private String msg_content;
    /**
     * 响应码
     */
    private String code;
}
xp-api/src/main/java/com/xiaopeng/api/vo/vehicleConvoy/VehiclesCommandEnum.java
New file
@@ -0,0 +1,27 @@
package com.xiaopeng.api.vo.vehicleConvoy;
import lombok.Getter;
/**
 * 车辆控制指令枚举
 */
@Getter
public enum VehiclesCommandEnum {
    DOOR_TRUNK_OPEN("DOOR_TRUNK_OPEN", "后备箱开启"),
    DOOR_TRUNK_CLOSE("DOOR_TRUNK_CLOSE", "后备箱关闭"),
    DOOR_UNLOCK("DOOR_UNLOCK", "车门开锁"),
    HVAC_TEMP_SET("HVAC_TEMP_SET", "设定温度");
    /**
     * 命令
     */
    private String command;
    /**
     * 描述
     */
    private String desc;
    VehiclesCommandEnum(String command, String desc) {
        this.command = command;
        this.desc = desc;
    }
}
xp-api/src/main/java/com/xiaopeng/api/vo/vehicleConvoy/VehiclesCommandParamVo.java
New file
@@ -0,0 +1,15 @@
package com.xiaopeng.api.vo.vehicleConvoy;
import lombok.Data;
/**
 * 车辆控制参数
 */
@Data
public class VehiclesCommandParamVo {
    /**
     * 设置温度度数值
     */
    private Integer degree;
}
xp-api/src/main/java/com/xiaopeng/api/vo/vehicleConvoy/VehiclesCommandVo.java
New file
@@ -0,0 +1,43 @@
package com.xiaopeng.api.vo.vehicleConvoy;
import lombok.Data;
import lombok.Getter;
/**
 * 车辆控制请求
 */
@Getter
public class VehiclesCommandVo {
    /**
     * 用户id
     */
    private Long uid;
    /**
     * 车辆vin
     */
    private String vin;
    /**
     * 车辆控制命令
     */
    private String commandCode;
    /**
     * 命令参数
     */
    private VehiclesCommandParamVo extParam;
    public void setUid(Long uid) {
        this.uid = uid;
    }
    public void setVin(String vin) {
        this.vin = vin;
    }
    public void setCommandCode(VehiclesCommandEnum commandCode) {
        this.commandCode = commandCode.getCommand();
    }
    public void setExtParam(VehiclesCommandParamVo extParam) {
        this.extParam = extParam;
    }
}
xp-common/xp-common-core/src/main/java/com/xiaopeng/common/core/utils/MessageUtils.java
New file
@@ -0,0 +1,26 @@
package com.xiaopeng.common.core.utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
@Component
public class MessageUtils {
    @Autowired
    private MessageSource messageSource;
    /**
     * 根据消息键和参数 获取消息 委托给spring messageSource
     *
     * @param code 消息键
     * @param args 参数
     * @return 获取国际化翻译值
     */
    public String get(String code, Object... args) {
        return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
    }
}
xp-gateway/pom.xml
@@ -121,11 +121,6 @@
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <!--mysql-->
        <dependency>
            <groupId>mysql</groupId>
xp-service/xp-account/pom.xml
@@ -77,11 +77,6 @@
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
xp-service/xp-account/src/main/java/com/xiaopeng/account/config/MessageLocalConfig.java
New file
@@ -0,0 +1,46 @@
package com.xiaopeng.account.config;
import org.springframework.boot.autoconfigure.context.MessageSourceProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import java.time.Duration;
/**
 * 国际化配置
 */
@Configuration
public class MessageLocalConfig {
    @Bean
    public MessageSource messageSource(MessageSourceProperties properties) {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        if (StringUtils.hasText(properties.getBasename())) {
            messageSource.setBasenames(StringUtils
                    .commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
        }
        if (properties.getEncoding() != null) {
            messageSource.setDefaultEncoding(properties.getEncoding().name());
        }
        messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
        Duration cacheDuration = properties.getCacheDuration();
        if (cacheDuration != null) {
            messageSource.setCacheMillis(cacheDuration.toMillis());
        }
        messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
        messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
        return messageSource;
    }
    @Bean//注册国际化组件
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
}
xp-service/xp-account/src/main/java/com/xiaopeng/account/config/MyLocaleResolver.java
New file
@@ -0,0 +1,82 @@
package com.xiaopeng.account.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;
public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        //1=中文,2=英文,3=印尼文
        //1=Chinese, 2=English, 3=Indonesian.
        String language = getQueryParams(request, "language");
        Locale locale = null;
        if (StringUtils.isEmpty(language)) {
            locale = Locale.getDefault();
        }
        //如果请求不为空
        //If the request is not empty.
        if (language.equals("1")) {
            locale = new Locale("zh", "CN");
        } else if (language.equals("2")) {
            locale = new Locale("en", "US");
        } else {
            locale = new Locale("in", "ID");
        }
        return locale;
    }
    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
    }
    public String getQueryParams(HttpServletRequest request, String key) {
        try {
            String method = request.getMethod();
            if("POST".equals(method)){
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
                StringBuffer sb = new StringBuffer();
                ServletInputStream inputStream = request.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                String s;
                while ((s = bufferedReader.readLine()) != null){
                    sb.append(s);
                }
                bufferedReader.close();
                inputStream.close();
                JSONObject jsonObject = JSON.parseObject(sb.toString());
                return jsonObject.getString(key);
            }else{
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
xp-service/xp-account/src/main/resources/i18n/messages.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-account/src/main/resources/i18n/messages_en_US.properties
New file
@@ -0,0 +1,2 @@
# English (US)
welcome.message=Welcome to our application!
xp-service/xp-account/src/main/resources/i18n/messages_zh_CN.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-automaticPilot/pom.xml
@@ -65,11 +65,6 @@
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
xp-service/xp-automaticPilot/src/main/java/com/xiaopeng/automaticPilot/config/MessageLocalConfig.java
New file
@@ -0,0 +1,47 @@
package com.xiaopeng.automaticPilot.config;
import org.springframework.boot.autoconfigure.context.MessageSourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import java.time.Duration;
/**
 * 国际化配置
 */
@Configuration
public class MessageLocalConfig {
    @Bean
    public MessageSource messageSource(MessageSourceProperties properties) {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        if (StringUtils.hasText(properties.getBasename())) {
            messageSource.setBasenames(StringUtils
                    .commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
        }
        if (properties.getEncoding() != null) {
            messageSource.setDefaultEncoding(properties.getEncoding().name());
        }
        messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
        Duration cacheDuration = properties.getCacheDuration();
        if (cacheDuration != null) {
            messageSource.setCacheMillis(cacheDuration.toMillis());
        }
        messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
        messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
        return messageSource;
    }
    @Bean//注册国际化组件
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
}
xp-service/xp-automaticPilot/src/main/java/com/xiaopeng/automaticPilot/config/MyLocaleResolver.java
New file
@@ -0,0 +1,82 @@
package com.xiaopeng.automaticPilot.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;
public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        //1=中文,2=英文,3=印尼文
        //1=Chinese, 2=English, 3=Indonesian.
        String language = getQueryParams(request, "language");
        Locale locale = null;
        if (StringUtils.isEmpty(language)) {
            locale = Locale.getDefault();
        }
        //如果请求不为空
        //If the request is not empty.
        if (language.equals("1")) {
            locale = new Locale("zh", "CN");
        } else if (language.equals("2")) {
            locale = new Locale("en", "US");
        } else {
            locale = new Locale("in", "ID");
        }
        return locale;
    }
    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
    }
    public String getQueryParams(HttpServletRequest request, String key) {
        try {
            String method = request.getMethod();
            if("POST".equals(method)){
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
                StringBuffer sb = new StringBuffer();
                ServletInputStream inputStream = request.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                String s;
                while ((s = bufferedReader.readLine()) != null){
                    sb.append(s);
                }
                bufferedReader.close();
                inputStream.close();
                JSONObject jsonObject = JSON.parseObject(sb.toString());
                return jsonObject.getString(key);
            }else{
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
xp-service/xp-automaticPilot/src/main/resources/i18n/messages.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-automaticPilot/src/main/resources/i18n/messages_en_US.properties
New file
@@ -0,0 +1,2 @@
# English (US)
welcome.message=Welcome to our application!
xp-service/xp-automaticPilot/src/main/resources/i18n/messages_zh_CN.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-itinerary/pom.xml
@@ -65,11 +65,6 @@
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
xp-service/xp-itinerary/src/main/java/com/xiaopeng/itinerary/config/MessageLocalConfig.java
New file
@@ -0,0 +1,47 @@
package com.xiaopeng.itinerary.config;
import org.springframework.boot.autoconfigure.context.MessageSourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import java.time.Duration;
/**
 * 国际化配置
 */
@Configuration
public class MessageLocalConfig {
    @Bean
    public MessageSource messageSource(MessageSourceProperties properties) {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        if (StringUtils.hasText(properties.getBasename())) {
            messageSource.setBasenames(StringUtils
                    .commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
        }
        if (properties.getEncoding() != null) {
            messageSource.setDefaultEncoding(properties.getEncoding().name());
        }
        messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
        Duration cacheDuration = properties.getCacheDuration();
        if (cacheDuration != null) {
            messageSource.setCacheMillis(cacheDuration.toMillis());
        }
        messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
        messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
        return messageSource;
    }
    @Bean//注册国际化组件
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
}
xp-service/xp-itinerary/src/main/java/com/xiaopeng/itinerary/config/MyLocaleResolver.java
New file
@@ -0,0 +1,82 @@
package com.xiaopeng.itinerary.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;
public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        //1=中文,2=英文,3=印尼文
        //1=Chinese, 2=English, 3=Indonesian.
        String language = getQueryParams(request, "language");
        Locale locale = null;
        if (StringUtils.isEmpty(language)) {
            locale = Locale.getDefault();
        }
        //如果请求不为空
        //If the request is not empty.
        if (language.equals("1")) {
            locale = new Locale("zh", "CN");
        } else if (language.equals("2")) {
            locale = new Locale("en", "US");
        } else {
            locale = new Locale("in", "ID");
        }
        return locale;
    }
    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
    }
    public String getQueryParams(HttpServletRequest request, String key) {
        try {
            String method = request.getMethod();
            if("POST".equals(method)){
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
                StringBuffer sb = new StringBuffer();
                ServletInputStream inputStream = request.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                String s;
                while ((s = bufferedReader.readLine()) != null){
                    sb.append(s);
                }
                bufferedReader.close();
                inputStream.close();
                JSONObject jsonObject = JSON.parseObject(sb.toString());
                return jsonObject.getString(key);
            }else{
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
xp-service/xp-itinerary/src/main/resources/i18n/messages.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-itinerary/src/main/resources/i18n/messages_en_US.properties
New file
@@ -0,0 +1,2 @@
# English (US)
welcome.message=Welcome to our application!
xp-service/xp-itinerary/src/main/resources/i18n/messages_zh_CN.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-maintenance/pom.xml
@@ -65,11 +65,6 @@
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
xp-service/xp-maintenance/src/main/java/com/xiaopeng/maintenance/config/MessageLocalConfig.java
New file
@@ -0,0 +1,47 @@
package com.xiaopeng.maintenance.config;
import org.springframework.boot.autoconfigure.context.MessageSourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import java.time.Duration;
/**
 * 国际化配置
 */
@Configuration
public class MessageLocalConfig {
    @Bean
    public MessageSource messageSource(MessageSourceProperties properties) {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        if (StringUtils.hasText(properties.getBasename())) {
            messageSource.setBasenames(StringUtils
                    .commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
        }
        if (properties.getEncoding() != null) {
            messageSource.setDefaultEncoding(properties.getEncoding().name());
        }
        messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
        Duration cacheDuration = properties.getCacheDuration();
        if (cacheDuration != null) {
            messageSource.setCacheMillis(cacheDuration.toMillis());
        }
        messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
        messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
        return messageSource;
    }
    @Bean//注册国际化组件
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
}
xp-service/xp-maintenance/src/main/java/com/xiaopeng/maintenance/config/MyLocaleResolver.java
New file
@@ -0,0 +1,82 @@
package com.xiaopeng.maintenance.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;
public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        //1=中文,2=英文,3=印尼文
        //1=Chinese, 2=English, 3=Indonesian.
        String language = getQueryParams(request, "language");
        Locale locale = null;
        if (StringUtils.isEmpty(language)) {
            locale = Locale.getDefault();
        }
        //如果请求不为空
        //If the request is not empty.
        if (language.equals("1")) {
            locale = new Locale("zh", "CN");
        } else if (language.equals("2")) {
            locale = new Locale("en", "US");
        } else {
            locale = new Locale("in", "ID");
        }
        return locale;
    }
    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
    }
    public String getQueryParams(HttpServletRequest request, String key) {
        try {
            String method = request.getMethod();
            if("POST".equals(method)){
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
                StringBuffer sb = new StringBuffer();
                ServletInputStream inputStream = request.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                String s;
                while ((s = bufferedReader.readLine()) != null){
                    sb.append(s);
                }
                bufferedReader.close();
                inputStream.close();
                JSONObject jsonObject = JSON.parseObject(sb.toString());
                return jsonObject.getString(key);
            }else{
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
xp-service/xp-maintenance/src/main/resources/i18n/messages.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-maintenance/src/main/resources/i18n/messages_en_US.properties
New file
@@ -0,0 +1,2 @@
# English (US)
welcome.message=Welcome to our application!
xp-service/xp-maintenance/src/main/resources/i18n/messages_zh_CN.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-map/pom.xml
@@ -65,11 +65,6 @@
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
xp-service/xp-map/src/main/java/com/xiaopeng/map/config/MessageLocalConfig.java
New file
@@ -0,0 +1,47 @@
package com.xiaopeng.map.config;
import org.springframework.boot.autoconfigure.context.MessageSourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import java.time.Duration;
/**
 * 国际化配置
 */
@Configuration
public class MessageLocalConfig {
    @Bean
    public MessageSource messageSource(MessageSourceProperties properties) {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        if (StringUtils.hasText(properties.getBasename())) {
            messageSource.setBasenames(StringUtils
                    .commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
        }
        if (properties.getEncoding() != null) {
            messageSource.setDefaultEncoding(properties.getEncoding().name());
        }
        messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
        Duration cacheDuration = properties.getCacheDuration();
        if (cacheDuration != null) {
            messageSource.setCacheMillis(cacheDuration.toMillis());
        }
        messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
        messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
        return messageSource;
    }
    @Bean//注册国际化组件
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
}
xp-service/xp-map/src/main/java/com/xiaopeng/map/config/MyLocaleResolver.java
New file
@@ -0,0 +1,82 @@
package com.xiaopeng.map.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;
public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        //1=中文,2=英文,3=印尼文
        //1=Chinese, 2=English, 3=Indonesian.
        String language = getQueryParams(request, "language");
        Locale locale = null;
        if (StringUtils.isEmpty(language)) {
            locale = Locale.getDefault();
        }
        //如果请求不为空
        //If the request is not empty.
        if (language.equals("1")) {
            locale = new Locale("zh", "CN");
        } else if (language.equals("2")) {
            locale = new Locale("en", "US");
        } else {
            locale = new Locale("in", "ID");
        }
        return locale;
    }
    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
    }
    public String getQueryParams(HttpServletRequest request, String key) {
        try {
            String method = request.getMethod();
            if("POST".equals(method)){
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
                StringBuffer sb = new StringBuffer();
                ServletInputStream inputStream = request.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                String s;
                while ((s = bufferedReader.readLine()) != null){
                    sb.append(s);
                }
                bufferedReader.close();
                inputStream.close();
                JSONObject jsonObject = JSON.parseObject(sb.toString());
                return jsonObject.getString(key);
            }else{
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
xp-service/xp-map/src/main/resources/i18n/messages.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-map/src/main/resources/i18n/messages_en_US.properties
New file
@@ -0,0 +1,2 @@
# English (US)
welcome.message=Welcome to our application!
xp-service/xp-map/src/main/resources/i18n/messages_zh_CN.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-operation/pom.xml
@@ -75,11 +75,6 @@
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
xp-service/xp-operation/src/main/java/com/xiaopeng/operation/config/MessageLocalConfig.java
New file
@@ -0,0 +1,47 @@
package com.xiaopeng.operation.config;
import org.springframework.boot.autoconfigure.context.MessageSourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import java.time.Duration;
/**
 * 国际化配置
 */
@Configuration
public class MessageLocalConfig {
    @Bean
    public MessageSource messageSource(MessageSourceProperties properties) {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        if (StringUtils.hasText(properties.getBasename())) {
            messageSource.setBasenames(StringUtils
                    .commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
        }
        if (properties.getEncoding() != null) {
            messageSource.setDefaultEncoding(properties.getEncoding().name());
        }
        messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
        Duration cacheDuration = properties.getCacheDuration();
        if (cacheDuration != null) {
            messageSource.setCacheMillis(cacheDuration.toMillis());
        }
        messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
        messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
        return messageSource;
    }
    @Bean//注册国际化组件
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
}
xp-service/xp-operation/src/main/java/com/xiaopeng/operation/config/MyLocaleResolver.java
New file
@@ -0,0 +1,82 @@
package com.xiaopeng.operation.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;
public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        //1=中文,2=英文,3=印尼文
        //1=Chinese, 2=English, 3=Indonesian.
        String language = getQueryParams(request, "language");
        Locale locale = null;
        if (StringUtils.isEmpty(language)) {
            locale = Locale.getDefault();
        }
        //如果请求不为空
        //If the request is not empty.
        if (language.equals("1")) {
            locale = new Locale("zh", "CN");
        } else if (language.equals("2")) {
            locale = new Locale("en", "US");
        } else {
            locale = new Locale("in", "ID");
        }
        return locale;
    }
    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
    }
    public String getQueryParams(HttpServletRequest request, String key) {
        try {
            String method = request.getMethod();
            if("POST".equals(method)){
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
                StringBuffer sb = new StringBuffer();
                ServletInputStream inputStream = request.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                String s;
                while ((s = bufferedReader.readLine()) != null){
                    sb.append(s);
                }
                bufferedReader.close();
                inputStream.close();
                JSONObject jsonObject = JSON.parseObject(sb.toString());
                return jsonObject.getString(key);
            }else{
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
xp-service/xp-operation/src/main/resources/i18n/messages.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-operation/src/main/resources/i18n/messages_en_US.properties
New file
@@ -0,0 +1,2 @@
# English (US)
welcome.message=Welcome to our application!
xp-service/xp-operation/src/main/resources/i18n/messages_zh_CN.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-order/pom.xml
@@ -65,11 +65,6 @@
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
xp-service/xp-order/src/main/java/com/xiaopeng/order/config/MessageLocalConfig.java
New file
@@ -0,0 +1,47 @@
package com.xiaopeng.order.config;
import org.springframework.boot.autoconfigure.context.MessageSourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import java.time.Duration;
/**
 * 国际化配置
 */
@Configuration
public class MessageLocalConfig {
    @Bean
    public MessageSource messageSource(MessageSourceProperties properties) {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        if (StringUtils.hasText(properties.getBasename())) {
            messageSource.setBasenames(StringUtils
                    .commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
        }
        if (properties.getEncoding() != null) {
            messageSource.setDefaultEncoding(properties.getEncoding().name());
        }
        messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
        Duration cacheDuration = properties.getCacheDuration();
        if (cacheDuration != null) {
            messageSource.setCacheMillis(cacheDuration.toMillis());
        }
        messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
        messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
        return messageSource;
    }
    @Bean//注册国际化组件
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
}
xp-service/xp-order/src/main/java/com/xiaopeng/order/config/MyLocaleResolver.java
New file
@@ -0,0 +1,82 @@
package com.xiaopeng.order.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;
public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        //1=中文,2=英文,3=印尼文
        //1=Chinese, 2=English, 3=Indonesian.
        String language = getQueryParams(request, "language");
        Locale locale = null;
        if (StringUtils.isEmpty(language)) {
            locale = Locale.getDefault();
        }
        //如果请求不为空
        //If the request is not empty.
        if (language.equals("1")) {
            locale = new Locale("zh", "CN");
        } else if (language.equals("2")) {
            locale = new Locale("en", "US");
        } else {
            locale = new Locale("in", "ID");
        }
        return locale;
    }
    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
    }
    public String getQueryParams(HttpServletRequest request, String key) {
        try {
            String method = request.getMethod();
            if("POST".equals(method)){
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
                StringBuffer sb = new StringBuffer();
                ServletInputStream inputStream = request.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                String s;
                while ((s = bufferedReader.readLine()) != null){
                    sb.append(s);
                }
                bufferedReader.close();
                inputStream.close();
                JSONObject jsonObject = JSON.parseObject(sb.toString());
                return jsonObject.getString(key);
            }else{
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
xp-service/xp-order/src/main/resources/i18n/messages.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-order/src/main/resources/i18n/messages_en_US.properties
New file
@@ -0,0 +1,2 @@
# English (US)
welcome.message=Welcome to our application!
xp-service/xp-order/src/main/resources/i18n/messages_zh_CN.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-payment/pom.xml
@@ -65,11 +65,6 @@
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
xp-service/xp-payment/src/main/java/com/xiaopeng/payment/config/MessageLocalConfig.java
New file
@@ -0,0 +1,47 @@
package com.xiaopeng.payment.config;
import org.springframework.boot.autoconfigure.context.MessageSourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import java.time.Duration;
/**
 * 国际化配置
 */
@Configuration
public class MessageLocalConfig {
    @Bean
    public MessageSource messageSource(MessageSourceProperties properties) {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        if (StringUtils.hasText(properties.getBasename())) {
            messageSource.setBasenames(StringUtils
                    .commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
        }
        if (properties.getEncoding() != null) {
            messageSource.setDefaultEncoding(properties.getEncoding().name());
        }
        messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
        Duration cacheDuration = properties.getCacheDuration();
        if (cacheDuration != null) {
            messageSource.setCacheMillis(cacheDuration.toMillis());
        }
        messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
        messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
        return messageSource;
    }
    @Bean//注册国际化组件
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
}
xp-service/xp-payment/src/main/java/com/xiaopeng/payment/config/MyLocaleResolver.java
New file
@@ -0,0 +1,82 @@
package com.xiaopeng.payment.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;
public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        //1=中文,2=英文,3=印尼文
        //1=Chinese, 2=English, 3=Indonesian.
        String language = getQueryParams(request, "language");
        Locale locale = null;
        if (StringUtils.isEmpty(language)) {
            locale = Locale.getDefault();
        }
        //如果请求不为空
        //If the request is not empty.
        if (language.equals("1")) {
            locale = new Locale("zh", "CN");
        } else if (language.equals("2")) {
            locale = new Locale("en", "US");
        } else {
            locale = new Locale("in", "ID");
        }
        return locale;
    }
    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
    }
    public String getQueryParams(HttpServletRequest request, String key) {
        try {
            String method = request.getMethod();
            if("POST".equals(method)){
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
                StringBuffer sb = new StringBuffer();
                ServletInputStream inputStream = request.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                String s;
                while ((s = bufferedReader.readLine()) != null){
                    sb.append(s);
                }
                bufferedReader.close();
                inputStream.close();
                JSONObject jsonObject = JSON.parseObject(sb.toString());
                return jsonObject.getString(key);
            }else{
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
xp-service/xp-payment/src/main/resources/i18n/messages.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-payment/src/main/resources/i18n/messages_en_US.properties
New file
@@ -0,0 +1,2 @@
# English (US)
welcome.message=Welcome to our application!
xp-service/xp-payment/src/main/resources/i18n/messages_zh_CN.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-pushMessage/pom.xml
@@ -65,11 +65,6 @@
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
xp-service/xp-pushMessage/src/main/java/com/xiaopeng/pushMessage/config/MessageLocalConfig.java
New file
@@ -0,0 +1,47 @@
package com.xiaopeng.pushMessage.config;
import org.springframework.boot.autoconfigure.context.MessageSourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import java.time.Duration;
/**
 * 国际化配置
 */
@Configuration
public class MessageLocalConfig {
    @Bean
    public MessageSource messageSource(MessageSourceProperties properties) {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        if (StringUtils.hasText(properties.getBasename())) {
            messageSource.setBasenames(StringUtils
                    .commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
        }
        if (properties.getEncoding() != null) {
            messageSource.setDefaultEncoding(properties.getEncoding().name());
        }
        messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
        Duration cacheDuration = properties.getCacheDuration();
        if (cacheDuration != null) {
            messageSource.setCacheMillis(cacheDuration.toMillis());
        }
        messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
        messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
        return messageSource;
    }
    @Bean//注册国际化组件
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
}
xp-service/xp-pushMessage/src/main/java/com/xiaopeng/pushMessage/config/MyLocaleResolver.java
New file
@@ -0,0 +1,82 @@
package com.xiaopeng.pushMessage.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;
public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        //1=中文,2=英文,3=印尼文
        //1=Chinese, 2=English, 3=Indonesian.
        String language = getQueryParams(request, "language");
        Locale locale = null;
        if (StringUtils.isEmpty(language)) {
            locale = Locale.getDefault();
        }
        //如果请求不为空
        //If the request is not empty.
        if (language.equals("1")) {
            locale = new Locale("zh", "CN");
        } else if (language.equals("2")) {
            locale = new Locale("en", "US");
        } else {
            locale = new Locale("in", "ID");
        }
        return locale;
    }
    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
    }
    public String getQueryParams(HttpServletRequest request, String key) {
        try {
            String method = request.getMethod();
            if("POST".equals(method)){
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
                StringBuffer sb = new StringBuffer();
                ServletInputStream inputStream = request.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                String s;
                while ((s = bufferedReader.readLine()) != null){
                    sb.append(s);
                }
                bufferedReader.close();
                inputStream.close();
                JSONObject jsonObject = JSON.parseObject(sb.toString());
                return jsonObject.getString(key);
            }else{
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
xp-service/xp-pushMessage/src/main/resources/i18n/messages.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-pushMessage/src/main/resources/i18n/messages_en_US.properties
New file
@@ -0,0 +1,2 @@
# English (US)
welcome.message=Welcome to our application!
xp-service/xp-pushMessage/src/main/resources/i18n/messages_zh_CN.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-remoteDriving/pom.xml
@@ -65,11 +65,6 @@
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
xp-service/xp-remoteDriving/src/main/java/com/xiaopeng/remoteDriving/config/MessageLocalConfig.java
New file
@@ -0,0 +1,47 @@
package com.xiaopeng.remoteDriving.config;
import org.springframework.boot.autoconfigure.context.MessageSourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import java.time.Duration;
/**
 * 国际化配置
 */
@Configuration
public class MessageLocalConfig {
    @Bean
    public MessageSource messageSource(MessageSourceProperties properties) {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        if (StringUtils.hasText(properties.getBasename())) {
            messageSource.setBasenames(StringUtils
                    .commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
        }
        if (properties.getEncoding() != null) {
            messageSource.setDefaultEncoding(properties.getEncoding().name());
        }
        messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
        Duration cacheDuration = properties.getCacheDuration();
        if (cacheDuration != null) {
            messageSource.setCacheMillis(cacheDuration.toMillis());
        }
        messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
        messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
        return messageSource;
    }
    @Bean//注册国际化组件
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
}
xp-service/xp-remoteDriving/src/main/java/com/xiaopeng/remoteDriving/config/MyLocaleResolver.java
New file
@@ -0,0 +1,82 @@
package com.xiaopeng.remoteDriving.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;
public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        //1=中文,2=英文,3=印尼文
        //1=Chinese, 2=English, 3=Indonesian.
        String language = getQueryParams(request, "language");
        Locale locale = null;
        if (StringUtils.isEmpty(language)) {
            locale = Locale.getDefault();
        }
        //如果请求不为空
        //If the request is not empty.
        if (language.equals("1")) {
            locale = new Locale("zh", "CN");
        } else if (language.equals("2")) {
            locale = new Locale("en", "US");
        } else {
            locale = new Locale("in", "ID");
        }
        return locale;
    }
    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
    }
    public String getQueryParams(HttpServletRequest request, String key) {
        try {
            String method = request.getMethod();
            if("POST".equals(method)){
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
                StringBuffer sb = new StringBuffer();
                ServletInputStream inputStream = request.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                String s;
                while ((s = bufferedReader.readLine()) != null){
                    sb.append(s);
                }
                bufferedReader.close();
                inputStream.close();
                JSONObject jsonObject = JSON.parseObject(sb.toString());
                return jsonObject.getString(key);
            }else{
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
xp-service/xp-remoteDriving/src/main/resources/i18n/messages.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-remoteDriving/src/main/resources/i18n/messages_en_US.properties
New file
@@ -0,0 +1,2 @@
# English (US)
welcome.message=Welcome to our application!
xp-service/xp-remoteDriving/src/main/resources/i18n/messages_zh_CN.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-vehicleConvoy/pom.xml
@@ -65,11 +65,6 @@
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.47</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
xp-service/xp-vehicleConvoy/src/main/java/com/xiaopeng/vehicleConvoy/config/MessageLocalConfig.java
New file
@@ -0,0 +1,47 @@
package com.xiaopeng.vehicleConvoy.config;
import org.springframework.boot.autoconfigure.context.MessageSourceProperties;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import java.time.Duration;
/**
 * 国际化配置
 */
@Configuration
public class MessageLocalConfig {
    @Bean
    public MessageSource messageSource(MessageSourceProperties properties) {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        if (StringUtils.hasText(properties.getBasename())) {
            messageSource.setBasenames(StringUtils
                    .commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
        }
        if (properties.getEncoding() != null) {
            messageSource.setDefaultEncoding(properties.getEncoding().name());
        }
        messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
        Duration cacheDuration = properties.getCacheDuration();
        if (cacheDuration != null) {
            messageSource.setCacheMillis(cacheDuration.toMillis());
        }
        messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
        messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
        return messageSource;
    }
    @Bean//注册国际化组件
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
}
xp-service/xp-vehicleConvoy/src/main/java/com/xiaopeng/vehicleConvoy/config/MyLocaleResolver.java
New file
@@ -0,0 +1,82 @@
package com.xiaopeng.vehicleConvoy.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;
public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        //1=中文,2=英文,3=印尼文
        //1=Chinese, 2=English, 3=Indonesian.
        String language = getQueryParams(request, "language");
        Locale locale = null;
        if (StringUtils.isEmpty(language)) {
            locale = Locale.getDefault();
        }
        //如果请求不为空
        //If the request is not empty.
        if (language.equals("1")) {
            locale = new Locale("zh", "CN");
        } else if (language.equals("2")) {
            locale = new Locale("en", "US");
        } else {
            locale = new Locale("in", "ID");
        }
        return locale;
    }
    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {
    }
    public String getQueryParams(HttpServletRequest request, String key) {
        try {
            String method = request.getMethod();
            if("POST".equals(method)){
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
                StringBuffer sb = new StringBuffer();
                ServletInputStream inputStream = request.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
                String s;
                while ((s = bufferedReader.readLine()) != null){
                    sb.append(s);
                }
                bufferedReader.close();
                inputStream.close();
                JSONObject jsonObject = JSON.parseObject(sb.toString());
                return jsonObject.getString(key);
            }else{
                String parameter = request.getParameter(key);
                if(!StringUtils.isEmpty(parameter)){
                    return parameter;
                }
                Object attribute = request.getAttribute(key);
                if(null != attribute){
                    return attribute.toString();
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
xp-service/xp-vehicleConvoy/src/main/java/com/xiaopeng/vehicleConvoy/controller/VehiclesController.java
New file
@@ -0,0 +1,33 @@
package com.xiaopeng.vehicleConvoy.controller;
import com.alibaba.fastjson2.JSON;
import com.xiaopeng.api.vo.vehicleConvoy.VehiclesCommandCallbackVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * 车辆控制控制层
 */
@Slf4j
@RestController
@RequestMapping("")
public class VehiclesController {
    /**
     * 车辆控制消息回调通知
     * 开关门、设定温度
     * @param callbackVo
     */
    @PostMapping("/base/vehicles/command/callback")
    public void vehiclesCommandCallback(@RequestBody VehiclesCommandCallbackVo callbackVo){
        log.info("车辆控制消息回调:{}", JSON.toJSONString(callbackVo));
        if(null != callbackVo.getMsg_ref()){
            //继续执行业务逻辑上的代码
        }
    }
}
xp-service/xp-vehicleConvoy/src/main/java/com/xiaopeng/vehicleConvoy/util/HMACSHA1.java
New file
@@ -0,0 +1,35 @@
package com.xiaopeng.vehicleConvoy.util;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
public class HMACSHA1 {
    private static final String MAC_NAME = "HmacSHA1";
    private static final String ENCODING = "UTF-8";
    /**
     * 使用 HMAC-SHA1 签名方法对对encryptText进行签名
     *
     * @param encryptText 被签名的字符串
     * @param encryptKey  密钥
     * @return
     * @throws Exception
     */
    public static byte[] HmacSHA1Encrypt(String encryptText, String encryptKey) throws Exception {
        byte[] data = encryptKey.getBytes(ENCODING);
        // 根据给定的字节数组构造一个密钥,第二参数指定一个密钥算法的名称
        Mac mac = Mac.getInstance(MAC_NAME);
        SecretKey secretKey = new SecretKeySpec(data, MAC_NAME);
        // 生成一个指定 Mac 算法 的 Mac 对象
        // 用给定密钥初始化 Mac 对象
        mac.init(secretKey);
        byte[] text = encryptText.getBytes(ENCODING);
        // 完成 Mac 操作
        return mac.doFinal(text);
    }
}
xp-service/xp-vehicleConvoy/src/main/java/com/xiaopeng/vehicleConvoy/util/VehicleControlUtil.java
New file
@@ -0,0 +1,146 @@
package com.xiaopeng.vehicleConvoy.util;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.xiaopeng.api.vo.vehicleConvoy.VehicleTemperatureVo;
import com.xiaopeng.api.vo.vehicleConvoy.VehiclesCommandVo;
import com.xiaopeng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
 * 车辆控制工具类
 */
@Slf4j
@Component
public class VehicleControlUtil {
    // 车辆控制接口地址
    @Value("${vehicle.control.url}")
    private String url;
    // 车辆控制接口appid
    @Value("${vehicle.control.appId}")
    private String appid;
    // 车辆控制接口appSecret
    @Value("${vehicle.control.appSecret}")
    private String appSecret;
    /**
     * 查询车辆内温度
     * @param uid   用户id
     * @param vin   车辆vin
     * @return
     */
    public VehicleTemperatureVo queryVehicleTemperature(String uid, String vin){
        String path = url + "/api/v1/vehicles/state";
        log.info("查询车内温度 请求地址:{}", path);
        String nonce = System.currentTimeMillis() + "";
        HttpRequest get = HttpUtil.createGet(path);
        get.header("uid", uid);
        log.info("查询车内温度 请求头:{}", JSON.toJSONString(get.headers()));
        get.form("appId", appid);
        get.form("nonce", nonce);
        get.form("openId", "RobotT");
        get.form("sign", sign("", nonce));
        get.form("vin", vin);
        get.form("stateList", Arrays.asList("hvacInnerTemp"));
        log.info("查询车内温度 请求参数:{}", JSON.toJSONString(get.form()));
        HttpResponse execute = get.execute();
        if(!execute.isOk()){
            log.error("查询车内温度失败:{}", execute.body());
            throw new RuntimeException("查询车内温度失败:" + execute.body());
        }
        JSONObject jsonObject = JSON.parseObject(execute.body());
        Integer code = jsonObject.getInteger("code");
        if(200 != code){
            log.error("查询车内温度失败:{}", jsonObject.getString("msg"));
            throw new RuntimeException("查询车内温度失败:" + jsonObject.getString("msg"));
        }
        return jsonObject.getObject("data", VehicleTemperatureVo.class);
    }
    /**
     * 车辆控制操作
     * @param commandVo
     * @return  msgId 消息id
     */
    public String vehiclesCommand(VehiclesCommandVo commandVo){
        String path = url + "/api/v1/vehicles/command";
        log.info("车辆控制 请求地址:{}", path);
        String nonce = System.currentTimeMillis() + "";
        HttpRequest post = HttpUtil.createPost(path);
        post.header("uid", String.valueOf(commandVo.getUid()));
        log.info("车辆控制 请求头:{}", JSON.toJSONString(post.headers()));
        post.form("appId", appid);
        post.form("nonce", nonce);
        post.form("openId", "RobotT");
        post.form("sign", sign(JSON.toJSONString(commandVo), nonce));
        post.body(JSON.toJSONString(commandVo));
        log.info("车辆控制 请求参数:{}", JSON.toJSONString(post.form()));
        HttpResponse execute = post.execute();
        if(!execute.isOk()){
            log.error("车辆控制失败:{}", execute.body());
            throw new RuntimeException("车辆控制失败:" + execute.body());
        }
        JSONObject jsonObject = JSON.parseObject(execute.body());
        Integer code = jsonObject.getInteger("code");
        if(200 != code){
            log.error("车辆控制失败:{}", jsonObject.getString("msg"));
            throw new RuntimeException("车辆控制失败:" + jsonObject.getString("msg"));
        }
        return jsonObject.getJSONObject("data").getString("msgId");
    }
    /**
     * 参数签名
     * @param nonce 请求时间戳
     * @return
     */
    private String sign(String body, String nonce){
        Map<String, String> map = new HashMap<>();
        map.put("openId", appid);
        map.put("body", body);
        map.put("nonce", nonce);
        //将map的key进行自然排序再以key+value拼接中间无分隔符
        StringBuilder stringBuilder = new StringBuilder();
        map.keySet().stream().sorted(String::compareTo).forEach(key -> {
            String v = map.get(key);
            if(StringUtils.isNotEmpty(v)){
                stringBuilder.append(key).append(v);
            }
        });
        String stringA = stringBuilder.toString();
        String stringB = appid + stringA + appSecret;
        log.info("车控接口待签名串:{}", stringB);
        try {
            byte[] signByte = HMACSHA1.HmacSHA1Encrypt(stringB, appSecret);
            String localSign = Base64.encodeBase64String(signByte);
            log.info("车控接口已签名串:{}", stringB);
            return localSign;
        } catch (Exception e) {
            e.printStackTrace();
            log.error("车控接口签名失败", e);
            throw new RuntimeException("车控接口签名失败");
        }
    }
}
xp-service/xp-vehicleConvoy/src/main/resources/i18n/messages.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!
xp-service/xp-vehicleConvoy/src/main/resources/i18n/messages_en_US.properties
New file
@@ -0,0 +1,2 @@
# English (US)
welcome.message=Welcome to our application!
xp-service/xp-vehicleConvoy/src/main/resources/i18n/messages_zh_CN.properties
New file
@@ -0,0 +1,2 @@
# 中文
welcome.message=欢迎来到我们的应用程序!