更新
This commit is contained in:
@@ -47,6 +47,8 @@ public interface DictService {
|
||||
*/
|
||||
List<DictDto> queryAll(DictQueryCriteria dict);
|
||||
|
||||
List<Dict> queryAll();
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.nl.modules.system.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.acs.history.ErrorUtil;
|
||||
import org.nl.modules.common.utils.PageUtil;
|
||||
import org.nl.modules.common.utils.QueryHelp;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
@@ -39,9 +40,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
*/
|
||||
* @author Zheng Jie
|
||||
* @date 2019-04-10
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "dict")
|
||||
@@ -53,8 +54,8 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
|
||||
Page<DictDetail> page = dictDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
public Map<String, Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
|
||||
Page<DictDetail> page = dictDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
return PageUtil.toPage(page.map(dictDetailMapper::toDto));
|
||||
}
|
||||
|
||||
@@ -64,17 +65,21 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
dictDetailRepository.save(resources);
|
||||
// 清理缓存
|
||||
delCaches(resources);
|
||||
Dict dict = dictRepository.findById(resources.getDict().getId()).get();
|
||||
ErrorUtil.dictMap.put(dict.getName(), this.getDictByName(dict.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DictDetail resources) {
|
||||
DictDetail dictDetail = dictDetailRepository.findById(resources.getId()).orElseGet(DictDetail::new);
|
||||
ValidationUtil.isNull( dictDetail.getId(),"DictDetail","id",resources.getId());
|
||||
ValidationUtil.isNull(dictDetail.getId(), "DictDetail", "id", resources.getId());
|
||||
resources.setId(dictDetail.getId());
|
||||
dictDetailRepository.save(resources);
|
||||
// 清理缓存
|
||||
delCaches(resources);
|
||||
Dict dict = dictRepository.findById(resources.getDict().getId()).get();
|
||||
ErrorUtil.dictMap.put(dict.getName(), this.getDictByName(dict.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,9 +95,11 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
// 清理缓存
|
||||
delCaches(dictDetail);
|
||||
dictDetailRepository.deleteById(id);
|
||||
Dict dict = dictRepository.findById(id).get();
|
||||
ErrorUtil.dictMap.put(dict.getName(), this.getDictByName(dict.getName()));
|
||||
}
|
||||
|
||||
public void delCaches(DictDetail dictDetail){
|
||||
public void delCaches(DictDetail dictDetail) {
|
||||
Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
|
||||
redisUtils.del("dict::name:" + dict.getName());
|
||||
}
|
||||
|
||||
@@ -60,6 +60,12 @@ public class DictServiceImpl implements DictService {
|
||||
return dictMapper.toDto(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Dict> queryAll() {
|
||||
List<Dict> list = dictRepository.findAll();
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(Dict resources) {
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user