Commit 053b02e7 by flying-cattle

返回结果修改

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