清理归档下,已经迁移的逻辑
This commit is contained in:
parent
e20600f0c2
commit
ff18d2f30a
|
@ -1,71 +0,0 @@
|
|||
package cn.iocoder.common.framework.exception;
|
||||
|
||||
import cn.iocoder.common.framework.exception.enums.GlobalErrorCodeConstants;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
|
||||
/**
|
||||
* 全局异常 Exception
|
||||
*/
|
||||
public class GlobalException extends RuntimeException {
|
||||
|
||||
/**
|
||||
* 全局错误码
|
||||
*
|
||||
* @see GlobalErrorCodeConstants
|
||||
*/
|
||||
private Integer code;
|
||||
/**
|
||||
* 错误提示
|
||||
*/
|
||||
private String message;
|
||||
/**
|
||||
* 错误明细,内部调试错误
|
||||
*
|
||||
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
||||
*/
|
||||
private String detailMessage;
|
||||
|
||||
/**
|
||||
* 空构造方法,避免反序列化问题
|
||||
*/
|
||||
public GlobalException() {
|
||||
}
|
||||
|
||||
public GlobalException(ErrorCode errorCode) {
|
||||
this.code = errorCode.getCode();
|
||||
this.message = errorCode.getMessage();
|
||||
}
|
||||
|
||||
public GlobalException(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDetailMessage() {
|
||||
return detailMessage;
|
||||
}
|
||||
|
||||
public GlobalException setDetailMessage(String detailMessage) {
|
||||
this.detailMessage = detailMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GlobalException setCode(Integer code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public GlobalException setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package cn.iocoder.common.framework.exception;
|
||||
|
||||
import cn.iocoder.common.framework.exception.enums.ServiceErrorCodeRange;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
|
||||
/**
|
||||
* 业务逻辑异常 Exception
|
||||
*/
|
||||
public final class ServiceException extends RuntimeException {
|
||||
|
||||
/**
|
||||
* 业务错误码
|
||||
*
|
||||
* @see ServiceErrorCodeRange
|
||||
*/
|
||||
private Integer code;
|
||||
/**
|
||||
* 错误提示
|
||||
*/
|
||||
private String message;
|
||||
/**
|
||||
* 错误明细,内部调试错误
|
||||
*
|
||||
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
||||
*/
|
||||
private String detailMessage;
|
||||
|
||||
/**
|
||||
* 空构造方法,避免反序列化问题
|
||||
*/
|
||||
public ServiceException() {
|
||||
}
|
||||
|
||||
public ServiceException(ErrorCode errorCode) {
|
||||
this.code = errorCode.getCode();
|
||||
this.message = errorCode.getMessage();
|
||||
}
|
||||
|
||||
public ServiceException(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDetailMessage() {
|
||||
return detailMessage;
|
||||
}
|
||||
|
||||
public ServiceException setDetailMessage(String detailMessage) {
|
||||
this.detailMessage = detailMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServiceException setCode(Integer code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public ServiceException setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package cn.iocoder.common.framework.exception.enums;
|
||||
|
||||
import cn.iocoder.common.framework.exception.ErrorCode;
|
||||
|
||||
/**
|
||||
* 全局错误码枚举
|
||||
* 0-999 系统异常编码保留
|
||||
*
|
||||
* 一般情况下,使用 HTTP 响应状态码 https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Status
|
||||
* 虽然说,HTTP 响应状态码作为业务使用表达能力偏弱,但是使用在系统层面还是非常不错的
|
||||
* 比较特殊的是,因为之前一直使用 0 作为成功,就不使用 200 啦。
|
||||
*/
|
||||
public interface GlobalErrorCodeConstants {
|
||||
|
||||
ErrorCode SUCCESS = new ErrorCode(0, "成功");
|
||||
|
||||
// ========== 客户端错误段 ==========
|
||||
|
||||
ErrorCode BAD_REQUEST = new ErrorCode(400, "请求参数不正确");
|
||||
ErrorCode UNAUTHORIZED = new ErrorCode(401, "账号未登录");
|
||||
ErrorCode FORBIDDEN = new ErrorCode(403, "没有该操作权限");
|
||||
ErrorCode NOT_FOUND = new ErrorCode(404, "请求未找到");
|
||||
ErrorCode METHOD_NOT_ALLOWED = new ErrorCode(405, "请求方法不正确");
|
||||
|
||||
// ========== 服务端错误段 ==========
|
||||
|
||||
ErrorCode INTERNAL_SERVER_ERROR = new ErrorCode(500, "系统异常");
|
||||
|
||||
ErrorCode UNKNOWN = new ErrorCode(999, "未知错误");
|
||||
|
||||
static boolean isMatch(Integer code) {
|
||||
return code != null
|
||||
&& code >= SUCCESS.getCode() && code <= UNKNOWN.getCode();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package cn.iocoder.common.framework.exception.enums;
|
||||
|
||||
/**
|
||||
* 业务异常的错误码区间,解决:解决各模块错误码定义,避免重复,在此只声明不做实际使用
|
||||
*
|
||||
* 一共 10 位,分成四段
|
||||
*
|
||||
* 第一段,1 位,类型
|
||||
* 1 - 业务级别异常
|
||||
* x - 预留
|
||||
* 第二段,3 位,系统类型
|
||||
* 001 - 用户系统
|
||||
* 002 - 商品系统
|
||||
* 003 - 订单系统
|
||||
* 004 - 支付系统
|
||||
* 005 - 优惠劵系统
|
||||
* ... - ...
|
||||
* 第三段,3 位,模块
|
||||
* 不限制规则。
|
||||
* 一般建议,每个系统里面,可能有多个模块,可以再去做分段。以用户系统为例子:
|
||||
* 001 - OAuth2 模块
|
||||
* 002 - User 模块
|
||||
* 003 - MobileCode 模块
|
||||
* 第四段,3 位,错误码
|
||||
* 不限制规则。
|
||||
* 一般建议,每个模块自增。
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-23 11:28
|
||||
*/
|
||||
public class ServiceErrorCodeRange {
|
||||
|
||||
// order 错误码区间 [1-000-001-000 ~ 1-000-002-000]
|
||||
|
||||
// user 错误码区间 [1-001-000-000 ~ 1-002-000-000)
|
||||
|
||||
// system-service 服务 => 错误码区间 [1-002-000-000 ~ 1-003-000-000)
|
||||
|
||||
// product 错误码区间 [1-003-000-000 ~ 1-004-000-000)
|
||||
|
||||
// pay 错误码区间 [1-004-000-000 ~ 1-005-000-000)
|
||||
|
||||
// cart 错误码区间 [1-005-000-000 ~ 1-006-000-000)
|
||||
|
||||
// promotion 错误码区间 [1-006-000-000 ~ 1-007-000-000)
|
||||
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>common</artifactId>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>mall-security-annotations</artifactId>
|
||||
|
||||
|
||||
</project>
|
|
@ -1,18 +0,0 @@
|
|||
package cn.iocoder.security.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 要求用户认证(登陆)注解。通过将该注解添加到 Controller 上,会自动校验用户是否登陆。
|
||||
*
|
||||
* 默认请求下,用户访问的 API 接口,无需登陆。主要的考虑是,
|
||||
* 1. 需要用户登陆的接口,本身会获取在线用户的编号。如果不添加 @RequiresLogin 注解就会报错。
|
||||
* 2. 大多数情况下,用户的 API 接口无需登陆。
|
||||
*
|
||||
* ps:同样适用于管理员 Admin
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.METHOD}) // 暂时不支持 ElementType.TYPE ,因为没有场景
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface RequiresAuthenticate {
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package cn.iocoder.security.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 通过将该注解添加到 Controller 的方法上,声明无需进行登陆
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.METHOD}) // 暂时不支持 ElementType.TYPE ,因为没有场景
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface RequiresNone {
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package cn.iocoder.security.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 参考 Shiro @RequiresPermissions 设计 http://shiro.apache.org/static/1.3.2/apidocs/org/apache/shiro/authz/annotation/RequiresPermissions.html
|
||||
*
|
||||
* 通过将该注解添加到 Controller 的方法上,进行授权鉴定
|
||||
*
|
||||
* ps:目前暂时只有管理员 Admin 使用到
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.METHOD}) // 暂时不支持 ElementType.TYPE ,因为没有场景
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface RequiresPermissions {
|
||||
|
||||
/**
|
||||
* 当有多个标识时,必须全部拥有权限,才可以操作
|
||||
*
|
||||
* @return 权限标识数组
|
||||
*/
|
||||
String[] value() default {};
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>common</artifactId>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>mall-spring-boot-starter-security-admin</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- Mall 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>system-service-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring 核心 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-web</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-security-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RPC 相关 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,60 +0,0 @@
|
|||
package cn.iocoder.mall.security.admin.config;
|
||||
|
||||
import cn.iocoder.mall.security.admin.core.interceptor.AdminDemoInterceptor;
|
||||
import cn.iocoder.mall.security.admin.core.interceptor.AdminSecurityInterceptor;
|
||||
import cn.iocoder.mall.web.config.CommonWebAutoConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
@AutoConfigureAfter(CommonWebAutoConfiguration.class) // 在 CommonWebAutoConfiguration 之后自动配置,保证过滤器的顺序
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
@EnableConfigurationProperties(AdminSecurityProperties.class)
|
||||
public class AdminSecurityAutoConfiguration implements WebMvcConfigurer {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public AdminSecurityProperties adminSecurityProperties() {
|
||||
return new AdminSecurityProperties();
|
||||
}
|
||||
|
||||
// ========== 拦截器相关 ==========
|
||||
|
||||
@Bean
|
||||
public AdminSecurityInterceptor adminSecurityInterceptor() {
|
||||
return new AdminSecurityInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AdminDemoInterceptor adminDemoInterceptor() {
|
||||
return new AdminDemoInterceptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
AdminSecurityProperties properties = this.adminSecurityProperties();
|
||||
// AdminSecurityInterceptor 拦截器
|
||||
registry.addInterceptor(this.adminSecurityInterceptor())
|
||||
.excludePathPatterns(properties.getIgnorePaths())
|
||||
.excludePathPatterns(properties.getDefaultIgnorePaths());
|
||||
logger.info("[addInterceptors][加载 AdminSecurityInterceptor 拦截器完成]");
|
||||
// AdminDemoInterceptor 拦截器
|
||||
if (Boolean.TRUE.equals(properties.getDemo())) {
|
||||
registry.addInterceptor(this.adminDemoInterceptor())
|
||||
.excludePathPatterns(properties.getIgnorePaths())
|
||||
.excludePathPatterns(properties.getDefaultIgnorePaths());
|
||||
logger.info("[addInterceptors][加载 AdminDemoInterceptor 拦截器完成]");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package cn.iocoder.mall.security.admin.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("mall.security.admin")
|
||||
public class AdminSecurityProperties {
|
||||
|
||||
private static final String[] DEFAULT_IGNORE_PATHS = new String[]{
|
||||
// Swagger 相关
|
||||
"/doc.html", "/swagger-resources", "/swagger-resources/**", "/webjars/**",
|
||||
// Actuator 相关
|
||||
};
|
||||
|
||||
/**
|
||||
* 演示模式 - 默认值(关闭)
|
||||
*/
|
||||
private static final Boolean DEFAULT_DEMO = false;
|
||||
|
||||
/**
|
||||
* 自定义忽略 Path
|
||||
*/
|
||||
private String[] ignorePaths = new String[0];
|
||||
/**
|
||||
* 默认忽略 Path
|
||||
*/
|
||||
private String[] defaultIgnorePaths = DEFAULT_IGNORE_PATHS;
|
||||
/**
|
||||
* 是否开启演示模式
|
||||
*/
|
||||
private Boolean demo = DEFAULT_DEMO;
|
||||
|
||||
public String[] getIgnorePaths() {
|
||||
return ignorePaths;
|
||||
}
|
||||
|
||||
public AdminSecurityProperties setIgnorePaths(String[] ignorePaths) {
|
||||
this.ignorePaths = ignorePaths;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String[] getDefaultIgnorePaths() {
|
||||
return defaultIgnorePaths;
|
||||
}
|
||||
|
||||
public AdminSecurityProperties setDefaultIgnorePaths(String[] defaultIgnorePaths) {
|
||||
this.defaultIgnorePaths = defaultIgnorePaths;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getDemo() {
|
||||
return demo;
|
||||
}
|
||||
|
||||
public AdminSecurityProperties setDemo(Boolean demo) {
|
||||
this.demo = demo;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package cn.iocoder.mall.security.admin.core.context;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* Admin Security 上下文
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminSecurityContext {
|
||||
|
||||
/**
|
||||
* 管理员编号
|
||||
*/
|
||||
private Integer adminId;
|
||||
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package cn.iocoder.mall.security.admin.core.context;
|
||||
|
||||
/**
|
||||
* {@link AdminSecurityContext} Holder
|
||||
*
|
||||
* 参考 spring security 的 ThreadLocalSecurityContextHolderStrategy 类,简单实现。
|
||||
*/
|
||||
public class AdminSecurityContextHolder {
|
||||
|
||||
private static final ThreadLocal<AdminSecurityContext> SECURITY_CONTEXT = new ThreadLocal<>();
|
||||
|
||||
public static void setContext(AdminSecurityContext context) {
|
||||
SECURITY_CONTEXT.set(context);
|
||||
}
|
||||
|
||||
public static AdminSecurityContext getContext() {
|
||||
AdminSecurityContext ctx = SECURITY_CONTEXT.get();
|
||||
// 为空时,设置一个空的进去
|
||||
if (ctx == null) {
|
||||
ctx = new AdminSecurityContext();
|
||||
SECURITY_CONTEXT.set(ctx);
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
SECURITY_CONTEXT.remove();
|
||||
}
|
||||
|
||||
public static Integer getAdminId() {
|
||||
return getContext().getAdminId();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package cn.iocoder.mall.security.admin.core.interceptor;
|
||||
|
||||
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.mall.security.admin.core.context.AdminSecurityContextHolder;
|
||||
import cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Admin 演示拦截器
|
||||
*
|
||||
* 这是个比较“奇怪”的拦截器,用于演示的管理员账号,禁止使用 POST 请求,从而实现即达到阉割版的演示的效果,又避免影响了数据
|
||||
*/
|
||||
public class AdminDemoInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
// 当 Admin 编号等于 1 时,约定为演示账号
|
||||
// TODO 芋艿,后续去优化
|
||||
if (Objects.equals(AdminSecurityContextHolder.getAdminId(), 1)
|
||||
&& request.getMethod().equalsIgnoreCase(HttpMethod.POST.toString())) {
|
||||
throw ServiceExceptionUtil.exception(SystemErrorCodeConstants.PERMISSION_DEMO_PERMISSION_DENY);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package cn.iocoder.mall.security.admin.core.interceptor;
|
||||
|
||||
import cn.iocoder.common.framework.enums.UserTypeEnum;
|
||||
import cn.iocoder.common.framework.exception.GlobalException;
|
||||
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.util.CollectionUtils;
|
||||
import cn.iocoder.common.framework.util.HttpUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.security.admin.core.context.AdminSecurityContext;
|
||||
import cn.iocoder.mall.security.admin.core.context.AdminSecurityContextHolder;
|
||||
import cn.iocoder.mall.systemservice.rpc.oauth.OAuthFeign;
|
||||
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.PermissionFeign;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.PermissionCheckDTO;
|
||||
import cn.iocoder.mall.web.core.util.CommonWebUtil;
|
||||
import cn.iocoder.security.annotations.RequiresNone;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static cn.iocoder.common.framework.exception.enums.GlobalErrorCodeConstants.UNAUTHORIZED;
|
||||
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.OAUTH_USER_TYPE_ERROR;
|
||||
|
||||
public class AdminSecurityInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
|
||||
@Autowired
|
||||
private OAuthFeign oAuthFeign;
|
||||
@Autowired
|
||||
private PermissionFeign permissionFeign;
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
// 获得访问令牌
|
||||
Integer adminId = this.obtainAdminId(request);
|
||||
// 校验认证
|
||||
this.checkAuthentication((HandlerMethod) handler, adminId);
|
||||
// 校验权限
|
||||
this.checkPermission((HandlerMethod) handler, adminId);
|
||||
return true;
|
||||
}
|
||||
|
||||
private Integer obtainAdminId(HttpServletRequest request) {
|
||||
String accessToken = HttpUtil.obtainAuthorization(request);
|
||||
Integer adminId = null;
|
||||
if (accessToken != null) {
|
||||
CommonResult<OAuth2AccessTokenRespDTO> checkAccessTokenResult = oAuthFeign.checkAccessToken(accessToken);
|
||||
checkAccessTokenResult.checkError();
|
||||
// 校验用户类型正确
|
||||
if (!UserTypeEnum.ADMIN.getValue().equals(checkAccessTokenResult.getData().getUserType())) {
|
||||
throw ServiceExceptionUtil.exception(OAUTH_USER_TYPE_ERROR);
|
||||
}
|
||||
// 获得用户编号
|
||||
adminId = checkAccessTokenResult.getData().getUserId();
|
||||
// 设置到 Request 中
|
||||
CommonWebUtil.setUserId(request, adminId);
|
||||
CommonWebUtil.setUserType(request, UserTypeEnum.ADMIN.getValue());
|
||||
// 设置到
|
||||
AdminSecurityContext adminSecurityContext = new AdminSecurityContext().setAdminId(adminId);
|
||||
AdminSecurityContextHolder.setContext(adminSecurityContext);
|
||||
}
|
||||
return adminId;
|
||||
}
|
||||
|
||||
private void checkAuthentication(HandlerMethod handlerMethod, Integer adminId) {
|
||||
boolean requiresAuthenticate = !handlerMethod.hasMethodAnnotation(RequiresNone.class); // 对于 ADMIN 来说,默认需登录
|
||||
if (requiresAuthenticate && adminId == null) {
|
||||
throw new GlobalException(UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPermission(HandlerMethod handlerMethod, Integer adminId) {
|
||||
RequiresPermissions requiresPermissions = handlerMethod.getMethodAnnotation(RequiresPermissions.class);
|
||||
if (requiresPermissions == null) {
|
||||
return;
|
||||
}
|
||||
String[] permissions = requiresPermissions.value();
|
||||
if (CollectionUtils.isEmpty(permissions)) {
|
||||
return;
|
||||
}
|
||||
// 权限验证
|
||||
permissionFeign.checkPermission(new PermissionCheckDTO().setAdminId(adminId).setPermissions(Arrays.asList(permissions)))
|
||||
.checkError();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
||||
// 清空 SecurityContext
|
||||
AdminSecurityContextHolder.clear();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
cn.iocoder.mall.security.admin.config.AdminSecurityAutoConfiguration
|
|
@ -1,47 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>common</artifactId>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>mall-spring-boot-starter-security-user</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- Mall 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>system-service-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring 核心 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-security-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- RPC 相关 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.dubbo</groupId>
|
||||
<artifactId>dubbo</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,47 +0,0 @@
|
|||
package cn.iocoder.mall.security.user.config;
|
||||
|
||||
import cn.iocoder.mall.security.user.core.interceptor.UserSecurityInterceptor;
|
||||
import cn.iocoder.mall.web.config.CommonWebAutoConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
@AutoConfigureAfter(CommonWebAutoConfiguration.class) // 在 CommonWebAutoConfiguration 之后自动配置,保证过滤器的顺序
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
@EnableConfigurationProperties(UserSecurityProperties.class)
|
||||
public class UserSecurityAutoConfiguration implements WebMvcConfigurer {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public UserSecurityProperties userSecurityProperties() {
|
||||
return new UserSecurityProperties();
|
||||
}
|
||||
|
||||
// ========== 拦截器相关 ==========
|
||||
|
||||
@Bean
|
||||
public UserSecurityInterceptor userSecurityInterceptor() {
|
||||
return new UserSecurityInterceptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
UserSecurityProperties properties = this.userSecurityProperties();
|
||||
// UserSecurityInterceptor 拦截器
|
||||
registry.addInterceptor(this.userSecurityInterceptor())
|
||||
.excludePathPatterns(properties.getIgnorePaths())
|
||||
.excludePathPatterns(properties.getDefaultIgnorePaths());;
|
||||
logger.info("[addInterceptors][加载 UserSecurityInterceptor 拦截器完成]");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package cn.iocoder.mall.security.user.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("mall.security.user")
|
||||
public class UserSecurityProperties {
|
||||
|
||||
private static final String[] DEFAULT_IGNORE_PATHS = new String[]{
|
||||
// Swagger 相关
|
||||
"/doc.html", "/swagger-resources", "/swagger-resources/**", "/webjars/**",
|
||||
// Actuator 相关
|
||||
};
|
||||
|
||||
/**
|
||||
* 自定义忽略 Path
|
||||
*/
|
||||
private String[] ignorePaths = new String[0];
|
||||
/**
|
||||
* 默认忽略 Path
|
||||
*/
|
||||
private String[] defaultIgnorePaths = DEFAULT_IGNORE_PATHS;
|
||||
|
||||
public String[] getIgnorePaths() {
|
||||
return ignorePaths;
|
||||
}
|
||||
|
||||
public UserSecurityProperties setIgnorePaths(String[] ignorePaths) {
|
||||
this.ignorePaths = ignorePaths;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String[] getDefaultIgnorePaths() {
|
||||
return defaultIgnorePaths;
|
||||
}
|
||||
|
||||
public UserSecurityProperties setDefaultIgnorePaths(String[] defaultIgnorePaths) {
|
||||
this.defaultIgnorePaths = defaultIgnorePaths;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package cn.iocoder.mall.security.user.core.context;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* User Security 上下文
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class UserSecurityContext {
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Integer userId;
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package cn.iocoder.mall.security.user.core.context;
|
||||
|
||||
/**
|
||||
* {@link UserSecurityContext} Holder
|
||||
*
|
||||
* 参考 spring security 的 ThreadLocalSecurityContextHolderStrategy 类,简单实现。
|
||||
*/
|
||||
public class UserSecurityContextHolder {
|
||||
|
||||
private static final ThreadLocal<UserSecurityContext> SECURITY_CONTEXT = new ThreadLocal<UserSecurityContext>();
|
||||
|
||||
public static void setContext(UserSecurityContext context) {
|
||||
SECURITY_CONTEXT.set(context);
|
||||
}
|
||||
|
||||
public static UserSecurityContext getContext() {
|
||||
UserSecurityContext ctx = SECURITY_CONTEXT.get();
|
||||
// 为空时,设置一个空的进去
|
||||
if (ctx == null) {
|
||||
ctx = new UserSecurityContext();
|
||||
SECURITY_CONTEXT.set(ctx);
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
public static Integer getUserId() {
|
||||
UserSecurityContext ctx = SECURITY_CONTEXT.get();
|
||||
return ctx != null ? ctx.getUserId() : null;
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
SECURITY_CONTEXT.remove();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package cn.iocoder.mall.security.user.core.interceptor;
|
||||
|
||||
import cn.iocoder.common.framework.enums.UserTypeEnum;
|
||||
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.util.HttpUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.security.user.core.context.UserSecurityContext;
|
||||
import cn.iocoder.mall.security.user.core.context.UserSecurityContextHolder;
|
||||
import cn.iocoder.mall.systemservice.rpc.oauth.OAuthFeign;
|
||||
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO;
|
||||
import cn.iocoder.mall.web.core.util.CommonWebUtil;
|
||||
import cn.iocoder.security.annotations.RequiresAuthenticate;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import static cn.iocoder.common.framework.exception.enums.GlobalErrorCodeConstants.UNAUTHORIZED;
|
||||
import static cn.iocoder.mall.systemservice.enums.SystemErrorCodeConstants.OAUTH_USER_TYPE_ERROR;
|
||||
|
||||
public class UserSecurityInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
@Autowired
|
||||
private OAuthFeign oAuthFeign;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
// 获得访问令牌
|
||||
Integer userId = this.obtainUserId(request);
|
||||
// 校验认证
|
||||
this.checkAuthentication((HandlerMethod) handler, userId);
|
||||
return true;
|
||||
}
|
||||
|
||||
private Integer obtainUserId(HttpServletRequest request) {
|
||||
String accessToken = HttpUtil.obtainAuthorization(request);
|
||||
Integer userId = null;
|
||||
if (accessToken != null) {
|
||||
CommonResult<OAuth2AccessTokenRespDTO> checkAccessTokenResult = oAuthFeign.checkAccessToken(accessToken);
|
||||
checkAccessTokenResult.checkError();
|
||||
// 校验用户类型正确
|
||||
if (!UserTypeEnum.USER.getValue().equals(checkAccessTokenResult.getData().getUserType())) {
|
||||
throw ServiceExceptionUtil.exception(OAUTH_USER_TYPE_ERROR);
|
||||
}
|
||||
// 获得用户编号
|
||||
userId = checkAccessTokenResult.getData().getUserId();
|
||||
// 设置到 Request 中
|
||||
CommonWebUtil.setUserId(request, userId);
|
||||
CommonWebUtil.setUserType(request, UserTypeEnum.USER.getValue());
|
||||
// 设置到
|
||||
UserSecurityContext userSecurityContext = new UserSecurityContext().setUserId(userId);
|
||||
UserSecurityContextHolder.setContext(userSecurityContext);
|
||||
}
|
||||
return userId;
|
||||
}
|
||||
|
||||
private void checkAuthentication(HandlerMethod handlerMethod, Integer userId) {
|
||||
boolean requiresAuthenticate = false; // 对于 USER 来说,默认无需登录
|
||||
if (handlerMethod.hasMethodAnnotation(RequiresAuthenticate.class)
|
||||
|| handlerMethod.hasMethodAnnotation(RequiresPermissions.class)) { // 如果需要权限验证,也认为需要认证
|
||||
requiresAuthenticate = true;
|
||||
}
|
||||
if (requiresAuthenticate && userId == null) {
|
||||
throw ServiceExceptionUtil.exception(UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
||||
// 清空 SecurityContext
|
||||
UserSecurityContextHolder.clear();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
cn.iocoder.mall.security.user.config.UserSecurityAutoConfiguration
|
|
@ -1,18 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients(basePackages = {"cn.iocoder.mall.productservice.rpc","cn.iocoder.mall.payservice.rpc"
|
||||
,"cn.iocoder.mall.promotion.api.rpc","cn.iocoder.mall.systemservice.rpc","cn.iocoder.mall.userservice.rpc"})
|
||||
public class ManagementWebApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ManagementWebApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.client.pay.transaction;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.PayTransactionFeign;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionPageReqDTO;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionRespDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class PayTransactionClient {
|
||||
|
||||
|
||||
@Autowired
|
||||
private PayTransactionFeign payTransactionFeign;
|
||||
public PageResult<PayTransactionRespDTO> pagePayTransaction(PayTransactionPageReqDTO pageReqDTO) {
|
||||
CommonResult<PageResult<PayTransactionRespDTO>> pagePayTransactionResult = payTransactionFeign.pagePayTransaction(pageReqDTO);
|
||||
pagePayTransactionResult.checkError();
|
||||
return pagePayTransactionResult.getData();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
### /admin/page 成功
|
||||
GET http://127.0.0.1:18083/management-api/admin/page?pageNo=1&pageSize=10
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
### /admin/create 成功
|
||||
POST http://127.0.0.1:18083/management-api/admin/create
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
username=admin02&password=buzhidao&name=测试管理员&departmentId=1
|
||||
|
||||
### /admin/update 成功
|
||||
POST http://127.0.0.1:18083/management-api/admin/update
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
id=31&username=admin02&password=buzhidao&name=测试管理员&departmentId=1
|
||||
|
||||
### /admin/update-status 成功
|
||||
POST http://127.0.0.1:18083/management-api/admin/update-status
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
adminId=31&status=1
|
||||
|
||||
### /admin/update-status 失败,参数缺失
|
||||
POST http://127.0.0.1:18083/management-api/admin/update-status
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
adminId=31
|
||||
|
||||
### admin/update-status 失败,地址不存在
|
||||
GET http://127.0.0.1:18083/management-api/admin/update-status---
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
adminId=31&status=sss
|
||||
|
||||
###
|
|
@ -1,67 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.admin;
|
||||
|
||||
import cn.iocoder.common.framework.util.HttpUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminCreateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminPageDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminUpdateInfoDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminUpdateStatusDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.vo.AdminPageItemVO;
|
||||
import cn.iocoder.mall.managementweb.manager.admin.AdminManager;
|
||||
import cn.iocoder.mall.security.admin.core.context.AdminSecurityContextHolder;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@Api(tags = "管理员 API")
|
||||
@RestController
|
||||
@RequestMapping("/admin")
|
||||
@Validated
|
||||
public class AdminController {
|
||||
|
||||
@Autowired
|
||||
private AdminManager adminManager;
|
||||
|
||||
@ApiOperation(value = "管理员分页")
|
||||
@GetMapping("/page")
|
||||
@RequiresPermissions("system:admin:page")
|
||||
public CommonResult<PageResult<AdminPageItemVO>> page(AdminPageDTO adminPageDTO) {
|
||||
return success(adminManager.pageAdmin(adminPageDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "创建管理员")
|
||||
@PostMapping("/create")
|
||||
@RequiresPermissions("system:admin:create")
|
||||
public CommonResult<Integer> createAdmin(AdminCreateDTO createDTO, HttpServletRequest request) {
|
||||
return success(adminManager.createAdmin(createDTO, AdminSecurityContextHolder.getAdminId(), HttpUtil.getIp(request)));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "更新管理员")
|
||||
@RequiresPermissions("system:admin:update")
|
||||
public CommonResult<Boolean> updateAdmin(AdminUpdateInfoDTO updateInfoDTO) {
|
||||
adminManager.updateAdmin(updateInfoDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/update-status")
|
||||
@ApiOperation(value = "更新管理员状态")
|
||||
@RequiresPermissions("system:admin:update-status")
|
||||
public CommonResult<Boolean> updateAdminStatus(@Valid AdminUpdateStatusDTO updateStatusDTO) {
|
||||
adminManager.updateAdminStatus(updateStatusDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
### /department/create 成功
|
||||
POST http://127.0.0.1:18083/management-api/department/create
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
dubbo-tag: {{dubboTag}}
|
||||
|
||||
name=测试部门&pid=0&sort=0
|
||||
|
||||
### /department/update 成功
|
||||
POST http://127.0.0.1:18083/management-api/department/update
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
id=1&name=测试部门&pid=0&sort=0
|
||||
|
||||
### /resource/delete 成功
|
||||
POST http://127.0.0.1:18083/management-api/department/delete
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
id=1
|
||||
|
||||
### /department/get 成功
|
||||
GET http://127.0.0.1:18083/management-api/department/get?departmentId=1
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
### /department/list 成功
|
||||
GET http://127.0.0.1:18083/management-api/department/list?departmentIds=1,13
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
### /department/tree 成功
|
||||
GET http://127.0.0.1:18083/management-api/department/tree
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
###
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.admin;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.DepartmentCreateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.DepartmentUpdateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.vo.DepartmentTreeNodeVO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.vo.DepartmentVO;
|
||||
import cn.iocoder.mall.managementweb.manager.admin.DepartmentManager;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 部门 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/department")
|
||||
@Api(tags = "部门")
|
||||
@Validated
|
||||
public class DepartmentController {
|
||||
|
||||
@Autowired
|
||||
private DepartmentManager departmentManager;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建部门")
|
||||
@RequiresPermissions("system:department:create")
|
||||
public CommonResult<Integer> createDepartment(@Valid DepartmentCreateDTO createDTO) {
|
||||
return success(departmentManager.createDepartment(createDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新部门")
|
||||
@RequiresPermissions("system:department:update")
|
||||
public CommonResult<Boolean> updateDepartment(@Valid DepartmentUpdateDTO updateDTO) {
|
||||
departmentManager.updateDepartment(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除部门")
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门编号", required = true)
|
||||
@RequiresPermissions("system:department:delete")
|
||||
public CommonResult<Boolean> deleteDepartment(@RequestParam("departmentId") Integer departmentId) {
|
||||
departmentManager.deleteDepartment(departmentId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得部门")
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门编号", required = true)
|
||||
@RequiresPermissions("system:department:tree")
|
||||
public CommonResult<DepartmentVO> getDepartment(@RequestParam("departmentId") Integer departmentId) {
|
||||
return success(departmentManager.getDepartment(departmentId));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得部门列表")
|
||||
@ApiImplicitParam(name = "departmentIds", value = "部门编号列表", required = true)
|
||||
@RequiresPermissions("system:department:tree")
|
||||
public CommonResult<List<DepartmentVO>> listDepartments(@RequestParam("departmentIds") List<Integer> departmentIds) {
|
||||
return success(departmentManager.listDepartments(departmentIds));
|
||||
}
|
||||
|
||||
@GetMapping("/tree")
|
||||
@ApiOperation("获得部门树")
|
||||
@RequiresPermissions("system:department:tree")
|
||||
public CommonResult<List<DepartmentTreeNodeVO>> treeDepartment() {
|
||||
return success(departmentManager.treeDepartment());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.admin.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@ApiModel("管理员创建 DTO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminCreateDTO {
|
||||
|
||||
@ApiModelProperty(value = "真实名字", required = true, example = "小王")
|
||||
@NotEmpty(message = "真实名字不能为空")
|
||||
@Length(max = 10, message = "真实名字长度最大为 10 位")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "部门编号", required = true, example = "1")
|
||||
@NotNull(message = "部门不能为空")
|
||||
private Integer departmentId;
|
||||
|
||||
@ApiModelProperty(value = "登陆账号", required = true, example = "15601691300")
|
||||
@NotEmpty(message = "登陆账号不能为空")
|
||||
@Length(min = 5, max = 16, message = "账号长度为 5-16 位")
|
||||
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "密码", required = true, example = "buzhidao")
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
private String password;
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.admin.dto;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@ApiModel("管理员分页查询 DTO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class AdminPageDTO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "真实名字,模糊匹配", example = "小王")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "部门编号")
|
||||
private Integer departmentId;
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.admin.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@ApiModel("管理员更新信息 DTO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminUpdateInfoDTO {
|
||||
|
||||
@ApiModelProperty(value = "管理员编号", required = true, example = "1")
|
||||
@NotNull(message = "管理员编号不能为空")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "登陆账号", required = true, example = "15601691300")
|
||||
@NotEmpty(message = "登陆账号不能为空")
|
||||
@Length(min = 5, max = 16, message = "账号长度为 5-16 位")
|
||||
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "密码", required = true, example = "buzhidao")
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "真实名字", required = true, example = "小王")
|
||||
@NotEmpty(message = "真实名字不能为空")
|
||||
@Length(max = 10, message = "真实名字长度最大为 10 位")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "部门编号", required = true, example = "1")
|
||||
@NotNull(message = "部门不能为空")
|
||||
private Integer departmentId;
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.admin.dto;
|
||||
|
||||
import cn.iocoder.common.framework.enums.CommonStatusEnum;
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("管理员更新状态 DTO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminUpdateStatusDTO {
|
||||
|
||||
@ApiModelProperty(value = "管理员编号", required = true, example = "1")
|
||||
@NotNull(message = "管理员编号不能为空")
|
||||
private Integer adminId;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.admin.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("部门创建 DTO")
|
||||
@Data
|
||||
public class DepartmentCreateDTO {
|
||||
|
||||
@ApiModelProperty(value = "部门名称", required = true, example = "技术部")
|
||||
@NotEmpty(message = "部门名称不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "排序字段", required = true, example = "1024")
|
||||
@NotNull(message = "排序字段不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "父级部门编号", required = true, example = "2048")
|
||||
@NotNull(message = "父级部门编号不能为空")
|
||||
private Integer pid;
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.admin.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("部门更新 DTO")
|
||||
@Data
|
||||
public class DepartmentUpdateDTO {
|
||||
|
||||
@ApiModelProperty(value = "部门编号", required = true, example = "1")
|
||||
@NotNull(message = "部门编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "部门名称", required = true, example = "技术部")
|
||||
@NotEmpty(message = "部门名称不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "排序字段", required = true, example = "1024")
|
||||
@NotNull(message = "排序字段不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "父级部门编号", required = true, example = "2048")
|
||||
@NotNull(message = "父级部门编号不能为空")
|
||||
private Integer pid;
|
||||
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.admin.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "分页时,管理员的信息 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminPageItemVO {
|
||||
|
||||
@ApiModel("角色")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Role {
|
||||
|
||||
@ApiModelProperty(value = "角色编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "角色名", required = true, example = "码神")
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
||||
@ApiModel("部门")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Department {
|
||||
|
||||
@ApiModelProperty(value = "部门编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "部门名称", required = true, example = "研发部")
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "管理员编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "真实名字", required = true, example = "小王")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
@ApiModelProperty(value = "在职状态", required = true, example = "1", notes = "见 AdminStatusEnum 枚举")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "登陆账号", required = true, example = "15601691300")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 角色列表
|
||||
*/
|
||||
private List<Role> roles;
|
||||
/**
|
||||
* 所在部门
|
||||
*/
|
||||
private Department department;
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.admin.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel(value = "管理员 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminVO {
|
||||
|
||||
@ApiModelProperty(value = "管理员编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "真实名字", required = true, example = "小王")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
@ApiModelProperty(value = "在职状态", required = true, example = "1", notes = "见 AdminStatusEnum 枚举")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "登陆账号", required = true, example = "15601691300")
|
||||
private String username;
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.admin.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("部门树节点 VO")
|
||||
@Data
|
||||
public class DepartmentTreeNodeVO {
|
||||
|
||||
@ApiModelProperty(value = "部门编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "部门名称", required = true, example = "技术部")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "排序字段", required = true, example = "1024")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "父级部门编号", required = true, example = "2048")
|
||||
private Integer pid;
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
private List<DepartmentTreeNodeVO> children;
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.admin.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.*;
|
||||
|
||||
@ApiModel("部门 VO")
|
||||
@Data
|
||||
public class DepartmentVO {
|
||||
|
||||
@ApiModelProperty(value = "部门编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "部门名称", required = true, example = "技术部")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "排序字段", required = true, example = "1024")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "父级部门编号", required = true, example = "2048")
|
||||
private Integer pid;
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.datadict;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.controller.datadict.dto.DataDictCreateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.datadict.dto.DataDictUpdateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.datadict.vo.DataDictSimpleVO;
|
||||
import cn.iocoder.mall.managementweb.controller.datadict.vo.DataDictVO;
|
||||
import cn.iocoder.mall.managementweb.manager.datadict.DataDictManager;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 数据字典 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/data-dict")
|
||||
@Api(tags = "数据字典")
|
||||
@Validated
|
||||
public class DataDictController {
|
||||
|
||||
@Autowired
|
||||
private DataDictManager dataDictManager;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建数据字典")
|
||||
@RequiresPermissions("system:data-dict:create")
|
||||
public CommonResult<Integer> createDataDict(@Valid DataDictCreateDTO createDTO) {
|
||||
return success(dataDictManager.createDataDict(createDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新数据字典")
|
||||
@RequiresPermissions("system:data-dict:update")
|
||||
public CommonResult<Boolean> updateDataDict(@Valid DataDictUpdateDTO updateDTO) {
|
||||
dataDictManager.updateDataDict(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除数据字典")
|
||||
@ApiImplicitParam(name = "dataDictId", value = "数据字典编号", required = true)
|
||||
@RequiresPermissions("system:data-dict:delete")
|
||||
public CommonResult<Boolean> deleteDataDict(@RequestParam("dataDictId") Integer dataDictId) {
|
||||
dataDictManager.deleteDataDict(dataDictId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得数据字典")
|
||||
@ApiImplicitParam(name = "dataDictId", value = "数据字典编号", required = true)
|
||||
@RequiresPermissions("system:data-dict:list")
|
||||
public CommonResult<DataDictVO> getDataDict(@RequestParam("dataDictId") Integer dataDictId) {
|
||||
return success(dataDictManager.getDataDict(dataDictId));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得数据字典列表")
|
||||
@ApiImplicitParam(name = "dataDictIds", value = "数据字典编号列表", required = true)
|
||||
@RequiresPermissions("system:data-dict:list")
|
||||
public CommonResult<List<DataDictVO>> listDataDicts(@RequestParam("dataDictIds") List<Integer> dataDictIds) {
|
||||
return success(dataDictManager.listDataDicts(dataDictIds));
|
||||
}
|
||||
|
||||
@GetMapping("/list-all")
|
||||
@ApiOperation("获得全部数据字典列表")
|
||||
@RequiresPermissions("system:data-dict:list")
|
||||
public CommonResult<List<DataDictVO>> listDataDicts() {
|
||||
return success(dataDictManager.listDataDicts());
|
||||
}
|
||||
|
||||
@GetMapping("/list-all-simple")
|
||||
@ApiOperation(value = "获得全部数据字典列表", notes = "一般用于管理后台缓存数据字典在本地")
|
||||
// 无需添加权限认证,因为前端全局都需要
|
||||
public CommonResult<List<DataDictSimpleVO>> listSimpleDataDicts() {
|
||||
return success(dataDictManager.listSimpleDataDicts());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.datadict.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("数据字典创建 DTO")
|
||||
@Data
|
||||
public class DataDictCreateDTO {
|
||||
|
||||
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
|
||||
@NotEmpty(message = "大类枚举值不能为空")
|
||||
private String enumValue;
|
||||
@ApiModelProperty(value = "小类数值", required = true, example = "1")
|
||||
@NotEmpty(message = "小类数值不能为空")
|
||||
private String value;
|
||||
@ApiModelProperty(value = "展示名", required = true, example = "男")
|
||||
@NotEmpty(message = "展示名不能为空")
|
||||
private String displayName;
|
||||
@ApiModelProperty(value = "排序值", required = true, example = "1")
|
||||
@NotNull(message = "排序值不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "备注", example = "性别 - 男(嗨)")
|
||||
private String memo;
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.datadict.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("数据字典更新 DTO")
|
||||
@Data
|
||||
public class DataDictUpdateDTO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
|
||||
@NotEmpty(message = "大类枚举值不能为空")
|
||||
private String enumValue;
|
||||
@ApiModelProperty(value = "小类数值", required = true, example = "1")
|
||||
@NotEmpty(message = "小类数值不能为空")
|
||||
private String value;
|
||||
@ApiModelProperty(value = "展示名", required = true, example = "男")
|
||||
@NotEmpty(message = "展示名不能为空")
|
||||
private String displayName;
|
||||
@ApiModelProperty(value = "排序值", required = true, example = "1")
|
||||
@NotNull(message = "排序值不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "备注", example = "性别 - 男(嗨)")
|
||||
private String memo;
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.datadict.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@ApiModel("数据字典精简 VO")
|
||||
@Data
|
||||
public class DataDictSimpleVO {
|
||||
|
||||
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
|
||||
private String enumValue;
|
||||
@ApiModelProperty(value = "小类数值", required = true, example = "1")
|
||||
private String value;
|
||||
@ApiModelProperty(value = "展示名", required = true, example = "男")
|
||||
private String displayName;
|
||||
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.datadict.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.*;
|
||||
|
||||
@ApiModel("数据字典 VO")
|
||||
@Data
|
||||
public class DataDictVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "大类枚举值", required = true, example = "gender")
|
||||
@NotEmpty(message = "大类枚举值不能为空")
|
||||
private String enumValue;
|
||||
@ApiModelProperty(value = "小类数值", required = true, example = "1")
|
||||
@NotEmpty(message = "小类数值不能为空")
|
||||
private String value;
|
||||
@ApiModelProperty(value = "展示名", required = true, example = "男")
|
||||
@NotEmpty(message = "展示名不能为空")
|
||||
private String displayName;
|
||||
@ApiModelProperty(value = "排序值", required = true, example = "1")
|
||||
@NotNull(message = "排序值不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "备注", example = "性别 - 男(嗨)")
|
||||
private String memo;
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.errorcode;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodeCreateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodePageDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodeUpdateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.errorcode.vo.ErrorCodeVO;
|
||||
import cn.iocoder.mall.managementweb.manager.errorcode.ErrorCodeManager;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 错误码 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/error-code")
|
||||
@Api(tags = "错误码")
|
||||
@Validated
|
||||
public class ErrorCodeController {
|
||||
|
||||
@Autowired
|
||||
private ErrorCodeManager errorCodeManager;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建错误码")
|
||||
@RequiresPermissions("system:error-code:create")
|
||||
public CommonResult<Integer> createErrorCode(@Valid ErrorCodeCreateDTO createDTO) {
|
||||
return success(errorCodeManager.createErrorCode(createDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新错误码")
|
||||
@RequiresPermissions("system:error-code:update")
|
||||
public CommonResult<Boolean> updateErrorCode(@Valid ErrorCodeUpdateDTO updateDTO) {
|
||||
errorCodeManager.updateErrorCode(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除错误码")
|
||||
@ApiImplicitParam(name = "errorCodeId", value = "错误码编号", required = true)
|
||||
@RequiresPermissions("system:error-code:delete")
|
||||
public CommonResult<Boolean> deleteErrorCode(@RequestParam("errorCodeId") Integer errorCodeId) {
|
||||
errorCodeManager.deleteErrorCode(errorCodeId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得错误码")
|
||||
@ApiImplicitParam(name = "errorCodeId", value = "错误码编号", required = true)
|
||||
@RequiresPermissions("system:error-code:page")
|
||||
public CommonResult<ErrorCodeVO> getErrorCode(@RequestParam("errorCodeId") Integer errorCodeId) {
|
||||
return success(errorCodeManager.getErrorCode(errorCodeId));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得错误码分页")
|
||||
@RequiresPermissions("system:error-code:page")
|
||||
public CommonResult<PageResult<ErrorCodeVO>> pageErrorCode(ErrorCodePageDTO pageDTO) {
|
||||
return success(errorCodeManager.pageErrorCode(pageDTO));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.errorcode.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("错误码创建 DTO")
|
||||
@Data
|
||||
public class ErrorCodeCreateDTO {
|
||||
|
||||
@ApiModelProperty(value = "错误码编码", required = true, example = "10086")
|
||||
@NotNull(message = "错误码编码不能为空")
|
||||
private Integer code;
|
||||
@ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑")
|
||||
@NotEmpty(message = "错误码错误提示不能为空")
|
||||
private String message;
|
||||
@ApiModelProperty(value = "错误码分组", required = true, example = "user-service")
|
||||
@NotEmpty(message = "错误码分组不能为空")
|
||||
private String group;
|
||||
@ApiModelProperty(value = "错误码备注", example = "我就是一个备注")
|
||||
private String memo;
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.errorcode.dto;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ApiModel("错误码分页 DTO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ErrorCodePageDTO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "错误码编码", required = true)
|
||||
private Integer code;
|
||||
@ApiModelProperty(value = "错误码错误提示", required = true)
|
||||
private String message;
|
||||
@ApiModelProperty(value = "错误码分组", required = true)
|
||||
private String group;
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.errorcode.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("错误码更新 DTO")
|
||||
@Data
|
||||
public class ErrorCodeUpdateDTO {
|
||||
|
||||
@ApiModelProperty(value = "错误码编号", required = true, example = "1")
|
||||
@NotNull(message = "错误码编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "错误码编码", required = true, example = "10086")
|
||||
@NotNull(message = "错误码编码不能为空")
|
||||
private Integer code;
|
||||
@ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑")
|
||||
@NotEmpty(message = "错误码错误提示不能为空")
|
||||
private String message;
|
||||
@ApiModelProperty(value = "错误码分组", required = true, example = "user-service")
|
||||
@NotEmpty(message = "错误码分组不能为空")
|
||||
private String group;
|
||||
@ApiModelProperty(value = "错误码备注", example = "我就是一个备注")
|
||||
private String memo;
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.errorcode.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("错误码 VO")
|
||||
@Data
|
||||
public class ErrorCodeVO {
|
||||
|
||||
@ApiModelProperty(value = "错误码编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "错误码编码", required = true, example = "10086")
|
||||
private Integer code;
|
||||
@ApiModelProperty(value = "错误码错误提示", required = true, example = "艿艿长的丑")
|
||||
private String message;
|
||||
@ApiModelProperty(value = "错误码类型", required = true, notes = "见 ErrorCodeTypeEnum 枚举", example = "1")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "错误码分组", required = true, example = "user-service")
|
||||
private String group;
|
||||
@ApiModelProperty(value = "错误码备注", example = "我就是一个备注")
|
||||
private String memo;
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
### /passport/login 成功
|
||||
POST http://127.0.0.1:18083/management-api/passport/login
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
username=admin&password=buzhidao
|
||||
|
||||
### /passport/login 密码不正确
|
||||
POST http://127.0.0.1:18083/management-api/passport/login
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
username=admin&password=1024
|
||||
|
||||
### /passport/login 少传参数
|
||||
POST http://127.0.0.1:18083/management-api/passport/login
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
username=admin
|
||||
|
||||
### /passport/info 成功
|
||||
GET http://127.0.0.1:18083/management-api/passport/info
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
### /passport/tree-admin-menu 成功
|
||||
GET http://127.0.0.1:18083/management-api/passport/tree-admin-menu
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
### /passport/list-admin-permission 成功
|
||||
GET http://127.0.0.1:18083/management-api/passport/list-admin-permission
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
#Authorization: Bearer yudaoyuanma
|
||||
Authorization: Bearer 36dce986276b4d6c8f9f4f3b89b22810
|
||||
|
||||
###
|
|
@ -1,67 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.passport;
|
||||
|
||||
import cn.iocoder.common.framework.util.HttpUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.controller.passport.dto.PassportLoginDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.passport.vo.PassportAccessTokenVO;
|
||||
import cn.iocoder.mall.managementweb.controller.passport.vo.PassportAdminMenuTreeNodeVO;
|
||||
import cn.iocoder.mall.managementweb.controller.passport.vo.PassportAdminVO;
|
||||
import cn.iocoder.mall.managementweb.manager.passport.PassportManager;
|
||||
import cn.iocoder.mall.security.admin.core.context.AdminSecurityContextHolder;
|
||||
import cn.iocoder.security.annotations.RequiresNone;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@Api(tags = "管理员 Passport API")
|
||||
@RestController
|
||||
@RequestMapping("/passport")
|
||||
public class PassportController {
|
||||
|
||||
@Autowired
|
||||
private PassportManager passportManager;
|
||||
|
||||
@PostMapping("/login")
|
||||
@ApiOperation("账号密码登陆")
|
||||
@RequiresNone
|
||||
public CommonResult<PassportAccessTokenVO> login(PassportLoginDTO loginDTO,
|
||||
HttpServletRequest request) {
|
||||
return success(passportManager.login(loginDTO, HttpUtil.getIp(request)));
|
||||
}
|
||||
|
||||
@GetMapping("/info")
|
||||
@ApiOperation(value = "获得当前管理员信息")
|
||||
public CommonResult<PassportAdminVO> getInfo() {
|
||||
return success(passportManager.getAdmin(AdminSecurityContextHolder.getAdminId()));
|
||||
}
|
||||
|
||||
@PostMapping("/refresh-token")
|
||||
@ApiOperation("刷新令牌")
|
||||
@RequiresNone
|
||||
public CommonResult<PassportAccessTokenVO> refreshToken(@RequestParam("refreshToken") String refreshToken,
|
||||
HttpServletRequest request) {
|
||||
return success(passportManager.refreshToken(refreshToken, HttpUtil.getIp(request)));
|
||||
}
|
||||
|
||||
// TODO 优化点:迁移到 PermissionController
|
||||
@GetMapping("/tree-admin-menu")
|
||||
@ApiOperation("获得当前管理员的菜单树")
|
||||
public CommonResult<List<PassportAdminMenuTreeNodeVO>> treeAdminMenu() {
|
||||
return success(passportManager.treeAdminMenu(AdminSecurityContextHolder.getAdminId()));
|
||||
}
|
||||
|
||||
// TODO 优化点:迁移到 PermissionController
|
||||
@GetMapping("/list-admin-permission")
|
||||
@ApiOperation("获得当前管理员的权限列表")
|
||||
public CommonResult<Set<String>> listAdminPermission() {
|
||||
return success(passportManager.listAdminPermission(AdminSecurityContextHolder.getAdminId()));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.passport.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel("管理登录 DTO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PassportLoginDTO implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "用户名", required = true, example = "yudaoyuanma")
|
||||
@NotEmpty(message = "登陆账号不能为空")
|
||||
@Length(min = 5, max = 16, message = "账号长度为 5-16 位")
|
||||
@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
|
||||
private String username;
|
||||
|
||||
@ApiModelProperty(value = "密码", required = true, example = "buzhidao")
|
||||
@NotEmpty(message = "密码不能为空")
|
||||
@Length(min = 4, max = 16, message = "密码长度为 4-16 位")
|
||||
private String password;
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.passport.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("访问令牌信息 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PassportAccessTokenVO {
|
||||
|
||||
@ApiModelProperty(value = "访问令牌", required = true, example = "001e8f49b20e47f7b3a2de774497cd50")
|
||||
private String accessToken;
|
||||
@ApiModelProperty(value = "刷新令牌", required = true, example = "001e8f49b20e47f7b3a2de774497cd50")
|
||||
private String refreshToken;
|
||||
@ApiModelProperty(value = "过期时间", required = true)
|
||||
private Date expiresTime;
|
||||
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.passport.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "管理员拥有的菜单树", description = "一般用于首页菜单")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PassportAdminMenuTreeNodeVO {
|
||||
|
||||
@ApiModelProperty(value = "菜单编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "菜单名", required = true, example = "商品管理")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "前端路由", required = true, example = "/order/list")
|
||||
private String route;
|
||||
@ApiModelProperty(value = "菜单图标", required = true, example = "user")
|
||||
private String icon;
|
||||
@ApiModelProperty(value = "前端界面", example = "@/views/example/edit")
|
||||
private String view;
|
||||
@ApiModelProperty(value = "父级资源编号", required = true, example = "1", notes = "如果无父资源,则值为 0")
|
||||
private Integer pid;
|
||||
|
||||
/**
|
||||
* 子节点数组
|
||||
*/
|
||||
private List<PassportAdminMenuTreeNodeVO> children;
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.passport.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@ApiModel("管理员信息 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PassportAdminVO {
|
||||
|
||||
@ApiModelProperty(value = "真实名字", required = true, example = "小王")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "头像", required = true, example = "http://www.iocoder.cn/xxx.jpg")
|
||||
private String avatar;
|
||||
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
### /product-spu/page 成功(全部)
|
||||
GET http://127.0.0.1:18083/management-api/pay/transaction/page?pageNo=1&pageSize=10
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
dubbo-tag: {{dubboTag}}
|
||||
|
||||
###
|
|
@ -1,38 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.pay;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.pay.vo.transaction.PayTransactionPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.pay.vo.transaction.PayTransactionRespVO;
|
||||
import cn.iocoder.mall.managementweb.service.pay.transaction.PayTransactionService;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@Api("支付交易单 API")
|
||||
@RestController
|
||||
@RequestMapping("/pay/transaction")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class PayTransactionController {
|
||||
|
||||
@Autowired
|
||||
private PayTransactionService payTransactionService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@RequiresPermissions("pay:transaction:page")
|
||||
@ApiOperation("获得交易支付单分页")
|
||||
public CommonResult<PageResult<PayTransactionRespVO>> pagePayTransaction(PayTransactionPageReqVO pageReqVO) {
|
||||
// 执行查询
|
||||
return success(payTransactionService.pagePayTransaction(pageReqVO));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.pay.vo.transaction;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("支付交易分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class PayTransactionPageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "创建时间(开始)", example = "2019-10-10 11:12:13")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createBeginTime;
|
||||
@ApiModelProperty(value = "创建时间(结束)", example = "2019-10-10 11:12:13")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createEndTime;
|
||||
|
||||
@ApiModelProperty(value = "创建时间()", example = "2019-10-10 11:12:13")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date paymentBeginTime;
|
||||
@ApiModelProperty(value = "创建时间()", example = "2019-10-10 11:12:13")
|
||||
private Date paymentEndTime;
|
||||
|
||||
@ApiModelProperty(value = "支付状态", example = "1", notes = "参见 PayTransactionStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否退款", example = "true")
|
||||
private Boolean hasRefund;
|
||||
|
||||
@ApiModelProperty(value = "支付渠道", example = "1", notes = "参见 PayChannelEnum 枚举")
|
||||
private Integer payChannel;
|
||||
|
||||
@ApiModelProperty(value = "商品标题", example = "芋头")
|
||||
private String orderSubject;
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.pay.vo.transaction;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("支付交易单 Response VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayTransactionRespVO {
|
||||
|
||||
@ApiModelProperty(value = "交易编号", required = true, example = "POd4RC6a")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "1024")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "应用编号", required = true, example = "POd4RC6a")
|
||||
private String appId;
|
||||
|
||||
@ApiModelProperty(value = "发起交易的 IP", required = true, example = "192.168.10.1")
|
||||
private String createIp;
|
||||
|
||||
@ApiModelProperty(value = "订单号不能为空", required = true, example = "1024")
|
||||
private String orderId;
|
||||
|
||||
@ApiModelProperty(value = "商品名", required = true, example = "芋道源码")
|
||||
private String orderSubject;
|
||||
|
||||
@ApiModelProperty(value = "订单商品描述", required = true, example = "绵啾啾的")
|
||||
private String orderDescription;
|
||||
|
||||
@ApiModelProperty(value = "订单商品备注", example = "绵啾啾的")
|
||||
private String orderMemo;
|
||||
|
||||
@ApiModelProperty(value = "支付金额,单位:分。", required = true, example = "10")
|
||||
private Integer price;
|
||||
|
||||
@ApiModelProperty(value = "订单状态", required = true, example = "1", notes = "参见 PayTransactionStatusEnum 枚举")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "交易过期时间", required = true)
|
||||
private Date expireTime;
|
||||
|
||||
@ApiModelProperty(value = "回调业务线完成时间")
|
||||
private Date finishTime;
|
||||
|
||||
@ApiModelProperty(value = "成功支付的交易拓展编号", example = "1024")
|
||||
private Integer extensionId;
|
||||
|
||||
@ApiModelProperty(value = "支付成功的支付渠道", example = "1", notes = "参见 PayChannelEnum 枚举")
|
||||
private Integer payChannel;
|
||||
|
||||
@ApiModelProperty(value = "第三方支付成功的时间")
|
||||
private Date paymentTime;
|
||||
|
||||
@ApiModelProperty(value = "收到第三方系统通知的时间")
|
||||
private Date notifyTime;
|
||||
|
||||
@ApiModelProperty(value = "第三方的流水号", example = "11122233344444")
|
||||
private String tradeNo;
|
||||
|
||||
@ApiModelProperty(value = "添加时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
// ========== 退款相关 ==========
|
||||
|
||||
@ApiModelProperty(value = "退款总金额,单位:分", example = "100")
|
||||
private Integer refundTotal;
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
### /permission/list 成功
|
||||
GET http://127.0.0.1:18083/management-api/permission/list-role-resource?roleId=1
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
### /permission/list-admin-roles 成功
|
||||
GET http://127.0.0.1:18083/management-api/permission/list-admin-roles?adminId=1
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
###
|
|
@ -1,66 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.dto.PermissionAssignAdminRoleDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.dto.PermissionAssignRoleResourceDTO;
|
||||
import cn.iocoder.mall.managementweb.manager.permission.PermissionManager;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 权限 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/permission")
|
||||
@Api(tags = "权限")
|
||||
@Validated
|
||||
public class PermissionController {
|
||||
|
||||
@Autowired
|
||||
private PermissionManager permissionManager;
|
||||
|
||||
@GetMapping("/list-role-resources")
|
||||
@ApiOperation("获得角色拥有的资源编号")
|
||||
@ApiImplicitParam(name = "roleId", value = "角色编号", required = true)
|
||||
@RequiresPermissions("system:permission:assign-role-resource")
|
||||
public CommonResult<Set<Integer>> listRoleResources(Integer roleId) {
|
||||
return success(permissionManager.listRoleResources(roleId));
|
||||
}
|
||||
|
||||
@PostMapping("/assign-role-resource")
|
||||
@ApiOperation("赋予角色资源")
|
||||
@RequiresPermissions("system:permission:assign-role-resource")
|
||||
public CommonResult<Boolean> assignRoleResource(PermissionAssignRoleResourceDTO assignRoleResourceDTO) {
|
||||
permissionManager.assignRoleResource(assignRoleResourceDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/list-admin-roles")
|
||||
@ApiOperation("获得管理员拥有的角色编号列表")
|
||||
@RequiresPermissions("system:permission:assign-admin-role")
|
||||
@ApiImplicitParam(name = "adminId", value = "管理员编号", required = true)
|
||||
public CommonResult<Set<Integer>> listAdminRoles(Integer adminId) {
|
||||
return success(permissionManager.listAdminRoles(adminId));
|
||||
}
|
||||
|
||||
@PostMapping("/assign-admin-role")
|
||||
@ApiOperation("赋予用户角色")
|
||||
@RequiresPermissions("system:permission:assign-admin-role")
|
||||
public CommonResult<Boolean> assignAdminRole(PermissionAssignAdminRoleDTO assignAdminRoleDTO) {
|
||||
permissionManager.assignAdminRole(assignAdminRoleDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
### /resource/create 成功
|
||||
POST http://127.0.0.1:18083/management-api/resource/create
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
name=测试菜单&permission=resource:add&type=1&sort=1&pid=0&route=/resource/list&icon=test
|
||||
|
||||
### /admin/update 成功
|
||||
POST http://127.0.0.1:18083/management-api/resource/update
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
id=61&name=测试菜单2&permission=resource:add&type=1&sort=1&pid=0&route=/resource/list&icon=test
|
||||
|
||||
### /resource/delete 成功
|
||||
POST http://127.0.0.1:18083/management-api/resource/delete
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
resourceId=61
|
||||
|
||||
### /resource/get 成功
|
||||
GET http://127.0.0.1:18083/management-api/resource/get?resourceId=61
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
### /resource/list 成功
|
||||
GET http://127.0.0.1:18083/management-api/resource/list?resourceIds=61,63
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
### /resource/tree 成功
|
||||
GET http://127.0.0.1:18083/management-api/resource/tree
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
###
|
|
@ -1,81 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.dto.ResourceCreateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.dto.ResourceUpdateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.vo.ResourceTreeNodeVO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.vo.ResourceVO;
|
||||
import cn.iocoder.mall.managementweb.manager.permission.ResourceManager;
|
||||
import cn.iocoder.mall.security.admin.core.context.AdminSecurityContextHolder;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 资源 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/resource")
|
||||
@Api(tags = "资源")
|
||||
@Validated
|
||||
public class ResourceController {
|
||||
|
||||
@Autowired
|
||||
private ResourceManager resourceManager;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建资源")
|
||||
@RequiresPermissions("system:resource:create")
|
||||
public CommonResult<Integer> createResource(@Valid ResourceCreateDTO createDTO) {
|
||||
return success(resourceManager.createResource(createDTO, AdminSecurityContextHolder.getAdminId()));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新资源")
|
||||
@RequiresPermissions("system:resource:update")
|
||||
public CommonResult<Boolean> updateResource(@Valid ResourceUpdateDTO updateDTO) {
|
||||
resourceManager.updateResource(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除资源")
|
||||
@ApiImplicitParam(name = "resourceId", value = "资源编号", required = true)
|
||||
@RequiresPermissions("system:resource:delete")
|
||||
public CommonResult<Boolean> deleteResource(@RequestParam("resourceId") Integer resourceId) {
|
||||
resourceManager.deleteResource(resourceId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得资源")
|
||||
@RequiresPermissions("system:resource:tree")
|
||||
public CommonResult<ResourceVO> getResource(@RequestParam("resourceId") Integer resourceId) {
|
||||
return success(resourceManager.getResource(resourceId));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得资源列表")
|
||||
@ApiImplicitParam(name = "resourceIds", value = "资源编号列表", required = true)
|
||||
@RequiresPermissions("system:resource:tree")
|
||||
public CommonResult<List<ResourceVO>> listResources(@RequestParam("resourceIds") List<Integer> resourceIds) {
|
||||
return success(resourceManager.listResources(resourceIds));
|
||||
}
|
||||
|
||||
@GetMapping("/tree")
|
||||
@ApiOperation("获得资源树")
|
||||
@RequiresPermissions("system:resource:tree")
|
||||
public CommonResult<List<ResourceTreeNodeVO>> treeResource() {
|
||||
return success(resourceManager.treeResource());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
### /role/create 成功
|
||||
POST http://127.0.0.1:18083/management-api/role/create
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
#Authorization: Bearer 9d250d9b6c034a6c88bf4034cdf1d4cc
|
||||
|
||||
name=测试角色
|
||||
|
||||
### /role/update 成功
|
||||
POST http://127.0.0.1:18083/management-api/role/update
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
id=14&name=test
|
||||
|
||||
### /resource/delete 成功
|
||||
POST http://127.0.0.1:18083/management-api/role/delete
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
roleId=14
|
||||
|
||||
### /role/get 成功
|
||||
GET http://127.0.0.1:18083/management-api/role/get?roleId=13
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
### /role/list-all 成功
|
||||
GET http://127.0.0.1:18083/management-api/role/list-all
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
### /role/list 成功
|
||||
GET http://127.0.0.1:18083/management-api/role/list?roleIds=1,13
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
### /role/page 成功
|
||||
GET http://127.0.0.1:18083/management-api/role/page?pageNo=1&pageSize=10
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
###
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.dto.RoleCreateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.dto.RolePageDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.dto.RoleUpdateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.vo.RoleVO;
|
||||
import cn.iocoder.mall.managementweb.manager.permission.RoleManager;
|
||||
import cn.iocoder.mall.security.admin.core.context.AdminSecurityContextHolder;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 角色 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/role")
|
||||
@Api(tags = "角色")
|
||||
@Validated
|
||||
public class RoleController {
|
||||
|
||||
@Autowired
|
||||
private RoleManager roleManager;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建角色")
|
||||
@RequiresPermissions("system:role:create")
|
||||
public CommonResult<Integer> createRole(@Valid RoleCreateDTO createDTO) {
|
||||
return success(roleManager.createRole(createDTO, AdminSecurityContextHolder.getAdminId()));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新角色")
|
||||
@RequiresPermissions("system:role:update")
|
||||
public CommonResult<Boolean> updateRole(@Valid RoleUpdateDTO updateDTO) {
|
||||
roleManager.updateRole(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除角色")
|
||||
@ApiImplicitParam(name = "roleId", value = "角色编号", required = true)
|
||||
@RequiresPermissions("system:role:delete")
|
||||
public CommonResult<Boolean> deleteRole(@RequestParam("roleId") Integer roleId) {
|
||||
roleManager.deleteRole(roleId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得角色")
|
||||
@ApiImplicitParam(name = "roleId", value = "角色编号", required = true)
|
||||
@RequiresPermissions("system:admin:page")
|
||||
public CommonResult<RoleVO> role(@RequestParam("roleId") Integer roleId) {
|
||||
return success(roleManager.getRole(roleId));
|
||||
}
|
||||
|
||||
@GetMapping("/list-all")
|
||||
@ApiOperation("获得所有角色列表")
|
||||
@RequiresPermissions("system:role:page")
|
||||
public CommonResult<List<RoleVO>> listAllRoles() {
|
||||
return success(roleManager.listAllRoles());
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得角色列表")
|
||||
@ApiImplicitParam(name = "roleIds", value = "角色编号列表", required = true)
|
||||
@RequiresPermissions("system:role:page")
|
||||
public CommonResult<List<RoleVO>> listRoles(@RequestParam("roleIds") List<Integer> roleIds) {
|
||||
return success(roleManager.listRoles(roleIds));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得角色分页")
|
||||
@RequiresPermissions("system:role:page")
|
||||
public CommonResult<PageResult<RoleVO>> pageRole(RolePageDTO pageDTO) {
|
||||
return success(roleManager.pageRole(pageDTO));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Set;
|
||||
|
||||
@ApiModel("赋予用户角色 DTO")
|
||||
@Data
|
||||
public class PermissionAssignAdminRoleDTO {
|
||||
|
||||
@ApiModelProperty(value = "管理员编号", required = true, example = "1")
|
||||
@NotNull(message = "管理员编号不能为空")
|
||||
private Integer adminId;
|
||||
@ApiModelProperty(value = "角色编号列表", example = "1,3,5")
|
||||
private Set<Integer> roleIds;
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Set;
|
||||
|
||||
@ApiModel("赋予角色资源 DTO")
|
||||
@Data
|
||||
public class PermissionAssignRoleResourceDTO {
|
||||
|
||||
@ApiModelProperty(value = "角色名", required = true, example = "1")
|
||||
@NotNull(message = "角色编号不能为空")
|
||||
private Integer roleId;
|
||||
@ApiModelProperty(value = "资源编号列表", example = "1,3,5")
|
||||
private Set<Integer> resourceIds;
|
||||
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission.dto;
|
||||
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("资源创建 DTO")
|
||||
@Data
|
||||
public class ResourceCreateDTO {
|
||||
|
||||
@ApiModelProperty(value = "菜单名", required = true, example = "商品管理")
|
||||
@NotEmpty(message = "菜单名不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "权限标识", example = "resource:add")
|
||||
private String permission;
|
||||
@ApiModelProperty(value = "资源类型", required = true, example = "1")
|
||||
@NotNull(message = "资源类型不能为空")
|
||||
@InEnum(value = ResourceTypeEnum.class, message = "资源类型必须是 {value}")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "排序", required = true, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "父级资源编号", required = true, example = "1", notes = "如果无父资源,则值为 0")
|
||||
@NotNull(message = "父级资源编号不能为空")
|
||||
private Integer pid;
|
||||
@ApiModelProperty(value = "前端路由", example = "/resource/list")
|
||||
private String route;
|
||||
@ApiModelProperty(value = "菜单图标", example = "add")
|
||||
private String icon;
|
||||
@ApiModelProperty(value = "前端界面", example = "@/views/example/edit")
|
||||
private String view;
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission.dto;
|
||||
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("资源创建 DTO")
|
||||
@Data
|
||||
public class ResourceUpdateDTO {
|
||||
|
||||
@ApiModelProperty(value = "资源编号", required = true, example = "1")
|
||||
@NotNull(message = "资源编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "菜单名", required = true, example = "商品管理")
|
||||
@NotEmpty(message = "菜单名不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "权限标识", example = "resource:add")
|
||||
private String permission;
|
||||
@ApiModelProperty(value = "资源类型", required = true, example = "1")
|
||||
@NotNull(message = "资源类型不能为空")
|
||||
@InEnum(value = ResourceTypeEnum.class, message = "资源类型必须是 {value}")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "排序", required = true, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "父级资源编号", required = true, example = "1", notes = "如果无父资源,则值为 0")
|
||||
@NotNull(message = "父级资源编号不能为空")
|
||||
private Integer pid;
|
||||
@ApiModelProperty(value = "前端路由", example = "/resource/list")
|
||||
private String route;
|
||||
@ApiModelProperty(value = "菜单图标", example = "add")
|
||||
private String icon;
|
||||
@ApiModelProperty(value = "前端界面", example = "@/views/example/edit")
|
||||
private String view;
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@ApiModel("角色创建 DTO")
|
||||
@Data
|
||||
public class RoleCreateDTO {
|
||||
|
||||
@ApiModelProperty(value = "角色名", required = true, example = "管理员")
|
||||
@NotEmpty(message = "角色名不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "角色编码", example = "ADMIN")
|
||||
private String code;
|
||||
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission.dto;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel("角色分页 DTO")
|
||||
@Data
|
||||
public class RolePageDTO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "角色名", example = "管理", notes = "模糊匹配")
|
||||
private String name;
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("角色更新 DTO")
|
||||
@Data
|
||||
public class RoleUpdateDTO {
|
||||
|
||||
@ApiModelProperty(value = "角色编号", required = true, example = "1")
|
||||
@NotNull(message = "角色编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "角色名", required = true, example = "管理员")
|
||||
@NotEmpty(message = "角色名不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "角色编码", example = "ADMIN")
|
||||
private String code;
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission.vo;
|
||||
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("资源树节点 VO")
|
||||
@Data
|
||||
public class ResourceTreeNodeVO {
|
||||
|
||||
@ApiModelProperty(value = "资源编号", required = true, example = "1")
|
||||
@NotNull(message = "资源编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "菜单名", required = true, example = "商品管理")
|
||||
@NotEmpty(message = "菜单名不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "权限标识", example = "resource:add")
|
||||
private String permission;
|
||||
@ApiModelProperty(value = "资源类型", required = true, example = "1")
|
||||
@NotNull(message = "资源类型不能为空")
|
||||
@InEnum(value = ResourceTypeEnum.class, message = "资源类型必须是 {value}")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "排序", required = true, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "父级资源编号", required = true, example = "1", notes = "如果无父资源,则值为 0")
|
||||
@NotNull(message = "父级资源编号不能为空")
|
||||
private Integer pid;
|
||||
@ApiModelProperty(value = "前端路由", example = "/resource/list")
|
||||
private String route;
|
||||
@ApiModelProperty(value = "菜单图标", example = "add")
|
||||
private String icon;
|
||||
@ApiModelProperty(value = "前端界面", example = "@/views/example/edit")
|
||||
private String view;
|
||||
@ApiModelProperty(value = "添加时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
private List<ResourceTreeNodeVO> children;
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission.vo;
|
||||
|
||||
import cn.iocoder.common.framework.validator.InEnum;
|
||||
import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum;
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.*;
|
||||
|
||||
@ApiModel("资源 VO")
|
||||
@Data
|
||||
public class ResourceVO {
|
||||
|
||||
@ApiModelProperty(value = "资源编号", required = true, example = "1")
|
||||
@NotNull(message = "资源编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "菜单名", required = true, example = "商品管理")
|
||||
@NotEmpty(message = "菜单名不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "权限标识", example = "resource:add")
|
||||
private String permission;
|
||||
@ApiModelProperty(value = "资源类型", required = true, example = "1")
|
||||
@NotNull(message = "资源类型不能为空")
|
||||
@InEnum(value = ResourceTypeEnum.class, message = "资源类型必须是 {value}")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "排序", required = true, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "父级资源编号", required = true, example = "1", notes = "如果无父资源,则值为 0")
|
||||
@NotNull(message = "父级资源编号不能为空")
|
||||
private Integer pid;
|
||||
@ApiModelProperty(value = "前端路由", example = "/resource/list")
|
||||
private String route;
|
||||
@ApiModelProperty(value = "菜单图标", example = "add")
|
||||
private String icon;
|
||||
@ApiModelProperty(value = "前端界面", example = "@/views/example/edit")
|
||||
private String view;
|
||||
@ApiModelProperty(value = "添加时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.permission.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("角色 VO")
|
||||
@Data
|
||||
public class RoleVO {
|
||||
|
||||
@ApiModelProperty(value = "角色编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "角色名", required = true, example = "管理员")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "角色编码", example = "ADMIN")
|
||||
private String code;
|
||||
@ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "见 RoleTypeEnum 枚举")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "创建管理员编号", required = true, example = "1")
|
||||
private Integer createAdminId;
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
### /system-access-log/page 成功
|
||||
GET http://127.0.0.1:18083/management-api/system-access-log/page?pageNo=1&pageSize=10
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer yudaoyuanma
|
||||
|
||||
###
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemAccessLogPageDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemAccessLogVO;
|
||||
import cn.iocoder.mall.managementweb.manager.systemlog.SystemAccessLogManager;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 系统访问日志 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system-access-log")
|
||||
@Api(tags = "系统访问日志")
|
||||
@Validated
|
||||
public class SystemAccessLogController {
|
||||
|
||||
@Autowired
|
||||
private SystemAccessLogManager systemAccessLogManager;
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得系统访问日志分页")
|
||||
@RequiresPermissions("system:system-access-log:page")
|
||||
public CommonResult<PageResult<SystemAccessLogVO>> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) {
|
||||
return success(systemAccessLogManager.pageSystemAccessLog(pageDTO));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemExceptionLogPageDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemExceptionLogProcessDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemExceptionLogDetailVO;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemExceptionLogVO;
|
||||
import cn.iocoder.mall.managementweb.manager.systemlog.SystemExceptionLogManager;
|
||||
import cn.iocoder.mall.security.admin.core.context.AdminSecurityContextHolder;
|
||||
import cn.iocoder.security.annotations.RequiresPermissions;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 系统异常日志 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system-exception-log")
|
||||
@Api(tags = "系统异常日志")
|
||||
@Validated
|
||||
public class SystemExceptionLogController {
|
||||
|
||||
@Autowired
|
||||
private SystemExceptionLogManager systemExceptionLogManager;
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得系统异常日志明细")
|
||||
@ApiImplicitParam(name = "logId", value = "系统异常日志编号", required = true)
|
||||
@RequiresPermissions("system:system-exception-log:page")
|
||||
public CommonResult<SystemExceptionLogDetailVO> getSystemExceptionLogDetail(@RequestParam("logId") Integer logId) {
|
||||
return success(systemExceptionLogManager.getSystemExceptionLogDetail(logId));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得系统异常日志分页")
|
||||
@RequiresPermissions("system:system-exception-log:page")
|
||||
public CommonResult<PageResult<SystemExceptionLogVO>> pageSystemExceptionLog(SystemExceptionLogPageDTO pageDTO) {
|
||||
return success(systemExceptionLogManager.pageSystemExceptionLog(pageDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/process")
|
||||
@ApiOperation("处理系统异常日志")
|
||||
@RequiresPermissions("system:system-exception-log:process")
|
||||
public CommonResult<Boolean> processSystemExceptionLog(SystemExceptionLogProcessDTO processDTO) {
|
||||
systemExceptionLogManager.processSystemExceptionLog(AdminSecurityContextHolder.getAdminId(), processDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.systemlog.dto;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel("系统访问日志分页 DTO")
|
||||
@Data
|
||||
public class SystemAccessLogPageDTO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", example = "1")
|
||||
private Integer userId;
|
||||
@ApiModelProperty(value = "用户类型", example = "2")
|
||||
private Integer userType;
|
||||
@ApiModelProperty(value = "应用名", example = "xxx-service-application")
|
||||
private String applicationName;
|
||||
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.systemlog.dto;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel("系统异常日志分页 DTO")
|
||||
@Data
|
||||
public class SystemExceptionLogPageDTO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", example = "1")
|
||||
private Integer userId;
|
||||
@ApiModelProperty(value = "用户类型", example = "2")
|
||||
private Integer userType;
|
||||
@ApiModelProperty(value = "应用名", example = "xxx-service-application")
|
||||
private String applicationName;
|
||||
@ApiModelProperty(value = "处理状态", notes = "对应 SystemExceptionLogProcessStatusEnum 枚举类", example = "1")
|
||||
private Integer processStatus;
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.systemlog.dto;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@ApiModel("系统异常日志处理 DTO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SystemExceptionLogProcessDTO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "系统异常日志编号", required = true, example = "1")
|
||||
private Integer logId;
|
||||
@ApiModelProperty(value = "处理状态", required = true, notes = "对应 SystemExceptionLogProcessStatusEnum 枚举类", example = "1")
|
||||
private Integer processStatus;
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.systemlog.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.*;
|
||||
|
||||
@ApiModel("系统访问日志 VO")
|
||||
@Data
|
||||
public class SystemAccessLogVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "用户编号", example = "1024")
|
||||
private Integer userId;
|
||||
@ApiModelProperty(value = "用户类型", example = "1")
|
||||
private Integer userType;
|
||||
@ApiModelProperty(value = "链路追踪编号", example = "89aca178-a370-411c-ae02-3f0d672be4ab")
|
||||
private String traceId;
|
||||
@ApiModelProperty(value = "应用名", required = true, example = "user-shop-application")
|
||||
private String applicationName;
|
||||
@ApiModelProperty(value = "访问地址", required = true, example = "/management-api/system-access-log/page")
|
||||
private String uri;
|
||||
@ApiModelProperty(value = "参数", required = true, example = "pageNo=1&pageSize=10")
|
||||
private String queryString;
|
||||
@ApiModelProperty(value = "http 方法", required = true, example = "GET")
|
||||
private String method;
|
||||
@ApiModelProperty(value = "userAgent", required = true, example = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
|
||||
private String userAgent;
|
||||
@ApiModelProperty(value = "ip", required = true, example = "127.0.0.1")
|
||||
private String ip;
|
||||
@ApiModelProperty(value = "请求时间", required = true)
|
||||
private Date startTime;
|
||||
@ApiModelProperty(value = "响应时长 -- 毫秒级", required = true, example = "1024")
|
||||
private Integer responseTime;
|
||||
@ApiModelProperty(value = "错误码", required = true, example = "0")
|
||||
private Integer errorCode;
|
||||
@ApiModelProperty(value = "错误提示", example = "你的昵称过长~")
|
||||
private String errorMessage;
|
||||
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.systemlog.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("系统异常日志明细 DTO")
|
||||
@Data
|
||||
public class SystemExceptionLogDetailVO {
|
||||
|
||||
@ApiModel("管理员")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Admin {
|
||||
|
||||
@ApiModelProperty(value = "管理员编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "真实名字", required = true, example = "小王")
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "用户编号", example = "1024")
|
||||
private Integer userId;
|
||||
@ApiModelProperty(value = "用户类型", example = "1")
|
||||
private Integer userType;
|
||||
@ApiModelProperty(value = "链路追踪编号", example = "89aca178-a370-411c-ae02-3f0d672be4ab")
|
||||
private String traceId;
|
||||
@ApiModelProperty(value = "应用名", required = true, example = "user-shop-application")
|
||||
private String applicationName;
|
||||
@ApiModelProperty(value = "访问地址", required = true, example = "/management-api/system-access-log/page")
|
||||
private String uri;
|
||||
@ApiModelProperty(value = "参数", required = true, example = "pageNo=1&pageSize=10")
|
||||
private String queryString;
|
||||
@ApiModelProperty(value = "http 方法", required = true, example = "GET")
|
||||
private String method;
|
||||
@ApiModelProperty(value = "userAgent", required = true, example = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
|
||||
private String userAgent;
|
||||
@ApiModelProperty(value = "ip", required = true, example = "127.0.0.1")
|
||||
private String ip;
|
||||
@ApiModelProperty(value = "异常发生时间", required = true)
|
||||
private Date exceptionTime;
|
||||
@ApiModelProperty(value = "异常名, {@link Throwable#getClass()} 的类全名", required = true)
|
||||
private String exceptionName;
|
||||
@ApiModelProperty(value = "异常导致的消息, {@link cn.iocoder.common.framework.util.ExceptionUtil#getMessage(Throwable)}", required = true)
|
||||
private String exceptionMessage;
|
||||
@ApiModelProperty(value = "异常导致的根消息, {@link cn.iocoder.common.framework.util.ExceptionUtil#getRootCauseMessage(Throwable)}", required = true)
|
||||
private String exceptionRootCauseMessage;
|
||||
@ApiModelProperty(value = "异常的栈轨迹, {@link cn.iocoder.common.framework.util.ExceptionUtil#getServiceException(Exception)}", required = true)
|
||||
private String exceptionStackTrace;
|
||||
@ApiModelProperty(value = "异常发生的类全名, {@link StackTraceElement#getClassName()}", required = true)
|
||||
private String exceptionClassName;
|
||||
@ApiModelProperty(value = "异常发生的类文件, {@link StackTraceElement#getFileName()}", required = true)
|
||||
private String exceptionFileName;
|
||||
@ApiModelProperty(value = "异常发生的方法名, {@link StackTraceElement#getMethodName()}", required = true)
|
||||
private String exceptionMethodName;
|
||||
@ApiModelProperty(value = "异常发生的方法所在行, {@link StackTraceElement#getLineNumber()}", required = true)
|
||||
private Integer exceptionLineNumber;
|
||||
@ApiModelProperty(value = "处理状态", required = true, notes = "对应 SystemExceptionLogProcessStatusEnum 枚举类", example = "1")
|
||||
private Integer processStatus;
|
||||
@ApiModelProperty(value = "处理时间")
|
||||
private Date processTime;
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 处理的管理员信息
|
||||
*/
|
||||
private Admin processAdmin;
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.controller.systemlog.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.*;
|
||||
|
||||
@ApiModel("系统异常日志 VO")
|
||||
@Data
|
||||
public class SystemExceptionLogVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "用户编号", example = "1024")
|
||||
private Integer userId;
|
||||
@ApiModelProperty(value = "用户类型", example = "1")
|
||||
private Integer userType;
|
||||
@ApiModelProperty(value = "链路追踪编号", example = "89aca178-a370-411c-ae02-3f0d672be4ab")
|
||||
private String traceId;
|
||||
@ApiModelProperty(value = "应用名", required = true, example = "user-shop-application")
|
||||
private String applicationName;
|
||||
@ApiModelProperty(value = "访问地址", required = true, example = "/management-api/system-access-log/page")
|
||||
private String uri;
|
||||
@ApiModelProperty(value = "参数", required = true, example = "pageNo=1&pageSize=10")
|
||||
private String queryString;
|
||||
@ApiModelProperty(value = "http 方法", required = true, example = "GET")
|
||||
private String method;
|
||||
@ApiModelProperty(value = "userAgent", required = true, example = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0")
|
||||
private String userAgent;
|
||||
@ApiModelProperty(value = "ip", required = true, example = "127.0.0.1")
|
||||
private String ip;
|
||||
@ApiModelProperty(value = "异常发生时间", required = true)
|
||||
private Date exceptionTime;
|
||||
@ApiModelProperty(value = "异常名, {@link Throwable#getClass()} 的类全名", required = true)
|
||||
private String exceptionName;
|
||||
@ApiModelProperty(value = "异常导致的消息, {@link cn.iocoder.common.framework.util.ExceptionUtil#getMessage(Throwable)}", required = true)
|
||||
private String exceptionMessage;
|
||||
@ApiModelProperty(value = "异常导致的根消息, {@link cn.iocoder.common.framework.util.ExceptionUtil#getRootCauseMessage(Throwable)}", required = true)
|
||||
private String exceptionRootCauseMessage;
|
||||
@ApiModelProperty(value = "异常的栈轨迹, {@link cn.iocoder.common.framework.util.ExceptionUtil#getServiceException(Exception)}", required = true)
|
||||
private String exceptionStackTrace;
|
||||
@ApiModelProperty(value = "异常发生的类全名, {@link StackTraceElement#getClassName()}", required = true)
|
||||
private String exceptionClassName;
|
||||
@ApiModelProperty(value = "异常发生的类文件, {@link StackTraceElement#getFileName()}", required = true)
|
||||
private String exceptionFileName;
|
||||
@ApiModelProperty(value = "异常发生的方法名, {@link StackTraceElement#getMethodName()}", required = true)
|
||||
private String exceptionMethodName;
|
||||
@ApiModelProperty(value = "异常发生的方法所在行, {@link StackTraceElement#getLineNumber()}", required = true)
|
||||
private Integer exceptionLineNumber;
|
||||
@ApiModelProperty(value = "处理状态", required = true, notes = "对应 SystemExceptionLogProcessStatusEnum 枚举类", example = "1")
|
||||
private Integer processStatus;
|
||||
@ApiModelProperty(value = "处理时间")
|
||||
private Date processTime;
|
||||
@ApiModelProperty(value = "处理管理员编号", example = "1024")
|
||||
private Integer processAdminId;
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.convert.admin;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminUpdateInfoDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminUpdateStatusDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.vo.AdminPageItemVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminCreateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminPageDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminUpdateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AdminConvert {
|
||||
|
||||
AdminConvert INSTANCE = Mappers.getMapper(AdminConvert.class);
|
||||
|
||||
AdminCreateDTO convert(cn.iocoder.mall.managementweb.controller.admin.dto.AdminCreateDTO bean);
|
||||
|
||||
AdminUpdateDTO convert(AdminUpdateInfoDTO bean);
|
||||
|
||||
@Mapping(source = "adminId", target = "id")
|
||||
AdminUpdateDTO convert(AdminUpdateStatusDTO bean);
|
||||
|
||||
AdminPageDTO convert(cn.iocoder.mall.managementweb.controller.admin.dto.AdminPageDTO bean);
|
||||
|
||||
PageResult<AdminPageItemVO> convert(PageResult<AdminVO> pageResultData);
|
||||
|
||||
cn.iocoder.mall.managementweb.controller.admin.vo.AdminVO convert(AdminVO bean);
|
||||
|
||||
AdminPageItemVO convert02(AdminVO adminVO);
|
||||
AdminPageItemVO.Department convert(DepartmentVO bean);
|
||||
List<AdminPageItemVO.Role> convertList(List<RoleVO> list);
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.convert.admin;
|
||||
|
||||
import cn.iocoder.mall.managementweb.controller.admin.vo.DepartmentTreeNodeVO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.vo.DepartmentVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.dto.DepartmentCreateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.dto.DepartmentUpdateDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DepartmentConvert {
|
||||
|
||||
DepartmentConvert INSTANCE = Mappers.getMapper(DepartmentConvert.class);
|
||||
|
||||
DepartmentCreateDTO convert(cn.iocoder.mall.managementweb.controller.admin.dto.DepartmentCreateDTO bean);
|
||||
|
||||
DepartmentUpdateDTO convert(cn.iocoder.mall.managementweb.controller.admin.dto.DepartmentUpdateDTO bean);
|
||||
|
||||
List<DepartmentVO> convertList(List<cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO> list);
|
||||
|
||||
DepartmentVO convert(cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO bean);
|
||||
|
||||
DepartmentTreeNodeVO convertTreeNode(cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO bean);
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.convert.datadict;
|
||||
|
||||
import cn.iocoder.mall.managementweb.controller.datadict.vo.DataDictSimpleVO;
|
||||
import cn.iocoder.mall.managementweb.controller.datadict.vo.DataDictVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.datadict.dto.DataDictCreateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.datadict.dto.DataDictUpdateDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DataDictConvert {
|
||||
|
||||
DataDictConvert INSTANCE = Mappers.getMapper(DataDictConvert.class);
|
||||
|
||||
DataDictCreateDTO convert(cn.iocoder.mall.managementweb.controller.datadict.dto.DataDictCreateDTO bean);
|
||||
|
||||
DataDictUpdateDTO convert(cn.iocoder.mall.managementweb.controller.datadict.dto.DataDictUpdateDTO bean);
|
||||
|
||||
DataDictVO convert(cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO bean);
|
||||
|
||||
List<DataDictVO> convertList(List<cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO> list);
|
||||
|
||||
List<DataDictSimpleVO> convertList02(List<cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO> list);
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.convert.passport;
|
||||
|
||||
import cn.iocoder.mall.managementweb.controller.passport.dto.PassportLoginDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.passport.vo.PassportAccessTokenVO;
|
||||
import cn.iocoder.mall.managementweb.controller.passport.vo.PassportAdminVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.dto.AdminVerifyPasswordDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface AdminPassportConvert {
|
||||
|
||||
AdminPassportConvert INSTANCE = Mappers.getMapper(AdminPassportConvert.class);
|
||||
|
||||
AdminVerifyPasswordDTO convert(PassportLoginDTO bean);
|
||||
|
||||
PassportAccessTokenVO convert(OAuth2AccessTokenRespDTO bean);
|
||||
|
||||
PassportAdminVO convert(AdminVO bean);
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.convert.pay.transaction;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.pay.vo.transaction.PayTransactionPageReqVO;
|
||||
import cn.iocoder.mall.managementweb.controller.pay.vo.transaction.PayTransactionRespVO;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionPageReqDTO;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionRespDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface PayTransactionConvert {
|
||||
|
||||
PayTransactionConvert INSTANCE = Mappers.getMapper(PayTransactionConvert.class);
|
||||
|
||||
PayTransactionPageReqDTO convert(PayTransactionPageReqVO bean);
|
||||
|
||||
PageResult<PayTransactionRespVO> convertPage(PageResult<PayTransactionRespDTO> bean);
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.convert.permission;
|
||||
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.PermissionAssignAdminRoleDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.PermissionAssignRoleResourceDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface PermissionConvert {
|
||||
|
||||
PermissionConvert INSTANCE = Mappers.getMapper(PermissionConvert.class);
|
||||
|
||||
PermissionAssignRoleResourceDTO convert(cn.iocoder.mall.managementweb.controller.permission.dto.PermissionAssignRoleResourceDTO bean);
|
||||
|
||||
PermissionAssignAdminRoleDTO convert(cn.iocoder.mall.managementweb.controller.permission.dto.PermissionAssignAdminRoleDTO bean);
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.convert.permission;
|
||||
|
||||
import cn.iocoder.mall.managementweb.controller.passport.vo.PassportAdminMenuTreeNodeVO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.vo.ResourceTreeNodeVO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.vo.ResourceVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.ResourceCreateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.ResourceUpdateDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ResourceConvert {
|
||||
|
||||
ResourceConvert INSTANCE = Mappers.getMapper(ResourceConvert.class);
|
||||
|
||||
ResourceCreateDTO convert(cn.iocoder.mall.managementweb.controller.permission.dto.ResourceCreateDTO bean);
|
||||
|
||||
ResourceUpdateDTO convert(cn.iocoder.mall.managementweb.controller.permission.dto.ResourceUpdateDTO bean);
|
||||
|
||||
ResourceVO convert(cn.iocoder.mall.systemservice.rpc.permission.vo.ResourceVO bean);
|
||||
|
||||
List<ResourceVO> convertList(List<cn.iocoder.mall.systemservice.rpc.permission.vo.ResourceVO> list);
|
||||
|
||||
ResourceTreeNodeVO convertTreeNode(cn.iocoder.mall.systemservice.rpc.permission.vo.ResourceVO bean);
|
||||
|
||||
List<PassportAdminMenuTreeNodeVO> convert(List<ResourceTreeNodeVO> list);
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.convert.permission;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.vo.RoleVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.RolePageDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.RoleUpdateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleCreateDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface RoleConvert {
|
||||
|
||||
RoleConvert INSTANCE = Mappers.getMapper(RoleConvert.class);
|
||||
|
||||
RoleCreateDTO convert(cn.iocoder.mall.managementweb.controller.permission.dto.RoleCreateDTO bean);
|
||||
|
||||
RoleUpdateDTO convert(cn.iocoder.mall.managementweb.controller.permission.dto.RoleUpdateDTO bean);
|
||||
|
||||
RoleVO convert(cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO bean);
|
||||
|
||||
List<RoleVO> convertList(List<cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO> list);
|
||||
|
||||
RolePageDTO convert(cn.iocoder.mall.managementweb.controller.permission.dto.RolePageDTO bean);
|
||||
|
||||
PageResult<RoleVO> convertPage(PageResult<cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO> page);
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.convert.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemAccessLogVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SystemAccessLogConvert {
|
||||
|
||||
SystemAccessLogConvert INSTANCE = Mappers.getMapper(SystemAccessLogConvert.class);
|
||||
|
||||
SystemAccessLogPageDTO convert(cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemAccessLogPageDTO bean);
|
||||
|
||||
PageResult<SystemAccessLogVO> convertPage(PageResult<cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO> page);
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.convert.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemExceptionLogDetailVO;
|
||||
import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemExceptionLogVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogPageDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogProcessDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SystemExceptionLogConvert {
|
||||
|
||||
SystemExceptionLogConvert INSTANCE = Mappers.getMapper(SystemExceptionLogConvert.class);
|
||||
|
||||
SystemExceptionLogPageDTO convert(cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemExceptionLogPageDTO bean);
|
||||
|
||||
PageResult<SystemExceptionLogVO> convertPage(PageResult<cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemExceptionLogVO> page);
|
||||
|
||||
SystemExceptionLogDetailVO convert(cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemExceptionLogVO bean);
|
||||
|
||||
SystemExceptionLogDetailVO.Admin convert(AdminVO bean);
|
||||
|
||||
SystemExceptionLogProcessDTO convert(cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemExceptionLogProcessDTO bean);
|
||||
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.manager.admin;
|
||||
|
||||
import cn.iocoder.common.framework.util.CollectionUtils;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminCreateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminPageDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminUpdateInfoDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.AdminUpdateStatusDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.vo.AdminPageItemVO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.vo.AdminVO;
|
||||
import cn.iocoder.mall.managementweb.convert.admin.AdminConvert;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.AdminFeign;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.DepartmentFeign;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.PermissionFeign;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.RoleFeign;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class AdminManager {
|
||||
|
||||
@Autowired
|
||||
private AdminFeign adminFeign;
|
||||
@Autowired
|
||||
private RoleFeign roleFeign;
|
||||
@Autowired
|
||||
private DepartmentFeign departmentFeign;
|
||||
@Autowired
|
||||
private PermissionFeign permissionFeign;
|
||||
|
||||
public PageResult<AdminPageItemVO> pageAdmin(AdminPageDTO pageDTO) {
|
||||
CommonResult<PageResult<cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO>> pageResult =
|
||||
adminFeign.pageAdmin(AdminConvert.INSTANCE.convert(pageDTO));
|
||||
pageResult.checkError();
|
||||
// 转换结果
|
||||
PageResult<AdminPageItemVO> adminPageVO = new PageResult<>();
|
||||
adminPageVO.setTotal(pageResult.getData().getTotal());
|
||||
adminPageVO.setList(new ArrayList<>(pageResult.getData().getList().size()));
|
||||
// 拼接结果
|
||||
if (!pageResult.getData().getList().isEmpty()) {
|
||||
// 查询角色数组
|
||||
Map<Integer, List<RoleVO>> adminRoleMap = this.listAdminRoles(CollectionUtils.convertList(pageResult.getData().getList(),
|
||||
cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO::getId));
|
||||
// 查询部门
|
||||
CommonResult<List<DepartmentVO>> listDepartmentsResult = departmentFeign.listDepartments(
|
||||
CollectionUtils.convertSet(pageResult.getData().getList(),
|
||||
cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO::getDepartmentId));
|
||||
listDepartmentsResult.checkError();
|
||||
Map<Integer, DepartmentVO> departmentMap = CollectionUtils.convertMap(listDepartmentsResult.getData(), DepartmentVO::getId);
|
||||
// 拼接数据
|
||||
for (cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO adminVO : pageResult.getData().getList()) {
|
||||
AdminPageItemVO adminPageItemVO = AdminConvert.INSTANCE.convert02(adminVO);
|
||||
adminPageVO.getList().add(adminPageItemVO);
|
||||
// 拼接部门
|
||||
adminPageItemVO.setDepartment(AdminConvert.INSTANCE.convert(departmentMap.get(adminVO.getDepartmentId())));
|
||||
// 拼接角色
|
||||
adminPageItemVO.setRoles( AdminConvert.INSTANCE.convertList(adminRoleMap.get(adminVO.getId())));
|
||||
}
|
||||
} else {
|
||||
adminPageVO.setList(Collections.emptyList());
|
||||
}
|
||||
return adminPageVO;
|
||||
}
|
||||
|
||||
private Map<Integer, List<RoleVO>> listAdminRoles(List<Integer> adminIds) {
|
||||
// 获得管理员拥有的角色
|
||||
CommonResult<Map<Integer, Set<Integer>>> mapAdminRoleIdsResult = permissionFeign.mapAdminRoleIds(adminIds);
|
||||
mapAdminRoleIdsResult.checkError();
|
||||
// 获得角色列表
|
||||
Set<Integer> roleIds = new HashSet<>();
|
||||
mapAdminRoleIdsResult.getData().values().forEach(roleIds::addAll);
|
||||
CommonResult<List<RoleVO>> listRolesResult = roleFeign.listRoles(roleIds);
|
||||
listRolesResult.checkError();
|
||||
Map<Integer, RoleVO> roleVOMap = CollectionUtils.convertMap(listRolesResult.getData(), RoleVO::getId);
|
||||
// 拼接结果
|
||||
Map<Integer, List<RoleVO>> adminRoleVOMap = new HashMap<>();
|
||||
mapAdminRoleIdsResult.getData().forEach((adminId, adminRoleIds) -> {
|
||||
List<RoleVO> roleVOs = new ArrayList<>(adminRoleIds.size());
|
||||
adminRoleIds.forEach(roleId -> {
|
||||
RoleVO roleVO = roleVOMap.get(roleId);
|
||||
if (roleVO != null) {
|
||||
roleVOs.add(roleVO);
|
||||
}
|
||||
});
|
||||
adminRoleVOMap.put(adminId, roleVOs);
|
||||
});
|
||||
return adminRoleVOMap;
|
||||
}
|
||||
|
||||
public Integer createAdmin(AdminCreateDTO createDTO, Integer createAdminId, String createIp) {
|
||||
CommonResult<Integer> createAdminResult = adminFeign.createAdmin(AdminConvert.INSTANCE.convert(createDTO)
|
||||
.setCreateAdminId(createAdminId).setCreateIp(createIp));
|
||||
createAdminResult.checkError();
|
||||
return createAdminResult.getData();
|
||||
}
|
||||
|
||||
public void updateAdmin(AdminUpdateInfoDTO updateInfoDTO) {
|
||||
CommonResult<Boolean> updateAdminResult = adminFeign.updateAdmin(AdminConvert.INSTANCE.convert(updateInfoDTO));
|
||||
updateAdminResult.checkError();
|
||||
}
|
||||
|
||||
public void updateAdminStatus(@Valid AdminUpdateStatusDTO updateStatusDTO) {
|
||||
CommonResult<Boolean> updateAdminResult = adminFeign.updateAdmin(AdminConvert.INSTANCE.convert(updateStatusDTO));
|
||||
updateAdminResult.checkError();
|
||||
}
|
||||
|
||||
public AdminVO getAdmin(Integer adminId) {
|
||||
CommonResult<cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO> getAdminResult = adminFeign.getAdmin(adminId);
|
||||
getAdminResult.checkError();
|
||||
return AdminConvert.INSTANCE.convert(getAdminResult.getData());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.manager.admin;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.DepartmentCreateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.dto.DepartmentUpdateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.vo.DepartmentTreeNodeVO;
|
||||
import cn.iocoder.mall.managementweb.controller.admin.vo.DepartmentVO;
|
||||
import cn.iocoder.mall.managementweb.convert.admin.DepartmentConvert;
|
||||
import cn.iocoder.mall.systemservice.enums.admin.DepartmentIdEnum;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.DepartmentFeign;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 部门 Manager
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DepartmentManager {
|
||||
|
||||
@Autowired
|
||||
private DepartmentFeign departmentFeign;
|
||||
/**
|
||||
* 创建部门
|
||||
*
|
||||
* @param createDTO 创建部门 DTO
|
||||
* @return 部门
|
||||
*/
|
||||
public Integer createDepartment(DepartmentCreateDTO createDTO) {
|
||||
CommonResult<Integer> createDepartmentResult = departmentFeign.createDepartment(DepartmentConvert.INSTANCE.convert(createDTO));
|
||||
createDepartmentResult.checkError();
|
||||
return createDepartmentResult.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新部门
|
||||
*
|
||||
* @param updateDTO 更新部门 DTO
|
||||
*/
|
||||
public void updateDepartment(DepartmentUpdateDTO updateDTO) {
|
||||
CommonResult<Boolean> updateDepartmentResult = departmentFeign.updateDepartment(DepartmentConvert.INSTANCE.convert(updateDTO));
|
||||
updateDepartmentResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
*
|
||||
* @param departmentId 部门编号
|
||||
*/
|
||||
public void deleteDepartment(Integer departmentId) {
|
||||
CommonResult<Boolean> deleteDepartmentResult = departmentFeign.deleteDepartment(departmentId);
|
||||
deleteDepartmentResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得部门
|
||||
*
|
||||
* @param departmentId 部门编号
|
||||
* @return 部门
|
||||
*/
|
||||
public DepartmentVO getDepartment(Integer departmentId) {
|
||||
CommonResult<cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO> getDepartmentResult = departmentFeign.getDepartment(departmentId);
|
||||
getDepartmentResult.checkError();
|
||||
return DepartmentConvert.INSTANCE.convert(getDepartmentResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得部门列表
|
||||
*
|
||||
* @param departmentIds 部门编号列表
|
||||
* @return 部门列表
|
||||
*/
|
||||
public List<DepartmentVO> listDepartments(List<Integer> departmentIds) {
|
||||
CommonResult<List<cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO>> listDepartmentResult = departmentFeign.listDepartments(departmentIds);
|
||||
listDepartmentResult.checkError();
|
||||
return DepartmentConvert.INSTANCE.convertList(listDepartmentResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得部门树结构
|
||||
*
|
||||
* @return 部门树结构
|
||||
*/
|
||||
public List<DepartmentTreeNodeVO> treeDepartment() {
|
||||
// 获得资源全列表
|
||||
CommonResult<List<cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO>> listDepartmentResult = departmentFeign.listDepartments();
|
||||
listDepartmentResult.checkError();
|
||||
// 构建菜单树
|
||||
return buildDepartmentTree(listDepartmentResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建部门树
|
||||
*
|
||||
* @param departmentVOs 部门列表
|
||||
* @return 部门树
|
||||
*/
|
||||
public static List<DepartmentTreeNodeVO> buildDepartmentTree(List<cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO> departmentVOs) {
|
||||
// 排序,保证菜单的有序性
|
||||
departmentVOs.sort(Comparator.comparing(cn.iocoder.mall.systemservice.rpc.admin.vo.DepartmentVO::getSort));
|
||||
// 构建菜单树
|
||||
// 使用 LinkedHashMap 的原因,是为了排序 。实际也可以用 Stream API ,就是太丑了。
|
||||
Map<Integer, DepartmentTreeNodeVO> treeNodeMap = new LinkedHashMap<>();
|
||||
departmentVOs.forEach(departmentVO -> treeNodeMap.put(departmentVO.getId(), DepartmentConvert.INSTANCE.convertTreeNode(departmentVO)));
|
||||
// 处理父子关系
|
||||
treeNodeMap.values().stream().filter(node -> !node.getPid().equals(DepartmentIdEnum.ROOT.getId())).forEach((childNode) -> {
|
||||
// 获得父节点
|
||||
DepartmentTreeNodeVO parentNode = treeNodeMap.get(childNode.getPid());
|
||||
if (parentNode == null) {
|
||||
log.error("[buildDepartmentTree][department({}) 找不到父部门({})]", childNode.getId(), childNode.getPid());
|
||||
return;
|
||||
}
|
||||
// 将自己添加到父节点中
|
||||
if (parentNode.getChildren() == null) {
|
||||
parentNode.setChildren(new ArrayList<>());
|
||||
}
|
||||
parentNode.getChildren().add(childNode);
|
||||
});
|
||||
// 获得到所有的根节点
|
||||
return treeNodeMap.values().stream().filter(node -> node.getPid().equals(DepartmentIdEnum.ROOT.getId())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.manager.datadict;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.controller.datadict.dto.DataDictCreateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.datadict.dto.DataDictUpdateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.datadict.vo.DataDictSimpleVO;
|
||||
import cn.iocoder.mall.managementweb.controller.datadict.vo.DataDictVO;
|
||||
import cn.iocoder.mall.managementweb.convert.datadict.DataDictConvert;
|
||||
import cn.iocoder.mall.systemservice.rpc.datadict.DataDictFeign;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据字典 Manager
|
||||
*/
|
||||
@Service
|
||||
public class DataDictManager {
|
||||
|
||||
private static final Comparator<cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO> COMPARATOR_ENUM_VALUE_SORT = Comparator
|
||||
.comparing(cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO::getEnumValue)
|
||||
.thenComparingInt(cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO::getSort);
|
||||
|
||||
@Autowired
|
||||
private DataDictFeign dataDictFeign;
|
||||
/**
|
||||
* 创建数据字典
|
||||
*
|
||||
* @param createDTO 创建数据字典 DTO
|
||||
* @return 数据字典
|
||||
*/
|
||||
public Integer createDataDict(DataDictCreateDTO createDTO) {
|
||||
CommonResult<Integer> createDataDictResult = dataDictFeign.createDataDict(DataDictConvert.INSTANCE.convert(createDTO));
|
||||
createDataDictResult.checkError();
|
||||
return createDataDictResult.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据字典
|
||||
*
|
||||
* @param updateDTO 更新数据字典 DTO
|
||||
*/
|
||||
public void updateDataDict(DataDictUpdateDTO updateDTO) {
|
||||
CommonResult<Boolean> updateDataDictResult = dataDictFeign.updateDataDict(DataDictConvert.INSTANCE.convert(updateDTO));
|
||||
updateDataDictResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据字典
|
||||
*
|
||||
* @param dataDictId 数据字典编号
|
||||
*/
|
||||
public void deleteDataDict(Integer dataDictId) {
|
||||
CommonResult<Boolean> deleteDataDictResult = dataDictFeign.deleteDataDict(dataDictId);
|
||||
deleteDataDictResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得数据字典
|
||||
*
|
||||
* @param dataDictId 数据字典编号
|
||||
* @return 数据字典
|
||||
*/
|
||||
public DataDictVO getDataDict(Integer dataDictId) {
|
||||
CommonResult<cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO> getDataDictResult = dataDictFeign.getDataDict(dataDictId);
|
||||
getDataDictResult.checkError();
|
||||
return DataDictConvert.INSTANCE.convert(getDataDictResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得数据字典列表
|
||||
*
|
||||
* @param dataDictIds 数据字典编号列表
|
||||
* @return 数据字典列表
|
||||
*/
|
||||
public List<DataDictVO> listDataDicts(List<Integer> dataDictIds) {
|
||||
CommonResult<List<cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO>> listDataDictResult = dataDictFeign.listDataDicts(dataDictIds);
|
||||
listDataDictResult.checkError();
|
||||
return DataDictConvert.INSTANCE.convertList(listDataDictResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得全部数据字典
|
||||
*
|
||||
* @return 数据字典列表
|
||||
*/
|
||||
public List<DataDictVO> listDataDicts() {
|
||||
CommonResult<List<cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO>> listDataDictResult = dataDictFeign.listDataDicts();
|
||||
listDataDictResult.checkError();
|
||||
// 按照 enumValue 和 sort 排序
|
||||
listDataDictResult.getData().sort(COMPARATOR_ENUM_VALUE_SORT);
|
||||
return DataDictConvert.INSTANCE.convertList(listDataDictResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得全部数据字典
|
||||
*
|
||||
* 精简返回字段
|
||||
*
|
||||
* @return 数据字典列表
|
||||
*/
|
||||
public List<DataDictSimpleVO> listSimpleDataDicts() {
|
||||
CommonResult<List<cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO>> listDataDictResult = dataDictFeign.listDataDicts();
|
||||
listDataDictResult.checkError();
|
||||
// 按照 enumValue 和 sort 排序
|
||||
listDataDictResult.getData().sort(COMPARATOR_ENUM_VALUE_SORT);
|
||||
return DataDictConvert.INSTANCE.convertList02(listDataDictResult.getData());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.manager.errorcode;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodeCreateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodePageDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodeUpdateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.errorcode.vo.ErrorCodeVO;
|
||||
import cn.iocoder.mall.managementweb.convert.errorcode.ErrorCodeConvert;
|
||||
import cn.iocoder.mall.systemservice.enums.errorcode.ErrorCodeTypeEnum;
|
||||
import cn.iocoder.mall.systemservice.rpc.errorcode.ErrorCodeFeign;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 错误码 Manager
|
||||
*/
|
||||
@Service
|
||||
public class ErrorCodeManager {
|
||||
|
||||
@Autowired
|
||||
private ErrorCodeFeign errorCodeFeign;
|
||||
/**
|
||||
* 创建错误码
|
||||
*
|
||||
* @param createDTO 创建错误码 DTO
|
||||
* @return 错误码
|
||||
*/
|
||||
public Integer createErrorCode(ErrorCodeCreateDTO createDTO) {
|
||||
CommonResult<Integer> createErrorCodeResult = errorCodeFeign.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO)
|
||||
.setType(ErrorCodeTypeEnum.MANUAL_OPERATION.getType()));
|
||||
createErrorCodeResult.checkError();
|
||||
return createErrorCodeResult.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新错误码
|
||||
*
|
||||
* @param updateDTO 更新错误码 DTO
|
||||
*/
|
||||
public void updateErrorCode(ErrorCodeUpdateDTO updateDTO) {
|
||||
CommonResult<Boolean> updateErrorCodeResult = errorCodeFeign.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO)
|
||||
.setType(ErrorCodeTypeEnum.MANUAL_OPERATION.getType()));
|
||||
updateErrorCodeResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除错误码
|
||||
*
|
||||
* @param errorCodeId 错误码编号
|
||||
*/
|
||||
public void deleteErrorCode(Integer errorCodeId) {
|
||||
CommonResult<Boolean> deleteErrorCodeResult = errorCodeFeign.deleteErrorCode(errorCodeId);
|
||||
deleteErrorCodeResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得错误码
|
||||
*
|
||||
* @param errorCodeId 错误码编号
|
||||
* @return 错误码
|
||||
*/
|
||||
public ErrorCodeVO getErrorCode(Integer errorCodeId) {
|
||||
CommonResult<cn.iocoder.mall.systemservice.rpc.errorcode.vo.ErrorCodeVO> getErrorCodeResult = errorCodeFeign.getErrorCode(errorCodeId);
|
||||
getErrorCodeResult.checkError();
|
||||
return ErrorCodeConvert.INSTANCE.convert(getErrorCodeResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得错误码列表
|
||||
*
|
||||
* @param errorCodeIds 错误码编号列表
|
||||
* @return 错误码列表
|
||||
*/
|
||||
public List<ErrorCodeVO> listErrorCodes(List<Integer> errorCodeIds) {
|
||||
CommonResult<List<cn.iocoder.mall.systemservice.rpc.errorcode.vo.ErrorCodeVO>> listErrorCodeResult = errorCodeFeign.listErrorCodes(errorCodeIds);
|
||||
listErrorCodeResult.checkError();
|
||||
return ErrorCodeConvert.INSTANCE.convertList(listErrorCodeResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得错误码分页
|
||||
*
|
||||
* @param pageDTO 错误码分页查询
|
||||
* @return 错误码分页结果
|
||||
*/
|
||||
public PageResult<ErrorCodeVO> pageErrorCode(ErrorCodePageDTO pageDTO) {
|
||||
CommonResult<PageResult<cn.iocoder.mall.systemservice.rpc.errorcode.vo.ErrorCodeVO>> pageErrorCodeResult
|
||||
= errorCodeFeign.pageErrorCode(ErrorCodeConvert.INSTANCE.convert(pageDTO));
|
||||
pageErrorCodeResult.checkError();
|
||||
return ErrorCodeConvert.INSTANCE.convertPage(pageErrorCodeResult.getData());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.manager.passport;
|
||||
|
||||
import cn.iocoder.common.framework.enums.UserTypeEnum;
|
||||
import cn.iocoder.common.framework.util.CollectionUtils;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.controller.passport.dto.PassportLoginDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.passport.vo.PassportAccessTokenVO;
|
||||
import cn.iocoder.mall.managementweb.controller.passport.vo.PassportAdminMenuTreeNodeVO;
|
||||
import cn.iocoder.mall.managementweb.controller.passport.vo.PassportAdminVO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.vo.ResourceTreeNodeVO;
|
||||
import cn.iocoder.mall.managementweb.convert.passport.AdminPassportConvert;
|
||||
import cn.iocoder.mall.managementweb.convert.permission.ResourceConvert;
|
||||
import cn.iocoder.mall.managementweb.manager.permission.ResourceManager;
|
||||
import cn.iocoder.mall.systemservice.enums.permission.ResourceTypeEnum;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.AdminFeign;
|
||||
import cn.iocoder.mall.systemservice.rpc.admin.vo.AdminVO;
|
||||
import cn.iocoder.mall.systemservice.rpc.oauth.OAuthFeign;
|
||||
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2AccessTokenRespDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2CreateAccessTokenReqDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.oauth.dto.OAuth2RefreshAccessTokenReqDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.ResourceFeign;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.RoleFeign;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.ResourceVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
public class PassportManager {
|
||||
|
||||
|
||||
@Autowired
|
||||
private AdminFeign adminFeign;
|
||||
@Autowired
|
||||
private OAuthFeign oAuthFeign;
|
||||
@Autowired
|
||||
private RoleFeign roleFeign;
|
||||
@Autowired
|
||||
private ResourceFeign resourceFeign;
|
||||
public PassportAccessTokenVO login(PassportLoginDTO loginDTO, String ip) {
|
||||
// 校验管理员密码
|
||||
// CommonResult<AdminVO> verifyPasswordResult = adminFeign.verifyPassword(AdminPassportConvert.INSTANCE.convert(loginDTO).setIp(ip));
|
||||
CommonResult<AdminVO> verifyPasswordResult = adminFeign.verifyPassword(AdminPassportConvert.INSTANCE.convert(loginDTO).setIp(ip));
|
||||
verifyPasswordResult.checkError();
|
||||
// 创建访问令牌
|
||||
CommonResult<OAuth2AccessTokenRespDTO> createAccessTokenResult = oAuthFeign.createAccessToken(
|
||||
new OAuth2CreateAccessTokenReqDTO().setUserId(verifyPasswordResult.getData().getId())
|
||||
.setUserType(UserTypeEnum.ADMIN.getValue()).setCreateIp(ip));
|
||||
createAccessTokenResult.checkError();
|
||||
// 返回
|
||||
return AdminPassportConvert.INSTANCE.convert(createAccessTokenResult.getData());
|
||||
}
|
||||
|
||||
public PassportAdminVO getAdmin(Integer adminId) {
|
||||
CommonResult<AdminVO> getAdminResult = adminFeign.getAdmin(adminId);
|
||||
getAdminResult.checkError();
|
||||
return AdminPassportConvert.INSTANCE.convert(getAdminResult.getData());
|
||||
}
|
||||
|
||||
public PassportAccessTokenVO refreshToken(String refreshToken, String ip) {
|
||||
CommonResult<OAuth2AccessTokenRespDTO> refreshAccessTokenResult = oAuthFeign.refreshAccessToken(
|
||||
new OAuth2RefreshAccessTokenReqDTO().setRefreshToken(refreshToken).setCreateIp(ip));
|
||||
refreshAccessTokenResult.checkError();
|
||||
return AdminPassportConvert.INSTANCE.convert(refreshAccessTokenResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定管理员的权限列表
|
||||
*
|
||||
* @param adminId 管理员编号
|
||||
* @return 权限列表
|
||||
*/
|
||||
public Set<String> listAdminPermission(Integer adminId) {
|
||||
// 获得管理员拥有的角色编号列表
|
||||
CommonResult<Set<Integer>> listAdminRoleIdsResult = roleFeign.listAdminRoleIds(adminId);
|
||||
listAdminRoleIdsResult.checkError();
|
||||
if (CollectionUtils.isEmpty(listAdminRoleIdsResult.getData())) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
// 获得角色拥有的资源列表
|
||||
CommonResult<List<ResourceVO>> resourceVOResult = resourceFeign.listRoleResource(
|
||||
listAdminRoleIdsResult.getData(), null);
|
||||
resourceVOResult.checkError();
|
||||
return CollectionUtils.convertSet(resourceVOResult.getData(), cn.iocoder.mall.systemservice.rpc.permission.vo.ResourceVO::getPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得管理员的菜单树
|
||||
*
|
||||
* @param adminId 管理员编号
|
||||
* @return 菜单树
|
||||
*/
|
||||
public List<PassportAdminMenuTreeNodeVO> treeAdminMenu(Integer adminId) {
|
||||
// 获得管理员拥有的角色编号列表
|
||||
CommonResult<Set<Integer>> listAdminRoleIdsResult = roleFeign.listAdminRoleIds(adminId);
|
||||
listAdminRoleIdsResult.checkError();
|
||||
if (CollectionUtils.isEmpty(listAdminRoleIdsResult.getData())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 获得角色拥有的资源(菜单)列表
|
||||
CommonResult<List<cn.iocoder.mall.systemservice.rpc.permission.vo.ResourceVO>> resourceVOResult = resourceFeign.listRoleResource(
|
||||
listAdminRoleIdsResult.getData(), ResourceTypeEnum.MENU.getType());
|
||||
resourceVOResult.checkError();
|
||||
// 构建菜单树
|
||||
return this.buildAdminMenuTree(resourceVOResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建菜单树
|
||||
*
|
||||
* @param resourceVOs 资源(都是菜单)列表
|
||||
* @return 菜单树
|
||||
*/
|
||||
private List<PassportAdminMenuTreeNodeVO> buildAdminMenuTree(List<cn.iocoder.mall.systemservice.rpc.permission.vo.ResourceVO> resourceVOs) {
|
||||
List<ResourceTreeNodeVO> treeNodeVOS = ResourceManager.buildResourceTree(resourceVOs);
|
||||
// 虽然多了一层转换,但是可维护性更好。
|
||||
return ResourceConvert.INSTANCE.convert(treeNodeVOS);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package cn.iocoder.mall.managementweb.manager.permission;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.dto.PermissionAssignAdminRoleDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.dto.PermissionAssignRoleResourceDTO;
|
||||
import cn.iocoder.mall.managementweb.convert.permission.PermissionConvert;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.PermissionFeign;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 权限 Manager
|
||||
*/
|
||||
@Service
|
||||
public class PermissionManager {
|
||||
|
||||
|
||||
@Autowired
|
||||
private PermissionFeign permissionFeign;
|
||||
/**
|
||||
* 获得角色拥有的资源编号列表
|
||||
*
|
||||
* @param roleId 角色编号
|
||||
* @return 资源编号列表
|
||||
*/
|
||||
public Set<Integer> listRoleResources(Integer roleId) {
|
||||
CommonResult<Set<Integer>> listRoleResourceIdsResult = permissionFeign.listRoleResourceIds(roleId);
|
||||
listRoleResourceIdsResult.checkError();
|
||||
return listRoleResourceIdsResult.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 赋予角色资源
|
||||
*
|
||||
* @param assignRoleResourceDTO 赋予角色资源 DTO
|
||||
*/
|
||||
public void assignRoleResource(PermissionAssignRoleResourceDTO assignRoleResourceDTO) {
|
||||
CommonResult<Boolean> assignRoleResourceResult = permissionFeign.assignRoleResource(
|
||||
PermissionConvert.INSTANCE.convert(assignRoleResourceDTO));
|
||||
assignRoleResourceResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 赋予用户角色
|
||||
*
|
||||
* @param assignAdminRoleDTO 赋予用户角色 DTO
|
||||
*/
|
||||
public void assignAdminRole(PermissionAssignAdminRoleDTO assignAdminRoleDTO) {
|
||||
CommonResult<Boolean> assignAdminRoleResult = permissionFeign.assignAdminRole(
|
||||
PermissionConvert.INSTANCE.convert(assignAdminRoleDTO));
|
||||
assignAdminRoleResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得用户拥有的角色编号列表
|
||||
*
|
||||
* @param adminId 管理员编号
|
||||
* @return 角色编号列表
|
||||
*/
|
||||
public Set<Integer> listAdminRoles(Integer adminId) {
|
||||
CommonResult<Set<Integer>> listAdminRoleIdsResult = permissionFeign.listAdminRoleIds(adminId);
|
||||
listAdminRoleIdsResult.checkError();
|
||||
return listAdminRoleIdsResult.getData();
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue