1.初始化版本,2.引入thirdpart模块,引入canteen模块,初始化菜品分类,spu
This commit is contained in:
commit
aff77150d6
1595 files changed
+168833
No files matched your search
+26
@@ -0,0 +1,26 @@
|
||||
package com.bsd.pjcloud.common.core.config;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* 明确异步线程池配置,避免和 @EnableScheduling 造成的线程池冲突
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2024/4/20
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@RequiredArgsConstructor
|
||||
public class AsyncConfiguration implements AsyncConfigurer {
|
||||
|
||||
private final ThreadPoolTaskExecutor applicationTaskExecutor;
|
||||
|
||||
@Override
|
||||
public Executor getAsyncExecutor() {
|
||||
return applicationTaskExecutor;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.bsd.pjcloud.common.core.config;
|
||||
|
||||
import com.bsd.pjcloud.common.core.factory.YamlPropertySourceFactory;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
/**
|
||||
* 加载不可变配置项,这样的配置文件一舦是放在jar包中的,不会随着环境的变化而变化。
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2024/7/20
|
||||
*/
|
||||
@PropertySource(value = "classpath:common-config.yml", factory = YamlPropertySourceFactory.class)
|
||||
public class ImmutableConfiguration {
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.bsd.pjcloud.common.core.config;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.bsd.pjcloud.common.core.jackson.PjcloudJavaTimeModule;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
import org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.format.FormatterRegistry;
|
||||
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* JacksonConfig 配置时间转换规则
|
||||
* {@link com.bsd.pjcloud.common.core.jackson.PjcloudJavaTimeModule}、默认时区等
|
||||
*
|
||||
* @author L.cm
|
||||
* @author pjcloud
|
||||
* @author lishangbu
|
||||
* @date 2020-06-15
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(ObjectMapper.class)
|
||||
@AutoConfigureBefore(JacksonAutoConfiguration.class)
|
||||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
|
||||
public class JacksonConfiguration implements WebMvcConfigurer {
|
||||
|
||||
private static final String ASIA_SHANGHAI = "Asia/Shanghai";
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public Jackson2ObjectMapperBuilderCustomizer customizer() {
|
||||
return builder -> {
|
||||
builder.locale(Locale.CHINA);
|
||||
builder.timeZone(TimeZone.getTimeZone(ASIA_SHANGHAI));
|
||||
builder.simpleDateFormat(DatePattern.NORM_DATETIME_PATTERN);
|
||||
builder.serializerByType(Long.class, ToStringSerializer.instance);
|
||||
builder.modules(new PjcloudJavaTimeModule());
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加GET请求参数中时间类型转换 {@link com.bsd.pjcloud.common.core.jackson.PjcloudJavaTimeModule}
|
||||
* <ul>
|
||||
* <li>HH:mm:ss -> LocalTime</li>
|
||||
* <li>yyyy-MM-dd -> LocalDate</li>
|
||||
* <li>yyyy-MM-dd HH:mm:ss -> LocalDateTime</li>
|
||||
* </ul>
|
||||
* @param registry
|
||||
*/
|
||||
@Override
|
||||
public void addFormatters(FormatterRegistry registry) {
|
||||
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
|
||||
registrar.setTimeFormatter(DateTimeFormatter.ofPattern(DatePattern.NORM_TIME_PATTERN));
|
||||
registrar.setDateFormatter(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
|
||||
registrar.setDateTimeFormatter(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
|
||||
registrar.registerFormatters(registry);
|
||||
}
|
||||
|
||||
/**
|
||||
* 避免form 提交 context-type 不规范中文乱码
|
||||
* @return Filter
|
||||
*/
|
||||
@Bean
|
||||
public OrderedCharacterEncodingFilter characterEncodingFilter() {
|
||||
OrderedCharacterEncodingFilter filter = new OrderedCharacterEncodingFilter();
|
||||
filter.setEncoding(StandardCharsets.UTF_8.name());
|
||||
filter.setForceEncoding(true);
|
||||
filter.setOrder(Ordered.HIGHEST_PRECEDENCE);
|
||||
return filter;
|
||||
}
|
||||
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.config;
|
||||
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018/11/14
|
||||
* <p>
|
||||
* 国际化配置
|
||||
*/
|
||||
@Configuration
|
||||
public class MessageSourceConfiguration {
|
||||
|
||||
@Bean
|
||||
public MessageSource pjcloudMessageSource() {
|
||||
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
|
||||
messageSource.setBasename("classpath:i18n/messages");
|
||||
return messageSource;
|
||||
}
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018/8/16 RestTemplate
|
||||
*/
|
||||
@Configuration
|
||||
public class RestTemplateConfiguration {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
package com.bsd.pjcloud.common.core.constant;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2019-04-28
|
||||
* <p>
|
||||
* 缓存的key 常量
|
||||
*/
|
||||
public interface CacheConstants {
|
||||
|
||||
/**
|
||||
* 全局缓存,在缓存名称上加上该前缀表示该缓存不区分租户,比如:
|
||||
* <p/>
|
||||
* {@code @Cacheable(value = CacheConstants.GLOBALLY+CacheConstants.MENU_DETAILS, key = "#roleId + '_menu'", unless = "#result == null")}
|
||||
*/
|
||||
String GLOBALLY = "gl:";
|
||||
|
||||
/**
|
||||
* 验证码前缀
|
||||
*/
|
||||
String DEFAULT_CODE_KEY = "DEFAULT_CODE_KEY:";
|
||||
|
||||
/**
|
||||
* 菜单信息缓存
|
||||
*/
|
||||
String MENU_DETAILS = "menu_details";
|
||||
|
||||
/**
|
||||
* 用户信息缓存
|
||||
*/
|
||||
String USER_DETAILS = "user_details";
|
||||
|
||||
/**
|
||||
* 移动端用户信息缓存
|
||||
*/
|
||||
String USER_DETAILS_MINI = "user_details_mini";
|
||||
|
||||
/**
|
||||
* 角色信息缓存
|
||||
*/
|
||||
String ROLE_DETAILS = "role_details";
|
||||
|
||||
/**
|
||||
* 字典信息缓存
|
||||
*/
|
||||
String DICT_DETAILS = "dict_details";
|
||||
|
||||
/**
|
||||
* oauth 客户端信息
|
||||
*/
|
||||
String CLIENT_DETAILS_KEY = "pjcloud_oauth:client:details";
|
||||
|
||||
/**
|
||||
* spring boot admin 事件key
|
||||
*/
|
||||
String EVENT_KEY = GLOBALLY + "event_key";
|
||||
|
||||
/**
|
||||
* 路由存放
|
||||
*/
|
||||
String ROUTE_KEY = GLOBALLY + "gateway_route_key";
|
||||
|
||||
/**
|
||||
* 内存reload 时间
|
||||
*/
|
||||
String ROUTE_JVM_RELOAD_TOPIC = "gateway_jvm_route_reload_topic";
|
||||
|
||||
/**
|
||||
* redis 重新加载 路由信息
|
||||
*/
|
||||
String ROUTE_REDIS_RELOAD_TOPIC = "upms_redis_route_reload_topic";
|
||||
|
||||
/**
|
||||
* redis 重新加载客户端信息
|
||||
*/
|
||||
String CLIENT_REDIS_RELOAD_TOPIC = "upms_redis_client_reload_topic";
|
||||
|
||||
/**
|
||||
* 敏感词重新加载
|
||||
*/
|
||||
String SENSITIVE_REDIS_RELOAD_TOPIC = "sensitive_client_reload_topic";
|
||||
|
||||
/**
|
||||
* 公众号 reload
|
||||
*/
|
||||
String MP_REDIS_RELOAD_TOPIC = "mp_redis_reload_topic";
|
||||
|
||||
/**
|
||||
* 支付 reload 事件
|
||||
*/
|
||||
String PAY_REDIS_RELOAD_TOPIC = "pay_redis_reload_topic";
|
||||
|
||||
/**
|
||||
* 参数缓存
|
||||
*/
|
||||
String PARAMS_DETAILS = "params_details";
|
||||
|
||||
/**
|
||||
* 租户缓存 (不区分租户)
|
||||
*/
|
||||
String TENANT_DETAILS = GLOBALLY + "tenant_details";
|
||||
|
||||
/**
|
||||
* i18n缓存 (不区分租户)
|
||||
*/
|
||||
String I18N_DETAILS = GLOBALLY + "i18n_details";
|
||||
|
||||
/**
|
||||
* 客户端配置缓存
|
||||
*/
|
||||
String CLIENT_FLAG = "client_config_flag";
|
||||
|
||||
/**
|
||||
* 登录错误次数
|
||||
*/
|
||||
String LOGIN_ERROR_TIMES = "login_error_times";
|
||||
|
||||
/**
|
||||
* oauth 缓存前缀
|
||||
*/
|
||||
String PROJECT_OAUTH_ACCESS = "token::access_token";
|
||||
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.constant;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2017/10/29
|
||||
*/
|
||||
public interface CommonConstants {
|
||||
|
||||
/**
|
||||
* header 中租户ID
|
||||
*/
|
||||
String TENANT_ID = "TENANT-ID";
|
||||
|
||||
/**
|
||||
* header 中版本信息
|
||||
*/
|
||||
String VERSION = "VERSION";
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
Long TENANT_ID_1 = 1L;
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
String STATUS_DEL = "1";
|
||||
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
String STATUS_NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 锁定
|
||||
*/
|
||||
String STATUS_LOCK = "9";
|
||||
|
||||
/**
|
||||
* 菜单树根节点
|
||||
*/
|
||||
Long MENU_TREE_ROOT_ID = -1L;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
String UTF8 = "UTF-8";
|
||||
|
||||
/**
|
||||
* 前端工程名
|
||||
*/
|
||||
String FRONT_END_PROJECT = "pjcloud-ui";
|
||||
|
||||
/**
|
||||
* 移动端工程名
|
||||
*/
|
||||
String UNI_END_PROJECT = "pjcloud-app";
|
||||
|
||||
/**
|
||||
* 后端工程名
|
||||
*/
|
||||
String BACK_END_PROJECT = "pjcloud";
|
||||
|
||||
/**
|
||||
* 公共参数
|
||||
*/
|
||||
String PIG_PUBLIC_PARAM_KEY = "PIG_PUBLIC_PARAM_KEY";
|
||||
|
||||
/**
|
||||
* 成功标记
|
||||
*/
|
||||
Integer SUCCESS = 0;
|
||||
|
||||
/**
|
||||
* 失败标记
|
||||
*/
|
||||
Integer FAIL = 1;
|
||||
|
||||
/**
|
||||
* 默认存储bucket
|
||||
*/
|
||||
String BUCKET_NAME = "pjcloud";
|
||||
|
||||
/**
|
||||
* 滑块验证码
|
||||
*/
|
||||
String IMAGE_CODE_TYPE = "blockPuzzle";
|
||||
|
||||
/**
|
||||
* 验证码开关
|
||||
*/
|
||||
String CAPTCHA_FLAG = "captcha_flag";
|
||||
|
||||
/**
|
||||
* 密码传输是否加密
|
||||
*/
|
||||
String ENC_FLAG = "enc_flag";
|
||||
|
||||
/**
|
||||
* 客户端允许同时在线数量
|
||||
*/
|
||||
String ONLINE_QUANTITY = "online_quantity";
|
||||
|
||||
/**
|
||||
* 请求开始时间
|
||||
*/
|
||||
String REQUEST_START_TIME = "REQUEST-START-TIME";
|
||||
|
||||
/**
|
||||
* 当前页
|
||||
*/
|
||||
String CURRENT = "current";
|
||||
|
||||
/**
|
||||
* size
|
||||
*/
|
||||
String SIZE = "size";
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.bsd.pjcloud.common.core.constant;
|
||||
|
||||
/**
|
||||
* 分页相关的参数
|
||||
*
|
||||
* @author lishangbu
|
||||
* @date 2018/11/22
|
||||
*/
|
||||
public interface PaginationConstants {
|
||||
|
||||
/**
|
||||
* 当前页
|
||||
*/
|
||||
String CURRENT = "current";
|
||||
|
||||
/**
|
||||
* 每页大小
|
||||
*/
|
||||
String SIZE = "size";
|
||||
|
||||
}
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.constant;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2017-12-18
|
||||
*/
|
||||
public interface SecurityConstants {
|
||||
|
||||
/**
|
||||
* 启动时是否检查Inner注解安全性
|
||||
*/
|
||||
boolean INNER_CHECK = true;
|
||||
|
||||
/**
|
||||
* 刷新
|
||||
*/
|
||||
String REFRESH_TOKEN = "refresh_token";
|
||||
|
||||
/**
|
||||
* 验证码有效期
|
||||
*/
|
||||
int CODE_TIME = 60;
|
||||
|
||||
/**
|
||||
* 验证码长度
|
||||
*/
|
||||
String CODE_SIZE = "4";
|
||||
|
||||
/**
|
||||
* 角色前缀
|
||||
*/
|
||||
String ROLE = "ROLE_";
|
||||
|
||||
/**
|
||||
* 前缀
|
||||
*/
|
||||
String PIGX_PREFIX = "pjcloud_";
|
||||
|
||||
/**
|
||||
* token 相关前缀
|
||||
*/
|
||||
String TOKEN_PREFIX = "token:";
|
||||
|
||||
/**
|
||||
* oauth 相关前缀
|
||||
*/
|
||||
String OAUTH_PREFIX = "oauth:";
|
||||
|
||||
/**
|
||||
* 授权码模式code key 前缀
|
||||
*/
|
||||
String OAUTH_CODE_PREFIX = "oauth:code:";
|
||||
|
||||
/**
|
||||
* 项目的license
|
||||
*/
|
||||
String PIGX_LICENSE = "https://pig4cloud.com";
|
||||
|
||||
/**
|
||||
* 内部
|
||||
*/
|
||||
String FROM_IN = "Y";
|
||||
|
||||
/**
|
||||
* 标志
|
||||
*/
|
||||
String FROM = "from";
|
||||
|
||||
/**
|
||||
* 请求header
|
||||
*/
|
||||
String HEADER_FROM_IN = FROM + "=" + FROM_IN;
|
||||
|
||||
/**
|
||||
* OAUTH URL
|
||||
*/
|
||||
String OAUTH_TOKEN_URL = "/oauth2/token";
|
||||
|
||||
/**
|
||||
* 移动端授权
|
||||
*/
|
||||
String GRANT_MOBILE = "mobile";
|
||||
|
||||
/**
|
||||
* TOC 客户端
|
||||
*/
|
||||
String HEADER_TOC = "CLIENT-TOC";
|
||||
|
||||
/**
|
||||
* TOC 客户端
|
||||
*/
|
||||
String HEADER_TOC_YES = "Y";
|
||||
|
||||
/**
|
||||
* QQ获取token
|
||||
*/
|
||||
String QQ_AUTHORIZATION_CODE_URL = "https://graph.qq.com/oauth2.0/token?grant_type="
|
||||
+ "authorization_code&code=%S&client_id=%s&redirect_uri=" + "%s&client_secret=%s";
|
||||
|
||||
/**
|
||||
* 微信获取OPENID
|
||||
*/
|
||||
String WX_AUTHORIZATION_CODE_URL = "https://api.weixin.qq.com/sns/oauth2/access_token"
|
||||
+ "?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
|
||||
|
||||
/**
|
||||
* 微信小程序OPENID
|
||||
*/
|
||||
String MINI_APP_AUTHORIZATION_CODE_URL = "https://api.weixin.qq.com/sns/jscode2session"
|
||||
+ "?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code";
|
||||
|
||||
/**
|
||||
* 码云获取token
|
||||
*/
|
||||
String GITEE_AUTHORIZATION_CODE_URL = "https://gitee.com/oauth/token?grant_type="
|
||||
+ "authorization_code&code=%S&client_id=%s&redirect_uri=" + "%s&client_secret=%s";
|
||||
|
||||
/**
|
||||
* 开源中国获取token
|
||||
*/
|
||||
String OSC_AUTHORIZATION_CODE_URL = "https://www.oschina.net/action/openapi/token";
|
||||
|
||||
/**
|
||||
* QQ获取用户信息
|
||||
*/
|
||||
String QQ_USER_INFO_URL = "https://graph.qq.com/oauth2.0/me?access_token=%s";
|
||||
|
||||
/**
|
||||
* 码云获取用户信息
|
||||
*/
|
||||
String GITEE_USER_INFO_URL = "https://gitee.com/api/v5/user?access_token=%s";
|
||||
|
||||
/**
|
||||
* 开源中国用户信息
|
||||
*/
|
||||
String OSC_USER_INFO_URL = "https://www.oschina.net/action/openapi/user?access_token=%s&dataType=json";
|
||||
|
||||
/**
|
||||
* 钉钉获取 token
|
||||
*/
|
||||
String DING_OLD_GET_TOKEN = "https://oapi.dingtalk.com/gettoken";
|
||||
|
||||
/**
|
||||
* 钉钉同步部门列表
|
||||
*/
|
||||
String DING_OLD_DEPT_URL = "https://oapi.dingtalk.com/topapi/v2/department/listsub";
|
||||
|
||||
/**
|
||||
* 钉钉部门用户id列表
|
||||
*/
|
||||
String DING_DEPT_USERIDS_URL = "https://oapi.dingtalk.com/topapi/user/listid";
|
||||
|
||||
/**
|
||||
* 钉钉用户详情
|
||||
*/
|
||||
String DING_USER_INFO_URL = "https://oapi.dingtalk.com/topapi/v2/user/get";
|
||||
|
||||
/**
|
||||
* {bcrypt} 加密的特征码
|
||||
*/
|
||||
String BCRYPT = "{bcrypt}";
|
||||
|
||||
/**
|
||||
* 客户端模式
|
||||
*/
|
||||
String CLIENT_CREDENTIALS = "client_credentials";
|
||||
|
||||
/**
|
||||
* 客户端编号
|
||||
*/
|
||||
String CLIENT_ID = "client_id";
|
||||
|
||||
/**
|
||||
* 客户端唯一令牌
|
||||
*/
|
||||
String CLIENT_RECREATE = "recreate_flag";
|
||||
|
||||
/**
|
||||
* 用户ID字段
|
||||
*/
|
||||
String DETAILS_USER_ID = "user_id";
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
String DETAILS_USERNAME = "username";
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
String NAME = "name";
|
||||
|
||||
/**
|
||||
* 协议字段
|
||||
*/
|
||||
String DETAILS_LICENSE = "license";
|
||||
|
||||
/**
|
||||
* 激活字段 兼容外围系统接入
|
||||
*/
|
||||
String ACTIVE = "active";
|
||||
|
||||
/**
|
||||
* AES 加密
|
||||
*/
|
||||
String AES = "aes";
|
||||
|
||||
/**
|
||||
* 授权码模式confirm
|
||||
*/
|
||||
String CUSTOM_CONSENT_PAGE_URI = "/token/confirm_access";
|
||||
|
||||
/**
|
||||
* {noop} 加密的特征码
|
||||
*/
|
||||
String NOOP = "{noop}";
|
||||
|
||||
/**
|
||||
* 短信登录 参数名称
|
||||
*/
|
||||
String SMS_PARAMETER_NAME = "mobile";
|
||||
|
||||
/**
|
||||
* 手机号登录
|
||||
*/
|
||||
String APP = "mobile";
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
String DETAILS_USER = "user_info";
|
||||
|
||||
/**
|
||||
* 不脱敏的权限
|
||||
*/
|
||||
String NO_MASK = "no_mask";
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.constant;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018年06月22日16:41:01 服务名称
|
||||
*/
|
||||
public interface ServiceNameConstants {
|
||||
|
||||
/**
|
||||
* 认证中心
|
||||
*/
|
||||
String AUTH_SERVICE = "pjcloud-auth";
|
||||
|
||||
/**
|
||||
* UMPS模块
|
||||
*/
|
||||
String UPMS_SERVICE = "pjcloud-upms-biz";
|
||||
|
||||
/**
|
||||
* app服务
|
||||
*/
|
||||
String APP_SERVER = "pjcloud-app-server-biz";
|
||||
|
||||
/**
|
||||
* 流程引擎
|
||||
*/
|
||||
String FLOW_ENGINE_SERVER = "pjcloud-flow-engine-biz";
|
||||
|
||||
/**
|
||||
* 流程工单
|
||||
*/
|
||||
String FLOW_TASK_SERVER = "pjcloud-flow-task-biz";
|
||||
|
||||
/**
|
||||
* 代码生成模块
|
||||
*/
|
||||
String CODEGEN_SERVICE = "pjcloud-codegen";
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.bsd.pjcloud.common.core.constant.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2020-11-18
|
||||
* <p>
|
||||
* 验证码状态
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CaptchaFlagTypeEnum {
|
||||
|
||||
/**
|
||||
* 开启验证码
|
||||
*/
|
||||
ON("1", "开启验证码"),
|
||||
|
||||
/**
|
||||
* 关闭验证码
|
||||
*/
|
||||
OFF("0", "关闭验证码");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.bsd.pjcloud.common.core.constant.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2019-05-16
|
||||
* <p>
|
||||
* 字典类型
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DictTypeEnum {
|
||||
|
||||
/**
|
||||
* 字典类型-系统内置(不可修改)
|
||||
*/
|
||||
SYSTEM("1", "系统内置"),
|
||||
|
||||
/**
|
||||
* 字典类型-业务类型
|
||||
*/
|
||||
BIZ("0", "业务类");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.bsd.pjcloud.common.core.constant.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2020-11-18
|
||||
* <p>
|
||||
* 密码是否加密传输
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum EncFlagTypeEnum {
|
||||
|
||||
/**
|
||||
* 是
|
||||
*/
|
||||
YES("1", "是"),
|
||||
|
||||
/**
|
||||
* 否
|
||||
*/
|
||||
NO("0", "否");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.constant.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018/8/15 社交登录类型
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum LoginTypeEnum {
|
||||
|
||||
/**
|
||||
* 账号密码登录
|
||||
*/
|
||||
PWD("PWD", "账号密码登录"),
|
||||
|
||||
/**
|
||||
* 验证码登录
|
||||
*/
|
||||
SMS("SMS", "验证码登录"),
|
||||
|
||||
APPSMS("APP-SMS", "APP验证码登录"),
|
||||
|
||||
/**
|
||||
* QQ登录
|
||||
*/
|
||||
QQ("QQ", "QQ登录"),
|
||||
|
||||
/**
|
||||
* 微信登录
|
||||
*/
|
||||
WECHAT("WX", "微信登录"),
|
||||
|
||||
/**
|
||||
* 微信小程序
|
||||
*/
|
||||
MINI_APP("MINI", "微信小程序"),
|
||||
|
||||
/**
|
||||
* 码云登录
|
||||
*/
|
||||
GITEE("GITEE", "码云登录"),
|
||||
|
||||
/**
|
||||
* 开源中国登录
|
||||
*/
|
||||
OSC("OSC", "开源中国登录"),
|
||||
|
||||
/**
|
||||
* 钉钉
|
||||
*/
|
||||
DINGTALK("DINGTALK", "钉钉"),
|
||||
|
||||
/**
|
||||
* 企业微信
|
||||
*/
|
||||
WEIXIN_CP("WEIXIN_CP", "企业微信"),
|
||||
|
||||
/**
|
||||
* CAS 登录
|
||||
*/
|
||||
CAS("CAS", "CAS 登录");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.bsd.pjcloud.common.core.constant.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2020-02-17
|
||||
* <p>
|
||||
* 菜单类型
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum MenuTypeEnum {
|
||||
|
||||
/**
|
||||
* 左侧菜单
|
||||
*/
|
||||
LEFT_MENU("0", "left"),
|
||||
|
||||
/**
|
||||
* 顶部菜单
|
||||
*/
|
||||
TOP_MENU("2", "top"),
|
||||
|
||||
/**
|
||||
* 按钮
|
||||
*/
|
||||
BUTTON("1", "button");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.constant.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018/9/30 流程状态
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ProcessStatusEnum {
|
||||
|
||||
/**
|
||||
* 激活
|
||||
*/
|
||||
ACTIVE("active"),
|
||||
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
SUSPEND("suspend");
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final String status;
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.constant.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018/9/30 资源类型
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ResourceTypeEnum {
|
||||
|
||||
/**
|
||||
* 图片资源
|
||||
*/
|
||||
IMAGE("image", "图片资源"),
|
||||
|
||||
/**
|
||||
* xml资源
|
||||
*/
|
||||
XML("xml", "xml资源");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String type;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package com.bsd.pjcloud.common.core.constant.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2020-01-19
|
||||
* <p>
|
||||
* 前端类型类型
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum StyleTypeEnum {
|
||||
|
||||
/**
|
||||
* 前端类型-avue 风格
|
||||
*/
|
||||
AVUE("0", "avue"),
|
||||
|
||||
/**
|
||||
* 前端类型-element 风格
|
||||
*/
|
||||
ELEMENT("1", "element"),
|
||||
|
||||
/**
|
||||
* 前端风格-uview 风格
|
||||
*/
|
||||
UVIEW("2", "uview"),
|
||||
|
||||
/**
|
||||
* magic
|
||||
*/
|
||||
MAGIC("3", "magic"),
|
||||
/**
|
||||
* element-plus
|
||||
*/
|
||||
PLUS("4", "plus");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private String style;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
public static String getDesc(String style) {
|
||||
return Arrays.stream(StyleTypeEnum.values())
|
||||
.filter(styleTypeEnum -> styleTypeEnum.getStyle().equals(style))
|
||||
.findFirst()
|
||||
.get()
|
||||
.getDescription();
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.constant.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018/9/30 流程状态
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum TaskStatusEnum {
|
||||
|
||||
/**
|
||||
* 未提交
|
||||
*/
|
||||
UNSUBMIT("0", "未提交"),
|
||||
|
||||
/**
|
||||
* 审核中
|
||||
*/
|
||||
CHECK("1", "审核中"),
|
||||
|
||||
/**
|
||||
* 已完成
|
||||
*/
|
||||
COMPLETED("2", "已完成"),
|
||||
|
||||
/**
|
||||
* 驳回
|
||||
*/
|
||||
OVERRULE("9", "驳回");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String status;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.bsd.pjcloud.common.core.constant.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum UserTypeEnum {
|
||||
|
||||
TOB("0", "面向后台应用"), TOC("1", "面向小程序");
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private final String status;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private final String description;
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.bsd.pjcloud.common.core.constant.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* yes and no enum
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2023/10/25
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum YesNoEnum {
|
||||
|
||||
YES("1", "是"), NO("0", "否");
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.exception;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 😴2018年06月22日16:21:57
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
public class CheckedException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CheckedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CheckedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public CheckedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public CheckedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
package com.bsd.pjcloud.common.core.exception;
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2022/3/30
|
||||
*/
|
||||
public interface ErrorCodes {
|
||||
|
||||
/**
|
||||
* 系统编码错误
|
||||
*/
|
||||
String SYS_PARAM_CONFIG_ERROR = "sys.param.config.error";
|
||||
|
||||
/**
|
||||
* 系统内置参数不能删除
|
||||
*/
|
||||
String SYS_PARAM_DELETE_SYSTEM = "sys.param.delete.system";
|
||||
|
||||
/**
|
||||
* 用户已存在
|
||||
*/
|
||||
String SYS_USER_USERNAME_EXISTING = "sys.user.username.existing";
|
||||
|
||||
/**
|
||||
* 用户已存在
|
||||
*/
|
||||
String SYS_USER_PHONE_EXISTING = "sys.user.phone.existing";
|
||||
|
||||
/**
|
||||
* 用户原密码错误,修改失败
|
||||
*/
|
||||
String SYS_USER_UPDATE_PASSWORDERROR = "sys.user.update.passwordError";
|
||||
|
||||
/**
|
||||
* 用户信息为空
|
||||
*/
|
||||
String SYS_USER_USERINFO_EMPTY = "sys.user.userInfo.empty";
|
||||
|
||||
/**
|
||||
* 获取当前用户信息失败
|
||||
*/
|
||||
String SYS_USER_QUERY_ERROR = "sys.user.query.error";
|
||||
|
||||
String SYS_USER_IMPORT_SUCCEED = "sys.user.import.succeed";
|
||||
|
||||
/**
|
||||
* 部门名称不存在
|
||||
*/
|
||||
String SYS_DEPT_DEPTNAME_INEXISTENCE = "sys.dept.deptName.inexistence";
|
||||
|
||||
/**
|
||||
* 岗位名称不存在
|
||||
*/
|
||||
String SYS_POST_POSTNAME_INEXISTENCE = "sys.post.postName.inexistence";
|
||||
|
||||
/**
|
||||
* 岗位名称或编码已经存在
|
||||
*/
|
||||
String SYS_POST_NAMEORCODE_EXISTING = "sys.post.nameOrCode.existing";
|
||||
|
||||
/**
|
||||
* 角色名称不存在
|
||||
*/
|
||||
String SYS_ROLE_ROLENAME_INEXISTENCE = "sys.role.roleName.inexistence";
|
||||
|
||||
/**
|
||||
* 角色名或角色编码已经存在
|
||||
*/
|
||||
String SYS_ROLE_NAMEORCODE_EXISTING = "sys.role.nameOrCode.existing";
|
||||
|
||||
/**
|
||||
* 菜单存在下级节点 删除失败
|
||||
*/
|
||||
String SYS_MENU_DELETE_EXISTING = "sys.menu.delete.existing";
|
||||
|
||||
/**
|
||||
* 系统内置字典不允许删除
|
||||
*/
|
||||
String SYS_DICT_DELETE_SYSTEM = "sys.dict.delete.system";
|
||||
|
||||
/**
|
||||
* 系统内置字典不能修改
|
||||
*/
|
||||
String SYS_DICT_UPDATE_SYSTEM = "sys.dict.update.system";
|
||||
|
||||
/**
|
||||
* 验证码发送频繁
|
||||
*/
|
||||
String SYS_APP_SMS_OFTEN = "sys.app.sms.often";
|
||||
|
||||
/**
|
||||
* 手机号未注册
|
||||
*/
|
||||
String SYS_APP_PHONE_UNREGISTERED = "sys.app.phone.unregistered";
|
||||
|
||||
/**
|
||||
* 企微调用接口错误
|
||||
*/
|
||||
String SYS_CONNECT_CP_DEPT_SYNC_ERROR = "sys.connect.cp.dept.sync.error";
|
||||
|
||||
/**
|
||||
* 企微调用接口错误
|
||||
*/
|
||||
String SYS_CONNECT_CP_USER_SYNC_ERROR = "sys.connect.cp.user.sync.error";
|
||||
|
||||
/**
|
||||
* 用户信息为空
|
||||
*/
|
||||
String APP_USER_USERINFO_EMPTY = "app.user.userInfo.empty";
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.exception;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018年06月22日16:22:15
|
||||
*/
|
||||
public class ValidateCodeException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = -7285211528095468156L;
|
||||
|
||||
public ValidateCodeException() {
|
||||
}
|
||||
|
||||
public ValidateCodeException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.bsd.pjcloud.common.core.factory;
|
||||
|
||||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||
import org.springframework.core.env.PropertiesPropertySource;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.core.io.support.EncodedResource;
|
||||
import org.springframework.core.io.support.PropertySourceFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2022/3/29
|
||||
* <p>
|
||||
* 读取自定义 yaml 文件工厂类
|
||||
*/
|
||||
public class YamlPropertySourceFactory implements PropertySourceFactory {
|
||||
|
||||
@Override
|
||||
public PropertySource<?> createPropertySource(@Nullable String name, EncodedResource resource) throws IOException {
|
||||
Properties propertiesFromYaml = loadYamlIntoProperties(resource);
|
||||
String sourceName = name != null ? name : resource.getResource().getFilename();
|
||||
return new PropertiesPropertySource(sourceName, propertiesFromYaml);
|
||||
}
|
||||
|
||||
private Properties loadYamlIntoProperties(EncodedResource resource) throws FileNotFoundException {
|
||||
try {
|
||||
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
|
||||
factory.setResources(resource.getResource());
|
||||
factory.afterPropertiesSet();
|
||||
return factory.getObject();
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof FileNotFoundException)
|
||||
throw (FileNotFoundException) e.getCause();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.bsd.pjcloud.common.core.jackson;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.PackageVersion;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.*;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.*;
|
||||
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* java 8 时间默认序列化
|
||||
*
|
||||
* @author L.cm
|
||||
* @author lishanbu
|
||||
*/
|
||||
public class PjcloudJavaTimeModule extends SimpleModule {
|
||||
|
||||
/**
|
||||
* 指定序列化规则
|
||||
*/
|
||||
public PjcloudJavaTimeModule() {
|
||||
super(PackageVersion.VERSION);
|
||||
|
||||
// ======================= 时间序列化规则 ===============================
|
||||
// yyyy-MM-dd HH:mm:ss
|
||||
this.addSerializer(LocalDateTime.class,
|
||||
new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// yyyy-MM-dd
|
||||
this.addSerializer(LocalDate.class,
|
||||
new LocalDateSerializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
|
||||
// HH:mm:ss
|
||||
this.addSerializer(LocalTime.class,
|
||||
new LocalTimeSerializer(DateTimeFormatter.ofPattern(DatePattern.NORM_TIME_PATTERN)));
|
||||
|
||||
// Instant 类型序列化
|
||||
this.addSerializer(Instant.class, InstantSerializer.INSTANCE);
|
||||
|
||||
// Duration 类型序列化
|
||||
this.addSerializer(Duration.class, DurationSerializer.INSTANCE);
|
||||
|
||||
// ======================= 时间反序列化规则 ==============================
|
||||
// yyyy-MM-dd HH:mm:ss
|
||||
this.addDeserializer(LocalDateTime.class,
|
||||
new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
|
||||
// yyyy-MM-dd
|
||||
this.addDeserializer(LocalDate.class,
|
||||
new LocalDateDeserializer(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
|
||||
// HH:mm:ss
|
||||
this.addDeserializer(LocalTime.class,
|
||||
new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DatePattern.NORM_TIME_PATTERN)));
|
||||
// Instant 反序列化
|
||||
this.addDeserializer(Instant.class, InstantDeserializer.INSTANT);
|
||||
|
||||
// Duration 反序列化
|
||||
this.addDeserializer(Duration.class, DurationDeserializer.INSTANCE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.util;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.springframework.core.BridgeMethodResolver;
|
||||
import org.springframework.core.DefaultParameterNameDiscoverer;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.annotation.SynthesizingMethodParameter;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* 类工具类
|
||||
*
|
||||
* @author L.cm
|
||||
*/
|
||||
@UtilityClass
|
||||
public class ClassUtils extends org.springframework.util.ClassUtils {
|
||||
|
||||
private final ParameterNameDiscoverer PARAMETERNAMEDISCOVERER = new DefaultParameterNameDiscoverer();
|
||||
|
||||
/**
|
||||
* 获取方法参数信息
|
||||
* @param constructor 构造器
|
||||
* @param parameterIndex 参数序号
|
||||
* @return {MethodParameter}
|
||||
*/
|
||||
public MethodParameter getMethodParameter(Constructor<?> constructor, int parameterIndex) {
|
||||
MethodParameter methodParameter = new SynthesizingMethodParameter(constructor, parameterIndex);
|
||||
methodParameter.initParameterNameDiscovery(PARAMETERNAMEDISCOVERER);
|
||||
return methodParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取方法参数信息
|
||||
* @param method 方法
|
||||
* @param parameterIndex 参数序号
|
||||
* @return {MethodParameter}
|
||||
*/
|
||||
public MethodParameter getMethodParameter(Method method, int parameterIndex) {
|
||||
MethodParameter methodParameter = new SynthesizingMethodParameter(method, parameterIndex);
|
||||
methodParameter.initParameterNameDiscovery(PARAMETERNAMEDISCOVERER);
|
||||
return methodParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Annotation
|
||||
* @param method Method
|
||||
* @param annotationType 注解类
|
||||
* @param <A> 泛型标记
|
||||
* @return {Annotation}
|
||||
*/
|
||||
public <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType) {
|
||||
Class<?> targetClass = method.getDeclaringClass();
|
||||
// The method may be on an interface, but we need attributes from the target
|
||||
// class.
|
||||
// If the target class is null, the method will be unchanged.
|
||||
Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
|
||||
// If we are dealing with method with generic parameters, find the original
|
||||
// method.
|
||||
specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
|
||||
// 先找方法,再找方法上的类
|
||||
A annotation = AnnotatedElementUtils.findMergedAnnotation(specificMethod, annotationType);
|
||||
|
||||
if (null != annotation) {
|
||||
return annotation;
|
||||
}
|
||||
// 获取类上面的Annotation,可能包含组合注解,故采用spring的工具类
|
||||
return AnnotatedElementUtils.findMergedAnnotation(specificMethod.getDeclaringClass(), annotationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Annotation
|
||||
* @param handlerMethod HandlerMethod
|
||||
* @param annotationType 注解类
|
||||
* @param <A> 泛型标记
|
||||
* @return {Annotation}
|
||||
*/
|
||||
public <A extends Annotation> A getAnnotation(HandlerMethod handlerMethod, Class<A> annotationType) {
|
||||
// 先找方法,再找方法上的类
|
||||
A annotation = handlerMethod.getMethodAnnotation(annotationType);
|
||||
if (null != annotation) {
|
||||
return annotation;
|
||||
}
|
||||
// 获取类上面的Annotation,可能包含组合注解,故采用spring的工具类
|
||||
Class<?> beanType = handlerMethod.getBeanType();
|
||||
return AnnotatedElementUtils.findMergedAnnotation(beanType, annotationType);
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.bsd.pjcloud.common.core.util;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2020/9/29
|
||||
* <p>
|
||||
* 字符串处理,方便其他模块解耦处理
|
||||
*/
|
||||
public interface KeyStrResolver {
|
||||
|
||||
/**
|
||||
* 字符串加工
|
||||
* @param in 输入字符串
|
||||
* @param split 分割符
|
||||
* @return 输出字符串
|
||||
*/
|
||||
String extract(String in, String split);
|
||||
|
||||
/**
|
||||
* 字符串获取
|
||||
* @return 模块返回字符串
|
||||
*/
|
||||
String key();
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.bsd.pjcloud.common.core.util;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.springframework.context.MessageSource;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* i18n 工具类
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2022/3/30
|
||||
*/
|
||||
@UtilityClass
|
||||
public class MsgUtils {
|
||||
|
||||
/**
|
||||
* 通过code 获取中文错误信息
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public String getMessage(String code) {
|
||||
MessageSource messageSource = SpringContextHolder.getBean("pjcloudMessageSource");
|
||||
return messageSource.getMessage(code, null, Locale.CHINA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code 和参数获取中文错误信息
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public String getMessage(String code, Object... objects) {
|
||||
MessageSource messageSource = SpringContextHolder.getBean("pjcloudMessageSource");
|
||||
return messageSource.getMessage(code, objects, Locale.CHINA);
|
||||
}
|
||||
|
||||
/**
|
||||
* security 通过code 和参数获取中文错误信息
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public String getSecurityMessage(String code, Object... objects) {
|
||||
MessageSource messageSource = SpringContextHolder.getBean("securityMessageSource");
|
||||
return messageSource.getMessage(code, objects, Locale.CHINA);
|
||||
}
|
||||
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.util;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
import com.bsd.pjcloud.common.core.constant.CommonConstants;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 响应信息主体
|
||||
*
|
||||
* @param <T>
|
||||
* @author pjcloud
|
||||
*/
|
||||
@Builder
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@Schema(description = "响应信息主体")
|
||||
public class R<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonPropertyDescription(value = "调用成功返回0,调用失败返回1")
|
||||
@Schema(description = "返回标记:成功标记=0,失败标记=1")
|
||||
private int code;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@JsonPropertyDescription(value = "返回具体的信息")
|
||||
@Schema(description = "返回信息")
|
||||
private String msg;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "数据")
|
||||
private T data;
|
||||
|
||||
public static <T> R<T> ok() {
|
||||
return restResult(null, CommonConstants.SUCCESS, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data) {
|
||||
return restResult(data, CommonConstants.SUCCESS, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data, String msg) {
|
||||
return restResult(data, CommonConstants.SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed() {
|
||||
return restResult(null, CommonConstants.FAIL, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(String msg) {
|
||||
return restResult(null, CommonConstants.FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(T data) {
|
||||
return restResult(data, CommonConstants.FAIL, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> failed(T data, String msg) {
|
||||
return restResult(data, CommonConstants.FAIL, msg);
|
||||
}
|
||||
|
||||
static <T> R<T> restResult(T data, int code, String msg) {
|
||||
R<T> apiResult = new R<>();
|
||||
apiResult.setCode(code);
|
||||
apiResult.setData(data);
|
||||
apiResult.setMsg(msg);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||
public boolean isOk() {
|
||||
return this.code == CommonConstants.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2023-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.util;
|
||||
|
||||
import jakarta.servlet.ReadListener;
|
||||
import jakarta.servlet.ServletInputStream;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Request包装类:允许 body 重复读取
|
||||
*
|
||||
* @author Hccake
|
||||
*/
|
||||
@Slf4j
|
||||
public class RepeatBodyRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
private final byte[] bodyByteArray;
|
||||
private final Map<String, String[]> parameterMap;
|
||||
|
||||
public RepeatBodyRequestWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
this.bodyByteArray = getByteBody(request);
|
||||
// 使用 HashMap 以便后续可以修改
|
||||
this.parameterMap = new HashMap<>(request.getParameterMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() {
|
||||
return ObjectUtils.isEmpty(this.bodyByteArray) ? null
|
||||
: new BufferedReader(new InputStreamReader(getInputStream()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() {
|
||||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(this.bodyByteArray);
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return byteArrayInputStream.available() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return true; // 可以读取
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
// doNothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return byteArrayInputStream.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static byte[] getByteBody(HttpServletRequest request) {
|
||||
byte[] body = new byte[0];
|
||||
try {
|
||||
body = StreamUtils.copyToByteArray(request.getInputStream());
|
||||
} catch (IOException e) {
|
||||
log.error("解析流中数据异常", e);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getParameterMap() {
|
||||
return this.parameterMap; // 返回可变的 parameterMap
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置新的参数映射
|
||||
* @param parameterMap 新的参数映射
|
||||
*/
|
||||
public void setParameterMap(Map<String, String[]> parameterMap) {
|
||||
this.parameterMap.clear();
|
||||
this.parameterMap.putAll(parameterMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(String name) {
|
||||
String[] values = parameterMap.get(name);
|
||||
return (values != null && values.length > 0) ? values[0] : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
return parameterMap.get(name);
|
||||
}
|
||||
}
|
||||
+289
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.util;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.common.core.constant.CommonConstants;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* 简化{@code R<T>} 的访问操作,例子 <pre>
|
||||
* R<Integer> result = R.ok(0);
|
||||
* // 使用场景1: 链式操作: 断言然后消费
|
||||
* RetOps.of(result)
|
||||
* .assertCode(-1,r -> new RuntimeException("error "+r.getCode()))
|
||||
* .assertDataNotEmpty(r -> new IllegalStateException("oops!"))
|
||||
* .useData(System.out::println);
|
||||
*
|
||||
* // 使用场景2: 读取原始值(data),这里返回的是Optional
|
||||
* RetOps.of(result).getData().orElse(null);
|
||||
*
|
||||
* // 使用场景3: 类型转换
|
||||
* R<String> s = RetOps.of(result)
|
||||
* .assertDataNotNull(r -> new IllegalStateException("nani??"))
|
||||
* .map(i -> Integer.toHexString(i))
|
||||
* .peek();
|
||||
* </pre>
|
||||
*
|
||||
* @author CJ (power4j@outlook.com)
|
||||
* @date 2022/5/12
|
||||
* @since 4.4
|
||||
*/
|
||||
public class RetOps<T> {
|
||||
|
||||
/** 状态码为成功 */
|
||||
public static final Predicate<R<?>> CODE_SUCCESS = r -> CommonConstants.SUCCESS == r.getCode();
|
||||
|
||||
/** 数据有值 */
|
||||
public static final Predicate<R<?>> HAS_DATA = r -> ObjectUtil.isNotEmpty(r.getData());
|
||||
|
||||
/** 数据有值,并且包含元素 */
|
||||
public static final Predicate<R<?>> HAS_ELEMENT = r -> ObjectUtil.isNotEmpty(r.getData());
|
||||
|
||||
/** 状态码为成功并且有值 */
|
||||
public static final Predicate<R<?>> DATA_AVAILABLE = CODE_SUCCESS.and(HAS_DATA);
|
||||
|
||||
private final R<T> original;
|
||||
|
||||
// ~ 初始化
|
||||
// ===================================================================================================
|
||||
|
||||
RetOps(R<T> original) {
|
||||
this.original = original;
|
||||
}
|
||||
|
||||
public static <T> RetOps<T> of(R<T> original) {
|
||||
return new RetOps<>(Objects.requireNonNull(original));
|
||||
}
|
||||
|
||||
// ~ 杂项方法
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* 观察原始值
|
||||
* @return R
|
||||
*/
|
||||
public R<T> peek() {
|
||||
return original;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取{@code code}的值
|
||||
* @return 返回code的值
|
||||
*/
|
||||
public int getCode() {
|
||||
return original.getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取{@code data}的值
|
||||
* @return 返回 Optional 包装的data
|
||||
*/
|
||||
public Optional<T> getData() {
|
||||
return Optional.ofNullable(original.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 有条件地读取{@code data}的值
|
||||
* @param predicate 断言函数
|
||||
* @return 返回 Optional 包装的data,如果断言失败返回empty
|
||||
*/
|
||||
public Optional<T> getDataIf(Predicate<? super R<?>> predicate) {
|
||||
return predicate.test(original) ? getData() : Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取{@code msg}的值
|
||||
* @return 返回Optional包装的 msg
|
||||
*/
|
||||
public Optional<String> getMsg() {
|
||||
return Optional.ofNullable(original.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 对{@code code}的值进行相等性测试
|
||||
* @param value 基准值
|
||||
* @return 返回ture表示相等
|
||||
*/
|
||||
public boolean codeEquals(int value) {
|
||||
return original.getCode() == value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对{@code code}的值进行相等性测试
|
||||
* @param value 基准值
|
||||
* @return 返回ture表示不相等
|
||||
*/
|
||||
public boolean codeNotEquals(int value) {
|
||||
return !codeEquals(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否成功
|
||||
* @return 返回ture表示成功
|
||||
* @see CommonConstants#SUCCESS
|
||||
*/
|
||||
public boolean isSuccess() {
|
||||
return codeEquals(CommonConstants.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否失败
|
||||
* @return 返回ture表示失败
|
||||
*/
|
||||
public boolean notSuccess() {
|
||||
return !isSuccess();
|
||||
}
|
||||
|
||||
// ~ 链式操作
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* 断言{@code code}的值
|
||||
* @param expect 预期的值
|
||||
* @param func 用户函数,负责创建异常对象
|
||||
* @param <Ex> 异常类型
|
||||
* @return 返回实例,以便于继续进行链式操作
|
||||
* @throws Ex 断言失败时抛出
|
||||
*/
|
||||
public <Ex extends Exception> RetOps<T> assertCode(int expect, Function<? super R<T>, ? extends Ex> func)
|
||||
throws Ex {
|
||||
if (codeNotEquals(expect)) {
|
||||
throw func.apply(original);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 断言成功
|
||||
* @param func 用户函数,负责创建异常对象
|
||||
* @param <Ex> 异常类型
|
||||
* @return 返回实例,以便于继续进行链式操作
|
||||
* @throws Ex 断言失败时抛出
|
||||
*/
|
||||
public <Ex extends Exception> RetOps<T> assertSuccess(Function<? super R<T>, ? extends Ex> func) throws Ex {
|
||||
return assertCode(CommonConstants.SUCCESS, func);
|
||||
}
|
||||
|
||||
/**
|
||||
* 断言业务数据有值
|
||||
* @param func 用户函数,负责创建异常对象
|
||||
* @param <Ex> 异常类型
|
||||
* @return 返回实例,以便于继续进行链式操作
|
||||
* @throws Ex 断言失败时抛出
|
||||
*/
|
||||
public <Ex extends Exception> RetOps<T> assertDataNotNull(Function<? super R<T>, ? extends Ex> func) throws Ex {
|
||||
if (Objects.isNull(original.getData())) {
|
||||
throw func.apply(original);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 断言业务数据有值,并且包含元素
|
||||
* @param func 用户函数,负责创建异常对象
|
||||
* @param <Ex> 异常类型
|
||||
* @return 返回实例,以便于继续进行链式操作
|
||||
* @throws Ex 断言失败时抛出
|
||||
*/
|
||||
public <Ex extends Exception> RetOps<T> assertDataNotEmpty(Function<? super R<T>, ? extends Ex> func) throws Ex {
|
||||
if (ObjectUtil.isEmpty(original.getData())) {
|
||||
throw func.apply(original);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对业务数据(data)转换
|
||||
* @param mapper 业务数据转换函数
|
||||
* @param <U> 数据类型
|
||||
* @return 返回新实例,以便于继续进行链式操作
|
||||
*/
|
||||
public <U> RetOps<U> map(Function<? super T, ? extends U> mapper) {
|
||||
R<U> result = R.restResult(mapper.apply(original.getData()), original.getCode(), original.getMsg());
|
||||
return of(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对业务数据(data)转换
|
||||
* @param predicate 断言函数
|
||||
* @param mapper 业务数据转换函数
|
||||
* @param <U> 数据类型
|
||||
* @return 返回新实例,以便于继续进行链式操作
|
||||
* @see RetOps#CODE_SUCCESS
|
||||
* @see RetOps#HAS_DATA
|
||||
* @see RetOps#HAS_ELEMENT
|
||||
* @see RetOps#DATA_AVAILABLE
|
||||
*/
|
||||
public <U> RetOps<U> mapIf(Predicate<? super R<T>> predicate, Function<? super T, ? extends U> mapper) {
|
||||
R<U> result = R.restResult(mapper.apply(original.getData()), original.getCode(), original.getMsg());
|
||||
return of(result);
|
||||
}
|
||||
|
||||
// ~ 数据消费
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* 消费数据,注意此方法保证数据可用
|
||||
* @param consumer 消费函数
|
||||
*/
|
||||
public void useData(Consumer<? super T> consumer) {
|
||||
consumer.accept(original.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件消费(错误代码匹配某个值)
|
||||
* @param consumer 消费函数
|
||||
* @param codes 错误代码集合,匹配任意一个则调用消费函数
|
||||
*/
|
||||
public void useDataOnCode(Consumer<? super T> consumer, int... codes) {
|
||||
useDataIf(o -> Arrays.stream(codes).filter(c -> original.getCode() == c).findFirst().isPresent(), consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件消费(错误代码表示成功)
|
||||
* @param consumer 消费函数
|
||||
*/
|
||||
public void useDataIfSuccess(Consumer<? super T> consumer) {
|
||||
useDataIf(CODE_SUCCESS, consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件消费
|
||||
* @param predicate 断言函数
|
||||
* @param consumer 消费函数,断言函数返回{@code true}时被调用
|
||||
* @see RetOps#CODE_SUCCESS
|
||||
* @see RetOps#HAS_DATA
|
||||
* @see RetOps#HAS_ELEMENT
|
||||
* @see RetOps#DATA_AVAILABLE
|
||||
*/
|
||||
public void useDataIf(Predicate<? super R<T>> predicate, Consumer<? super T> consumer) {
|
||||
if (predicate.test(original)) {
|
||||
consumer.accept(original.getData());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @date 2018/6/27 Spring 工具类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Lazy(false)
|
||||
public class SpringContextHolder implements BeanFactoryPostProcessor, ApplicationContextAware, DisposableBean {
|
||||
|
||||
private static ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
private static ApplicationContext applicationContext = null;
|
||||
|
||||
/**
|
||||
* 取得存储在静态变量中的ApplicationContext.
|
||||
*/
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* BeanFactoryPostProcessor, 注入Context到静态变量中.
|
||||
*/
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory factory) throws BeansException {
|
||||
SpringContextHolder.beanFactory = factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现ApplicationContextAware接口, 注入Context到静态变量中.
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
SpringContextHolder.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public static ListableBeanFactory getBeanFactory() {
|
||||
return null == beanFactory ? applicationContext : beanFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getBean(String name) {
|
||||
return (T) getBeanFactory().getBean(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从静态变量applicationContext中取得Bean, Map<Bean名称,实现类></>
|
||||
*/
|
||||
public static <T> Map<String, T> getBeansOfType(Class<T> type) {
|
||||
return getBeanFactory().getBeansOfType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
||||
*/
|
||||
public static <T> T getBean(Class<T> requiredType) {
|
||||
return getBeanFactory().getBean(requiredType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除SpringContextHolder中的ApplicationContext为Null.
|
||||
*/
|
||||
public static void clearHolder() {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("清除SpringContextHolder中的ApplicationContext:" + applicationContext);
|
||||
}
|
||||
applicationContext = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布事件
|
||||
* @param event
|
||||
*/
|
||||
public static void publishEvent(ApplicationEvent event) {
|
||||
if (applicationContext == null) {
|
||||
return;
|
||||
}
|
||||
applicationContext.publishEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现DisposableBean接口, 在Context关闭时清理静态变量.
|
||||
*/
|
||||
@Override
|
||||
public void destroy() {
|
||||
SpringContextHolder.clearHolder();
|
||||
}
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.bsd.pjcloud.common.core.util;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author pjcloud
|
||||
* @since v5.3
|
||||
* <p>
|
||||
* table 实体增加此组件自动声明为租户表
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
|
||||
public @interface TenantTable {
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.bsd.pjcloud.common.core.util;
|
||||
|
||||
/**
|
||||
* 校验类型
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2022/4/26
|
||||
*/
|
||||
public class ValidGroup {
|
||||
|
||||
/**
|
||||
* 插入组
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2022/4/26
|
||||
*/
|
||||
public static interface Insert {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑组
|
||||
*
|
||||
* @author pjcloud
|
||||
* @date 2022/4/26
|
||||
*/
|
||||
public static interface Update {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+276
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2018-2025, pjcloud All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: pjcloud
|
||||
*
|
||||
*/
|
||||
|
||||
package com.bsd.pjcloud.common.core.util;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Miscellaneous utilities for web applications.
|
||||
*
|
||||
* @author L.cm
|
||||
*/
|
||||
@Slf4j
|
||||
@UtilityClass
|
||||
public class WebUtils extends org.springframework.web.util.WebUtils {
|
||||
|
||||
private final String BASIC_ = "Basic ";
|
||||
|
||||
private final String UNKNOWN = "unknown";
|
||||
|
||||
/**
|
||||
* 判断是否ajax请求 spring ajax 返回含有 ResponseBody 或者 RestController注解
|
||||
*
|
||||
* @param handlerMethod HandlerMethod
|
||||
* @return 是否ajax请求
|
||||
*/
|
||||
public boolean isBody(HandlerMethod handlerMethod) {
|
||||
ResponseBody responseBody = ClassUtils.getAnnotation(handlerMethod, ResponseBody.class);
|
||||
return responseBody != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取cookie
|
||||
*
|
||||
* @param name cookie name
|
||||
* @return cookie value
|
||||
*/
|
||||
public String getCookieVal(String name) {
|
||||
HttpServletRequest request = WebUtils.getRequest();
|
||||
Assert.notNull(request, "request from RequestContextHolder is null");
|
||||
return getCookieVal(request, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取cookie
|
||||
*
|
||||
* @param request HttpServletRequest
|
||||
* @param name cookie name
|
||||
* @return cookie value
|
||||
*/
|
||||
public String getCookieVal(HttpServletRequest request, String name) {
|
||||
Cookie cookie = getCookie(request, name);
|
||||
return cookie != null ? cookie.getValue() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除 某个指定的cookie
|
||||
*
|
||||
* @param response HttpServletResponse
|
||||
* @param key cookie key
|
||||
*/
|
||||
public void removeCookie(HttpServletResponse response, String key) {
|
||||
setCookie(response, key, null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置cookie
|
||||
*
|
||||
* @param response HttpServletResponse
|
||||
* @param name cookie name
|
||||
* @param value cookie value
|
||||
* @param maxAgeInSeconds maxage
|
||||
*/
|
||||
public void setCookie(HttpServletResponse response, String name, String value, int maxAgeInSeconds) {
|
||||
Cookie cookie = new Cookie(name, value);
|
||||
cookie.setPath("/");
|
||||
cookie.setMaxAge(maxAgeInSeconds);
|
||||
cookie.setHttpOnly(true);
|
||||
response.addCookie(cookie);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 HttpServletRequest
|
||||
*
|
||||
* @return {HttpServletRequest}
|
||||
*/
|
||||
public HttpServletRequest getRequest() {
|
||||
try {
|
||||
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
|
||||
return ((ServletRequestAttributes) requestAttributes).getRequest();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 HttpServletResponse
|
||||
*
|
||||
* @return {HttpServletResponse}
|
||||
*/
|
||||
public HttpServletResponse getResponse() {
|
||||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回json
|
||||
*
|
||||
* @param response HttpServletResponse
|
||||
* @param result 结果对象
|
||||
*/
|
||||
public void renderJson(HttpServletResponse response, Object result) {
|
||||
renderJson(response, result, MediaType.APPLICATION_JSON_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回json
|
||||
*
|
||||
* @param response HttpServletResponse
|
||||
* @param result 结果对象
|
||||
* @param contentType contentType
|
||||
*/
|
||||
public void renderJson(HttpServletResponse response, Object result, String contentType) {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType(contentType);
|
||||
try (PrintWriter out = response.getWriter()) {
|
||||
out.append(JSONUtil.toJsonStr(result));
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ip
|
||||
*
|
||||
* @return {String}
|
||||
*/
|
||||
public String getIP() {
|
||||
return getIP(WebUtils.getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ip
|
||||
*
|
||||
* @param request HttpServletRequest
|
||||
* @return {String}
|
||||
*/
|
||||
public String getIP(HttpServletRequest request) {
|
||||
Assert.notNull(request, "HttpServletRequest is null");
|
||||
String ip = request.getHeader("X-Requested-For");
|
||||
if (StrUtil.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("X-Forwarded-For");
|
||||
}
|
||||
if (StrUtil.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (StrUtil.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (StrUtil.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_CLIENT_IP");
|
||||
}
|
||||
if (StrUtil.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
|
||||
}
|
||||
if (StrUtil.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
return StrUtil.isBlank(ip) ? null : ip.split(",")[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 client id
|
||||
*
|
||||
* @param header
|
||||
* @param defVal
|
||||
* @return 如果解析失败返回默认值
|
||||
*/
|
||||
public String extractClientId(String header, final String defVal) {
|
||||
|
||||
if (header == null || !header.startsWith(BASIC_)) {
|
||||
log.debug("请求头中client信息为空: {}", header);
|
||||
return defVal;
|
||||
}
|
||||
byte[] base64Token = header.substring(6).getBytes(StandardCharsets.UTF_8);
|
||||
byte[] decoded;
|
||||
try {
|
||||
decoded = Base64.decode(base64Token);
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.debug("Failed to decode basic authentication token: {}", header);
|
||||
return defVal;
|
||||
}
|
||||
|
||||
String token = new String(decoded, StandardCharsets.UTF_8);
|
||||
|
||||
int delim = token.indexOf(":");
|
||||
|
||||
if (delim == -1) {
|
||||
log.debug("Invalid basic authentication token: {}", header);
|
||||
return defVal;
|
||||
}
|
||||
return token.substring(0, delim);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从请求头中解析 client id
|
||||
*
|
||||
* @param header
|
||||
* @return
|
||||
*/
|
||||
public Optional<String> extractClientId(String header) {
|
||||
return Optional.ofNullable(extractClientId(header, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 bearer 令牌
|
||||
*
|
||||
* @return {@link String }
|
||||
*/
|
||||
@SneakyThrows
|
||||
public String getToken() {
|
||||
if (Objects.isNull(WebUtils.getRequest())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 获取请求
|
||||
HttpServletRequest request = WebUtils.getRequest();
|
||||
// 获取Authorization头信息
|
||||
String authorizationHeader = request.getHeader(HttpHeaders.AUTHORIZATION);
|
||||
if (authorizationHeader != null && StrUtil.startWithAnyIgnoreCase(authorizationHeader, "Bearer ")) {
|
||||
// 返回去掉"Bearer "前缀的Token
|
||||
return authorizationHeader.substring(7);
|
||||
} else {
|
||||
// 处理Authorization头信息为空或格式不正确的情况
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
com.bsd.pjcloud.common.core.config.AsyncConfiguration
|
||||
com.bsd.pjcloud.common.core.config.JacksonConfiguration
|
||||
com.bsd.pjcloud.common.core.config.MessageSourceConfiguration
|
||||
com.bsd.pjcloud.common.core.config.RestTemplateConfiguration
|
||||
com.bsd.pjcloud.common.core.config.ImmutableConfiguration
|
||||
com.bsd.pjcloud.common.core.util.SpringContextHolder
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
${AnsiColor.BRIGHT_YELLOW}
|
||||
|
||||
::::::::: ::::::::::: :::::::: ::: :::
|
||||
:+: :+: :+: :+: :+: :+: :+:
|
||||
+:+ +:+ +:+ +:+ +:+ +:+
|
||||
+#++:++#+ +#+ :#: +#++:+
|
||||
+#+ +#+ +#+ +#+# +#+ +#+
|
||||
#+# #+# #+# #+# #+# #+#
|
||||
### ########### ######## ### ###
|
||||
|
||||
www.pig4cloud.com
|
||||
|
||||
Pig Microservice Architecture
|
||||
${AnsiColor.DEFAULT}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
# 很多第三方组件的配置默认值一般均不需要改动,写在nacos 中比较混乱冗余,就可以写在此处
|
||||
|
||||
# sms4j配置
|
||||
sms:
|
||||
is-print: false
|
||||
config-type: interface
|
||||
sms-oa:
|
||||
config-type: yaml
|
||||
|
||||
# 行为验证码配置
|
||||
aj:
|
||||
captcha:
|
||||
cache-type: redis
|
||||
|
||||
# 配置文件加密方法
|
||||
jasypt:
|
||||
encryptor:
|
||||
algorithm: PBEWithMD5AndDES
|
||||
iv-generator-classname: org.jasypt.iv.NoIvGenerator
|
||||
|
||||
# liteflow配置
|
||||
liteflow:
|
||||
rule-source: rules/*-rule.xml
|
||||
print-banner: false
|
||||
print-execution-log: false
|
||||
enable: true
|
||||
|
||||
# 关闭连表插件的banner
|
||||
mybatis-plus-join:
|
||||
banner: false
|
||||
|
||||
# sa-token 配置
|
||||
sa-token:
|
||||
is-print: false # 不输出 banner
|
||||
token-name: pig # token 存储的前缀
|
||||
is-concurrent: true # 是否允许同时在线
|
||||
is-share: false # 是否允许复用token (同一账号同时登录的情况)
|
||||
@@ -0,0 +1,21 @@
|
||||
sys.user.update.passwordError=\u539F\u5BC6\u7801\u9519\u8BEF\uFF0C\u4FEE\u6539\u5931\u8D25
|
||||
sys.user.query.error=\u83B7\u53D6\u5F53\u524D\u7528\u6237\u4FE1\u606F\u5931\u8D25
|
||||
sys.user.import.succeed=\u7528\u6237\u5BFC\u5165\u6210\u529F\uFF0C\u9ED8\u8BA4\u5BC6\u7801\u4E3A\u624B\u673A\u53F7
|
||||
sys.user.username.existing={0} \u7528\u6237\u540D\u5DF2\u5B58\u5728
|
||||
sys.user.phone.existing={0} \u624b\u673a\u53f7\u5df2\u5b58\u5728
|
||||
sys.user.userInfo.empty={0} \u7528\u6237\u4FE1\u606F\u4E3A\u7A7A
|
||||
sys.dept.deptName.inexistence={0} \u90E8\u95E8\u540D\u79F0\u4E0D\u5B58\u5728
|
||||
sys.post.postName.inexistence={0} \u5C97\u4F4D\u540D\u79F0\u4E0D\u5B58\u5728
|
||||
sys.post.nameOrCode.existing={0} {1} \u5C97\u4F4D\u540D\u6216\u5C97\u4F4D\u7F16\u7801\u5DF2\u7ECF\u5B58\u5728
|
||||
sys.role.roleName.inexistence={0} \u89D2\u8272\u540D\u79F0\u4E0D\u5B58\u5728
|
||||
sys.role.nameOrCode.existing={0} {1} \u89D2\u8272\u540D\u6216\u89D2\u8272\u7F16\u7801\u5DF2\u7ECF\u5B58\u5728
|
||||
sys.param.delete.system=\u7CFB\u7EDF\u5185\u7F6E\u53C2\u6570\u4E0D\u80FD\u5220\u9664
|
||||
sys.param.config.error={0} \u7CFB\u7EDF\u53C2\u6570\u914D\u7F6E\u9519\u8BEF
|
||||
sys.menu.delete.existing=\u83DC\u5355\u542B\u6709\u4E0B\u7EA7\u4E0D\u80FD\u5220\u9664
|
||||
sys.app.sms.often=\u9A8C\u8BC1\u7801\u53D1\u9001\u8FC7\u9891\u7E41
|
||||
sys.app.phone.unregistered={0} \u624B\u673A\u53F7\u672A\u6CE8\u518C
|
||||
sys.dict.delete.system=\u7CFB\u7EDF\u5185\u7F6E\u5B57\u5178\u9879\u76EE\u4E0D\u80FD\u5220\u9664
|
||||
sys.dict.update.system=\u7CFB\u7EDF\u5185\u7F6E\u5B57\u5178\u9879\u76EE\u4E0D\u80FD\u4FEE\u6539
|
||||
sys.connect.cp.dept.sync.error=\u83B7\u53D6\u4F01\u4E1A\u5FAE\u4FE1\u90E8\u95E8\u5217\u8868\u5931\u8D25
|
||||
sys.connect.cp.user.sync.error=\u83B7\u53D6\u4F01\u4E1A\u5FAE\u4FE1\u7528\u6237\u5217\u8868\u5931\u8D25
|
||||
app.user.userInfo.empty={0} \u7528\u6237\u4FE1\u606F\u4E3A\u7A7A
|
||||
Reference in new issue
Block a user