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.NwaUser;
import com.foreverwin.mesnac.meapi.mapper.NwaUserMapper;
import com.foreverwin.mesnac.meapi.service.NwaUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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 robert
 * @since 2021-06-16
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class NwaUserServiceImpl extends ServiceImpl<NwaUserMapper, NwaUser> implements NwaUserService {


    @Autowired
    private NwaUserMapper nwaUserMapper;

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

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

    @Override
    public NwaUser findUserByUserName(String user) {
        String site = CommonMethods.getSite();
        return nwaUserMapper.findUserByUserName(site, user);
    }

    @Override
    public List<NwaUser> findAllUser() {
        String site = CommonMethods.getSite();
        return nwaUserMapper.findAllUser(site);
    }


}