增加基础树状controller
This commit is contained in:
parent
fa1fcef183
commit
5ebb4922e8
|
|
@ -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 = "/dict/type/list")
|
||||||
|
public R<SysDictType> getDictType(@RequestParam(value = "dictName", required = false) String dictName);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询字典数据
|
||||||
|
*
|
||||||
|
* @param dictType 字典类型
|
||||||
|
* @return 字典数据集合信息
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/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());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
com.bonus.system.api.factory.RemoteUserFallbackFactory
|
com.bonus.system.api.factory.RemoteUserFallbackFactory
|
||||||
com.bonus.system.api.factory.RemoteLogFallbackFactory
|
com.bonus.system.api.factory.RemoteLogFallbackFactory
|
||||||
com.bonus.system.api.factory.RemoteFileFallbackFactory
|
com.bonus.system.api.factory.RemoteFileFallbackFactory
|
||||||
|
com.bonus.system.api.factory.RemoteDictFallbackFactory
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.bonus.base.controller;
|
||||||
|
|
||||||
|
import com.bonus.common.core.domain.R;
|
||||||
|
import com.bonus.system.api.RemoteDictService;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : 阮世耀
|
||||||
|
* @version : 1.0
|
||||||
|
* @PackagePath: com.bonus.base.controller
|
||||||
|
* @CreateTime: 2024-08-12 16:23
|
||||||
|
* @Description: 公共 下拉框、树形数据 控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/tree")
|
||||||
|
public class BaseTreeController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RemoteDictService remoteDictService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取工程类型
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getProjectType")
|
||||||
|
public R<Object> getProjectType(){
|
||||||
|
return R.ok(remoteDictService.getDictData("bm_pro_type"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取工程状态
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getProjectStatus")
|
||||||
|
public R<Object> getProjectStatus(){
|
||||||
|
return R.ok(remoteDictService.getDictData("bm_pro_status"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取工程性质
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getProjectNature")
|
||||||
|
public R<Object> getProjectNature(){
|
||||||
|
return R.ok(remoteDictService.getDictData("bm_pro_nature"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue