Commit 3540c3e4 by tyfanchz

调整异常处理方法

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