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.UserGroupMapper;
import com.foreverwin.mesnac.meapi.model.UserGroup;
import com.foreverwin.mesnac.meapi.service.UserGroupService;
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;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author robert
 * @since 2021-06-29
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class UserGroupServiceImpl extends ServiceImpl<UserGroupMapper, UserGroup> implements UserGroupService {


    @Autowired
    private UserGroupMapper userGroupMapper;

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

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

    @Override
    public List<UserGroup> getUserGroupListByUserBo(String userBo) {
        return userGroupMapper.selectUserGroupListByUserBo(userBo);
    }
    @Override
    public Integer getUserGroupByUser(String userBO, String userGroupBO) {
        return userGroupMapper.getUserGroupByUser(userBO,userGroupBO);
    }

    @Override
    public List<UserGroup> findAbnormalUserGroup(Map<String, Object> param) {
        String site = CommonMethods.getSite();
        return userGroupMapper.findAbnormalUserGroup(site,param);
    }

}