package com.zt.plat.module.base.dal.dao.businessdictionarytype;

import java.util.*;

import cn.hutool.core.collection.CollUtil;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 业务字典数据 Mapper
 *
 * @author yangxiaofeng
 */
@Mapper
public interface BusinessDictionaryDataMapper extends BaseMapperX<BusinessDictionaryDataDO> {

    default List<BusinessDictionaryDataDO> selectListByDictionaryTypeId(Long dictionaryTypeId) {
        return selectList(BusinessDictionaryDataDO::getDictionaryTypeId, dictionaryTypeId);
    }

    default int deleteByDictionaryTypeId(Long dictionaryTypeId) {
        return delete(BusinessDictionaryDataDO::getDictionaryTypeId, dictionaryTypeId);
    }

	default int deleteByDictionaryTypeIds(List<Long> dictionaryTypeIds) {
	    return deleteBatch(BusinessDictionaryDataDO::getDictionaryTypeId, dictionaryTypeIds);
	}

    default List<BusinessDictionaryDataDO> selectListByValues(Iterable<String> values) {
        if (values == null || !values.iterator().hasNext()) {
            return CollUtil.newArrayList();
        }
        List<String> valueList = CollUtil.newArrayList(values);
        if (CollUtil.isEmpty(valueList)) {
            return CollUtil.newArrayList();
        }
        return selectList(new LambdaQueryWrapperX<BusinessDictionaryDataDO>()
                .in(BusinessDictionaryDataDO::getValue, valueList));
    }

}
