feat:V3.1.1整合remi-comm到remi-cloud中
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package ai.remi.comm.core.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc AuthFilterConfig
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "filter.config")
|
||||
public class AuthFilterConfig {
|
||||
|
||||
/**
|
||||
* 公共忽略的url,网关、公共web的AuthFilter 都会忽略---- 配置在application-dev.yaml
|
||||
*/
|
||||
private List<String> commonIgnoreUrl= new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 网关忽略的ur----配置在ebg-shop-gateway-dev.yaml
|
||||
*/
|
||||
private List<String> gatewayIgnoreUrl=new ArrayList<>();
|
||||
|
||||
/**
|
||||
*各个服务自定义忽略的url---配置在自己的服务
|
||||
*/
|
||||
private List<String> customIgnoreUrl= new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 是否验证权限----配置在idaas服务
|
||||
*/
|
||||
private Boolean verifyPermission=true;
|
||||
/**
|
||||
* 只验证token不验证 权限的
|
||||
*/
|
||||
private List<String> onlyVerifyToken=new ArrayList<>();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package ai.remi.comm.core.constant;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 流程审批常量信息
|
||||
*/
|
||||
public class ApprovalStatusConstants {
|
||||
|
||||
/**
|
||||
* 待审批
|
||||
*/
|
||||
public static final Integer DSP = 0;
|
||||
|
||||
/**
|
||||
* 审批中
|
||||
*/
|
||||
public static final Integer SPZ = 1;
|
||||
|
||||
/**
|
||||
* 审批完成
|
||||
*/
|
||||
public static final Integer SPWC = 2;
|
||||
|
||||
/**
|
||||
* 已撤销
|
||||
*/
|
||||
public static final Integer YCX = 3;
|
||||
|
||||
/**
|
||||
* 已驳回
|
||||
*/
|
||||
public static final Integer YBH = 4;
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package ai.remi.comm.core.constant;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 通用常量信息
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
/**
|
||||
* UTF-8 字符集
|
||||
*/
|
||||
public static final String UTF8 = "UTF-8";
|
||||
|
||||
/**
|
||||
* GBK 字符集
|
||||
*/
|
||||
public static final String GBK = "GBK";
|
||||
|
||||
/**
|
||||
* RMI 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_RMI = "rmi:";
|
||||
|
||||
/**
|
||||
* LDAP 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_LDAP = "ldap:";
|
||||
|
||||
/**
|
||||
* LDAPS 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_LDAPS = "ldaps:";
|
||||
|
||||
/**
|
||||
* http请求
|
||||
*/
|
||||
public static final String HTTP = "http://";
|
||||
|
||||
/**
|
||||
* https请求
|
||||
*/
|
||||
public static final String HTTPS = "https://";
|
||||
|
||||
/**
|
||||
* 成功标记
|
||||
*/
|
||||
public static final String SUCCESS = "000000";
|
||||
|
||||
/**
|
||||
* 失败标记
|
||||
*/
|
||||
public static final String ERROR = "111111";
|
||||
|
||||
/**
|
||||
* 登录成功状态
|
||||
*/
|
||||
public static final String LOGIN_SUCCESS_STATUS = "0";
|
||||
|
||||
/**
|
||||
* 登录失败状态
|
||||
*/
|
||||
public static final String LOGIN_FAIL_STATUS = "1";
|
||||
|
||||
/**
|
||||
* 登录成功
|
||||
*/
|
||||
public static final String LOGIN_SUCCESS = "Success";
|
||||
|
||||
/**
|
||||
* 登录失败
|
||||
*/
|
||||
public static final String LOGIN_FAIL = "Error";
|
||||
|
||||
/**
|
||||
* 注销
|
||||
*/
|
||||
public static final String LOGOUT = "Logout";
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public static final String REGISTER = "Register";
|
||||
|
||||
/**
|
||||
* 当前记录起始索引
|
||||
*/
|
||||
public static final String PAGE_NUM = "pageNum";
|
||||
|
||||
/**
|
||||
* 每页显示记录数
|
||||
*/
|
||||
public static final String PAGE_SIZE = "pageSize";
|
||||
|
||||
/**
|
||||
* 排序列
|
||||
*/
|
||||
public static final String ORDER_BY_COLUMN = "orderByColumn";
|
||||
|
||||
/**
|
||||
* 排序的方向 "desc" 或者 "asc".
|
||||
*/
|
||||
public static final String IS_ASC = "isAsc";
|
||||
|
||||
/**
|
||||
* 验证码 redis key
|
||||
*/
|
||||
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||
|
||||
/**
|
||||
* 验证码有效期(分钟)
|
||||
*/
|
||||
public static final long CAPTCHA_EXPIRATION = 2;
|
||||
|
||||
|
||||
/**
|
||||
* 参数管理 cache key
|
||||
*/
|
||||
public static final String SYS_CONFIG_KEY = "sys_config:";
|
||||
|
||||
/**
|
||||
* 字典管理 cache key
|
||||
*/
|
||||
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||
|
||||
/**
|
||||
* 资源映射路径 前缀
|
||||
*/
|
||||
public static final String RESOURCE_PREFIX = "/profile";
|
||||
|
||||
/**
|
||||
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
||||
*/
|
||||
public static final String[] JOB_WHITELIST_STR = {"ai.remi"};
|
||||
|
||||
/**
|
||||
* 定时任务违规的字符
|
||||
*/
|
||||
public static final String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||
"org.springframework", "org.apache", "ai.remi.comm.core.utils.file"};
|
||||
|
||||
/**
|
||||
* 系统市公司编号
|
||||
*/
|
||||
public static final String SYS_COMPANY_ID = "1667075454562709506";
|
||||
|
||||
/**
|
||||
* 登录无权限
|
||||
*/
|
||||
public static final String LOGIN_NO_PERMISSION = "401";
|
||||
|
||||
/**
|
||||
* 无权限访问资源
|
||||
*/
|
||||
public static final String CODE_401 = "401";
|
||||
|
||||
/**
|
||||
* 当前角色权限不足
|
||||
*/
|
||||
public static final String CODE_403 = "403";
|
||||
|
||||
/**
|
||||
* SRS校验数据错误码
|
||||
*/
|
||||
public static final String SRS_DATA_CHECK_ERROR = "A02001";
|
||||
|
||||
/**
|
||||
* 功能检验错误码
|
||||
*/
|
||||
public static final String COMM_CHECK_ERROR = "222222";
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package ai.remi.comm.core.constant;
|
||||
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 过滤器忽略常量
|
||||
*/
|
||||
public class FilterIgnoreConstant {
|
||||
/**
|
||||
* 默认全部忽略的url 一般用于跟服务无关的
|
||||
*/
|
||||
public static final Set<String> FILTER_COMMON_IGNORE_URL = Sets.newHashSet("/**/swagger**/**", "/**/webjars/**",
|
||||
"/**/v2/api-docs", "/**/v3/api-docs", "/**/error", "/**/doc.html", "/doc.html", "/**/favicon.ico");
|
||||
|
||||
/**
|
||||
* 全局拦截器忽略的服务
|
||||
*/
|
||||
public static final Set<String> AUTH_FILTER_IGNORE_SERVICE_NAME = Sets.newHashSet("remi-ids-web","remi-ams-web","remi-mps-web","remi-sso-web","remi-dfe-web","remi-wfe-web","remi-bie-web","remi-wpe-web","remi-job-web","remi-lce-web");
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package ai.remi.comm.core.constant;
|
||||
|
||||
import ai.remi.comm.core.enums.IdentityTypeEnum;
|
||||
import ai.remi.comm.core.enums.PermissionScopeEnum;
|
||||
import ai.remi.comm.core.enums.ServiceTypeEnum;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 全局请求头常量
|
||||
*/
|
||||
public class HeaderConstant {
|
||||
|
||||
/**
|
||||
* 部门租户id
|
||||
*/
|
||||
public static final String X_DEPT_TENANT_ID = "X-DEPT-TENANT-ID";
|
||||
|
||||
/**
|
||||
* 公司租户id
|
||||
*/
|
||||
public static final String X_COMPANY_TENANT_ID = "X-COMPANY-TENANT-ID";
|
||||
|
||||
/**
|
||||
* 当前登陆人唯一id
|
||||
*/
|
||||
public static final String X_UNIQUE_ID = "X-UNIQUE-ID";
|
||||
|
||||
/**
|
||||
* 用户系统语言
|
||||
*/
|
||||
public static final String X_USER_LANGUAGE = "X-USER-LANGUAGE";
|
||||
|
||||
/**
|
||||
* 用户设备唯一标识
|
||||
*/
|
||||
public static final String X_DISTINCT_ID = "X-DISTINCT-ID";
|
||||
|
||||
/**
|
||||
* 登录token
|
||||
*/
|
||||
public static final String X_ACCESS_TOKEN = "X-ACCESS-TOKEN";
|
||||
|
||||
/**
|
||||
* 服务类型
|
||||
*
|
||||
* @see ServiceTypeEnum
|
||||
*/
|
||||
public static final String X_SERVICE_TYPE = "X-SERVICE-TYPE";
|
||||
|
||||
/**
|
||||
* 身份类型 公司用户 访客用户 瑞米用户
|
||||
*
|
||||
* @see IdentityTypeEnum
|
||||
*/
|
||||
public static final String X_IDENTITY_TYPE = "X-IDENTITY-TYPE";
|
||||
|
||||
|
||||
/**
|
||||
* 此请求头为用户请求过来的为集团还是公司权限
|
||||
*
|
||||
* @see PermissionScopeEnum
|
||||
*/
|
||||
public static final String X_PERMISSION_SCOPE = "X-PERMISSION-SCOPE";
|
||||
|
||||
/**
|
||||
* 当权限类型为集团类型时,此请求头包含的为这个用户管理的所有公司id {@link PermissionScopeEnum}
|
||||
*/
|
||||
public static final String X_COMPANY_IDS = "X-COMPANY-IDS";
|
||||
|
||||
/**
|
||||
* 当权限类型为公司类型时,此请求头包含的为这个用户管理的所有部门id {@link PermissionScopeEnum}
|
||||
*/
|
||||
public static final String X_DEPT_IDS = "X-DEPT-IDS";
|
||||
|
||||
/**
|
||||
* 请求/响应头报文类型
|
||||
*/
|
||||
public static final String CONTENT_TYPE = "Content-Type";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package ai.remi.comm.core.constant;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc HTTP状态码
|
||||
*/
|
||||
public class HttpStatus {
|
||||
|
||||
/**
|
||||
* 操作成功
|
||||
*/
|
||||
public static final int SUCCESS = 200;
|
||||
|
||||
/**
|
||||
* 对象创建成功
|
||||
*/
|
||||
public static final int CREATED = 201;
|
||||
|
||||
/**
|
||||
* 请求已经被接受
|
||||
*/
|
||||
public static final int ACCEPTED = 202;
|
||||
|
||||
/**
|
||||
* 操作已经执行成功,但是没有返回数据
|
||||
*/
|
||||
public static final int NO_CONTENT = 204;
|
||||
|
||||
/**
|
||||
* 资源已被移除
|
||||
*/
|
||||
public static final int MOVED_PERM = 301;
|
||||
|
||||
/**
|
||||
* 重定向
|
||||
*/
|
||||
public static final int SEE_OTHER = 303;
|
||||
|
||||
/**
|
||||
* 资源没有被修改
|
||||
*/
|
||||
public static final int NOT_MODIFIED = 304;
|
||||
|
||||
/**
|
||||
* 参数列表错误(缺少,格式不匹配)
|
||||
*/
|
||||
public static final int BAD_REQUEST = 400;
|
||||
|
||||
/**
|
||||
* 未授权
|
||||
*/
|
||||
public static final int UNAUTHORIZED = 401;
|
||||
|
||||
/**
|
||||
* 访问受限,授权过期
|
||||
*/
|
||||
public static final int FORBIDDEN = 403;
|
||||
|
||||
/**
|
||||
* 资源,服务未找到
|
||||
*/
|
||||
public static final int NOT_FOUND = 404;
|
||||
|
||||
/**
|
||||
* 不允许的http方法
|
||||
*/
|
||||
public static final int BAD_METHOD = 405;
|
||||
|
||||
/**
|
||||
* 资源冲突,或者资源被锁
|
||||
*/
|
||||
public static final int CONFLICT = 409;
|
||||
|
||||
/**
|
||||
* 不支持的数据,媒体类型
|
||||
*/
|
||||
public static final int UNSUPPORTED_TYPE = 415;
|
||||
|
||||
/**
|
||||
* 系统内部错误
|
||||
*/
|
||||
public static final int ERROR = 500;
|
||||
|
||||
/**
|
||||
* 接口未实现
|
||||
*/
|
||||
public static final int NOT_IMPLEMENTED = 501;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package ai.remi.comm.core.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc OAuth2异常常量
|
||||
*/
|
||||
public class OAuth2Constants {
|
||||
|
||||
/**
|
||||
* 认证异常
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum Error {
|
||||
USERNAME_NOT_FOUND("username_not_found", "用户名未找到", ""),
|
||||
BAD_CREDENTIALS("bad_credentials", "错误凭证", "AbstractUserDetailsAuthenticationProvider.badCredentials : Bad credentials"),
|
||||
USER_LOCKED("user_locked", "用户被锁", "AbstractUserDetailsAuthenticationProvider.locked : User account is locked"),
|
||||
USER_DISABLE("user_disable", "用户禁用", "AbstractUserDetailsAuthenticationProvider.disabled : User is disabled"),
|
||||
USER_EXPIRED("user_expired", "用户过期", "AbstractUserDetailsAuthenticationProvider.expired : User account has expired"),
|
||||
CREDENTIALS_EXPIRED("credentials_expired", "证书过期", "AbstractUserDetailsAuthenticationProvider.credentialsExpired : User credentials have expired"),
|
||||
INVALID_SCOPE("invalid_scope", "无效作用域", "AbstractAccessDecisionManager.accessDenied : invalid_scope"),
|
||||
SCOPE_IS_EMPTY("scope_is_empty", "scope 为空异常", ""),
|
||||
TOKEN_MISSING("token_missing", "令牌不存在", ""),
|
||||
UN_KNOW_LOGIN_ERROR("un_know_login_error", "未知的登录异常", ""),
|
||||
INVALID_BEARER_TOKEN("invalid_bearer_token", "不合法的Token", "");
|
||||
|
||||
private final String code;
|
||||
private final String info;
|
||||
private final String msg;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package ai.remi.comm.core.constant;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc Token的Key通用常量
|
||||
*/
|
||||
public class TokenConstants {
|
||||
|
||||
/**
|
||||
* 令牌自定义标识
|
||||
*/
|
||||
public static final String AUTHENTICATION = "Authorization";
|
||||
|
||||
/**
|
||||
* 补充令牌自定义标识
|
||||
*/
|
||||
public static final String SUPPLY_AUTHORIZATION = "X-Access-Token";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String PREFIX = "Remi";
|
||||
|
||||
/**
|
||||
* 回调地址
|
||||
*/
|
||||
public static final String REDIRECT_URL = "redirect_url";
|
||||
|
||||
/**
|
||||
* 令牌秘钥
|
||||
*/
|
||||
public final static String SECRET = "ce6e6cc15d0349b58f9d8c43e5f328ce7f329029434242c6aaaec5a06b930a4a4d73cf1a7e7b48eb80fad6a916ded78d614cc2e63779489d9a2aaaafd674c5515e708ba5869a4dcfa3e66799";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package ai.remi.comm.core.constant;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 用户常量信息
|
||||
*/
|
||||
public class UserConstants {
|
||||
|
||||
/**
|
||||
* 平台内系统用户的唯一标志
|
||||
*/
|
||||
public static final String SYS_USER = "SYS_USER";
|
||||
|
||||
/**
|
||||
* 正常状态
|
||||
*/
|
||||
public static final String NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 异常状态
|
||||
*/
|
||||
public static final String EXCEPTION = "1";
|
||||
|
||||
/**
|
||||
* 用户封禁状态
|
||||
*/
|
||||
public static final String USER_DISABLE = "1";
|
||||
|
||||
/**
|
||||
* 角色封禁状态
|
||||
*/
|
||||
public static final String ROLE_DISABLE = "1";
|
||||
|
||||
/**
|
||||
* 部门正常状态
|
||||
*/
|
||||
public static final String DEPT_NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 部门停用状态
|
||||
*/
|
||||
public static final String DEPT_DISABLE = "1";
|
||||
|
||||
/**
|
||||
* 字典正常状态
|
||||
*/
|
||||
public static final String DICT_NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 是否为系统默认(是)
|
||||
*/
|
||||
public static final String YES = "Y";
|
||||
|
||||
/**
|
||||
* 是否菜单外链(是)
|
||||
*/
|
||||
public static final String YES_FRAME = "0";
|
||||
|
||||
/**
|
||||
* 是否菜单外链(否)
|
||||
*/
|
||||
public static final String NO_FRAME = "1";
|
||||
|
||||
/**
|
||||
* 菜单类型(目录)
|
||||
*/
|
||||
public static final String TYPE_DIR = "M";
|
||||
|
||||
/**
|
||||
* 菜单类型(菜单)
|
||||
*/
|
||||
public static final String TYPE_MENU = "C";
|
||||
|
||||
/**
|
||||
* 菜单类型(按钮)
|
||||
*/
|
||||
public static final String TYPE_BUTTON = "F";
|
||||
|
||||
/**
|
||||
* Layout组件标识
|
||||
*/
|
||||
public final static String LAYOUT = "Layout";
|
||||
|
||||
/**
|
||||
* ParentView组件标识
|
||||
*/
|
||||
public final static String PARENT_VIEW = "ParentView";
|
||||
|
||||
/**
|
||||
* InnerLink组件标识
|
||||
*/
|
||||
public final static String INNER_LINK = "InnerLink";
|
||||
|
||||
/**
|
||||
* 校验返回结果码
|
||||
*/
|
||||
public final static String UNIQUE = "0";
|
||||
|
||||
public final static String NOT_UNIQUE = "1";
|
||||
|
||||
/**
|
||||
* 用户名长度限制
|
||||
*/
|
||||
public static final int USERNAME_MIN_LENGTH = 2;
|
||||
|
||||
public static final int USERNAME_MAX_LENGTH = 20;
|
||||
|
||||
/**
|
||||
* 密码长度限制
|
||||
*/
|
||||
public static final int PASSWORD_MIN_LENGTH = 5;
|
||||
|
||||
public static final int PASSWORD_MAX_LENGTH = 20;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package ai.remi.comm.core.enums;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 请求方式
|
||||
*/
|
||||
public enum HttpMethod {
|
||||
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
|
||||
|
||||
private static final Map<String, HttpMethod> mappings = new HashMap<>(16);
|
||||
|
||||
static {
|
||||
for (HttpMethod httpMethod : values()) {
|
||||
mappings.put(httpMethod.name(), httpMethod);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HttpMethod resolve(@Nullable String method) {
|
||||
return (method != null ? mappings.get(method) : null);
|
||||
}
|
||||
|
||||
public boolean matches(String method) {
|
||||
return (this == resolve(method));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package ai.remi.comm.core.enums;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 身份类型枚举定义
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public enum IdentityTypeEnum {
|
||||
|
||||
STARTDIS("remi", "瑞米官方账号"),
|
||||
COMPANY("company", "集团公司账户"),
|
||||
VISITOR("visitor", "游客体验账号");
|
||||
|
||||
private String code;
|
||||
|
||||
private String desc;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package ai.remi.comm.core.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 权限范围枚举定义
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PermissionScopeEnum {
|
||||
|
||||
GROUP("group","集团范围"),
|
||||
COMPANY("company","公司范围"),
|
||||
DEPT("dept","部门范围");
|
||||
|
||||
@JsonValue
|
||||
private String code;
|
||||
|
||||
private String desc;
|
||||
|
||||
@JsonCreator
|
||||
public static PermissionScopeEnum codeOf(String code) {
|
||||
return Arrays.stream(PermissionScopeEnum.values())
|
||||
.filter(each -> each.getCode().equals(code))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> {
|
||||
throw new IllegalArgumentException("非法参数");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package ai.remi.comm.core.enums;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 错误码设计描述
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public enum ServiceTypeEnum {
|
||||
|
||||
WEB_SERVICE("webService", "/web-api/**", "管理端服务"),
|
||||
APP_SERVICE("appService", "/app-api/**", "移动端服务");
|
||||
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 服务对应的路径前缀
|
||||
*/
|
||||
private String pathPrefix;
|
||||
|
||||
private String desc;
|
||||
|
||||
|
||||
public static ServiceTypeEnum codeOf(String code) {
|
||||
return Arrays.stream(values())
|
||||
.filter((each) -> each.getCode().equals(code)).findFirst()
|
||||
.orElseThrow(()->new RuntimeException("找不到服务"));
|
||||
}
|
||||
|
||||
public static ServiceTypeEnum pathPrefixOf(String pathPrefix){
|
||||
return Arrays.stream(values())
|
||||
.filter((each) -> each.getPathPrefix().equals(pathPrefix)).findFirst()
|
||||
.orElseThrow(()->new RuntimeException("找不到服务"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package ai.remi.comm.core.enums;
|
||||
|
||||
public interface TypeEnum {
|
||||
/**
|
||||
* 类型编码
|
||||
*/
|
||||
Integer getCode();
|
||||
|
||||
/**
|
||||
* 类型描述
|
||||
*/
|
||||
String getDesc();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package ai.remi.comm.core.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum YesNoEnum implements TypeEnum{
|
||||
|
||||
NO(0, "否"),
|
||||
|
||||
YES(1, "是");
|
||||
|
||||
@JsonValue
|
||||
private Integer code;
|
||||
|
||||
private String desc;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package ai.remi.comm.core.excel;
|
||||
|
||||
public interface ExcelDynamicSelect {
|
||||
|
||||
/**
|
||||
* 获取动态生成的下拉框可选数据
|
||||
* @return 动态生成的下拉框可选数据
|
||||
*/
|
||||
String[] getSource();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package ai.remi.comm.core.excel;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Target({ElementType.FIELD})//用此注解用在属性上。
|
||||
@Retention(RetentionPolicy.RUNTIME)//注解不仅被保存到class文件中,jvm加载class文件之后,仍然存在;
|
||||
public @interface ExcelSelected {
|
||||
|
||||
/**
|
||||
* 固定下拉内容
|
||||
*/
|
||||
String[] source() default {};
|
||||
|
||||
/**
|
||||
* 动态下拉内容
|
||||
*/
|
||||
Class<? extends ExcelDynamicSelect>[] sourceClass() default {};
|
||||
|
||||
/**
|
||||
* 设置下拉框的起始行,默认为第二行
|
||||
*/
|
||||
int firstRow() default 1;
|
||||
|
||||
/**
|
||||
* 设置下拉框的结束行,默认为最后一行
|
||||
*/
|
||||
int lastRow() default 0x10000;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package ai.remi.comm.core.result;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc PagerBean
|
||||
*/
|
||||
@Data
|
||||
public class PagerBean<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4804053559968742915L;
|
||||
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
private Long total;
|
||||
|
||||
/**
|
||||
* 当前页
|
||||
*/
|
||||
protected Long pageNum;
|
||||
|
||||
/**
|
||||
* 页大小
|
||||
*/
|
||||
protected Long pageSize;
|
||||
|
||||
/**
|
||||
* 列表数据
|
||||
*/
|
||||
private List<?> records;
|
||||
|
||||
/**
|
||||
* 是否可导入
|
||||
*/
|
||||
private boolean if_import;
|
||||
public PagerBean() {
|
||||
}
|
||||
|
||||
public PagerBean(Long total, Long pageNum, Long pageSize, List<T> records) {
|
||||
this.total = total;
|
||||
this.pageNum = pageNum;
|
||||
this.pageSize = pageSize;
|
||||
this.records = records;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package ai.remi.comm.core.result;
|
||||
|
||||
import ai.remi.comm.core.constant.Constants;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc ResultBean
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class ResultBean<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8676131899637805509L;
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
public static final String SUCCESS = Constants.SUCCESS;
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
public static final String ERROR = Constants.ERROR;
|
||||
|
||||
// 返回编码
|
||||
private String code;
|
||||
// 返回信息
|
||||
private String msg;
|
||||
// 返回数据封装
|
||||
@Builder.Default
|
||||
private T data = (T) "";
|
||||
|
||||
public ResultBean() {
|
||||
}
|
||||
|
||||
private static <T> ResultBean<T> restResult(String code, String msg, T data) {
|
||||
ResultBean<T> apiResult = new ResultBean<>();
|
||||
apiResult.setCode(code);
|
||||
apiResult.setData(data);
|
||||
apiResult.setMsg(msg);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static <T> ResultBean<T> success() {
|
||||
return restResult(SUCCESS, null, null);
|
||||
}
|
||||
|
||||
public static <T> ResultBean<T> success(String msg) {
|
||||
return restResult(SUCCESS, msg, null);
|
||||
}
|
||||
|
||||
public static <T> ResultBean<T> success(T data) {
|
||||
return restResult(SUCCESS, null, data);
|
||||
}
|
||||
|
||||
public static <T> ResultBean<T> success(String msg, T data) {
|
||||
return restResult(SUCCESS, msg, data);
|
||||
}
|
||||
|
||||
public static <T> ResultBean<T> error() {
|
||||
return restResult(ERROR, null, null);
|
||||
}
|
||||
|
||||
public static <T> ResultBean<T> error(String msg) {
|
||||
return restResult(ERROR, msg, null);
|
||||
}
|
||||
|
||||
public static <T> ResultBean<T> error(T data) {
|
||||
return restResult(ERROR, null, data);
|
||||
}
|
||||
|
||||
public static <T> ResultBean<T> error(String msg, T data) {
|
||||
return restResult(ERROR, msg, data);
|
||||
}
|
||||
|
||||
public static <T> ResultBean<T> error(String code, String msg, T data) {
|
||||
return restResult(code, msg, data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package ai.remi.comm.core.spring;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc SpringBeanUtils
|
||||
*/
|
||||
@Component
|
||||
public class SpringBeans implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
if (SpringBeans.applicationContext == null) {
|
||||
SpringBeans.applicationContext = applicationContext;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by dianjiu on 2022-06-23 ,contact lidianjiu@njydsz.com. 获取applicationContext.
|
||||
*/
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by dianjiu on 2022-06-23 ,contact lidianjiu@njydsz.com. 通过name获取 Bean.
|
||||
*/
|
||||
public static Object getBean(String name) {
|
||||
return getApplicationContext().getBean(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by dianjiu on 2022-06-23 ,contact lidianjiu@njydsz.com. 通过class获取Bean.
|
||||
*/
|
||||
public static <T> T getBean(Class<T> clazz) {
|
||||
return getApplicationContext().getBean(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by dianjiu on 2022-06-23 ,contact lidianjiu@njydsz.com. 通过name,以及Clazz返回指定的Bean.
|
||||
*/
|
||||
public static <T> T getBean(String name, Class<T> clazz) {
|
||||
return getApplicationContext().getBean(name, clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据clazz类型获取spring容器中的对象
|
||||
*/
|
||||
public static <T> Map<String, T> getBeansOfType(Class<T> clazz) {
|
||||
return getApplicationContext().getBeansOfType(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据注解类从容器中获取对象
|
||||
*/
|
||||
public static <T> Map<String, Object> getBeansOfAnnotation(Class<? extends Annotation> clazz) {
|
||||
return getApplicationContext().getBeansWithAnnotation(clazz);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package ai.remi.comm.core.spring;
|
||||
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author dianjiu【公众号 点九开源】
|
||||
* @email dianjiuxyz@gmail.com
|
||||
* @desc 通过"server.port"作为name格式调用getPropertiesValue()方法
|
||||
*/
|
||||
@Component
|
||||
public class SpringProperties implements EnvironmentAware {
|
||||
|
||||
private static Environment env;
|
||||
|
||||
@Override
|
||||
public void setEnvironment(Environment environment) {
|
||||
env = environment;
|
||||
}
|
||||
|
||||
public static String getString(String key) {
|
||||
return env.getProperty(key);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
ai.remi.comm.core.config.AuthFilterConfig,\
|
||||
ai.remi.comm.core.spring.SpringProperties,\
|
||||
ai.remi.comm.core.spring.SpringBeans
|
||||
|
||||
|
||||
Reference in New Issue
Block a user