Commit 053b02e7 by flying-cattle

返回结果修改

parent 3e852276
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<groupId>com.github.flying-cattle</groupId> <groupId>com.github.flying-cattle</groupId>
<artifactId>mybatis-dsc-generator</artifactId> <artifactId>mybatis-dsc-generator</artifactId>
<version>3.0.2.RELEASE</version> <version>3.0.3.RELEASE</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>mybatis-dsc-generator</name> <name>mybatis-dsc-generator</name>
......
...@@ -47,32 +47,47 @@ public class JsonResult<T> implements Serializable{ ...@@ -47,32 +47,47 @@ public class JsonResult<T> implements Serializable{
/** /**
* <p>返回成功,有数据</p> * <p>返回成功,有数据</p>
* @param T * @param message 操作说明
* @return JsonResult<T> * @param data 对象
* @return JsonResult
*/ */
public JsonResult<T> success(T data) { public JsonResult<T> success(String message,T data) {
this.setCode(Const.CODE_SUCCESS); this.setCode(Const.CODE_SUCCESS);
this.setOperate(Const.OPERATE_SUCCESS); this.setOperate(Const.OPERATE_SUCCESS);
this.setMessage("操作成功!"); this.setMessage(message);
this.setData(data); this.setData(data);
return this; return this;
} }
/** /**
* <p>返回成功,有数据</p>
* @param data 对象
* @return JsonResult
*/
public JsonResult<T> success(T data) {
this.setCode(Const.CODE_SUCCESS);
this.setOperate(Const.OPERATE_SUCCESS);
this.setMessage("操作成功");
this.setData(data);
return this;
}
/**
* <p>返回成功,无数据</p> * <p>返回成功,无数据</p>
* @param message 操作说明
* @return JsonResult
*/ */
public JsonResult<T> success() { public JsonResult<T> success(String message) {
this.setCode(Const.CODE_SUCCESS); this.setCode(Const.CODE_SUCCESS);
this.setOperate(Const.OPERATE_SUCCESS); this.setOperate(Const.OPERATE_SUCCESS);
this.setMessage("操作成功!"); this.setMessage(message);
this.setData(null); this.setData(null);
return this; return this;
} }
/** /**
* <p>返回成功,无数据</p> * <p>返回失败,无数据</p>
* @param message * @param message 消息
* @return JsonResult<T> * @return JsonResult
*/ */
public JsonResult<T> error(String message) { public JsonResult<T> error(String message) {
this.setCode(Const.CODE_FAILED); this.setCode(Const.CODE_FAILED);
...@@ -81,6 +96,19 @@ public class JsonResult<T> implements Serializable{ ...@@ -81,6 +96,19 @@ public class JsonResult<T> implements Serializable{
this.setData(null); this.setData(null);
return this; return this;
} }
/**
* <p>返回失败,有数据</p>
* @param message 消息
* @param data 对象
* @return JsonResult
*/
public JsonResult<T> error(String message,T data) {
this.setCode(Const.CODE_FAILED);
this.setOperate(Const.OPERATE_FAILED);
this.setMessage(message);
this.setData(data);
return this;
}
public JsonResult(Throwable throwable) { public JsonResult(Throwable throwable) {
this.operate=Const.OPERATE_FAILED; this.operate=Const.OPERATE_FAILED;
if(throwable instanceof NullPointerException){ if(throwable instanceof NullPointerException){
......
...@@ -70,7 +70,7 @@ public class AbstractController<S extends IService<T>,T>{ ...@@ -70,7 +70,7 @@ public class AbstractController<S extends IService<T>,T>{
if (null!=obj) { if (null!=obj) {
boolean rsg = baseService.removeById(id); boolean rsg = baseService.removeById(id);
if (rsg) { if (rsg) {
result.success(); result.success("删除成功");
}else { }else {
result.error("删除失败!"); result.error("删除失败!");
} }
...@@ -94,7 +94,7 @@ public class AbstractController<S extends IService<T>,T>{ ...@@ -94,7 +94,7 @@ public class AbstractController<S extends IService<T>,T>{
if (null!=entity) { if (null!=entity) {
boolean rsg = baseService.save(entity); boolean rsg = baseService.save(entity);
if (rsg) { if (rsg) {
result.success(); result.success("添加成功");
}else { }else {
result.error("添加失败!"); result.error("添加失败!");
} }
...@@ -118,7 +118,7 @@ public class AbstractController<S extends IService<T>,T>{ ...@@ -118,7 +118,7 @@ public class AbstractController<S extends IService<T>,T>{
if (null!=entity) { if (null!=entity) {
boolean rsg = baseService.updateById(entity); boolean rsg = baseService.updateById(entity);
if (rsg) { if (rsg) {
result.success(); result.success("修改成功");
}else { }else {
result.error("修改失败!"); result.error("修改失败!");
} }
......
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