From 75d974997efb40b437510809a626c487ec96d1d8 Mon Sep 17 00:00:00 2001 From: sin <2943460818@qq.com> Date: Tue, 16 Apr 2019 19:49:15 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E6=B7=BB=E5=8A=A0=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=A4=9A=E4=B8=AA=20=E5=AD=97=E5=85=B8=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/iocoder/mall/admin/dao/DataDictMapper.java | 13 +++++++++++-- .../mall/admin/service/DataDictServiceImpl.java | 11 +++++++++++ .../src/main/resources/mapper/DataDictMapper.xml | 13 +++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/dao/DataDictMapper.java b/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/dao/DataDictMapper.java index 2468358db..381634363 100644 --- a/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/dao/DataDictMapper.java +++ b/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/dao/DataDictMapper.java @@ -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 selectByEnumValueAndValues( + @Param("enumValue") String enumValue, + @Param("values") Collection values + ); + List selectList(); diff --git a/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/DataDictServiceImpl.java b/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/DataDictServiceImpl.java index 663d7fc75..740b82d83 100644 --- a/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/DataDictServiceImpl.java +++ b/admin/admin-service-impl/src/main/java/cn/iocoder/mall/admin/service/DataDictServiceImpl.java @@ -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> getDataDict(String dictKey, Collection dictValueList) { + Set convertDictValueList = dictValueList.stream().map(o -> String.valueOf(o)).collect(Collectors.toSet()); + List dataDictDOList = dataDictMapper.selectByEnumValueAndValues(dictKey, convertDictValueList); + List dataDictBOList = DataDictConvert.INSTANCE.convert(dataDictDOList); + return CommonResult.success(dataDictBOList); + } } \ No newline at end of file diff --git a/admin/admin-service-impl/src/main/resources/mapper/DataDictMapper.xml b/admin/admin-service-impl/src/main/resources/mapper/DataDictMapper.xml index 5aad44a5d..d272e102b 100644 --- a/admin/admin-service-impl/src/main/resources/mapper/DataDictMapper.xml +++ b/admin/admin-service-impl/src/main/resources/mapper/DataDictMapper.xml @@ -17,6 +17,19 @@ LIMIT 1 + + +