package com.foreverwin.mesnac.listener.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.common.dto.UsrDto;
import com.foreverwin.mesnac.common.service.UserService;
import com.foreverwin.mesnac.listener.mapper.UsrMapper;
import com.foreverwin.mesnac.listener.model.SysUser;
import com.foreverwin.mesnac.listener.model.Usr;
import com.foreverwin.mesnac.listener.service.UsrService;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sungang
 * @since 2020-10-16
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class UsrServiceImpl extends ServiceImpl<UsrMapper, Usr> implements UsrService,UserService {


    @Autowired
    private UsrMapper usrMapper;

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

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

    @Override
    public List<SysUser> selectListForPd(String site) {
        return usrMapper.selectListForPd(site);
    }

    @Override
    public List<UsrDto> findList(String user) {
        String site = CommonMethods.getSite();
        return usrMapper.findList(site,user);
    }

    @Override
    public IPage findPage(IPage page, String user) {
        String site = CommonMethods.getSite();
        return usrMapper.findPage(page,site,user);
    }

  /*  @Override
    public List<Usr> userList(Usr user) {
        String site = CommonMethods.getSite();
        String user1 = CommonMethods.getUser();
        user.setSite(site);
        return usrMapper.userList(user);
    }*/

}