Browse Source

1、租户字典api接口

dongpo 6 months ago
parent
commit
62abf1e6d2

+ 25 - 0
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dicttenant/DictDataTenantApi.java

@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.module.system.api.dicttenant;
+
+import cn.iocoder.yudao.module.system.api.dicttenant.dto.DictDataTenantRespDTO;
+
+import java.util.List;
+
+public interface DictDataTenantApi {
+
+    /**
+     * 获得指定的字典数据
+     *
+     * @param dictType 字典类型
+     * @param value    字典数据值
+     * @return 字典数据
+     */
+    DictDataTenantRespDTO getDictData(String dictType, String value);
+
+    /**
+     * 获得指定的字典数据列表
+     *
+     * @param dictType 字典类型
+     * @return 字典数据列表
+     */
+    List<DictDataTenantRespDTO> getDictDataList(String dictType);
+}

+ 24 - 0
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dicttenant/dto/DictDataTenantRespDTO.java

@@ -0,0 +1,24 @@
+package cn.iocoder.yudao.module.system.api.dicttenant.dto;
+
+import lombok.Data;
+
+@Data
+public class DictDataTenantRespDTO {
+
+    /**
+     * 字典标签
+     */
+    private String label;
+    /**
+     * 字典值
+     */
+    private String value;
+    /**
+     * 字典类型
+     */
+    private String dictType;
+    /**
+     * 状态 0开启 1关闭
+     */
+    private Integer status;
+}

+ 37 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dicttenant/DictDataApiImpl.java

@@ -0,0 +1,37 @@
+package cn.iocoder.yudao.module.system.api.dicttenant;
+
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.system.api.dicttenant.dto.DictDataTenantRespDTO;
+import cn.iocoder.yudao.module.system.dal.dataobject.dictTenant.DictDataTenantDO;
+import cn.iocoder.yudao.module.system.service.dictTenant.DictDataTenantService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Collections;
+import java.util.List;
+
+@Service
+public class DictDataApiImpl implements DictDataTenantApi {
+
+    @Resource
+    private DictDataTenantService dictDataTenantService;
+
+    @Override
+    public DictDataTenantRespDTO getDictData(String dictType, String value) {
+        if (StrUtil.isBlank(dictType) || StrUtil.isBlank(value)) {
+            return null;
+        }
+        DictDataTenantDO dictDataTenantDO = dictDataTenantService.getDictData(dictType, value);
+        return BeanUtils.toBean(dictDataTenantDO, DictDataTenantRespDTO.class);
+    }
+
+    @Override
+    public List<DictDataTenantRespDTO> getDictDataList(String dictType) {
+        if (StrUtil.isBlank(dictType)) {
+            return Collections.emptyList();
+        }
+        List<DictDataTenantDO> dictDataTenantDOList = dictDataTenantService.getDictDataListByDictType(dictType);
+        return BeanUtils.toBean(dictDataTenantDOList, DictDataTenantRespDTO.class);
+    }
+}