新增字典表service
This commit is contained in:
parent
fa1fcef183
commit
0b94665c19
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.bonus.system.api;
|
||||||
|
|
||||||
|
import com.bonus.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.bonus.common.core.domain.R;
|
||||||
|
import com.bonus.system.api.domain.SysDictData;
|
||||||
|
import com.bonus.system.api.domain.SysDictType;
|
||||||
|
import com.bonus.system.api.factory.RemoteDictFallbackFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典服务
|
||||||
|
* @author : 阮世耀
|
||||||
|
* @version : 1.0
|
||||||
|
* @PackagePath: com.bonus.system.api
|
||||||
|
* @CreateTime: 2024-08-12 15:31
|
||||||
|
* @Description: 字典服务service
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteDictService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteDictFallbackFactory.class)
|
||||||
|
public interface RemoteDictService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询字典类型
|
||||||
|
*
|
||||||
|
* @param dictName 字典名称
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/system/dict/type/list")
|
||||||
|
public R<SysDictType> getDictType(@RequestParam(value = "dictName", required = false) String dictName);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询字典数据
|
||||||
|
*
|
||||||
|
* @param dictType 字典类型
|
||||||
|
* @return 字典数据集合信息
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/system/dict/data/list")
|
||||||
|
public R<SysDictData> getDictData(@RequestParam(value = "dictType", required = false) String dictType);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.bonus.system.api.factory;
|
||||||
|
|
||||||
|
import com.bonus.common.core.domain.R;
|
||||||
|
import com.bonus.system.api.RemoteDictService;
|
||||||
|
import com.bonus.system.api.domain.SysDictData;
|
||||||
|
import com.bonus.system.api.domain.SysDictType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典服务降级处理
|
||||||
|
*
|
||||||
|
* @author bonus
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RemoteDictFallbackFactory implements FallbackFactory<RemoteDictService>
|
||||||
|
{
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RemoteDictFallbackFactory.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RemoteDictService create(Throwable throwable) {
|
||||||
|
log.error("字典服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemoteDictService() {
|
||||||
|
@Override
|
||||||
|
public R<SysDictType> getDictType(String dictType) {
|
||||||
|
return R.fail("获取字典类型失败" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<SysDictData> getDictData(String dictType) {
|
||||||
|
return R.fail("获取字典数据失败" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,4 +21,10 @@ public class ServiceNameConstants
|
||||||
* 文件服务的serviceid
|
* 文件服务的serviceid
|
||||||
*/
|
*/
|
||||||
public static final String FILE_SERVICE = "bonus-file";
|
public static final String FILE_SERVICE = "bonus-file";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典服务的service
|
||||||
|
*/
|
||||||
|
public static final String DICT_SERVICE = "bonus-dict";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue