SysDictDataServiceImpl.java 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package com.warewms.system.service.impl;
  2. import java.util.List;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.warewms.common.core.domain.base.page.PageDomain;
  5. import com.warewms.common.core.domain.base.page.TableDataInfo;
  6. import com.warewms.common.service.impl.SystemService;
  7. import com.warewms.system.domain.SysNotice;
  8. import com.warewms.system.service.ISysDictDataService;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.stereotype.Service;
  11. import com.warewms.common.core.domain.entity.SysDictData;
  12. import com.warewms.common.utils.DictUtils;
  13. import com.warewms.system.mapper.SysDictDataMapper;
  14. /**
  15. * 字典 业务层处理
  16. *
  17. * @author ruoyi
  18. */
  19. @Service
  20. public class SysDictDataServiceImpl extends SystemService<SysDictData> implements ISysDictDataService
  21. {
  22. @Autowired
  23. private SysDictDataMapper dictDataMapper;
  24. @Override
  25. public TableDataInfo<SysDictData> selectDictDataList(PageDomain pageDomain, SysDictData dictData)
  26. {
  27. Page<SysDictData> page = convertToPage(pageDomain);
  28. return getDataTable(dictDataMapper.selectDictDataList(page, dictData));
  29. }
  30. /**
  31. * 根据条件分页查询字典数据
  32. *
  33. * @param dictData 字典数据信息
  34. * @return 字典数据集合信息
  35. */
  36. @Override
  37. public List<SysDictData> selectDictDataList(SysDictData dictData)
  38. {
  39. return dictDataMapper.selectDictDataList(dictData);
  40. }
  41. /**
  42. * 根据字典类型和字典键值查询字典数据信息
  43. *
  44. * @param dictType 字典类型
  45. * @param dictValue 字典键值
  46. * @return 字典标签
  47. */
  48. @Override
  49. public String selectDictLabel(String dictType, String dictValue)
  50. {
  51. return dictDataMapper.selectDictLabel(dictType, dictValue);
  52. }
  53. /**
  54. * 根据字典数据ID查询信息
  55. *
  56. * @param dictCode 字典数据ID
  57. * @return 字典数据
  58. */
  59. @Override
  60. public SysDictData selectDictDataById(Long dictCode)
  61. {
  62. return dictDataMapper.selectDictDataById(dictCode);
  63. }
  64. /**
  65. * 批量删除字典数据信息
  66. *
  67. * @param dictCodes 需要删除的字典数据ID
  68. */
  69. @Override
  70. public void deleteDictDataByIds(Long[] dictCodes)
  71. {
  72. for (Long dictCode : dictCodes)
  73. {
  74. SysDictData data = selectDictDataById(dictCode);
  75. dictDataMapper.deleteDictDataById(dictCode);
  76. List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
  77. DictUtils.setDictCache(data.getDictType(), dictDatas);
  78. }
  79. }
  80. /**
  81. * 新增保存字典数据信息
  82. *
  83. * @param data 字典数据信息
  84. * @return 结果
  85. */
  86. @Override
  87. public int insertDictData(SysDictData data)
  88. {
  89. int row = dictDataMapper.insertDictData(data);
  90. if (row > 0)
  91. {
  92. List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
  93. DictUtils.setDictCache(data.getDictType(), dictDatas);
  94. }
  95. return row;
  96. }
  97. /**
  98. * 修改保存字典数据信息
  99. *
  100. * @param data 字典数据信息
  101. * @return 结果
  102. */
  103. @Override
  104. public int updateDictData(SysDictData data)
  105. {
  106. int row = dictDataMapper.updateDictData(data);
  107. if (row > 0)
  108. {
  109. List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
  110. DictUtils.setDictCache(data.getDictType(), dictDatas);
  111. }
  112. return row;
  113. }
  114. }