|
@ -39,37 +39,6 @@ public class SystemDictEntryService extends BaseJpaService<SystemDictEntry, Syst
|
|
|
return null == nextSort ? 1 : nextSort + 1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取所有字典项。对于大字典,若不分页效率可能会很低。
|
|
|
*
|
|
|
* @param dictId 字典ID
|
|
|
* @param page 分页,-1 表示查找全部
|
|
|
* @param size 页大小, page 为 -1 时忽略此参数
|
|
|
* @return
|
|
|
*/
|
|
|
public Page<SystemDictEntry> getDictEntries(String dictId, int page, int size) {
|
|
|
SystemDictEntryDao repo = (SystemDictEntryDao) getJpaRepository();
|
|
|
|
|
|
return repo.findByDictId(dictId, page == -1 ? null : new PageRequest(page, size));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取简易字典项列表.
|
|
|
*
|
|
|
* @param dictId
|
|
|
* @param codes 字典项代码列表,为空返回所有字典项. 但对于大字典效率会很低.
|
|
|
* @return
|
|
|
*/
|
|
|
public List<SystemDictEntry> getDictEntries(String dictId, String[] codes) {
|
|
|
SystemDictEntryDao repo = (SystemDictEntryDao) getJpaRepository();
|
|
|
|
|
|
if (codes == null) {
|
|
|
return repo.findByDictId(dictId);
|
|
|
} else {
|
|
|
return repo.findByDictIdAndCodes(dictId, codes);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取字典项。
|
|
|
*
|
|
@ -83,14 +52,6 @@ public class SystemDictEntryService extends BaseJpaService<SystemDictEntry, Syst
|
|
|
return repo.findOne(new DictEntryKey(code, dictId));
|
|
|
}
|
|
|
|
|
|
public SystemDictEntry getDictEntryByValueAndDictId(String value, String dictId) {
|
|
|
List<SystemDictEntry> systemDictEntryList = systemDictEntryDao.findByDictIdAndValue(dictId, value);
|
|
|
if (null != systemDictEntryList && systemDictEntryList.size() > 0) {
|
|
|
return systemDictEntryList.get(0);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按字典ID与字典项值查找字典项.
|
|
|
*
|
|
@ -103,20 +64,6 @@ public class SystemDictEntryService extends BaseJpaService<SystemDictEntry, Syst
|
|
|
return repo.findByDictIdAndValueLike(dictId, value);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按字典ID查找字典项.
|
|
|
*
|
|
|
* @param dictId
|
|
|
* @param page
|
|
|
* @param size
|
|
|
* @return
|
|
|
*/
|
|
|
public Page<SystemDictEntry> findByDictId(String dictId, int page, int size) {
|
|
|
SystemDictEntryDao repo = (SystemDictEntryDao) getJpaRepository();
|
|
|
|
|
|
return repo.findByDictId(dictId, new PageRequest(page, size));
|
|
|
}
|
|
|
|
|
|
public boolean isDictContainEntry(String dictId, String code) {
|
|
|
SystemDictEntryDao repo = (SystemDictEntryDao) getJpaRepository();
|
|
|
|
|
@ -131,18 +78,11 @@ public class SystemDictEntryService extends BaseJpaService<SystemDictEntry, Syst
|
|
|
return repo.save(systemDictEntry);
|
|
|
}
|
|
|
|
|
|
public void createDictEntry(SystemDictEntry systemDictEntry) {
|
|
|
SystemDictEntryDao repo = (SystemDictEntryDao) getJpaRepository();
|
|
|
|
|
|
repo.save(systemDictEntry);
|
|
|
}
|
|
|
|
|
|
public void deleteDictEntry(String dictId, String code) {
|
|
|
SystemDictEntryDao repo = (SystemDictEntryDao) getJpaRepository();
|
|
|
repo.delete(new DictEntryKey(code, dictId));
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据字典id获取字典项编码和值
|
|
|
*/
|