Commit 38aaca5f authored by 王飞's avatar 王飞

Feat

1、调整swagger兼容性问题。

Reference N/A
parent a59d8914
...@@ -2,7 +2,7 @@ package com.ruoyi.web; ...@@ -2,7 +2,7 @@ package com.ruoyi.web;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.common.utils.bean.BeanUtils;
...@@ -35,35 +35,35 @@ public class ReviewSceneChangeTaskController extends BaseController { ...@@ -35,35 +35,35 @@ public class ReviewSceneChangeTaskController extends BaseController {
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")}) @Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@Log(title = "场景变更任务", businessType = BusinessType.INSERT) @Log(title = "场景变更任务", businessType = BusinessType.INSERT)
@RequestMapping(method = RequestMethod.POST, value = "/create") @RequestMapping(method = RequestMethod.POST, value = "/create")
public AjaxResult create(@Validated @RequestBody ReviewSceneChangeTaskCreateRequest request) { public R<String> create(@Validated @RequestBody ReviewSceneChangeTaskCreateRequest request) {
ReviewSceneChangeTask reviewSceneChangeTask = new ReviewSceneChangeTask(); ReviewSceneChangeTask reviewSceneChangeTask = new ReviewSceneChangeTask();
BeanUtils.copyBeanProp(reviewSceneChangeTask, request); BeanUtils.copyBeanProp(reviewSceneChangeTask, request);
reviewSceneChangeTaskService.create(reviewSceneChangeTask); reviewSceneChangeTaskService.create(reviewSceneChangeTask);
return success(); return R.ok();
} }
@Trace @Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")}) @Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@Log(title = "审核通过任务", businessType = BusinessType.UPDATE) @Log(title = "审核通过任务", businessType = BusinessType.UPDATE)
@RequestMapping(method = RequestMethod.POST, value = "/pass") @RequestMapping(method = RequestMethod.POST, value = "/pass")
public AjaxResult pass(@Validated @RequestBody ReviewSceneChangeTaskPassRequest request) { public R<String> pass(@Validated @RequestBody ReviewSceneChangeTaskPassRequest request) {
reviewSceneChangeTaskService.pass(request.getTaskId(),request.getComment()); reviewSceneChangeTaskService.pass(request.getTaskId(),request.getComment());
return success(); return R.ok();
} }
@Trace @Trace
@Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")}) @Tags({@Tag(key = "param", value = "arg[0]"), @Tag(key = "result", value = "returnedObj")})
@Log(title = "审核驳回任务", businessType = BusinessType.UPDATE) @Log(title = "审核驳回任务", businessType = BusinessType.UPDATE)
@RequestMapping(method = RequestMethod.POST, value = "/reject") @RequestMapping(method = RequestMethod.POST, value = "/reject")
public AjaxResult reject(@Validated @RequestBody ReviewSceneChangeTaskPassRequest request) { public R<String> reject(@Validated @RequestBody ReviewSceneChangeTaskPassRequest request) {
reviewSceneChangeTaskService.reject(request.getTaskId(),request.getComment()); reviewSceneChangeTaskService.reject(request.getTaskId(),request.getComment());
return success(); return R.ok();
} }
/** /**
......
package com.ruoyi.common.core.domain; package com.ruoyi.common.core.domain;
import java.io.Serializable; import java.util.HashMap;
import java.util.Objects;
import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
/** /**
* 操作消息提醒 * 操作消息提醒
* *
* @author ruoyi * @author ruoyi
*/ */
public class AjaxResult<T> implements Serializable public class AjaxResult extends HashMap<String, Object>
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 数据对象 */ /** 状态码 */
public static final String DATA_TAG = "data"; public static final String CODE_TAG = "code";
/** /** 返回内容 */
* 是否成功 true or false public static final String MSG_TAG = "msg";
*/
private boolean success;
/** /** 数据对象 */
* 状态码 public static final String DATA_TAG = "data";
*/
private int code;
/**
* 返回内容
*/
private String msg;
/**
* 数据对象
*/
private T data;
/** /**
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
...@@ -47,38 +33,29 @@ public class AjaxResult<T> implements Serializable ...@@ -47,38 +33,29 @@ public class AjaxResult<T> implements Serializable
/** /**
* 初始化一个新创建的 AjaxResult 对象 * 初始化一个新创建的 AjaxResult 对象
* *
* @param code 错误 * @param code 状态
* @param msg 返回内容 * @param msg 返回内容
* @param data 数据对象
*/ */
public AjaxResult(int code, String msg, T data) { public AjaxResult(int code, String msg)
this.code = code; {
this.msg = msg; super.put(CODE_TAG, code);
if (StringUtils.isNotNull(data)) { super.put(MSG_TAG, msg);
this.data = data;
}
if (code == HttpStatus.SUCCESS) {
this.success = Boolean.TRUE;
} else {
this.success = Boolean.FALSE;
}
} }
/** /**
* 初始化一个新创建的 AjaxResult 对象 * 初始化一个新创建的 AjaxResult 对象
* *
* @param code 错误 * @param code 状态
* @param msg 返回内容 * @param msg 返回内容
* @param data 数据对象
*/ */
public AjaxResult(int code, String msg) { public AjaxResult(int code, String msg, Object data)
this.code = code; {
this.msg = msg; super.put(CODE_TAG, code);
super.put(MSG_TAG, msg);
if (code == HttpStatus.SUCCESS) { if (StringUtils.isNotNull(data))
this.success = Boolean.TRUE; {
} else { super.put(DATA_TAG, data);
this.success = Boolean.FALSE;
} }
} }
...@@ -97,7 +74,7 @@ public class AjaxResult<T> implements Serializable ...@@ -97,7 +74,7 @@ public class AjaxResult<T> implements Serializable
* *
* @return 成功消息 * @return 成功消息
*/ */
public static <U> AjaxResult<U> success(U data) public static AjaxResult success(Object data)
{ {
return AjaxResult.success("操作成功", data); return AjaxResult.success("操作成功", data);
} }
...@@ -120,7 +97,7 @@ public class AjaxResult<T> implements Serializable ...@@ -120,7 +97,7 @@ public class AjaxResult<T> implements Serializable
* @param data 数据对象 * @param data 数据对象
* @return 成功消息 * @return 成功消息
*/ */
public static <U> AjaxResult<U> success(String msg, U data) public static AjaxResult success(String msg, Object data)
{ {
return new AjaxResult(HttpStatus.SUCCESS, msg, data); return new AjaxResult(HttpStatus.SUCCESS, msg, data);
} }
...@@ -143,7 +120,7 @@ public class AjaxResult<T> implements Serializable ...@@ -143,7 +120,7 @@ public class AjaxResult<T> implements Serializable
* @param data 数据对象 * @param data 数据对象
* @return 警告消息 * @return 警告消息
*/ */
public static <U> AjaxResult<U> warn(String msg, U data) public static AjaxResult warn(String msg, Object data)
{ {
return new AjaxResult(HttpStatus.WARN, msg, data); return new AjaxResult(HttpStatus.WARN, msg, data);
} }
...@@ -151,7 +128,7 @@ public class AjaxResult<T> implements Serializable ...@@ -151,7 +128,7 @@ public class AjaxResult<T> implements Serializable
/** /**
* 返回错误消息 * 返回错误消息
* *
* @return * @return 错误消息
*/ */
public static AjaxResult error() public static AjaxResult error()
{ {
...@@ -162,7 +139,7 @@ public class AjaxResult<T> implements Serializable ...@@ -162,7 +139,7 @@ public class AjaxResult<T> implements Serializable
* 返回错误消息 * 返回错误消息
* *
* @param msg 返回内容 * @param msg 返回内容
* @return 警告消息 * @return 错误消息
*/ */
public static AjaxResult error(String msg) public static AjaxResult error(String msg)
{ {
...@@ -174,9 +151,9 @@ public class AjaxResult<T> implements Serializable ...@@ -174,9 +151,9 @@ public class AjaxResult<T> implements Serializable
* *
* @param msg 返回内容 * @param msg 返回内容
* @param data 数据对象 * @param data 数据对象
* @return 警告消息 * @return 错误消息
*/ */
public static <U> AjaxResult<U> error(String msg, U data) public static AjaxResult error(String msg, Object data)
{ {
return new AjaxResult(HttpStatus.ERROR, msg, data); return new AjaxResult(HttpStatus.ERROR, msg, data);
} }
...@@ -184,43 +161,57 @@ public class AjaxResult<T> implements Serializable ...@@ -184,43 +161,57 @@ public class AjaxResult<T> implements Serializable
/** /**
* 返回错误消息 * 返回错误消息
* *
* @param code 响应 * @param code 状态
* @param msg 响应消息 * @param msg 返回内容
* @return 警告消息 * @return 错误消息
*/ */
public static <U> AjaxResult<U> error(int code, String msg) public static AjaxResult error(int code, String msg)
{ {
return new AjaxResult(code, msg); return new AjaxResult(code, msg, null);
} }
/** /**
* 方便链式调用 * 是否为成功消息
* *
* @param key 键 * @return 结果
* @param value 值
* @return 数据对象
*/ */
@Deprecated public boolean isSuccess()
public AjaxResult put(String key, Object value) { {
//super.put(key, value); return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG));
return this;
} }
/** /**
* 是否为成功消息 * 是否为警告消息
* *
* @return 结果 * @return 结果
*/ */
public boolean isSuccess() { public boolean isWarn()
return success; {
return Objects.equals(HttpStatus.WARN, this.get(CODE_TAG));
} }
public String getMsg() { /**
return msg; * 是否为错误消息
*
* @return 结果
*/
public boolean isError()
{
return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG));
} }
public Integer getCode() { /**
return code; * 方便链式调用
*
* @param key 键
* @param value 值
* @return 数据对象
*/
@Override
public AjaxResult put(String key, Object value)
{
super.put(key, value);
return this;
} }
} }
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