|
@@ -6,9 +6,11 @@ import com.backendsys.modules.cms.siteinfo.entity.SiteInfo;
|
|
import com.backendsys.modules.cms.siteinfo.service.SiteInfoService;
|
|
import com.backendsys.modules.cms.siteinfo.service.SiteInfoService;
|
|
import com.backendsys.modules.common.config.security.utils.HttpRequestUtil;
|
|
import com.backendsys.modules.common.config.security.utils.HttpRequestUtil;
|
|
import com.backendsys.modules.common.utils.CookieUtil;
|
|
import com.backendsys.modules.common.utils.CookieUtil;
|
|
|
|
+import com.backendsys.utils.LanguageUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -16,6 +18,9 @@ import java.util.Map;
|
|
@Service
|
|
@Service
|
|
public class SiteInfoServiceImpl implements SiteInfoService {
|
|
public class SiteInfoServiceImpl implements SiteInfoService {
|
|
|
|
|
|
|
|
+ @Value("${DEFAULT_LANGUAGE}")
|
|
|
|
+ private String DEFAULT_LANGUAGE;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private HttpRequestUtil httpRequestUtil;
|
|
private HttpRequestUtil httpRequestUtil;
|
|
|
|
|
|
@@ -29,8 +34,8 @@ public class SiteInfoServiceImpl implements SiteInfoService {
|
|
public SiteInfo selectSiteInfo() {
|
|
public SiteInfo selectSiteInfo() {
|
|
|
|
|
|
HttpServletRequest request = httpRequestUtil.getRequest();
|
|
HttpServletRequest request = httpRequestUtil.getRequest();
|
|
- String lang = CookieUtil.getCookie("lang", request);
|
|
|
|
- if (StrUtil.isEmpty(lang)) lang = "zh";
|
|
|
|
|
|
+ String lang = request.getHeader("lang");
|
|
|
|
+ if (StrUtil.isEmpty(lang)) lang = DEFAULT_LANGUAGE;
|
|
|
|
|
|
LambdaQueryWrapper<SiteInfo> wrapper = new LambdaQueryWrapper();
|
|
LambdaQueryWrapper<SiteInfo> wrapper = new LambdaQueryWrapper();
|
|
wrapper.eq(SiteInfo::getLanguage, lang);
|
|
wrapper.eq(SiteInfo::getLanguage, lang);
|
|
@@ -42,7 +47,14 @@ public class SiteInfoServiceImpl implements SiteInfoService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> updateSiteInfo(SiteInfo siteInfo) {
|
|
public Map<String, Object> updateSiteInfo(SiteInfo siteInfo) {
|
|
- siteInfoDao.updateById(siteInfo);
|
|
|
|
|
|
+
|
|
|
|
+ HttpServletRequest request = httpRequestUtil.getRequest();
|
|
|
|
+ String lang = request.getHeader("lang");
|
|
|
|
+ if (StrUtil.isEmpty(lang)) lang = DEFAULT_LANGUAGE;
|
|
|
|
+
|
|
|
|
+ LambdaQueryWrapper<SiteInfo> wrapper = new LambdaQueryWrapper();
|
|
|
|
+ wrapper.eq(SiteInfo::getLanguage, lang);
|
|
|
|
+ siteInfoDao.update(siteInfo, wrapper);
|
|
return Map.of("id", siteInfo.getId());
|
|
return Map.of("id", siteInfo.getId());
|
|
}
|
|
}
|
|
|
|
|