package io.hmit.modules.sys.service.impl;

import io.hmit.common.service.impl.BaseServiceImpl;
import io.hmit.modules.sys.dao.SysLanguageDao;
import io.hmit.modules.sys.entity.SysLanguageEntity;
import io.hmit.modules.sys.service.SysLanguageService;
import org.springframework.stereotype.Service;

/**
 * 国际化
 *
 * @author zsh 408538940@qq.com
 */
@Service
public class SysLanguageServiceImpl extends BaseServiceImpl<SysLanguageDao, SysLanguageEntity> implements SysLanguageService {

    @Override
    public void saveOrUpdate(String tableName, Long tableId, String fieldName, String fieldValue, String language) {

        SysLanguageEntity entity = new SysLanguageEntity();
        entity.setTableName(tableName);
        entity.setTableId(tableId);
        entity.setFieldName(fieldName);
        entity.setFieldValue(fieldValue);
        entity.setLanguage(language);

        //判断是否有数据
        if (baseDao.getLanguage(entity) == null) {
            baseDao.insert(entity);
        } else {
            baseDao.updateLanguage(entity);
        }
    }

    @Override
    public void deleteLanguage(String tableName, Long tableId) {

        baseDao.deleteLanguage(tableName, tableId);
    }
}