parent
1c8164b7e3
commit
16ed4e3bc2
@ -1,11 +1,14 @@ |
|||||||
package cn.toesbieya.jxc.api.system; |
package cn.toesbieya.jxc.api.system; |
||||||
|
|
||||||
|
import cn.toesbieya.jxc.common.model.entity.SysResource; |
||||||
import cn.toesbieya.jxc.common.model.entity.SysRole; |
import cn.toesbieya.jxc.common.model.entity.SysRole; |
||||||
import cn.toesbieya.jxc.common.model.vo.ResourceVo; |
|
||||||
|
|
||||||
import java.util.List; |
import java.util.List; |
||||||
|
|
||||||
public interface ResourceApi { |
public interface ResourceApi { |
||||||
|
//获取已启用的数据接口列表
|
||||||
|
List<SysResource> getEnableApi(); |
||||||
|
|
||||||
//获取角色的权限列表,包含admin权限
|
//获取角色的权限列表,包含admin权限
|
||||||
List<ResourceVo> getResourceByRole(SysRole role); |
List<SysResource> getResourceByRole(SysRole role); |
||||||
} |
} |
||||||
|
|||||||
@ -0,0 +1,15 @@ |
|||||||
|
package cn.toesbieya.jxc.common.enumeration; |
||||||
|
|
||||||
|
public enum ResourceTypeEnum { |
||||||
|
FOLDER(1), LEAF(2), API(3); |
||||||
|
|
||||||
|
private final int code; |
||||||
|
|
||||||
|
ResourceTypeEnum(int code) { |
||||||
|
this.code = code; |
||||||
|
} |
||||||
|
|
||||||
|
public int getCode() { |
||||||
|
return code; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,83 @@ |
|||||||
|
package cn.toesbieya.jxc.common.model.vo; |
||||||
|
|
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.Builder; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.NoArgsConstructor; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
@Data |
||||||
|
@AllArgsConstructor |
||||||
|
@NoArgsConstructor |
||||||
|
@Builder |
||||||
|
public class R implements Serializable { |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
//返回码,200表示成功,其他表示失败
|
||||||
|
private int status; |
||||||
|
|
||||||
|
//返回的信息
|
||||||
|
private String msg; |
||||||
|
|
||||||
|
//返回的数据
|
||||||
|
private Object data; |
||||||
|
|
||||||
|
public R(int status) { |
||||||
|
this.status = status; |
||||||
|
} |
||||||
|
|
||||||
|
public R(int status, String msg) { |
||||||
|
this.status = status; |
||||||
|
this.msg = msg; |
||||||
|
} |
||||||
|
|
||||||
|
public R(int status, Object data) { |
||||||
|
this.status = status; |
||||||
|
this.data = data; |
||||||
|
} |
||||||
|
|
||||||
|
public static R success() { |
||||||
|
return new R(200); |
||||||
|
} |
||||||
|
|
||||||
|
public static R success(String msg) { |
||||||
|
return new R(200, msg); |
||||||
|
} |
||||||
|
|
||||||
|
public static R success(Object data) { |
||||||
|
return new R(200, data); |
||||||
|
} |
||||||
|
|
||||||
|
public static R success(String msg, Object data) { |
||||||
|
return new R(200, msg, data); |
||||||
|
} |
||||||
|
|
||||||
|
public static R fail(String msg) { |
||||||
|
return new R(500, msg); |
||||||
|
} |
||||||
|
|
||||||
|
public static R notfound() { |
||||||
|
return new R(404, "请求地址不存在"); |
||||||
|
} |
||||||
|
|
||||||
|
public static R requireLogin() { |
||||||
|
return new R(401, "请登录后重试"); |
||||||
|
} |
||||||
|
|
||||||
|
public static R noPermission() { |
||||||
|
return new R(403, "没有权限进行该操作"); |
||||||
|
} |
||||||
|
|
||||||
|
public static R overload() { |
||||||
|
return new R(503, "当前请求的人数过多,请稍后重试"); |
||||||
|
} |
||||||
|
|
||||||
|
public static R tooManyRequest() { |
||||||
|
return new R(429, "操作过于频繁,请稍后重试"); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isSuccess() { |
||||||
|
return this.status == 200; |
||||||
|
} |
||||||
|
} |
||||||
@ -1,83 +0,0 @@ |
|||||||
package cn.toesbieya.jxc.common.model.vo; |
|
||||||
|
|
||||||
import lombok.AllArgsConstructor; |
|
||||||
import lombok.Builder; |
|
||||||
import lombok.Data; |
|
||||||
import lombok.NoArgsConstructor; |
|
||||||
|
|
||||||
import java.io.Serializable; |
|
||||||
|
|
||||||
@Data |
|
||||||
@AllArgsConstructor |
|
||||||
@NoArgsConstructor |
|
||||||
@Builder |
|
||||||
public class Result implements Serializable { |
|
||||||
private static final long serialVersionUID = 1L; |
|
||||||
|
|
||||||
//返回码,200表示成功,其他表示失败
|
|
||||||
private int status; |
|
||||||
|
|
||||||
//返回的信息
|
|
||||||
private String msg; |
|
||||||
|
|
||||||
//返回的数据
|
|
||||||
private Object data; |
|
||||||
|
|
||||||
public Result(int status) { |
|
||||||
this.status = status; |
|
||||||
} |
|
||||||
|
|
||||||
public Result(int status, String msg) { |
|
||||||
this.status = status; |
|
||||||
this.msg = msg; |
|
||||||
} |
|
||||||
|
|
||||||
public Result(int status, Object data) { |
|
||||||
this.status = status; |
|
||||||
this.data = data; |
|
||||||
} |
|
||||||
|
|
||||||
public static Result success() { |
|
||||||
return new Result(200); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result success(String msg) { |
|
||||||
return new Result(200, msg); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result success(Object data) { |
|
||||||
return new Result(200, data); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result success(String msg, Object data) { |
|
||||||
return new Result(200, msg, data); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result fail(String msg) { |
|
||||||
return new Result(500, msg); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result notfound() { |
|
||||||
return new Result(404, "请求地址不存在"); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result requireLogin() { |
|
||||||
return new Result(401, "请登录后重试"); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result noPermission() { |
|
||||||
return new Result(403, "没有权限进行该操作"); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result overload() { |
|
||||||
return new Result(503, "当前请求的人数过多,请稍后重试"); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result tooManyRequest() { |
|
||||||
return new Result(429, "操作过于频繁,请稍后重试"); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isSuccess() { |
|
||||||
return this.status == 200; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,13 +1,13 @@ |
|||||||
package cn.toesbieya.jxc.gateway.controller; |
package cn.toesbieya.jxc.gateway.controller; |
||||||
|
|
||||||
import cn.toesbieya.jxc.common.model.vo.Result; |
import cn.toesbieya.jxc.common.model.vo.R; |
||||||
import org.springframework.web.bind.annotation.RequestMapping; |
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
import org.springframework.web.bind.annotation.ResponseBody; |
import org.springframework.web.bind.annotation.ResponseBody; |
||||||
|
|
||||||
public class FallbackController { |
public class FallbackController { |
||||||
@RequestMapping("fallback") |
@RequestMapping("fallback") |
||||||
@ResponseBody |
@ResponseBody |
||||||
public Result fallback() { |
public R fallback() { |
||||||
return Result.fail("服务异常"); |
return R.fail("服务异常"); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|||||||
@ -0,0 +1,37 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="cn.toesbieya.jxc.system.mapper.SysResourceMapper"> |
||||||
|
<select id="selectChildren" resultType="cn.toesbieya.jxc.common.model.entity.SysResource"> |
||||||
|
with recursive t as ( |
||||||
|
select id, |
||||||
|
pid, |
||||||
|
type, |
||||||
|
name, |
||||||
|
path, |
||||||
|
component, |
||||||
|
meta, |
||||||
|
admin, |
||||||
|
enable |
||||||
|
from sys_resource |
||||||
|
where pid = 0 |
||||||
|
union all |
||||||
|
select c.id, |
||||||
|
c.pid, |
||||||
|
c.type, |
||||||
|
c.name, |
||||||
|
concat(t.path, '/', c.path) as path, |
||||||
|
c.component, |
||||||
|
c.meta, |
||||||
|
c.admin, |
||||||
|
if(t.enable = false, false, c.enable) enable |
||||||
|
from sys_resource c, |
||||||
|
t |
||||||
|
where c.pid = t.id |
||||||
|
) |
||||||
|
select * |
||||||
|
from t |
||||||
|
<if test="ids != null and ids != ''"> |
||||||
|
where id in (${ids}) |
||||||
|
</if> |
||||||
|
</select> |
||||||
|
</mapper> |
||||||
Binary file not shown.
@ -0,0 +1,15 @@ |
|||||||
|
package cn.toesbieya.jxc.enumeration; |
||||||
|
|
||||||
|
public enum ResourceTypeEnum { |
||||||
|
FOLDER(1), LEAF(2), API(3); |
||||||
|
|
||||||
|
private final int code; |
||||||
|
|
||||||
|
ResourceTypeEnum(int code) { |
||||||
|
this.code = code; |
||||||
|
} |
||||||
|
|
||||||
|
public int getCode() { |
||||||
|
return code; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,81 @@ |
|||||||
|
package cn.toesbieya.jxc.model.vo; |
||||||
|
|
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.Builder; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
@Data |
||||||
|
@AllArgsConstructor |
||||||
|
@Builder |
||||||
|
public class R { |
||||||
|
/** |
||||||
|
* 返回的代码,200表示成功,其他表示失败 |
||||||
|
*/ |
||||||
|
private int status; |
||||||
|
/** |
||||||
|
* 成功或失败时返回的错误信息 |
||||||
|
*/ |
||||||
|
private String msg; |
||||||
|
/** |
||||||
|
* 成功时返回的数据信息 |
||||||
|
*/ |
||||||
|
private Object data; |
||||||
|
|
||||||
|
public R(int status) { |
||||||
|
this.status = status; |
||||||
|
} |
||||||
|
|
||||||
|
public R(int status, String msg) { |
||||||
|
this.status = status; |
||||||
|
this.msg = msg; |
||||||
|
} |
||||||
|
|
||||||
|
public R(int status, Object data) { |
||||||
|
this.status = status; |
||||||
|
this.data = data; |
||||||
|
} |
||||||
|
|
||||||
|
public static R success() { |
||||||
|
return new R(200); |
||||||
|
} |
||||||
|
|
||||||
|
public static R success(String msg) { |
||||||
|
return new R(200, msg); |
||||||
|
} |
||||||
|
|
||||||
|
public static R success(Object data) { |
||||||
|
return new R(200, data); |
||||||
|
} |
||||||
|
|
||||||
|
public static R success(String msg, Object data) { |
||||||
|
return new R(200, msg, data); |
||||||
|
} |
||||||
|
|
||||||
|
public static R fail(String msg) { |
||||||
|
return new R(500, msg); |
||||||
|
} |
||||||
|
|
||||||
|
public static R notfound() { |
||||||
|
return new R(404, "请求地址不存在"); |
||||||
|
} |
||||||
|
|
||||||
|
public static R requireLogin() { |
||||||
|
return new R(401, "请登录后重试"); |
||||||
|
} |
||||||
|
|
||||||
|
public static R noPermission() { |
||||||
|
return new R(403, "没有权限进行该操作"); |
||||||
|
} |
||||||
|
|
||||||
|
public static R overload() { |
||||||
|
return new R(503, "当前请求的人数过多,请稍后重试"); |
||||||
|
} |
||||||
|
|
||||||
|
public static R tooManyRequest() { |
||||||
|
return new R(429, "操作过于频繁,请稍后重试"); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isSuccess() { |
||||||
|
return this.status == 200; |
||||||
|
} |
||||||
|
} |
||||||
@ -1,20 +0,0 @@ |
|||||||
package cn.toesbieya.jxc.model.vo; |
|
||||||
|
|
||||||
import cn.toesbieya.jxc.model.entity.SysResource; |
|
||||||
import lombok.Data; |
|
||||||
import lombok.EqualsAndHashCode; |
|
||||||
import lombok.NoArgsConstructor; |
|
||||||
import lombok.ToString; |
|
||||||
import org.springframework.beans.BeanUtils; |
|
||||||
|
|
||||||
@Data |
|
||||||
@NoArgsConstructor |
|
||||||
@ToString(callSuper = true) |
|
||||||
@EqualsAndHashCode(callSuper = true) |
|
||||||
public class ResourceVo extends SysResource { |
|
||||||
private String fullname; |
|
||||||
|
|
||||||
public ResourceVo(SysResource parent) { |
|
||||||
BeanUtils.copyProperties(parent, this); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,81 +0,0 @@ |
|||||||
package cn.toesbieya.jxc.model.vo; |
|
||||||
|
|
||||||
import lombok.AllArgsConstructor; |
|
||||||
import lombok.Builder; |
|
||||||
import lombok.Data; |
|
||||||
|
|
||||||
@Data |
|
||||||
@AllArgsConstructor |
|
||||||
@Builder |
|
||||||
public class Result { |
|
||||||
/** |
|
||||||
* 返回的代码,200表示成功,其他表示失败 |
|
||||||
*/ |
|
||||||
private int status; |
|
||||||
/** |
|
||||||
* 成功或失败时返回的错误信息 |
|
||||||
*/ |
|
||||||
private String msg; |
|
||||||
/** |
|
||||||
* 成功时返回的数据信息 |
|
||||||
*/ |
|
||||||
private Object data; |
|
||||||
|
|
||||||
public Result(int status) { |
|
||||||
this.status = status; |
|
||||||
} |
|
||||||
|
|
||||||
public Result(int status, String msg) { |
|
||||||
this.status = status; |
|
||||||
this.msg = msg; |
|
||||||
} |
|
||||||
|
|
||||||
public Result(int status, Object data) { |
|
||||||
this.status = status; |
|
||||||
this.data = data; |
|
||||||
} |
|
||||||
|
|
||||||
public static Result success() { |
|
||||||
return new Result(200); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result success(String msg) { |
|
||||||
return new Result(200, msg); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result success(Object data) { |
|
||||||
return new Result(200, data); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result success(String msg, Object data) { |
|
||||||
return new Result(200, msg, data); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result fail(String msg) { |
|
||||||
return new Result(500, msg); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result notfound() { |
|
||||||
return new Result(404, "请求地址不存在"); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result requireLogin() { |
|
||||||
return new Result(401, "请登录后重试"); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result noPermission() { |
|
||||||
return new Result(403, "没有权限进行该操作"); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result overload() { |
|
||||||
return new Result(503, "当前请求的人数过多,请稍后重试"); |
|
||||||
} |
|
||||||
|
|
||||||
public static Result tooManyRequest() { |
|
||||||
return new Result(429, "操作过于频繁,请稍后重试"); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isSuccess() { |
|
||||||
return this.status == 200; |
|
||||||
} |
|
||||||
} |
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue