- 添加查询多个 字典值
parent
371eba5537
commit
75d974997e
|
@ -4,6 +4,7 @@ import cn.iocoder.mall.admin.dataobject.DataDictDO;
|
|||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
|
@ -11,8 +12,16 @@ public interface DataDictMapper {
|
|||
|
||||
DataDictDO selectById(@Param("id") Integer id);
|
||||
|
||||
DataDictDO selectByEnumValueAndValue(@Param("enumValue") String enumValue,
|
||||
@Param("value") String value);
|
||||
DataDictDO selectByEnumValueAndValue(
|
||||
@Param("enumValue") String enumValue,
|
||||
@Param("value") String value
|
||||
);
|
||||
|
||||
List<DataDictDO> selectByEnumValueAndValues(
|
||||
@Param("enumValue") String enumValue,
|
||||
@Param("values") Collection<String> values
|
||||
);
|
||||
|
||||
|
||||
List<DataDictDO> selectList();
|
||||
|
||||
|
|
|
@ -14,8 +14,11 @@ import cn.iocoder.mall.admin.dataobject.DataDictDO;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据字典 Service
|
||||
|
@ -93,4 +96,12 @@ public class DataDictServiceImpl implements DataDictService {
|
|||
DataDictBO dataDictBO = DataDictConvert.INSTANCE.convert(dataDictDO);
|
||||
return CommonResult.success(dataDictBO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<DataDictBO>> getDataDict(String dictKey, Collection<Object> dictValueList) {
|
||||
Set<String> convertDictValueList = dictValueList.stream().map(o -> String.valueOf(o)).collect(Collectors.toSet());
|
||||
List<DataDictDO> dataDictDOList = dataDictMapper.selectByEnumValueAndValues(dictKey, convertDictValueList);
|
||||
List<DataDictBO> dataDictBOList = DataDictConvert.INSTANCE.convert(dataDictDOList);
|
||||
return CommonResult.success(dataDictBOList);
|
||||
}
|
||||
}
|
|
@ -17,6 +17,19 @@
|
|||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectByEnumValueAndValues" resultType="cn.iocoder.mall.admin.dataobject.DataDictDO">
|
||||
SELECT
|
||||
<include refid="FIELDS"/>
|
||||
FROM data_dict
|
||||
WHERE deleted = 0
|
||||
AND enum_value = #{enumValue}
|
||||
AND `value` IN
|
||||
<foreach collection="values" item="value" separator="," open="(" close=")">
|
||||
#{value}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectById" resultType="DataDictDO">
|
||||
SELECT
|
||||
<include refid="FIELDS"/>
|
||||
|
|
Loading…
Reference in New Issue