package io.renren.modules.admin.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.admin.dao.TypesOfAttendersDao;
import io.renren.modules.admin.entity.TypesOfAttendersEntity;
import io.renren.modules.admin.service.TypesOfAttendersService;


@Service("typesOfAttendersService")
public class TypesOfAttendersServiceImpl extends ServiceImpl<TypesOfAttendersDao, TypesOfAttendersEntity> implements TypesOfAttendersService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");
        IPage<TypesOfAttendersEntity> page = this.page(
                new Query<TypesOfAttendersEntity>().getPage(params),
                new QueryWrapper<TypesOfAttendersEntity>()
                        .like(StringUtils.isNotBlank(key),"type",key)
        );

        return new PageUtils(page);
    }

    @Override
    public void delete(Long[] ids) {
        baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    @Override
    public List<TypesOfAttendersEntity> findAllByType(String name) {
        return baseMapper.findAllByType(name);
    }

    @Override
    public int selectIsnameAndId(String name, Long meetingId) {
        return baseMapper.selectIsnameAndId(name, meetingId);
    }

}