update 优化 新增返回警告消息提示

2.X
疯狂的狮子li 2 years ago
parent 306f9e04d0
commit 424d787ab4

@ -85,4 +85,9 @@ public interface HttpStatus {
*
*/
int NOT_IMPLEMENTED = 501;
/**
*
*/
public static final int WARN = 601;
}

@ -1,6 +1,7 @@
package com.ruoyi.common.core.domain;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.constant.HttpStatus;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -77,6 +78,27 @@ public class R<T> implements Serializable {
return restResult(null, code, msg);
}
/**
*
*
* @param msg
* @return
*/
public static <T> R<T> warn(String msg) {
return restResult(null, HttpStatus.WARN, msg);
}
/**
*
*
* @param msg
* @param data
* @return
*/
public static <T> R<T> warn(String msg, T data) {
return restResult(data, HttpStatus.WARN, msg);
}
private static <T> R<T> restResult(T data, int code, String msg) {
R<T> r = new R<>();
r.setCode(code);

@ -1,7 +1,6 @@
package com.ruoyi.system.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.util.ArrayUtil;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.domain.R;
@ -15,9 +14,7 @@ import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
@ -108,10 +105,10 @@ public class SysDeptController extends BaseController {
@DeleteMapping("/{deptId}")
public R<Void> remove(@PathVariable Long deptId) {
if (deptService.hasChildByDeptId(deptId)) {
return R.fail("存在下级部门,不允许删除");
return R.warn("存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId)) {
return R.fail("部门存在用户,不允许删除");
return R.warn("部门存在用户,不允许删除");
}
deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId));

@ -122,10 +122,10 @@ public class SysMenuController extends BaseController {
@DeleteMapping("/{menuId}")
public R<Void> remove(@PathVariable("menuId") Long menuId) {
if (menuService.hasChildByMenuId(menuId)) {
return R.fail("存在子菜单,不允许删除");
return R.warn("存在子菜单,不允许删除");
}
if (menuService.checkMenuExistRole(menuId)) {
return R.fail("菜单已分配,不允许删除");
return R.warn("菜单已分配,不允许删除");
}
return toAjax(menuService.deleteMenuById(menuId));
}

Loading…
Cancel
Save