package org.jk.system.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jk.common.mybatis.core.mapper.BaseMapperPlus;
import org.jk.system.domain.SysDictData;
import org.jk.system.domain.vo.SysDictDataVo;

import java.util.List;

/**
 * 字典表 数据层
 *
 * @author jk
 */
public interface SysDictDataMapper extends BaseMapperPlus<SysDictData, SysDictDataVo> {

    /**
     * 根据字典类型查询字典数据列表
     *
     * @param dictType 字典类型
     * @return 符合条件的字典数据列表
     */
    default List<SysDictDataVo> selectDictDataByType(String dictType) {
        return selectVoList(
            new LambdaQueryWrapper<SysDictData>()
                .eq(SysDictData::getDictType, dictType)
                .orderByAsc(SysDictData::getDictSort));
    }

    @InterceptorIgnore(tenantLine = "true", dataPermission = "false")
    @Select("<script>" +
        "select * from sys_dict_data where dict_type = #{dictType} and tenant_id = '000000'" +
        "</script>")
    List<SysDictDataVo> queryList(@Param("dictType")String dictType);
}
