优化代码
This commit is contained in:
parent
ab8c373d8d
commit
0e152e2ac7
|
@ -27,9 +27,9 @@ public class SysDictDataEntity extends BaseEntity {
|
|||
*/
|
||||
private String dictValue;
|
||||
/**
|
||||
* 字典tag类型
|
||||
* 标签样式
|
||||
*/
|
||||
private String tagType;
|
||||
private String labelClass;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
|
|
@ -43,12 +43,12 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeDao, SysD
|
|||
private final DictionaryTransService dictionaryTransService;
|
||||
|
||||
@Override
|
||||
public PageResult<SysDictTypeVO> page (SysDictTypeQuery query) {
|
||||
public PageResult<SysDictTypeVO> page(SysDictTypeQuery query) {
|
||||
IPage<SysDictTypeEntity> page = baseMapper.selectPage(getPage(query), getWrapper(query));
|
||||
return new PageResult<>(SysDictTypeConvert.INSTANCE.convertList(page.getRecords()), page.getTotal());
|
||||
}
|
||||
|
||||
private Wrapper<SysDictTypeEntity> getWrapper (SysDictTypeQuery query) {
|
||||
private Wrapper<SysDictTypeEntity> getWrapper(SysDictTypeQuery query) {
|
||||
LambdaQueryWrapper<SysDictTypeEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(StrUtil.isNotBlank(query.getDictType()), SysDictTypeEntity::getDictType, query.getDictType());
|
||||
wrapper.like(StrUtil.isNotBlank(query.getDictName()), SysDictTypeEntity::getDictName, query.getDictName());
|
||||
|
@ -59,7 +59,7 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeDao, SysD
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save (SysDictTypeVO vo) {
|
||||
public void save(SysDictTypeVO vo) {
|
||||
SysDictTypeEntity entity = SysDictTypeConvert.INSTANCE.convert(vo);
|
||||
|
||||
baseMapper.insert(entity);
|
||||
|
@ -67,7 +67,7 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeDao, SysD
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update (SysDictTypeVO vo) {
|
||||
public void update(SysDictTypeVO vo) {
|
||||
SysDictTypeEntity entity = SysDictTypeConvert.INSTANCE.convert(vo);
|
||||
|
||||
updateById(entity);
|
||||
|
@ -75,12 +75,12 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeDao, SysD
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete (List<Long> idList) {
|
||||
public void delete(List<Long> idList) {
|
||||
removeByIds(idList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDictVO.DictData> getDictSql (Long id) {
|
||||
public List<SysDictVO.DictData> getDictSql(Long id) {
|
||||
SysDictTypeEntity entity = this.getById(id);
|
||||
try {
|
||||
return sysDictDataDao.getListForSql(entity.getDictSql());
|
||||
|
@ -90,7 +90,7 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeDao, SysD
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<SysDictVO> getDictList () {
|
||||
public List<SysDictVO> getDictList() {
|
||||
// 全部字典类型列表
|
||||
List<SysDictTypeEntity> typeList = this.list(Wrappers.emptyWrapper());
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeDao, SysD
|
|||
|
||||
for (SysDictDataEntity data : dataList) {
|
||||
if (type.getId().equals(data.getDictTypeId())) {
|
||||
dict.getDataList().add(new SysDictVO.DictData(data.getDictLabel(), data.getDictValue(), data.getTagType()));
|
||||
dict.getDataList().add(new SysDictVO.DictData(data.getDictLabel(), data.getDictValue(), data.getLabelClass()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,11 +128,11 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeDao, SysD
|
|||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet () {
|
||||
public void afterPropertiesSet() {
|
||||
refreshTransCache();
|
||||
}
|
||||
|
||||
public void refreshTransCache () {
|
||||
public void refreshTransCache() {
|
||||
// 异步不阻塞主线程,不会 增加启动用时
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
// 获取所有的字典项数据
|
||||
|
|
|
@ -32,8 +32,8 @@ public class SysDictDataVO implements Serializable {
|
|||
@NotBlank(message = "字典标签不能为空")
|
||||
private String dictLabel;
|
||||
|
||||
@Schema(description = "字典tag类型")
|
||||
private String tagType;
|
||||
@Schema(description = "标签样式")
|
||||
private String labelClass;
|
||||
|
||||
@Schema(description = "字典值")
|
||||
private String dictValue;
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SysDictVO {
|
|||
@Schema(description = "字典值")
|
||||
private String dictValue;
|
||||
|
||||
@Schema(description = "字典tag类型")
|
||||
private String tagType;
|
||||
@Schema(description = "标签样式")
|
||||
private String labelClass;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user