Commit 3540c3e4 by tyfanchz

调整异常处理方法

1 parent b90aa0ca
......@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSON;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import com.glsx.smart.dao.entity.SmartSysCode;
import com.glsx.smart.exception.BusinessException;
import com.glsx.smart.exception.ResultEnum;
import com.glsx.smart.service.SmartSysCodeService;
import lombok.extern.slf4j.Slf4j;
......@@ -26,7 +25,6 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/sysCode")
public class SysCodeController {
@Autowired
private SmartSysCodeService sysCodeService;
......@@ -35,9 +33,15 @@ public class SysCodeController {
log.info("/sysCode/getList param: {}", JSON.toJSONString(code));
if(StringUtils.isEmpty(code.getDictType())
|| StringUtils.isEmpty(code.getParentKey())){
throw BusinessException.create(ResultEnum.PARAM_ERROR);
return R.error(ResultEnum.PARAM_ERROR.getCode(), ResultEnum.PARAM_ERROR.getMessage());
}
try {
List<SmartSysCode> sysCodeList = sysCodeService.getList(code);
return R.ok().data(sysCodeList);
} catch (Exception e) {
log.error("!!!! /sysCode/getList ERROR", e);
return R.error();
}
return R.ok().data(sysCodeService.getList(code));
}
@RequestMapping(value = "/getListByCondition", method = {RequestMethod.POST})
......
package com.glsx.smart.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
import java.util.Map;
import com.glsx.plat.core.web.R;
import com.glsx.smart.pojo.FileDTO;
import com.glsx.smart.service.SmartSysFileService;
......@@ -9,10 +9,11 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>Description:
......@@ -43,6 +44,7 @@ public class SysFileController {
try {
mapList = sysFileService.saveFile(files);
} catch (Exception e) {
log.error("批量保存图片失败:", e);
return R.error();
}
return R.ok().data(mapList);
......@@ -54,7 +56,7 @@ public class SysFileController {
try {
return R.ok().data(sysFileService.updateFile(fileDTO));
} catch (Exception e) {
log.error("保存图片失败:{}", e);
log.error("保存更新图片失败:", e);
return R.error();
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!