package com.foreverwin.mesnac.meapi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mesnac.meapi.mapper.DataFieldListMapper;
import com.foreverwin.mesnac.meapi.model.DataField;
import com.foreverwin.mesnac.meapi.model.DataFieldList;
import com.foreverwin.mesnac.meapi.service.DataFieldListService;
import com.foreverwin.modular.core.util.FrontPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author robert
 * @since 2021-06-29
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class DataFieldListServiceImpl extends ServiceImpl<DataFieldListMapper, DataFieldList> implements DataFieldListService {


    @Autowired
    private DataFieldListMapper dataFieldListMapper;

    @Override
    public IPage<DataFieldList> selectPage(FrontPage<DataFieldList> frontPage, DataFieldList dataFieldList) {
        QueryWrapper<DataFieldList> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(dataFieldList);
        return super.page(frontPage.getPagePlus(), queryWrapper);
    }

    @Override
    public List<DataFieldList> selectList(DataFieldList dataFieldList) {
        QueryWrapper<DataFieldList> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(dataFieldList);
        return super.list(queryWrapper);
    }

    @Override
    public List<DataField> findDataFieldListById(DataField dataField) {
        String locale = LocaleContextHolder.getLocale().getLanguage();
        return dataFieldListMapper.findDataFieldListById(dataField,locale);
    }

    @Override
    public List<DataFieldList> findDataFieldList(DataField dataField) {
        return dataFieldListMapper.findDataFieldList(dataField);
    }
}