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

import org.springframework.stereotype.Service;
import org.apache.commons.lang.StringUtils;
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.IndustryDao;
import io.renren.modules.admin.entity.IndustryEntity;
import io.renren.modules.admin.service.IndustryService;


@Service("industryService")
public class IndustryServiceImpl extends ServiceImpl<IndustryDao, IndustryEntity> implements IndustryService {

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

        return new PageUtils(page);
    }

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

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

    @Override
    public int selectIsName(String name) {
        return baseMapper.selectIsName(name);
    }


}