package com.vetti.web.service.impl;

import cn.hutool.core.util.StrUtil;
import com.vetti.common.config.InternationalProperties;
import com.vetti.common.exception.ServiceException;
import com.vetti.common.utils.I18nUtil;
import com.vetti.common.utils.MessageUtils;
import com.vetti.common.utils.spring.SpringUtils;
import com.vetti.web.service.ISystemI18nGainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Properties;

/**
 * 国际化操作 信息 服务实现类
 *
 * @author WangXiangShun
 * @since 2025-08-27
 */
@Slf4j
@Service
public class SystemI18nGainServiceImpl implements ISystemI18nGainService {

    @Autowired
    protected HttpServletRequest request;

    /**
     * 获取国际化数据
     *
     * @return
     */
    @Override
    public Properties getI18nInfo() {
        //获取语言类型
        InternationalProperties iProperties = SpringUtils.getBean(InternationalProperties.class);
        // 获取客户语言环境
        String lang = iProperties.getLang();
        if(StrUtil.isEmpty(lang)){
            throw new ServiceException(MessageUtils.messageCustomize("systemExceptionSystemI18nGainServiceImpl10001"));
        }
        Properties properties = I18nUtil.loadI18nProp(lang);
        return properties;
    }

}
