SystemDictService.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package cn.cslg.pas.service;
  2. import cn.cslg.pas.domain.SystemDict;
  3. import cn.cslg.pas.domain.SystemDictAssociate;
  4. import cn.cslg.pas.mapper.SystemDictMapper;
  5. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  6. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  7. import lombok.RequiredArgsConstructor;
  8. import org.springframework.context.annotation.Lazy;
  9. import org.springframework.stereotype.Service;
  10. import java.util.ArrayList;
  11. import java.util.List;
  12. /**
  13. * <p>
  14. * 系统字典 服务类
  15. * </p>
  16. *
  17. * @author 王岩
  18. * @since 2022-03-30
  19. */
  20. @Service
  21. @RequiredArgsConstructor(onConstructor_ = {@Lazy})
  22. public class SystemDictService extends ServiceImpl<SystemDictMapper, SystemDict> {
  23. public List<SystemDict> getSystemDictListByType(List<String> type) {
  24. if (type == null || type.size() == 0) {
  25. return new ArrayList<>();
  26. }
  27. LambdaQueryWrapper<SystemDict> queryWrapper = new LambdaQueryWrapper<>();
  28. queryWrapper.in(SystemDict::getType, type);
  29. return this.list(queryWrapper);
  30. }
  31. public String getSystemDictLabelByTypeAndValue(String type, Object value) {
  32. LambdaQueryWrapper<SystemDict> queryWrapper = new LambdaQueryWrapper<>();
  33. queryWrapper.eq(SystemDict::getType, type);
  34. queryWrapper.eq(SystemDict::getValue, value);
  35. SystemDict systemDict = this.getOne(queryWrapper);
  36. if (systemDict != null) {
  37. return systemDict.getLabel();
  38. }
  39. return "";
  40. }
  41. }