Commit 1e722089 authored by 王飞's avatar 王飞

Merge branch 'wangfei' into 'dev'

Feat

See merge request !27
parents f317893c 917f40a7
package com.ruoyi; package com.ruoyi;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.ruoyi.common.utils.SnowflakeUtil;
import com.ruoyi.domain.ReviewStandard; import com.ruoyi.domain.ReviewStandard;
import com.ruoyi.service.ReviewStandardService; import com.ruoyi.service.ReviewStandardService;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
...@@ -26,10 +27,21 @@ public class ReviewStandardTest { ...@@ -26,10 +27,21 @@ public class ReviewStandardTest {
} }
@Test @Test
public void findTreeTest() { public void findTreeTestSystem() {
List<ReviewStandard> tree = reviewStandardService.findTree(1L, ReviewStandard.TYPE_SYSTEM); List<ReviewStandard> tree = reviewStandardService.findTree(1L, ReviewStandard.TYPE_SYSTEM);
System.out.println(JSONUtil.toJsonPrettyStr(tree)); System.out.println(JSONUtil.toJsonPrettyStr(tree));
} }
@Test
public void findTreeTestCar() {
List<ReviewStandard> tree = reviewStandardService.findTree(1L, ReviewStandard.TYPE_CAR);
System.out.println(JSONUtil.toJsonPrettyStr(tree));
}
@Test
public void generateId() {
for(int i=0; i<38; i++)
System.out.println(SnowflakeUtil.generate());
}
} }
...@@ -26,6 +26,8 @@ public final class ServiceException extends RuntimeException ...@@ -26,6 +26,8 @@ public final class ServiceException extends RuntimeException
*/ */
private String detailMessage; private String detailMessage;
private Object data;
/** /**
* 空构造方法,避免反序列化问题 * 空构造方法,避免反序列化问题
*/ */
...@@ -44,6 +46,13 @@ public final class ServiceException extends RuntimeException ...@@ -44,6 +46,13 @@ public final class ServiceException extends RuntimeException
this.code = code; this.code = code;
} }
public ServiceException(String message, Integer code, Object data)
{
this.message = message;
this.code = code;
this.data = data;
}
public String getDetailMessage() public String getDetailMessage()
{ {
return detailMessage; return detailMessage;
...@@ -71,4 +80,16 @@ public final class ServiceException extends RuntimeException ...@@ -71,4 +80,16 @@ public final class ServiceException extends RuntimeException
this.detailMessage = detailMessage; this.detailMessage = detailMessage;
return this; return this;
} }
public void setCode(Integer code) {
this.code = code;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
} }
\ No newline at end of file
...@@ -58,7 +58,9 @@ public class GlobalExceptionHandler ...@@ -58,7 +58,9 @@ public class GlobalExceptionHandler
{ {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
Integer code = e.getCode(); Integer code = e.getCode();
return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage()); Object data = e.getData();
return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage(), data == null ? null : data);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment