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

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

import java.util.List;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Leon.L
 * @since 2021-05-26
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class WorkCenterServiceImpl extends ServiceImpl<WorkCenterMapper, WorkCenter> implements WorkCenterService {


    @Autowired
    private WorkCenterMapper workCenterMapper;

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

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

    @Override
    public IPage workCenterlist(IPage page,String workCenter) {
        String site = CommonMethods.getSite();
        return workCenterMapper.workCenterlist(page,site, workCenter);
    }

    @Override
    public List<WorkCenter> getWorkShopList() {
        String site = CommonMethods.getSite();
        return workCenterMapper.getWorkShopList(site, LocaleContextHolder.getLocale().getLanguage());
    }
}