@ -8,6 +8,8 @@
package com.epmet.service.impl ;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.TypeReference ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
@ -16,6 +18,8 @@ import com.epmet.commons.tools.dto.result.DictListResultDTO;
import com.epmet.commons.tools.dto.result.DictTreeResultDTO ;
import com.epmet.commons.tools.dto.result.OptionResultDTO ;
import com.epmet.commons.tools.page.PageData ;
import com.epmet.commons.tools.redis.RedisKeys ;
import com.epmet.commons.tools.redis.RedisUtils ;
import com.epmet.commons.tools.utils.ConvertUtils ;
import com.epmet.commons.tools.utils.TreeUtils ;
import com.epmet.dao.SysDictDataDao ;
@ -23,6 +27,7 @@ import com.epmet.dto.SysDictDataDTO;
import com.epmet.entity.SysDictDataEntity ;
import com.epmet.service.SysDictDataService ;
import org.apache.commons.lang3.StringUtils ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
@ -39,6 +44,9 @@ import java.util.stream.Collectors;
@Service
public class SysDictDataServiceImpl extends BaseServiceImpl < SysDictDataDao , SysDictDataEntity > implements SysDictDataService {
@Autowired
private RedisUtils redisUtils ;
@Override
public PageData < SysDictDataDTO > page ( Map < String , Object > params ) {
IPage < SysDictDataEntity > page = baseDao . selectPage (
@ -102,17 +110,26 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataDao, SysD
* /
@Override
public List < OptionResultDTO > getNineSmallPlacesOption ( ) {
String cacheKey = RedisKeys . getNineSmallPlacesOptions ( ) ;
List < OptionResultDTO > cachedDatas = JSON . parseObject ( redisUtils . getString ( cacheKey ) , new TypeReference < List < OptionResultDTO > > ( ) { } ) ;
if ( cachedDatas ! = null ) {
return cachedDatas ;
}
LambdaQueryWrapper < SysDictDataEntity > wrapper = new LambdaQueryWrapper < > ( ) ;
wrapper . eq ( SysDictDataEntity : : getDictTypeId , 1000000000000000001L ) ;
wrapper . orderByAsc ( SysDictDataEntity : : getSort ) ;
List < SysDictDataEntity > list = baseDao . selectList ( wrapper ) ;
return list . stream ( ) . map ( item - > {
List < OptionResultDTO > datas = list . stream ( ) . map ( item - > {
OptionResultDTO dto = new OptionResultDTO ( ) ;
dto . setValue ( item . getDictValue ( ) ) ;
dto . setLabel ( item . getDictLabel ( ) ) ;
dto . setSysDictDataId ( item . getId ( ) . toString ( ) ) ;
return dto ;
} ) . collect ( Collectors . toList ( ) ) ;
redisUtils . setString ( cacheKey , JSON . toJSONString ( datas ) , 10 ) ;
return datas ;
}
/ * *
@ -125,16 +142,25 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataDao, SysD
* /
@Override
public List < OptionResultDTO > getEducationOption ( ) {
String cacheKey = RedisKeys . getEducationOptions ( ) ;
List < OptionResultDTO > cachedDatas = JSON . parseObject ( redisUtils . getString ( cacheKey ) , new TypeReference < List < OptionResultDTO > > ( ) { } ) ;
if ( cachedDatas ! = null ) {
return cachedDatas ;
}
LambdaQueryWrapper < SysDictDataEntity > wrapper = new LambdaQueryWrapper < > ( ) ;
wrapper . eq ( SysDictDataEntity : : getDictTypeId , 1000000000000000002L ) ;
wrapper . orderByAsc ( SysDictDataEntity : : getSort ) ;
List < SysDictDataEntity > list = baseDao . selectList ( wrapper ) ;
return list . stream ( ) . map ( item - > {
List < OptionResultDTO > datas = list . stream ( ) . map ( item - > {
OptionResultDTO dto = new OptionResultDTO ( ) ;
dto . setValue ( item . getDictValue ( ) ) ;
dto . setLabel ( item . getDictLabel ( ) ) ;
return dto ;
} ) . collect ( Collectors . toList ( ) ) ;
redisUtils . setString ( cacheKey , JSON . toJSONString ( datas ) , 10 ) ;
return datas ;
}
/ * *
@ -147,16 +173,25 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataDao, SysD
* /
@Override
public List < OptionResultDTO > getNationOption ( ) {
String cacheKey = RedisKeys . getEducationOptions ( ) ;
List < OptionResultDTO > cachedDatas = JSON . parseObject ( redisUtils . getString ( cacheKey ) , new TypeReference < List < OptionResultDTO > > ( ) { } ) ;
if ( cachedDatas ! = null ) {
return cachedDatas ;
}
LambdaQueryWrapper < SysDictDataEntity > wrapper = new LambdaQueryWrapper < > ( ) ;
wrapper . eq ( SysDictDataEntity : : getDictTypeId , 1000000000000000003L ) ;
wrapper . orderByAsc ( SysDictDataEntity : : getSort ) ;
List < SysDictDataEntity > list = baseDao . selectList ( wrapper ) ;
return list . stream ( ) . map ( item - > {
List < OptionResultDTO > datas = list . stream ( ) . map ( item - > {
OptionResultDTO dto = new OptionResultDTO ( ) ;
dto . setValue ( item . getDictValue ( ) ) ;
dto . setLabel ( item . getDictLabel ( ) ) ;
return dto ;
} ) . collect ( Collectors . toList ( ) ) ;
redisUtils . setString ( cacheKey , JSON . toJSONString ( datas ) , 10 ) ;
return datas ;
}
/ * *
@ -169,16 +204,25 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataDao, SysD
* /
@Override
public List < OptionResultDTO > getRelationshipOption ( ) {
String cacheKey = RedisKeys . getRelationshipOptions ( ) ;
List < OptionResultDTO > cachedDatas = JSON . parseObject ( redisUtils . getString ( cacheKey ) , new TypeReference < List < OptionResultDTO > > ( ) { } ) ;
if ( cachedDatas ! = null ) {
return cachedDatas ;
}
LambdaQueryWrapper < SysDictDataEntity > wrapper = new LambdaQueryWrapper < > ( ) ;
wrapper . eq ( SysDictDataEntity : : getDictTypeId , 1000000000000000004L ) ;
wrapper . orderByAsc ( SysDictDataEntity : : getSort ) ;
List < SysDictDataEntity > list = baseDao . selectList ( wrapper ) ;
return list . stream ( ) . map ( item - > {
List < OptionResultDTO > datas = list . stream ( ) . map ( item - > {
OptionResultDTO dto = new OptionResultDTO ( ) ;
dto . setValue ( item . getDictValue ( ) ) ;
dto . setLabel ( item . getDictLabel ( ) ) ;
return dto ;
} ) . collect ( Collectors . toList ( ) ) ;
redisUtils . setString ( cacheKey , JSON . toJSONString ( datas ) , 10 ) ;
return datas ;
}
/ * *
@ -191,16 +235,26 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataDao, SysD
* /
@Override
public List < OptionResultDTO > getHouseOption ( ) {
String cacheKey = RedisKeys . getHouseOptions ( ) ;
List < OptionResultDTO > cachedDatas = JSON . parseObject ( redisUtils . getString ( cacheKey ) , new TypeReference < List < OptionResultDTO > > ( ) { } ) ;
if ( cachedDatas ! = null ) {
return cachedDatas ;
}
LambdaQueryWrapper < SysDictDataEntity > wrapper = new LambdaQueryWrapper < > ( ) ;
wrapper . eq ( SysDictDataEntity : : getDictTypeId , 1000000000000000005L ) ;
wrapper . orderByAsc ( SysDictDataEntity : : getSort ) ;
List < SysDictDataEntity > list = baseDao . selectList ( wrapper ) ;
return list . stream ( ) . map ( item - > {
List < OptionResultDTO > datas = list . stream ( ) . map ( item - > {
OptionResultDTO dto = new OptionResultDTO ( ) ;
dto . setValue ( item . getDictValue ( ) ) ;
dto . setLabel ( item . getDictLabel ( ) ) ;
return dto ;
} ) . collect ( Collectors . toList ( ) ) ;
redisUtils . setString ( cacheKey , JSON . toJSONString ( datas ) , 10 ) ;
return datas ;
}
/ * *