异常拦截器修改,公用返回字段类修改
This commit is contained in:
parent
685fd8e14b
commit
113dd8c164
|
|
@ -9,6 +9,8 @@ import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典服务
|
* 字典服务
|
||||||
* @author : 阮世耀
|
* @author : 阮世耀
|
||||||
|
|
@ -36,8 +38,8 @@ public interface RemoteDictService {
|
||||||
* @param dictType 字典类型
|
* @param dictType 字典类型
|
||||||
* @return 字典数据集合信息
|
* @return 字典数据集合信息
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/dict/data/list")
|
@GetMapping(value = "/dict/data/type/{dictType}")
|
||||||
public R<SysDictData> getDictData(@RequestParam(value = "dictType", required = false) String dictType);
|
public R<List<Object>> getDictData(@RequestParam(value = "dictType", required = false) String dictType);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典服务降级处理
|
* 字典服务降级处理
|
||||||
*
|
*
|
||||||
|
|
@ -29,7 +31,7 @@ public class RemoteDictFallbackFactory implements FallbackFactory<RemoteDictServ
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R<SysDictData> getDictData(String dictType) {
|
public R<List<Object>> getDictData(String dictType) {
|
||||||
return R.fail("获取字典数据失败" + throwable.getMessage());
|
return R.fail("获取字典数据失败" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public final class ResultBean<T> implements java.io.Serializable{
|
||||||
|
|
||||||
private final int code;
|
private final int code;
|
||||||
|
|
||||||
private final String message;
|
private final String msg;
|
||||||
|
|
||||||
private final T data;
|
private final T data;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,15 +144,6 @@ public class GlobalExceptionHandler
|
||||||
return AjaxResult.error(message);
|
return AjaxResult.error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理系统异常,在其他异常拦截均未捕获时进行兜底处理
|
|
||||||
*/
|
|
||||||
@ExceptionHandler(value = Exception.class)
|
|
||||||
public AjaxResult defaultHandleException(Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
return AjaxResult.error(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 内部认证异常
|
* 内部认证异常
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,14 @@ package com.bonus.base.controller;
|
||||||
|
|
||||||
import com.bonus.common.core.domain.R;
|
import com.bonus.common.core.domain.R;
|
||||||
import com.bonus.system.api.RemoteDictService;
|
import com.bonus.system.api.RemoteDictService;
|
||||||
|
import com.bonus.system.api.domain.SysDictData;
|
||||||
import org.apache.poi.ss.formula.functions.T;
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -45,7 +47,8 @@ public class BaseTreeController {
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/getProjectNature")
|
@RequestMapping("/getProjectNature")
|
||||||
public R<Object> getProjectNature(){
|
public R<Object> getProjectNature(){
|
||||||
return R.ok(remoteDictService.getDictData("bm_pro_nature"));
|
R<List<Object>> bmProNature = remoteDictService.getDictData("bm_pro_nature");
|
||||||
|
return R.ok(bmProNature);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,9 @@ public class BmProjectController extends BaseController {
|
||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
@RequiresPermissions("base:project:add")
|
@RequiresPermissions("base:project:add")
|
||||||
public ResultBean<Boolean> add(@NotNull @Valid @RequestBody BmProject obj) {
|
public ResultBean<Boolean> add(@NotNull @Valid @RequestBody BmProject obj) {
|
||||||
ResultBean<Boolean> error = validRecord(obj);
|
if (this.bmProjectService.selectByName(obj.getName()) != 0) {
|
||||||
if (error != null) return error;
|
return ResultBean.error("工程名称重复");
|
||||||
|
}
|
||||||
int result = this.bmProjectService.insertSelective(obj);
|
int result = this.bmProjectService.insertSelective(obj);
|
||||||
return result > 0 ? ResultBean.success(true) : ResultBean.error(0, "增加失败");
|
return result > 0 ? ResultBean.success(true) : ResultBean.error(0, "增加失败");
|
||||||
}
|
}
|
||||||
|
|
@ -100,23 +101,13 @@ public class BmProjectController extends BaseController {
|
||||||
@PutMapping(value = "/update")
|
@PutMapping(value = "/update")
|
||||||
@RequiresPermissions("base:project:edit")
|
@RequiresPermissions("base:project:edit")
|
||||||
public ResultBean<Boolean> edit(@NotNull @RequestBody BmProject obj) {
|
public ResultBean<Boolean> edit(@NotNull @RequestBody BmProject obj) {
|
||||||
ResultBean<Boolean> validResult = validRecord(obj);
|
if (this.bmProjectService.selectByName(obj.getName()) > 1) {
|
||||||
if (validResult != null) return validResult;
|
return ResultBean.error("工程名称重复");
|
||||||
|
}
|
||||||
this.bmProjectService.updateByPrimaryKeySelective(obj);
|
this.bmProjectService.updateByPrimaryKeySelective(obj);
|
||||||
return ResultBean.success(true);
|
return ResultBean.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 参数校验,检验新增、修改的参数是否符合要求
|
|
||||||
* @param obj 请求对象
|
|
||||||
* @return 校验结果
|
|
||||||
*/
|
|
||||||
private ResultBean<Boolean> validRecord(BmProject obj) {
|
|
||||||
if (this.bmProjectService.selectByName(obj.getName()) != 0) {
|
|
||||||
return ResultBean.error("工程名称重复");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 逻辑删除
|
* 逻辑删除
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,6 @@ public interface BmProjectMapper {
|
||||||
|
|
||||||
int selectByName(@Param("name")String name);
|
int selectByName(@Param("name")String name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<BmProject> selectAll(BmProject bmProject);
|
List<BmProject> selectAll(BmProject bmProject);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ import com.bonus.system.service.ISysDictTypeService;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/dict/data")
|
@RequestMapping("/dict/data")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SysDictDataController extends BaseController
|
public class SysDictDataController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDictDataService dictDataService;
|
private ISysDictDataService dictDataService;
|
||||||
|
|
||||||
|
|
@ -58,6 +58,8 @@ public class SysDictDataController extends BaseController
|
||||||
return getDataTableError(new ArrayList<>());
|
return getDataTableError(new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RequiresPermissions("system:dict:export")
|
@RequiresPermissions("system:dict:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@SysLog(title = "字典管理", businessType = OperaType.EXPORT,logType = 0,module = "系统管理->字典管理")
|
@SysLog(title = "字典管理", businessType = OperaType.EXPORT,logType = 0,module = "系统管理->字典管理")
|
||||||
|
|
@ -93,7 +95,7 @@ public class SysDictDataController extends BaseController
|
||||||
try{
|
try{
|
||||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||||
if (StringUtils.isNull(data)) {
|
if (StringUtils.isNull(data)) {
|
||||||
data = new ArrayList<SysDictData>();
|
data = new ArrayList<>();
|
||||||
}
|
}
|
||||||
return success(data);
|
return success(data);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
|
@ -117,7 +119,6 @@ public class SysDictDataController extends BaseController
|
||||||
log.error(e.toString(),e);
|
log.error(e.toString(),e);
|
||||||
}
|
}
|
||||||
return error("系统错误");
|
return error("系统错误");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -134,7 +135,6 @@ public class SysDictDataController extends BaseController
|
||||||
log.error(e.toString(),e);
|
log.error(e.toString(),e);
|
||||||
}
|
}
|
||||||
return error("系统错误");
|
return error("系统错误");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue