refactor: 默认语言优先级选择优化
Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
parent
2a48763c41
commit
e46a2c2ea8
|
@ -7,23 +7,27 @@ import io.metersphere.commons.constants.OperLogConstants;
|
|||
import io.metersphere.commons.constants.OperLogModule;
|
||||
import io.metersphere.commons.constants.ParamConstants;
|
||||
import io.metersphere.commons.constants.PermissionConstants;
|
||||
import io.metersphere.request.HeaderRequest;
|
||||
import io.metersphere.commons.user.SessionUser;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
import io.metersphere.ldap.domain.LdapInfo;
|
||||
import io.metersphere.log.annotation.MsAuditLog;
|
||||
import io.metersphere.notice.domain.MailInfo;
|
||||
import io.metersphere.request.HeaderRequest;
|
||||
import io.metersphere.service.BaseUserService;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/system")
|
||||
|
@ -145,8 +149,13 @@ public class SystemParameterController {
|
|||
|
||||
@GetMapping(value = "/default-locale")
|
||||
public String defaultLocale() {
|
||||
return defaultLocale;
|
||||
SessionUser user = SessionUtils.getUser();
|
||||
String language = Optional.ofNullable(user)
|
||||
.map(SessionUser::getLanguage)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.orElse(defaultLocale);
|
||||
|
||||
return language.replace("_", "-");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue