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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mesnac.meapi.mapper.RouterSubstepMapper;
import com.foreverwin.mesnac.meapi.model.RouterSubstep;
import com.foreverwin.mesnac.meapi.service.RouterSubstepService;
import com.foreverwin.modular.core.util.CommonMethods;
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-03
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class RouterSubstepServiceImpl extends ServiceImpl<RouterSubstepMapper, RouterSubstep> implements RouterSubstepService {


    @Autowired
    private RouterSubstepMapper routerSubstepMapper;

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

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

    @Override
    public IPage<RouterSubstep> getRouterStepBo(Page<RouterSubstep> page,String globalQuery, String item, String operation) {
        String site = CommonMethods.getSite();
        String language = LocaleContextHolder.getLocale().getLanguage();
        return routerSubstepMapper.findRoutetStepBoByOperation(page,globalQuery,language,item,site,operation);
    }


}