mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-08 21:26:40 +08:00
修改类名
This commit is contained in:
parent
12012eaa70
commit
af48683691
@ -1,25 +1,36 @@
|
|||||||
package net.lab1024.smartadmin.service.common.constant;
|
package net.lab1024.smartadmin.service.common.constant;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Interner;
|
||||||
|
import com.google.common.collect.Interners;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [ ]
|
* [ 通用常量 ]
|
||||||
*
|
*
|
||||||
* @author 罗伊
|
* @author zhuoda
|
||||||
* @date 2020/9/14 15:48
|
|
||||||
*/
|
*/
|
||||||
public class CommonConst {
|
public class CommonConst {
|
||||||
|
|
||||||
|
public static final int ZERO = 0;
|
||||||
|
|
||||||
|
public static final long ONE = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局通用分隔符
|
* 全局通用分隔符
|
||||||
*/
|
*/
|
||||||
public static final String SEPARATOR = ",";
|
public static final String SEPARATOR = ",";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局通用分隔符 逗号
|
* 全局通用分隔符 下划线
|
||||||
|
*/
|
||||||
|
public static final String UNDERLINE = "_";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局通用分隔符
|
||||||
*/
|
*/
|
||||||
public static final Character SEPARATOR_CHAR = ',';
|
public static final Character SEPARATOR_CHAR = ',';
|
||||||
|
|
||||||
@ -28,88 +39,42 @@ public class CommonConst {
|
|||||||
*/
|
*/
|
||||||
public static final String SEPARATOR_SLASH = "/";
|
public static final String SEPARATOR_SLASH = "/";
|
||||||
|
|
||||||
/**
|
|
||||||
* 全局通用分隔符 下划线
|
|
||||||
*/
|
|
||||||
public static final String UNDERLINE = "_";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 空字符串
|
* 空字符串
|
||||||
*/
|
*/
|
||||||
public static final String EMPTY_STR = "";
|
public static final String EMPTY_STR = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 空 MaP
|
* 空MaP
|
||||||
* 注意:放入元素会抛异常
|
|
||||||
*/
|
*/
|
||||||
public static final Map EMPTY_MAP = Collections.unmodifiableMap(new HashMap<>(0));
|
public static final Map EMPTY_MAP = Collections.unmodifiableMap(new HashMap<>(0));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 空 list
|
* 空 list
|
||||||
* 注意:放入元素会抛异常
|
|
||||||
*/
|
*/
|
||||||
public static final List EMPTY_LIST = Collections.unmodifiableList(new ArrayList<>(0));
|
public static final List EMPTY_LIST = Collections.unmodifiableList(new ArrayList<>(0));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 空字符串
|
* 全局通用 默认id
|
||||||
*/
|
*/
|
||||||
public static final long DEFAULT_PARENT_ID = 0L;
|
public static final long DEFAULT_ID = 0L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 空字符串
|
* 100 常量
|
||||||
*/
|
*/
|
||||||
public static final int ZERO = 0;
|
public static final Integer ONE_HUNDRED = 100;
|
||||||
|
|
||||||
|
|
||||||
public static final class Token {
|
|
||||||
|
|
||||||
public static final String DEFAULT_TOKEN = "default-token-";
|
|
||||||
|
|
||||||
public static final String INNER_TOKEN_NAME = "inner-token";
|
|
||||||
|
|
||||||
public static final String OUTER_TOKEN_NAME = "x-access-token";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FileFolderConst {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公用读取文件夹 public
|
|
||||||
*/
|
|
||||||
public static final String FOLDER_PUBLIC = "pu";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私有读取文件夹 private
|
|
||||||
*/
|
|
||||||
public static final String FOLDER_PRIVATE = "pr";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件夹格式
|
|
||||||
*/
|
|
||||||
public static final String FOLDER_FORMAT = "folder";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class System {
|
|
||||||
/**
|
|
||||||
* oss url redis 过期时间
|
|
||||||
*/
|
|
||||||
public static final int FILE_URL_EXPIRE_SECOND = 3600;
|
|
||||||
|
|
||||||
public static final int FILE_VO_EXPIRE_SECOND = 86400;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 长度类常量
|
* 100 常量
|
||||||
*/
|
*/
|
||||||
public static final class NumberLimit {
|
public static final BigDecimal ONE_HUNDRED_DECIMAL = new BigDecimal(100);
|
||||||
/**
|
|
||||||
* 文件名称长度
|
|
||||||
*/
|
|
||||||
public static final int FILE_NAME = 100;
|
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* 全局通用 默认父级id 最顶级
|
||||||
|
*/
|
||||||
|
public static final Long DEFAULT_PARENT_ID = 0L;
|
||||||
|
|
||||||
|
public static final Interner<String> STRING_POOL = Interners.newWeakInterner();
|
||||||
|
|
||||||
public static final class ApiUrl {
|
public static final class ApiUrl {
|
||||||
/**
|
/**
|
||||||
@ -122,18 +87,112 @@ public class CommonConst {
|
|||||||
*/
|
*/
|
||||||
public static final String API_PREFIX_ADMIN = "/admin";
|
public static final String API_PREFIX_ADMIN = "/admin";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app 业务 api 前缀
|
||||||
|
*/
|
||||||
|
public static final String API_PREFIX_APP = "/app";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PC 业务 api 前缀
|
||||||
|
*/
|
||||||
|
public static final String API_PREFIX_PC = "/pc";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开放平台 api 前缀
|
||||||
|
*/
|
||||||
|
public static final String API_PREFIX_OPEN = "/open";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String IGNORE_H5_URL_MAPPING = "/h5/api";
|
||||||
|
|
||||||
|
public static final class FileServiceConst {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公用读取文件夹 public
|
||||||
|
*/
|
||||||
|
public static final String FOLDER_PUBLIC = "xmf-crm/pu";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 私有读取文件夹 private
|
||||||
|
*/
|
||||||
|
public static final String FOLDER_PRIVATE = "xmf-crm/pr";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件夹格式
|
||||||
|
*/
|
||||||
|
public static final String FOLDER_FORMAT = "folder";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class System {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* oss url redis 过期时间
|
||||||
|
*/
|
||||||
|
public static final int FILE_URL_EXPIRE_SECOND = 7100;
|
||||||
|
|
||||||
|
public static final int FILE_VO_EXPIRE_SECOND = 86400;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统 id
|
||||||
|
*/
|
||||||
|
public static final Long SYSTEM_ID = 0L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统 名称
|
||||||
|
*/
|
||||||
|
public static final String SYSTEM_NAME = "小蜜蜂CRM系统";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 长度类常量
|
||||||
|
*/
|
||||||
|
public static final class NumberLimit {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户昵称
|
||||||
|
*/
|
||||||
|
public static final int USER_NICKNAME = 15;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信验证码长度
|
||||||
|
*/
|
||||||
|
public static final int SMS_CODE = 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信发送间隔 秒
|
||||||
|
*/
|
||||||
|
public static final int SMS_SEND_INTERVAL = 60;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信有效期 秒
|
||||||
|
*/
|
||||||
|
public static final int SMS_VALID_SECOND = 300;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证码短信 每天的限制
|
||||||
|
*/
|
||||||
|
public static final int SMS_DAY_LIMIT = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件名称长度
|
||||||
|
*/
|
||||||
|
public static final int FILE_NAME = 100;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class Password {
|
public static final class Password {
|
||||||
|
|
||||||
public static final String DEFAULT = "123456";
|
public static final String DEFAULT = "123456";
|
||||||
|
|
||||||
public static final String SALT_FORMAT = "smart_%s_admin";
|
public static final String SALT_FORMAT = "xiaomifeng_%s_crm";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class CommonCollection {
|
public static final class CommonCollection {
|
||||||
|
|
||||||
public static final Set<String> IGNORE_URL = ImmutableSet.of("/swagger", "Excel", "/h5/api");
|
public static final Set<String> IGNORE_URL = ImmutableSet.of("/swagger", "Excel");
|
||||||
|
|
||||||
|
public static final Set<String> IGNORE_URL_MAPPING = ImmutableSet.of(IGNORE_H5_URL_MAPPING);
|
||||||
|
|
||||||
public static Boolean contain(Set<String> ignores, String uri) {
|
public static Boolean contain(Set<String> ignores, String uri) {
|
||||||
if (CollectionUtils.isEmpty(ignores)) {
|
if (CollectionUtils.isEmpty(ignores)) {
|
||||||
@ -147,4 +206,101 @@ public class CommonConst {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户类型
|
||||||
|
*/
|
||||||
|
public static class UserType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户
|
||||||
|
*/
|
||||||
|
public static final Integer USER = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理端
|
||||||
|
*/
|
||||||
|
public static final Integer ADMIN = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统
|
||||||
|
*/
|
||||||
|
public static final Integer SYSTEM = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 游客
|
||||||
|
*/
|
||||||
|
public static final Integer NO_LOGIN = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求头常量
|
||||||
|
*/
|
||||||
|
public static class RequestHeader {
|
||||||
|
|
||||||
|
public static final String TOKEN = "x-access-token";
|
||||||
|
|
||||||
|
public static final String USER_AGENT = "user-agent";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户唯一标识
|
||||||
|
*/
|
||||||
|
public static final String USER_IDENTITY = "user-identity";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 经纬度
|
||||||
|
*/
|
||||||
|
public static final String USER_GEO = "user-geo";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 位置
|
||||||
|
*/
|
||||||
|
public static final String USER_LOCATION = "user-location";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统类型
|
||||||
|
*/
|
||||||
|
public static class SystemType {
|
||||||
|
|
||||||
|
public static final int XMF_CRM = 100;
|
||||||
|
|
||||||
|
public static final int REN_MIN = 200;
|
||||||
|
|
||||||
|
public static final int ZHI_KAO = 300;
|
||||||
|
|
||||||
|
public static final int XIAO_YING_YI = 400;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付方式
|
||||||
|
*/
|
||||||
|
public static class PayType {
|
||||||
|
|
||||||
|
public static final int WX = 10;
|
||||||
|
|
||||||
|
public static final int ZFB = 15;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 20 线下支付
|
||||||
|
*/
|
||||||
|
public static final int OFFLINE = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 21 银行卡
|
||||||
|
*/
|
||||||
|
public static final int BANK = 21;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Token {
|
||||||
|
|
||||||
|
public static final String DEFAULT_TOKEN = "default-token-id-";
|
||||||
|
|
||||||
|
public static final String INNER_TOKEN_NAME = "inner-token";
|
||||||
|
|
||||||
|
public static final String OUTER_TOKEN_NAME = "x-access-token";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,41 +1,41 @@
|
|||||||
package net.lab1024.smartadmin.service.common.constant;
|
package net.lab1024.smartadmin.service.common.constant;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统环境枚举类
|
* 系统环境枚举类
|
||||||
*
|
*
|
||||||
* @author listen
|
* @author zhuoda
|
||||||
* @date 2019年4月11日 17:34:59
|
|
||||||
*/
|
*/
|
||||||
public enum SystemEnvironmentEnum implements BaseEnum {
|
public enum SystemEnvironmentEnum implements BaseEnum {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dev
|
* dev
|
||||||
*/
|
*/
|
||||||
DEV("dev", "开发环境"),
|
DEV(SystemEnvironmentNameConst.DEV, "开发环境"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sit
|
* sit
|
||||||
*/
|
*/
|
||||||
SIT("sit", "测试环境"),
|
SIT(SystemEnvironmentNameConst.SIT, "测试环境"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pre
|
* pre
|
||||||
*/
|
*/
|
||||||
PRE("pre", "预发布环境"),
|
PRE(SystemEnvironmentNameConst.PRE, "预发布环境"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* prod
|
* prod
|
||||||
*/
|
*/
|
||||||
PROD("prod", "生产环境");
|
PROD(SystemEnvironmentNameConst.PROD, "生产环境");
|
||||||
|
|
||||||
private final String value;
|
private String value;
|
||||||
|
|
||||||
private final String desc;
|
private String desc;
|
||||||
|
|
||||||
SystemEnvironmentEnum(String value, String desc) {
|
SystemEnvironmentEnum(String value, String desc) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取定义枚举value值
|
* 获取定义枚举value值
|
||||||
*
|
*
|
||||||
@ -56,4 +56,11 @@ public enum SystemEnvironmentEnum implements BaseEnum {
|
|||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final class SystemEnvironmentNameConst {
|
||||||
|
public static final String DEV = "dev";
|
||||||
|
public static final String SIT = "sit";
|
||||||
|
public static final String PRE = "pre";
|
||||||
|
public static final String PROD = "prod";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
package net.lab1024.smartadmin.service.common.domain;
|
||||||
|
|
||||||
|
|
||||||
|
import net.lab1024.smartadmin.service.common.constant.SystemEnvironmentEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 系统环境
|
||||||
|
*
|
||||||
|
* @author zhuoda
|
||||||
|
* @Date 2021/8/13
|
||||||
|
*/
|
||||||
|
public class SystemEnvironmentBO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否位生产环境
|
||||||
|
*/
|
||||||
|
private boolean isProd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前环境
|
||||||
|
*/
|
||||||
|
private SystemEnvironmentEnum currentEnvironment;
|
||||||
|
|
||||||
|
public SystemEnvironmentBO(boolean isProd, SystemEnvironmentEnum currentEnvironment) {
|
||||||
|
this.isProd = isProd;
|
||||||
|
this.currentEnvironment = currentEnvironment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isProd() {
|
||||||
|
return isProd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前环境
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SystemEnvironmentEnum getCurrentEnvironment() {
|
||||||
|
return currentEnvironment;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.service.common.json;
|
package net.lab1024.smartadmin.service.common.serializer;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.service.common.json;
|
package net.lab1024.smartadmin.service.common.serializer;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.service.common.json;
|
package net.lab1024.smartadmin.service.common.serializer;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
@ -0,0 +1,21 @@
|
|||||||
|
package net.lab1024.smartadmin.service.common.serializer;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||||
|
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class LongJsonDeserializer extends JsonDeserializer<Long> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
|
||||||
|
String value = jsonParser.getText();
|
||||||
|
try {
|
||||||
|
return value == null ? null : Long.parseLong(value);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package net.lab1024.smartadmin.service.common.serializer;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||||
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class LongJsonSerializer extends JsonSerializer<Long> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(Long value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
|
||||||
|
String text = (value == null ? null : String.valueOf(value));
|
||||||
|
if (text != null) {
|
||||||
|
jsonGenerator.writeString(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
package net.lab1024.smartadmin.service.common.swagger;
|
||||||
|
|
||||||
|
import com.google.common.collect.LinkedListMultimap;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
import io.swagger.models.Operation;
|
||||||
|
import io.swagger.models.Path;
|
||||||
|
import net.lab1024.smartadmin.service.config.SystemEnvironmentConfig;
|
||||||
|
import org.springframework.context.annotation.Conditional;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import springfox.documentation.service.ApiDescription;
|
||||||
|
import springfox.documentation.service.ApiListing;
|
||||||
|
import springfox.documentation.swagger2.mappers.ServiceModelToSwagger2MapperImpl;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static springfox.documentation.builders.BuilderDefaults.nullToEmptyList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改 api 顺序
|
||||||
|
*
|
||||||
|
* @author Turbolisten
|
||||||
|
* @date 2021/8/11 16:05
|
||||||
|
*/
|
||||||
|
@Conditional(SystemEnvironmentConfig.class)
|
||||||
|
@Component
|
||||||
|
@Primary
|
||||||
|
public class Swagger2MapperImplExtension extends ServiceModelToSwagger2MapperImpl {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<String, Path> mapApiListings(Multimap<String, ApiListing> apiListings) {
|
||||||
|
Map<String, Path> paths = new LinkedHashMap<>();
|
||||||
|
Multimap<String, ApiListing> apiListingMap = LinkedListMultimap.create();
|
||||||
|
Iterator iter = apiListings.entries().iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
Map.Entry<String, ApiListing> entry = (Map.Entry<String, ApiListing>) iter.next();
|
||||||
|
ApiListing apis = entry.getValue();
|
||||||
|
List<ApiDescription> apiList = apis.getApis();
|
||||||
|
apiList.sort((left, right) -> {
|
||||||
|
int position1 = left.getOperations().get(0).getPosition();
|
||||||
|
int position2 = right.getOperations().get(0).getPosition();
|
||||||
|
if (position1 == position2) {
|
||||||
|
return String.CASE_INSENSITIVE_ORDER.compare(left.getPath(), right.getPath());
|
||||||
|
}
|
||||||
|
return Integer.compare(position1, position2);
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
// 因ApiListing的属性都是final故需要通过反射来修改值
|
||||||
|
modify(apis, "apis", apiList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
apiListingMap.put(entry.getKey(), apis);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ApiListing each : apiListingMap.values()) {
|
||||||
|
for (ApiDescription api : each.getApis()) {
|
||||||
|
paths.put(api.getPath(), mapOperations(api, Optional.ofNullable(paths.get(api.getPath()))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Path mapOperations(ApiDescription api, Optional<Path> existingPath) {
|
||||||
|
Path path = existingPath.orElse(new Path());
|
||||||
|
for (springfox.documentation.service.Operation each : nullToEmptyList(api.getOperations())) {
|
||||||
|
Operation operation = mapOperation(each);
|
||||||
|
path.set(each.getMethod().toString().toLowerCase(), operation);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void modify(Object object, String fieldName, Object newFieldValue) throws Exception {
|
||||||
|
Field field = object.getClass().getDeclaredField(fieldName);
|
||||||
|
|
||||||
|
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||||
|
modifiersField.setAccessible(true);
|
||||||
|
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
|
||||||
|
|
||||||
|
if (!field.isAccessible()) {
|
||||||
|
field.setAccessible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
field.set(object, newFieldValue);
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@ import static springfox.documentation.schema.Annotations.findPropertyAnnotation;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Order(SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER + 1)
|
@Order(SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER + 1)
|
||||||
public class ApiModelPropertyEnumPlugin implements ModelPropertyBuilderPlugin {
|
public class SwaggerApiModelPropertyEnumPlugin implements ModelPropertyBuilderPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(ModelPropertyContext context) {
|
public void apply(ModelPropertyContext context) {
|
@ -1,40 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.common.validator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 比较符枚举类
|
|
||||||
*
|
|
||||||
* @author listen
|
|
||||||
* @date 2018/03/20 14:01
|
|
||||||
*/
|
|
||||||
public enum BigDecimalSymbolEnum {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 等于
|
|
||||||
*/
|
|
||||||
EQUAL,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 不等于
|
|
||||||
*/
|
|
||||||
NOT_EQUAL,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小于
|
|
||||||
*/
|
|
||||||
LESS_THAN,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小于等于
|
|
||||||
*/
|
|
||||||
LESS_THAN_OR_EQUAL,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 大于
|
|
||||||
*/
|
|
||||||
GREATER_THAN,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 大于等于
|
|
||||||
*/
|
|
||||||
GREATER_THAN_OR_EQUAL,
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.common.validator;
|
|
||||||
|
|
||||||
import net.lab1024.smartadmin.service.util.SmartBigDecimalUtil;
|
|
||||||
|
|
||||||
import javax.validation.ConstraintValidator;
|
|
||||||
import javax.validation.ConstraintValidatorContext;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BigDecimal 类校验器
|
|
||||||
*
|
|
||||||
* @author listen
|
|
||||||
* @date 2018年3月20日 13:51:46
|
|
||||||
*/
|
|
||||||
public class BigDecimalValidator implements ConstraintValidator<CheckBigDecimal, BigDecimal> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取定义的数值
|
|
||||||
*/
|
|
||||||
private BigDecimal value;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取比较符
|
|
||||||
*/
|
|
||||||
private BigDecimalSymbolEnum symbolEnum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否必须
|
|
||||||
*/
|
|
||||||
private boolean required;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(CheckBigDecimal constraintAnnotation) {
|
|
||||||
// 初始化属性
|
|
||||||
value = new BigDecimal(constraintAnnotation.value());
|
|
||||||
symbolEnum = constraintAnnotation.symbolEnum();
|
|
||||||
required = constraintAnnotation.required();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid(BigDecimal decimal, ConstraintValidatorContext constraintValidatorContext) {
|
|
||||||
|
|
||||||
// 如果数值为空,校验是否必须
|
|
||||||
if (null == decimal) {
|
|
||||||
return ! required;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据操作符,校验结果
|
|
||||||
switch (symbolEnum) {
|
|
||||||
// 等于
|
|
||||||
case EQUAL:
|
|
||||||
return SmartBigDecimalUtil.equals(decimal, value);
|
|
||||||
// 不等于
|
|
||||||
case NOT_EQUAL:
|
|
||||||
return ! SmartBigDecimalUtil.equals(decimal, value);
|
|
||||||
// 小于
|
|
||||||
case LESS_THAN:
|
|
||||||
return SmartBigDecimalUtil.isLessThan(decimal, value);
|
|
||||||
// 小于等于
|
|
||||||
case LESS_THAN_OR_EQUAL:
|
|
||||||
return SmartBigDecimalUtil.isLessThan(decimal, value) || SmartBigDecimalUtil.equals(decimal, value);
|
|
||||||
// 大于
|
|
||||||
case GREATER_THAN:
|
|
||||||
return SmartBigDecimalUtil.isGreaterThan(decimal, value);
|
|
||||||
// 大于等于
|
|
||||||
case GREATER_THAN_OR_EQUAL:
|
|
||||||
return SmartBigDecimalUtil.isGreaterThan(decimal, value) || SmartBigDecimalUtil.equals(decimal, value);
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.common.validator;
|
|
||||||
|
|
||||||
import javax.validation.Constraint;
|
|
||||||
import javax.validation.Payload;
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义的属性校验注解
|
|
||||||
*
|
|
||||||
* @author listen
|
|
||||||
* @date 2018年3月20日 13:53:33
|
|
||||||
*/
|
|
||||||
@Target(ElementType.FIELD)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Constraint(validatedBy = BigDecimalValidator.class)// 自定义验证的处理类
|
|
||||||
public @interface CheckBigDecimal {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 与这个数值校验
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String value();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 比较符 请使用 ComparisonSymbolEnum 枚举类
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
BigDecimalSymbolEnum symbolEnum();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 默认的错误提示信息
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
String message() default "非法的数值";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否必须 : 默认 true
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
boolean required() default true;
|
|
||||||
|
|
||||||
//下面这两个属性必须添加 :不然会报错
|
|
||||||
Class<?>[] groups() default {};
|
|
||||||
|
|
||||||
Class<? extends Payload>[] payload() default {};
|
|
||||||
}
|
|
@ -1,4 +1,5 @@
|
|||||||
package net.lab1024.smartadmin.service.common.validator;
|
package net.lab1024.smartadmin.service.common.validator.en;
|
||||||
|
|
||||||
|
|
||||||
import net.lab1024.smartadmin.service.common.constant.BaseEnum;
|
import net.lab1024.smartadmin.service.common.constant.BaseEnum;
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ import java.lang.annotation.Target;
|
|||||||
*/
|
*/
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Constraint(validatedBy = CheckEnumValidator.class)// 自定义验证的处理类
|
@Constraint(validatedBy = EnumValidator.class)// 自定义验证的处理类
|
||||||
public @interface CheckEnum {
|
public @interface CheckEnum {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,7 +34,7 @@ public @interface CheckEnum {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Class<? extends BaseEnum> enumClazz();
|
Class<? extends BaseEnum> value();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否必须
|
* 是否必须
|
@ -1,4 +1,5 @@
|
|||||||
package net.lab1024.smartadmin.service.common.validator;
|
package net.lab1024.smartadmin.service.common.validator.en;
|
||||||
|
|
||||||
|
|
||||||
import net.lab1024.smartadmin.service.common.constant.BaseEnum;
|
import net.lab1024.smartadmin.service.common.constant.BaseEnum;
|
||||||
|
|
||||||
@ -13,9 +14,8 @@ import java.util.stream.Stream;
|
|||||||
*
|
*
|
||||||
* @author listen
|
* @author listen
|
||||||
* @date 2017/11/11 15:34
|
* @date 2017/11/11 15:34
|
||||||
* @update 2021年1月20日 15:32:16
|
|
||||||
*/
|
*/
|
||||||
public class CheckEnumValidator implements ConstraintValidator<CheckEnum, Object> {
|
public class EnumValidator implements ConstraintValidator<CheckEnum, Object> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 枚举类实例集合
|
* 枚举类实例集合
|
||||||
@ -31,7 +31,7 @@ public class CheckEnumValidator implements ConstraintValidator<CheckEnum, Object
|
|||||||
public void initialize(CheckEnum constraintAnnotation) {
|
public void initialize(CheckEnum constraintAnnotation) {
|
||||||
// 获取注解传入的枚举类对象
|
// 获取注解传入的枚举类对象
|
||||||
required = constraintAnnotation.required();
|
required = constraintAnnotation.required();
|
||||||
Class<? extends BaseEnum> enumClass = constraintAnnotation.enumClazz();
|
Class<? extends BaseEnum> enumClass = constraintAnnotation.value();
|
||||||
enumValList = Stream.of(enumClass.getEnumConstants()).map(BaseEnum::getValue).collect(Collectors.toList());
|
enumValList = Stream.of(enumClass.getEnumConstants()).map(BaseEnum::getValue).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.service.common.validator;
|
package net.lab1024.smartadmin.service.common.validator.list;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
@ -0,0 +1,34 @@
|
|||||||
|
package net.lab1024.smartadmin.service.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description
|
||||||
|
* @Author zhuoda
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class AdminWebAppConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Map<String, HandlerInterceptor> interceptorMap;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
for(Map.Entry<String, HandlerInterceptor> entry : interceptorMap.entrySet()){
|
||||||
|
registry.addInterceptor(entry.getValue()).addPathPatterns(entry.getKey() + "/**");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
|
registry.addViewController("/druidMonitor").setViewName("redirect:druid/index.html");
|
||||||
|
registry.addViewController("/swaggerApi").setViewName("redirect:swagger-ui.html");
|
||||||
|
}
|
||||||
|
}
|
@ -14,31 +14,31 @@ import java.util.Arrays;
|
|||||||
/**
|
/**
|
||||||
* 异步调用线程配置
|
* 异步调用线程配置
|
||||||
*
|
*
|
||||||
* @author 胡克
|
* @author zhuoda
|
||||||
* @date 2019/12/26 11:54
|
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SmartAsyncConfig {
|
public class AsyncConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 线程池 配置bean名称
|
* 线程池 配置bean名称
|
||||||
*/
|
*/
|
||||||
public static final String ASYNC_EXECUTOR = "asyncExecutor";
|
public static final String ASYNC_EXECUTOR_THREAD_NAME = "smart-admin-async-executor";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置线程池
|
* 配置线程池
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Bean(name = ASYNC_EXECUTOR)
|
@Bean(name = ASYNC_EXECUTOR_THREAD_NAME)
|
||||||
public AsyncTaskExecutor executor() {
|
public AsyncTaskExecutor executor() {
|
||||||
|
int processors = Runtime.getRuntime().availableProcessors();
|
||||||
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
|
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
|
||||||
// 核心线程数量
|
// 核心线程数量
|
||||||
taskExecutor.setCorePoolSize(Runtime.getRuntime().availableProcessors());
|
taskExecutor.setCorePoolSize(processors);
|
||||||
// 最大线程数量
|
// 最大线程数量
|
||||||
taskExecutor.setMaxPoolSize(Runtime.getRuntime().availableProcessors());
|
taskExecutor.setMaxPoolSize(processors);
|
||||||
taskExecutor.setThreadNamePrefix(ASYNC_EXECUTOR);
|
taskExecutor.setThreadNamePrefix(ASYNC_EXECUTOR_THREAD_NAME);
|
||||||
taskExecutor.initialize();
|
taskExecutor.initialize();
|
||||||
return taskExecutor;
|
return taskExecutor;
|
||||||
}
|
}
|
@ -1,36 +1,23 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
package net.lab1024.smartadmin.service.config;
|
||||||
|
|
||||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.beancache.cache.AbstractCaffeineCache;
|
import net.lab1024.smartadmin.service.module.support.beancache.cache.AbstractCaffeineCache;
|
||||||
import net.lab1024.smartadmin.service.module.support.beancache.cache.AbstractDisableCache;
|
import net.lab1024.smartadmin.service.module.support.beancache.cache.AbstractDisableCache;
|
||||||
import net.lab1024.smartadmin.service.module.support.beancache.cache.IBeanCache;
|
import net.lab1024.smartadmin.service.module.support.beancache.cache.IBeanCache;
|
||||||
import net.lab1024.smartadmin.service.module.support.beancache.domain.CacheData;
|
import net.lab1024.smartadmin.service.module.support.beancache.domain.CacheData;
|
||||||
import net.lab1024.smartadmin.service.module.support.beancache.load.CacheLoad;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.beancache.load.CacheLoadMethod;
|
|
||||||
import org.reflections.Reflections;
|
|
||||||
import org.reflections.scanners.MethodAnnotationsScanner;
|
|
||||||
import org.reflections.util.ConfigurationBuilder;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [ ]
|
* [ ]
|
||||||
*
|
*
|
||||||
* @author 罗伊
|
* @author zhuoda
|
||||||
* @date 2020/9/6 16:01
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SmartCacheConfig {
|
public class CaffeineCacheConfig {
|
||||||
|
|
||||||
@Value("${cache.maximumSize:5000}")
|
@Value("${cache.maximumSize:5000}")
|
||||||
private Integer cacheMaximumSize;
|
private Integer cacheMaximumSize;
|
||||||
|
|
||||||
@ -44,7 +31,8 @@ public class SmartCacheConfig {
|
|||||||
@Primary
|
@Primary
|
||||||
public IBeanCache beanCache() {
|
public IBeanCache beanCache() {
|
||||||
return new AbstractCaffeineCache() {
|
return new AbstractCaffeineCache() {
|
||||||
LoadingCache<String, CacheData> cache = this.initCache(cacheMaximumSize,expireDays, scanPath);
|
LoadingCache<String, CacheData> cache = this.initCache(cacheMaximumSize, expireDays, scanPath);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoadingCache getCache() {
|
public LoadingCache getCache() {
|
||||||
return cache;
|
return cache;
|
||||||
@ -57,7 +45,5 @@ public class SmartCacheConfig {
|
|||||||
public IBeanCache beanDisableCache() {
|
public IBeanCache beanDisableCache() {
|
||||||
return new AbstractDisableCache(scanPath);
|
return new AbstractDisableCache(scanPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -10,13 +10,13 @@ import com.baomidou.mybatisplus.annotation.DbType;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.datascope.MyBatisPlugin;
|
||||||
import org.apache.ibatis.plugin.Interceptor;
|
import org.apache.ibatis.plugin.Interceptor;
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||||
import org.springframework.aop.support.JdkRegexpMethodPointcut;
|
import org.springframework.aop.support.JdkRegexpMethodPointcut;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -33,59 +33,55 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [ ]
|
* [ 数据源配置 ]
|
||||||
*
|
*
|
||||||
* @author 罗伊
|
* @author zhuoda
|
||||||
* @date 2020/8/25 11:57
|
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SmartDruidDataSourceConfig {
|
public class DataSourceConfig {
|
||||||
|
|
||||||
@Value("${spring.datasource.driver-class-name}")
|
@Value("${spring.datasource.driver-class-name}")
|
||||||
private String driver;
|
String driver;
|
||||||
|
|
||||||
@Value("${spring.datasource.url}")
|
@Value("${spring.datasource.url}")
|
||||||
private String url;
|
String url;
|
||||||
|
|
||||||
@Value("${spring.datasource.username}")
|
@Value("${spring.datasource.username}")
|
||||||
private String username;
|
String username;
|
||||||
|
|
||||||
@Value("${spring.datasource.password}")
|
@Value("${spring.datasource.password}")
|
||||||
private String password;
|
String password;
|
||||||
|
|
||||||
@Value("${spring.datasource.initial-size}")
|
@Value("${spring.datasource.initial-size}")
|
||||||
private int initialSize;
|
int initialSize;
|
||||||
|
|
||||||
@Value("${spring.datasource.min-idle}")
|
@Value("${spring.datasource.min-idle}")
|
||||||
private int minIdle;
|
int minIdle;
|
||||||
|
|
||||||
@Value("${spring.datasource.max-active}")
|
@Value("${spring.datasource.max-active}")
|
||||||
private int maxActive;
|
int maxActive;
|
||||||
|
|
||||||
@Value("${spring.datasource.max-wait}")
|
@Value("${spring.datasource.max-wait}")
|
||||||
private long maxWait;
|
long maxWait;
|
||||||
|
|
||||||
@Value("${spring.datasource.time-between-eviction-runs-millis}")
|
@Value("${spring.datasource.time-between-eviction-runs-millis}")
|
||||||
private long timeBetweenEvictionRunsMillis;
|
long timeBetweenEvictionRunsMillis;
|
||||||
|
|
||||||
@Value("${spring.datasource.min-evictable-idle-time-millis}")
|
@Value("${spring.datasource.min-evictable-idle-time-millis}")
|
||||||
private long minEvictableIdleTimeMillis;
|
long minEvictableIdleTimeMillis;
|
||||||
|
|
||||||
@Value("${spring.datasource.filters}")
|
@Value("${spring.datasource.filters}")
|
||||||
private String filters;
|
String filters;
|
||||||
|
|
||||||
@Value("${spring.datasource.druid.username}")
|
@Value("${spring.datasource.druid.username}")
|
||||||
private String druidUserName;
|
String druidUserName;
|
||||||
|
|
||||||
@Value("${spring.datasource.druid.password}")
|
@Value("${spring.datasource.druid.password}")
|
||||||
private String druidPassword;
|
String druidPassword;
|
||||||
|
|
||||||
@Value("${spring.datasource.druid.login.enabled}")
|
@Value("${spring.datasource.druid.login.enabled}")
|
||||||
private boolean druidLoginEnable;
|
boolean druidLoginEnable;
|
||||||
|
|
||||||
@Value("${spring.datasource.druid.service.scanner}")
|
|
||||||
private String serviceScanner;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private StatFilter logSlowSql;
|
private StatFilter logSlowSql;
|
||||||
@ -94,7 +90,10 @@ public class SmartDruidDataSourceConfig {
|
|||||||
private DruidStatInterceptor druidStatInterceptor;
|
private DruidStatInterceptor druidStatInterceptor;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MybatisPlusInterceptor mybatisPlusInterceptor;
|
private MybatisPlusInterceptor paginationInterceptor;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MyBatisPlugin myBatisPlugin;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Primary
|
@Primary
|
||||||
@ -130,29 +129,29 @@ public class SmartDruidDataSourceConfig {
|
|||||||
MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
|
MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
|
||||||
factoryBean.setDataSource(druidDataSource());
|
factoryBean.setDataSource(druidDataSource());
|
||||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
Resource[] resources = resolver.getResources("classpath*:/mapper/**/*.xml");
|
Resource[] resources = resolver.getResources("classpath:/mapper/**/*.xml");
|
||||||
factoryBean.setMapperLocations(resources);
|
factoryBean.setMapperLocations(resources);
|
||||||
|
|
||||||
// 设置 MyBatis-Plus 分页插件
|
// 设置 MyBatis-Plus 分页插件 注意此处myBatisPlugin一定要放在后面
|
||||||
Interceptor[] plugins = {mybatisPlusInterceptor};
|
Interceptor[] plugins = {paginationInterceptor,myBatisPlugin};
|
||||||
factoryBean.setPlugins(plugins);
|
factoryBean.setPlugins(plugins);
|
||||||
|
|
||||||
return factoryBean.getObject();
|
return factoryBean.getObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 非正式环境 加载
|
* 非正式环境 才加载
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Conditional(SystemEnvironmentConfig.class)
|
||||||
@Bean
|
@Bean
|
||||||
@Conditional(SmartSystemEnvNotProdCondition.class)
|
|
||||||
public ServletRegistrationBean<StatViewServlet> druidServlet() {
|
public ServletRegistrationBean<StatViewServlet> druidServlet() {
|
||||||
ServletRegistrationBean<StatViewServlet> servletRegistrationBean = new ServletRegistrationBean<StatViewServlet>();
|
ServletRegistrationBean<StatViewServlet> servletRegistrationBean = new ServletRegistrationBean<>();
|
||||||
servletRegistrationBean.setServlet(new StatViewServlet());
|
servletRegistrationBean.setServlet(new StatViewServlet());
|
||||||
servletRegistrationBean.addUrlMappings("/druid/*");
|
servletRegistrationBean.addUrlMappings("/druid/*");
|
||||||
Map<String, String> initParameters = new HashMap<String, String>();
|
Map<String, String> initParameters = new HashMap<String, String>();
|
||||||
// 不设置用户名密码可以直接通过druid/index.html访问
|
//不设置用户名密码可以直接通过druid/index.html访问
|
||||||
if (druidLoginEnable) {
|
if (druidLoginEnable) {
|
||||||
initParameters.put("loginUsername", druidUserName);
|
initParameters.put("loginUsername", druidUserName);
|
||||||
initParameters.put("loginPassword", druidPassword);
|
initParameters.put("loginPassword", druidPassword);
|
||||||
@ -182,13 +181,14 @@ public class SmartDruidDataSourceConfig {
|
|||||||
|
|
||||||
@Bean(name = "druid-stat-interceptor")
|
@Bean(name = "druid-stat-interceptor")
|
||||||
public DruidStatInterceptor druidStatInterceptor() {
|
public DruidStatInterceptor druidStatInterceptor() {
|
||||||
return new DruidStatInterceptor();
|
DruidStatInterceptor dsInterceptor = new DruidStatInterceptor();
|
||||||
|
return dsInterceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public JdkRegexpMethodPointcut jdkRegexpMethodPointcut() {
|
public JdkRegexpMethodPointcut jdkRegexpMethodPointcut() {
|
||||||
JdkRegexpMethodPointcut jdkRegexpMethodPointcut = new JdkRegexpMethodPointcut();
|
JdkRegexpMethodPointcut jdkRegexpMethodPointcut = new JdkRegexpMethodPointcut();
|
||||||
jdkRegexpMethodPointcut.setPatterns(serviceScanner);
|
jdkRegexpMethodPointcut.setPatterns("com.renminyixue.core.service.module..*Service.*");
|
||||||
return jdkRegexpMethodPointcut;
|
return jdkRegexpMethodPointcut;
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,117 @@
|
|||||||
|
package net.lab1024.smartadmin.service.config;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||||
|
import net.lab1024.smartadmin.service.util.date.SmartDateFormatterEnum;
|
||||||
|
import net.lab1024.smartadmin.service.util.date.SmartLocalDateUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.convert.converter.Converter;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* java8 localDate 时间类格式化配置
|
||||||
|
*
|
||||||
|
* @author listen
|
||||||
|
* @date 2019年10月18日 19:02:55
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class DateConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LocalDateTimeSerializer localDateTimeSerializer() {
|
||||||
|
return new LocalDateTimeSerializer(SmartDateFormatterEnum.YMD_HMS.getFormatter());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Jackson2ObjectMapperBuilderCustomizer localDateTimeSerializerCustomizer() {
|
||||||
|
return builder -> builder.serializerByType(LocalDateTime.class, localDateTimeSerializer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LocalDateTimeDeserializer localDateTimeDeserializer() {
|
||||||
|
return new LocalDateTimeDeserializer(SmartDateFormatterEnum.YMD_HMS.getFormatter());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Jackson2ObjectMapperBuilderCustomizer localDateTimeDeserializerCustomizer() {
|
||||||
|
return builder -> builder.deserializerByType(LocalDateTime.class, localDateTimeDeserializer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LocalDateSerializer localDateSerializer() {
|
||||||
|
return new LocalDateSerializer(SmartDateFormatterEnum.YMD.getFormatter());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Jackson2ObjectMapperBuilderCustomizer localDateSerializerCustomizer() {
|
||||||
|
return builder -> builder.serializerByType(LocalDate.class, localDateSerializer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LocalDateDeserializer localDateDeserializer() {
|
||||||
|
return new LocalDateDeserializer(SmartDateFormatterEnum.YMD.getFormatter());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Jackson2ObjectMapperBuilderCustomizer localDateDeserializerCustomizer() {
|
||||||
|
return builder -> builder.deserializerByType(LocalDate.class, localDateDeserializer());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* string 转为 LocalDate 配置类
|
||||||
|
*
|
||||||
|
* @author Turbolisten
|
||||||
|
* @date 2020/3/6 14:34
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public static class SmartConverterStringToLocalDateTime implements Converter<String, LocalDateTime> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalDateTime convert(String str) {
|
||||||
|
if (StringUtils.isBlank(str)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
LocalDateTime localDateTime;
|
||||||
|
try {
|
||||||
|
localDateTime = SmartLocalDateUtil.parse(str, SmartDateFormatterEnum.YMD_HMS);
|
||||||
|
} catch (DateTimeParseException e) {
|
||||||
|
throw new RuntimeException("请输入正确的日期格式:yyyy-MM-dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
return localDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* string 转为 LocalDate 配置类
|
||||||
|
*
|
||||||
|
* @author Turbolisten
|
||||||
|
* @date 2020/3/6 14:34
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public static class SmartConverterStringToLocalDate implements Converter<String, LocalDate> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LocalDate convert(String str) {
|
||||||
|
if (StringUtils.isBlank(str)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
LocalDate localDate;
|
||||||
|
try {
|
||||||
|
localDate = SmartLocalDateUtil.parseDate(str, SmartDateFormatterEnum.YMD);
|
||||||
|
} catch (DateTimeParseException e) {
|
||||||
|
throw new RuntimeException("请输入正确的日期格式:yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
return localDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,156 @@
|
|||||||
|
package net.lab1024.smartadmin.service.config;
|
||||||
|
|
||||||
|
import com.google.code.kaptcha.NoiseProducer;
|
||||||
|
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
||||||
|
import com.google.code.kaptcha.text.WordRenderer;
|
||||||
|
import com.google.code.kaptcha.util.Config;
|
||||||
|
import com.google.code.kaptcha.util.Configurable;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.font.FontRenderContext;
|
||||||
|
import java.awt.font.GlyphVector;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [ 验证码配置 ]
|
||||||
|
*
|
||||||
|
* @author zhuoda
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class KaptchaConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public DefaultKaptcha getDefaultKaptcha() {
|
||||||
|
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
|
||||||
|
Properties properties = new Properties();
|
||||||
|
properties.setProperty("kaptcha.border", "no");
|
||||||
|
properties.setProperty("kaptcha.border.color", "34,114,200");
|
||||||
|
properties.setProperty("kaptcha.image.width", "125");
|
||||||
|
properties.setProperty("kaptcha.image.height", "45");
|
||||||
|
properties.setProperty("kaptcha.textproducer.char.string", "123456789");
|
||||||
|
properties.setProperty("kaptcha.textproducer.char.length", "4");
|
||||||
|
properties.setProperty("kaptcha.textproducer.font.names", "Arial,Arial Narrow,Serif,Helvetica,Tahoma,Times New Roman,Verdana");
|
||||||
|
properties.setProperty("kaptcha.textproducer.font.size", "38");
|
||||||
|
|
||||||
|
properties.setProperty("kaptcha.background.clear.from", "white");
|
||||||
|
properties.setProperty("kaptcha.background.clear.to", "white");
|
||||||
|
|
||||||
|
properties.setProperty("kaptcha.word.impl", KaptchaWordRenderer.class.getName());
|
||||||
|
properties.setProperty("kaptcha.noise.impl", KaptchaNoise.class.getName());
|
||||||
|
|
||||||
|
Config config = new Config(properties);
|
||||||
|
defaultKaptcha.setConfig(config);
|
||||||
|
return defaultKaptcha;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class KaptchaColor {
|
||||||
|
|
||||||
|
public static Color getColor() {
|
||||||
|
|
||||||
|
List<Color> colors = Lists.newArrayList();
|
||||||
|
colors.add(new Color(0, 135, 255));
|
||||||
|
colors.add(new Color(51, 153, 51));
|
||||||
|
colors.add(new Color(255, 102, 102));
|
||||||
|
colors.add(new Color(255, 153, 0));
|
||||||
|
colors.add(new Color(153, 102, 0));
|
||||||
|
colors.add(new Color(153, 102, 153));
|
||||||
|
colors.add(new Color(51, 153, 153));
|
||||||
|
colors.add(new Color(102, 102, 255));
|
||||||
|
colors.add(new Color(0, 102, 204));
|
||||||
|
colors.add(new Color(204, 51, 51));
|
||||||
|
colors.add(new Color(128, 153, 65));
|
||||||
|
Random random = new Random();
|
||||||
|
int colorIndex = random.nextInt(10);
|
||||||
|
return colors.get(colorIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class KaptchaNoise extends Configurable implements NoiseProducer {
|
||||||
|
|
||||||
|
public KaptchaNoise() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void makeNoise(BufferedImage image, float factorOne, float factorTwo, float factorThree, float factorFour) {
|
||||||
|
|
||||||
|
int width = image.getWidth();
|
||||||
|
int height = image.getHeight();
|
||||||
|
Graphics2D graph = (Graphics2D) image.getGraphics();
|
||||||
|
graph.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
|
||||||
|
graph.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||||
|
Random random = new Random();
|
||||||
|
int noiseLineNum = random.nextInt(3);
|
||||||
|
if (noiseLineNum == 0) {
|
||||||
|
noiseLineNum = 1;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < noiseLineNum; i++) {
|
||||||
|
graph.setColor(KaptchaColor.getColor());
|
||||||
|
graph.drawLine(random.nextInt(width), random.nextInt(height), 10 + random.nextInt(20), 10 + random.nextInt(20));
|
||||||
|
}
|
||||||
|
|
||||||
|
graph.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class KaptchaWordRenderer extends Configurable implements WordRenderer {
|
||||||
|
|
||||||
|
public KaptchaWordRenderer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BufferedImage renderWord(String word, int width, int height) {
|
||||||
|
int fontSize = this.getConfig().getTextProducerFontSize();
|
||||||
|
Font[] fonts = this.getConfig().getTextProducerFonts(fontSize);
|
||||||
|
int charSpace = this.getConfig().getTextProducerCharSpace();
|
||||||
|
BufferedImage image = new BufferedImage(width, height, 2);
|
||||||
|
|
||||||
|
Graphics2D g2D = image.createGraphics();
|
||||||
|
g2D.setColor(Color.WHITE);
|
||||||
|
RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
|
||||||
|
g2D.setRenderingHints(hints);
|
||||||
|
g2D.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||||
|
|
||||||
|
FontRenderContext frc = g2D.getFontRenderContext();
|
||||||
|
Random random = new Random();
|
||||||
|
int startPosY = (height - fontSize) / 5 + fontSize;
|
||||||
|
char[] wordChars = word.toCharArray();
|
||||||
|
Font[] chosenFonts = new Font[wordChars.length];
|
||||||
|
int[] charWidths = new int[wordChars.length];
|
||||||
|
int widthNeeded = 0;
|
||||||
|
|
||||||
|
int startPosX;
|
||||||
|
for (startPosX = 0; startPosX < wordChars.length; ++startPosX) {
|
||||||
|
chosenFonts[startPosX] = fonts[random.nextInt(fonts.length)];
|
||||||
|
char[] charToDraw = new char[]{wordChars[startPosX]};
|
||||||
|
GlyphVector gv = chosenFonts[startPosX].createGlyphVector(frc, charToDraw);
|
||||||
|
charWidths[startPosX] = (int) gv.getVisualBounds().getWidth();
|
||||||
|
if (startPosX > 0) {
|
||||||
|
widthNeeded += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
widthNeeded += charWidths[startPosX];
|
||||||
|
}
|
||||||
|
|
||||||
|
startPosX = (width - widthNeeded) / 2;
|
||||||
|
|
||||||
|
for (int i = 0; i < wordChars.length; ++i) {
|
||||||
|
g2D.setColor(KaptchaColor.getColor());
|
||||||
|
g2D.setFont(chosenFonts[i].deriveFont(Font.PLAIN));
|
||||||
|
char[] charToDraw = new char[]{wordChars[i]};
|
||||||
|
g2D.drawChars(charToDraw, 0, charToDraw.length, startPosX, startPosY);
|
||||||
|
startPosX = startPosX + charWidths[i] + charSpace;
|
||||||
|
}
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -8,15 +8,13 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MybatisPlus 配置
|
* description
|
||||||
*
|
*
|
||||||
* @author listen
|
* @author zhuoda
|
||||||
* @date 2021/06/06 19:30
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
public class SmartMybatisPlusConfig {
|
@Configuration
|
||||||
|
public class MybatisPlusConfig {
|
||||||
/**
|
/**
|
||||||
* 分页插件
|
* 分页插件
|
||||||
*/
|
*/
|
@ -14,11 +14,10 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
|
|||||||
/**
|
/**
|
||||||
* [ redis配置 ]
|
* [ redis配置 ]
|
||||||
*
|
*
|
||||||
* @author 罗伊
|
* @author zhuoda
|
||||||
* @date 2020/8/25 11:57
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SmartRedisConfig {
|
public class RedisConfig {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisConnectionFactory factory;
|
private RedisConnectionFactory factory;
|
@ -29,11 +29,10 @@ import java.util.concurrent.TimeUnit;
|
|||||||
/**
|
/**
|
||||||
* [ ]
|
* [ ]
|
||||||
*
|
*
|
||||||
* @author 罗伊
|
* @author zhuoda
|
||||||
* @date 2020/8/25 11:57
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SmartRestTemplateConfig {
|
public class RestTemplateConfig {
|
||||||
|
|
||||||
@Value("${http.pool.max-total}")
|
@Value("${http.pool.max-total}")
|
||||||
private Integer maxTotal;
|
private Integer maxTotal;
|
||||||
@ -55,8 +54,8 @@ public class SmartRestTemplateConfig {
|
|||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
restTemplate.setRequestFactory(this.clientHttpRequestFactory());
|
restTemplate.setRequestFactory(this.clientHttpRequestFactory());
|
||||||
List<HttpMessageConverter<?>> messageConverterList = restTemplate.getMessageConverters();
|
List<HttpMessageConverter<?>> messageConverterList = restTemplate.getMessageConverters();
|
||||||
messageConverterList.add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
messageConverterList.add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));
|
||||||
messageConverterList.addAll(converters());
|
messageConverterList.addAll(this.converters());
|
||||||
return restTemplate;
|
return restTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,16 +74,17 @@ public class SmartRestTemplateConfig {
|
|||||||
|
|
||||||
|
|
||||||
public OkHttp3ClientHttpRequestFactory clientHttpRequestFactory() {
|
public OkHttp3ClientHttpRequestFactory clientHttpRequestFactory() {
|
||||||
return new OkHttp3ClientHttpRequestFactory(httpClientBuilder());
|
OkHttp3ClientHttpRequestFactory okHttp3ClientHttpRequestFactory = new OkHttp3ClientHttpRequestFactory(httpClientBuilder());
|
||||||
|
return okHttp3ClientHttpRequestFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OkHttpClient httpClientBuilder() {
|
public OkHttpClient httpClientBuilder() {
|
||||||
return new OkHttpClient.Builder()
|
return new OkHttpClient.Builder()
|
||||||
.retryOnConnectionFailure(false)
|
.retryOnConnectionFailure(true)
|
||||||
.connectionPool(this.pool())
|
.connectionPool(this.pool())
|
||||||
.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
|
.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
|
||||||
.readTimeout(readTimeout,TimeUnit.MILLISECONDS)
|
.readTimeout(readTimeout, TimeUnit.MILLISECONDS)
|
||||||
.writeTimeout(writeTimeout,TimeUnit.MILLISECONDS)
|
.writeTimeout(writeTimeout, TimeUnit.MILLISECONDS)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,9 +99,11 @@ public class SmartRestTemplateConfig {
|
|||||||
@Override
|
@Override
|
||||||
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
return new X509Certificate[0];
|
return new X509Certificate[0];
|
||||||
@ -116,11 +118,12 @@ public class SmartRestTemplateConfig {
|
|||||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||||
sslContext.init(null, new TrustManager[]{x509TrustManager()}, new SecureRandom());
|
sslContext.init(null, new TrustManager[]{x509TrustManager()}, new SecureRandom());
|
||||||
return sslContext.getSocketFactory();
|
return sslContext.getSocketFactory();
|
||||||
} catch (NoSuchAlgorithmException | KeyManagementException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (KeyManagementException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -12,22 +12,20 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 卓大
|
* @author zhuoda
|
||||||
* @Date 2020/5/22
|
* @Date 2020/5/22
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SmartSchedulingConfig implements SchedulingConfigurer {
|
public class ScheduleConfig implements SchedulingConfigurer {
|
||||||
|
|
||||||
private ScheduledTaskRegistrar taskRegistrar;
|
private ScheduledTaskRegistrar taskRegistrar;
|
||||||
|
|
||||||
public ScheduledTaskRegistrar getTaskRegistrar() {
|
@Override
|
||||||
return taskRegistrar;
|
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||||
|
this.taskRegistrar = taskRegistrar;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 结束定时任务
|
|
||||||
*/
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
List<Task> taskList = new ArrayList<>();
|
List<Task> taskList = new ArrayList<>();
|
||||||
taskList.addAll(taskRegistrar.getCronTaskList());
|
taskList.addAll(taskRegistrar.getCronTaskList());
|
||||||
@ -42,10 +40,4 @@ public class SmartSchedulingConfig implements SchedulingConfigurer {
|
|||||||
log.warn("已结束定时任务:\n{}", Strings.join(taskName, '\n'));
|
log.warn("已结束定时任务:\n{}", Strings.join(taskName, '\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
|
||||||
this.taskRegistrar = taskRegistrar;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
package net.lab1024.smartadmin.service.config;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.service.filter.SmartSecurityTokenFilter;
|
|
||||||
import net.lab1024.smartadmin.service.common.security.SmartSecurityUrlMatchers;
|
import net.lab1024.smartadmin.service.common.security.SmartSecurityUrlMatchers;
|
||||||
|
import net.lab1024.smartadmin.service.filter.SmartSecurityTokenFilter;
|
||||||
import net.lab1024.smartadmin.service.handler.AuthenticationFailHandler;
|
import net.lab1024.smartadmin.service.handler.AuthenticationFailHandler;
|
||||||
import net.lab1024.smartadmin.service.module.system.login.EmployeeLoginTokenService;
|
import net.lab1024.smartadmin.service.module.system.login.EmployeeLoginTokenService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Spring Security
|
* Spring Security
|
||||||
*
|
*
|
||||||
* @author 罗伊
|
* @author zhuoda
|
||||||
* @date 2021/8/3 17:50
|
* @date 2021/8/3 17:50
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ -12,7 +12,7 @@ import org.springframework.security.config.annotation.method.configuration.Globa
|
|||||||
/**
|
/**
|
||||||
* 此类用于注入自己的 method校验
|
* 此类用于注入自己的 method校验
|
||||||
* SmartSecurityMetadataSource
|
* SmartSecurityMetadataSource
|
||||||
* @author 罗伊
|
* @author zhuoda
|
||||||
* @date 2021-08-31 0:01
|
* @date 2021-08-31 0:01
|
||||||
*/
|
*/
|
||||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||||
|
@ -8,7 +8,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
/**
|
/**
|
||||||
* [ ]
|
* [ ]
|
||||||
*
|
*
|
||||||
* @author 罗伊
|
* @author zhuoda
|
||||||
* @date 2021/9/1 21:40
|
* @date 2021/9/1 21:40
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
|
||||||
|
|
||||||
import com.google.code.kaptcha.impl.DefaultKaptcha;
|
|
||||||
import com.google.code.kaptcha.util.Config;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.captcha.render.CaptchaNoise;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.captcha.render.CaptchaWordRenderer;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [ 验证码配置 ]
|
|
||||||
*
|
|
||||||
* @author 罗伊
|
|
||||||
* @version 1.0
|
|
||||||
* @since JDK1.8
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class SmartCaptchaConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 图形验证码配置
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public DefaultKaptcha getDefaultCaptcha() {
|
|
||||||
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
|
|
||||||
Properties properties = new Properties();
|
|
||||||
properties.setProperty("kaptcha.border", "no" );
|
|
||||||
properties.setProperty("kaptcha.border.color", "34,114,200" );
|
|
||||||
properties.setProperty("kaptcha.image.width", "125" );
|
|
||||||
properties.setProperty("kaptcha.image.height", "45" );
|
|
||||||
properties.setProperty("kaptcha.textproducer.char.string", "123456789" );
|
|
||||||
properties.setProperty("kaptcha.textproducer.char.length", "4" );
|
|
||||||
properties.setProperty("kaptcha.textproducer.font.names", "Arial,Arial Narrow,Serif,Helvetica,Tahoma,Times New Roman,Verdana" );
|
|
||||||
properties.setProperty("kaptcha.textproducer.font.size", "38" );
|
|
||||||
|
|
||||||
properties.setProperty("kaptcha.background.clear.from", "white" );
|
|
||||||
properties.setProperty("kaptcha.background.clear.to", "white" );
|
|
||||||
|
|
||||||
properties.setProperty("kaptcha.word.impl", CaptchaWordRenderer.class.getName());
|
|
||||||
properties.setProperty("kaptcha.noise.impl", CaptchaNoise.class.getName());
|
|
||||||
|
|
||||||
Config config = new Config(properties);
|
|
||||||
defaultKaptcha.setConfig(config);
|
|
||||||
return defaultKaptcha;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
|
||||||
|
|
||||||
import net.lab1024.smartadmin.service.util.date.SmartDateFormatterEnum;
|
|
||||||
import net.lab1024.smartadmin.service.util.date.SmartLocalDateUtil;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.format.DateTimeParseException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* string 转为 LocalDate 配置类
|
|
||||||
*
|
|
||||||
* @author 胡克
|
|
||||||
* @date 2020/3/6 14:34
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class SmartConverterStringToLocalDate implements Converter<String, LocalDate> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LocalDate convert(String str) {
|
|
||||||
if (StringUtils.isBlank(str)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
LocalDate localDate;
|
|
||||||
try {
|
|
||||||
localDate = SmartLocalDateUtil.parseDate(str, SmartDateFormatterEnum.YMD);
|
|
||||||
} catch (DateTimeParseException e) {
|
|
||||||
throw new RuntimeException("请输入正确的日期格式:yyyy-MM-dd");
|
|
||||||
}
|
|
||||||
return localDate;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
|
||||||
|
|
||||||
import net.lab1024.smartadmin.service.util.date.SmartDateFormatterEnum;
|
|
||||||
import net.lab1024.smartadmin.service.util.date.SmartLocalDateUtil;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeParseException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* string 转为 LocalDate 配置类
|
|
||||||
*
|
|
||||||
* @author 胡克
|
|
||||||
* @date 2020/3/6 14:34
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class SmartConverterStringToLocalDateTime implements Converter<String, LocalDateTime> {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LocalDateTime convert(String str) {
|
|
||||||
if (StringUtils.isBlank(str)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
LocalDateTime localDateTime;
|
|
||||||
try {
|
|
||||||
localDateTime = SmartLocalDateUtil.parse(str, SmartDateFormatterEnum.YMD_HMS);
|
|
||||||
} catch (DateTimeParseException e) {
|
|
||||||
throw new RuntimeException("请输入正确的日期格式:yyyy-MM-dd HH:mm:ss");
|
|
||||||
}
|
|
||||||
return localDateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
|
||||||
|
|
||||||
import net.lab1024.smartadmin.service.module.support.heartbeat.HeartBeatRecordHandler;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.heartbeat.core.HeartBeatManager;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [ 服务心跳配置 ]
|
|
||||||
*
|
|
||||||
* @author 罗伊
|
|
||||||
* @date 2021/1/9 14:13
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class SmartHeartBeatConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 延迟执行时间
|
|
||||||
*/
|
|
||||||
@Value("${heart-beat.delayHandlerTime}")
|
|
||||||
private Long delayHandlerTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 间隔执行时间
|
|
||||||
*/
|
|
||||||
@Value("${heart-beat.intervalTime}")
|
|
||||||
private Long intervalTime;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private HeartBeatRecordHandler heartBeatRecordHandler;
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public HeartBeatManager heartBeatManager(){
|
|
||||||
return new HeartBeatManager(delayHandlerTime,intervalTime,heartBeatRecordHandler);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.redismq.RedisMqTopicEnum;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.redismq.RedisMsgHandler;
|
|
||||||
import net.lab1024.smartadmin.service.util.SmartBaseEnumUtil;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|
||||||
import org.springframework.data.redis.listener.PatternTopic;
|
|
||||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
|
||||||
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [ ]
|
|
||||||
*
|
|
||||||
* @author 罗伊
|
|
||||||
* @date
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@Configuration
|
|
||||||
public class SmartRedisMqConfig {
|
|
||||||
|
|
||||||
@Value("${redis.mq.topic:SmartAdmin}")
|
|
||||||
private String topic;
|
|
||||||
@Value("${redis.mq.scanPath:net.lab1024.smartadmin.service}")
|
|
||||||
private String scanPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* redis topic
|
|
||||||
* @param connectionFactory
|
|
||||||
* @param listenerAdapter
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory, MessageListenerAdapter listenerAdapter) {
|
|
||||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
|
||||||
container.setConnectionFactory(connectionFactory);
|
|
||||||
boolean checkEnum = SmartBaseEnumUtil.checkEnum(topic, RedisMqTopicEnum.class);
|
|
||||||
if (!checkEnum) {
|
|
||||||
log.error("topic:{},系统暂未定义", topic);
|
|
||||||
throw new RuntimeException("无效的redis topic");
|
|
||||||
}
|
|
||||||
container.addMessageListener(listenerAdapter, new PatternTopic(topic));
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* redis消息处理类
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public RedisMsgHandler redisMsgHandler() {
|
|
||||||
return new RedisMsgHandler(scanPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* redis消息处理方法
|
|
||||||
* @param receiver
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public MessageListenerAdapter listenerAdapter(RedisMsgHandler receiver) {
|
|
||||||
return new MessageListenerAdapter(receiver, RedisMsgHandler.METHOD_NAME);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.repeatsubmit.SmartRepeatSubmitAspect;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.repeatsubmit.SmartRepeatSubmitUserDTO;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.login.domain.EmployeeLoginInfoDTO;
|
|
||||||
import net.lab1024.smartadmin.service.util.SmartEmployeeTokenUtil;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [ 接口重复提交配置 ]
|
|
||||||
*
|
|
||||||
* @author 罗伊
|
|
||||||
* @date 2021/1/27 11:22
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class SmartRepeatSubmitAspectConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public SmartRepeatSubmitAspect repeatSubmitAspect() {
|
|
||||||
return new SmartRepeatSubmitAspect(this::userFunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求用户信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private SmartRepeatSubmitUserDTO userFunction(HttpServletRequest request) {
|
|
||||||
EmployeeLoginInfoDTO requestEmployee = SmartEmployeeTokenUtil.getRequestEmployee();
|
|
||||||
if(requestEmployee == null){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
SmartRepeatSubmitUserDTO repeatSubmitUserDTO = new SmartRepeatSubmitUserDTO();
|
|
||||||
repeatSubmitUserDTO.setUserId(requestEmployee.getEmployeeId());
|
|
||||||
repeatSubmitUserDTO.setUserName(requestEmployee.getActualName());
|
|
||||||
repeatSubmitUserDTO.setExtData(JSON.toJSONString(requestEmployee));
|
|
||||||
return repeatSubmitUserDTO;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.responseencrypt.ResponseEncryptDecryptAspect;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.responseencrypt.ResponseEncryptDecryptUserDTO;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.login.domain.EmployeeLoginInfoDTO;
|
|
||||||
import net.lab1024.smartadmin.service.util.SmartEmployeeTokenUtil;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* [ 接口加解密配置 ]
|
|
||||||
*
|
|
||||||
* @author 罗伊
|
|
||||||
* @date 2021/1/27 11:22
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class SmartResponseEncryptAspectConfig {
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ResponseEncryptDecryptAspect responseEncryptAspect() {
|
|
||||||
return new ResponseEncryptDecryptAspect(this::employeeFunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求用户信息
|
|
||||||
* @param request
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private ResponseEncryptDecryptUserDTO employeeFunction(HttpServletRequest request){
|
|
||||||
EmployeeLoginInfoDTO employeeLoginInfoDTO = SmartEmployeeTokenUtil.getRequestEmployee();
|
|
||||||
if(employeeLoginInfoDTO == null){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ResponseEncryptDecryptUserDTO responseEncryptDecryptUserDTO = new ResponseEncryptDecryptUserDTO();
|
|
||||||
responseEncryptDecryptUserDTO.setUserId(employeeLoginInfoDTO.getEmployeeId());
|
|
||||||
responseEncryptDecryptUserDTO.setUserName(employeeLoginInfoDTO.getActualName());
|
|
||||||
responseEncryptDecryptUserDTO.setExtData(JSON.toJSONString(employeeLoginInfoDTO));
|
|
||||||
return responseEncryptDecryptUserDTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
|
||||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
|
||||||
import net.lab1024.smartadmin.service.util.date.SmartDateFormatterEnum;
|
|
||||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* java8 localDate 时间类格式化配置
|
|
||||||
*
|
|
||||||
* @author listen
|
|
||||||
* @date 2021年8月31日 21:19
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class SmartSerializerLocalDateTimeConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Jackson2ObjectMapperBuilderCustomizer customizer() {
|
|
||||||
return builder -> {
|
|
||||||
builder.deserializers(new LocalDateDeserializer(SmartDateFormatterEnum.YMD.getFormatter()));
|
|
||||||
builder.deserializers(new LocalDateTimeDeserializer(SmartDateFormatterEnum.YMD_HMS.getFormatter()));
|
|
||||||
builder.serializers(new LocalDateSerializer(SmartDateFormatterEnum.YMD.getFormatter()));
|
|
||||||
builder.serializers(new LocalDateTimeSerializer(SmartDateFormatterEnum.YMD_HMS.getFormatter()));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
|
||||||
|
|
||||||
import com.amazonaws.ClientConfiguration;
|
|
||||||
import com.amazonaws.Protocol;
|
|
||||||
import com.amazonaws.auth.AWSStaticCredentialsProvider;
|
|
||||||
import com.amazonaws.auth.BasicAWSCredentials;
|
|
||||||
import com.amazonaws.client.builder.AwsClientBuilder;
|
|
||||||
import com.amazonaws.services.s3.AmazonS3;
|
|
||||||
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Administrator
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Configuration
|
|
||||||
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = "cloud")
|
|
||||||
public class SmartStorageCloudConfig {
|
|
||||||
|
|
||||||
@Value("${file.storage.cloud.region}")
|
|
||||||
private String region;
|
|
||||||
|
|
||||||
@Value("${file.storage.cloud.endpoint}")
|
|
||||||
private String endpoint;
|
|
||||||
|
|
||||||
@Value("${file.storage.cloud.bucket-name}")
|
|
||||||
private String bucketName;
|
|
||||||
|
|
||||||
@Value("${file.storage.cloud.access-key}")
|
|
||||||
private String accessKey;
|
|
||||||
|
|
||||||
@Value("${file.storage.cloud.secret-key}")
|
|
||||||
private String secretKey;
|
|
||||||
|
|
||||||
@Value("${file.storage.cloud.url.expire}")
|
|
||||||
private Long urlExpire;
|
|
||||||
|
|
||||||
@Value("${file.storage.cloud.url.public}")
|
|
||||||
private String publicUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化 云oss client 配置
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public AmazonS3 initAmazonS3() {
|
|
||||||
ClientConfiguration clientConfig = new ClientConfiguration();
|
|
||||||
clientConfig.setProtocol(Protocol.HTTPS);
|
|
||||||
AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
|
|
||||||
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey)))
|
|
||||||
.withClientConfiguration(clientConfig)
|
|
||||||
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, region))
|
|
||||||
.withPathStyleAccessEnabled(false)
|
|
||||||
.build();
|
|
||||||
return s3Client;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description
|
|
||||||
* @Author 善逸
|
|
||||||
* @Date Created in 2017/10/24 13:48
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class SmartWebAppConfig implements WebMvcConfigurer {
|
|
||||||
|
|
||||||
@Value("${file.storage.local.path}")
|
|
||||||
private String localPath;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addViewControllers(ViewControllerRegistry registry) {
|
|
||||||
registry.addViewController("/druidMonitor").setViewName("redirect:druid/index.html");
|
|
||||||
registry.addViewController("/swaggerApi").setViewName("redirect:swagger-ui.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
||||||
registry.addResourceHandler("/**")
|
|
||||||
.addResourceLocations("classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "file:" + localPath);
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,6 +8,9 @@ import com.google.common.collect.Maps;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.smartadmin.service.common.constant.CommonConst;
|
import net.lab1024.smartadmin.service.common.constant.CommonConst;
|
||||||
|
import net.lab1024.smartadmin.service.common.constant.SwaggerTagConst;
|
||||||
|
import net.lab1024.smartadmin.service.common.constant.SystemEnvironmentEnum;
|
||||||
|
import net.lab1024.smartadmin.service.common.swagger.SwaggerApiModelPropertyEnumPlugin;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
@ -16,9 +19,10 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
|||||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
|
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
|
||||||
import org.springframework.context.EnvironmentAware;
|
import org.springframework.context.EnvironmentAware;
|
||||||
import org.springframework.context.annotation.Conditional;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import springfox.documentation.RequestHandler;
|
import springfox.documentation.RequestHandler;
|
||||||
@ -28,8 +32,10 @@ import springfox.documentation.builders.PathSelectors;
|
|||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
import springfox.documentation.schema.ModelRef;
|
import springfox.documentation.schema.ModelRef;
|
||||||
import springfox.documentation.service.ApiInfo;
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.service.Parameter;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger.common.SwaggerPluginSupport;
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -39,16 +45,24 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [ 根据SwaggerTagConst内部类动态生成Swagger ]
|
* [ 根据SwaggerTagConst内部类动态生成Swagger group ]
|
||||||
*
|
*
|
||||||
* @author 罗伊
|
* @author zhuoda
|
||||||
* @date 2020/8/25 11:57
|
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@EnableSwagger2
|
@EnableSwagger2
|
||||||
@Configuration
|
@Configuration
|
||||||
@Conditional(SmartSystemEnvNotProdCondition.class)
|
@Profile({
|
||||||
public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDefinitionRegistryPostProcessor {
|
SystemEnvironmentEnum.SystemEnvironmentNameConst.DEV,
|
||||||
|
SystemEnvironmentEnum.SystemEnvironmentNameConst.SIT,
|
||||||
|
SystemEnvironmentEnum.SystemEnvironmentNameConst.PRE
|
||||||
|
})
|
||||||
|
public class SwaggerConfig implements EnvironmentAware, BeanDefinitionRegistryPostProcessor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分组名称
|
||||||
|
*/
|
||||||
|
private String apiGroupName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文档标题
|
* 文档标题
|
||||||
@ -80,28 +94,30 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
|||||||
*/
|
*/
|
||||||
private String host;
|
private String host;
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口Tag类
|
|
||||||
*/
|
|
||||||
private String swaggerTagClass;
|
|
||||||
|
|
||||||
private int groupIndex = 0;
|
private int groupIndex = 0;
|
||||||
|
|
||||||
private String groupName = "default";
|
private String groupName = "default";
|
||||||
|
|
||||||
private final List<String> groupList = Lists.newArrayList();
|
private List<String> groupList = Lists.newArrayList();
|
||||||
|
|
||||||
private final Map<String, List<String>> groupMap = Maps.newHashMap();
|
private Map<String, List<String>> groupMap = Maps.newHashMap();
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Order(SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER + 1)
|
||||||
|
public SwaggerApiModelPropertyEnumPlugin swaggerEnum() {
|
||||||
|
return new SwaggerApiModelPropertyEnumPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEnvironment(Environment environment) {
|
public void setEnvironment(Environment environment) {
|
||||||
this.title = environment.getProperty("swagger.title" );
|
this.apiGroupName = environment.getProperty("swagger.apiGroupName");
|
||||||
this.description = environment.getProperty("swagger.description" );
|
this.title = environment.getProperty("swagger.title");
|
||||||
this.version = environment.getProperty("swagger.version" );
|
this.description = environment.getProperty("swagger.description");
|
||||||
this.serviceUrl = environment.getProperty("swagger.serviceUrl" );
|
this.version = environment.getProperty("swagger.version");
|
||||||
this.packAge = environment.getProperty("swagger.packAge" );
|
this.serviceUrl = environment.getProperty("swagger.serviceUrl");
|
||||||
this.host = environment.getProperty("swagger.host" );
|
this.packAge = environment.getProperty("swagger.packAge");
|
||||||
this.swaggerTagClass = environment.getProperty("swagger.tagClass" );
|
this.host = environment.getProperty("swagger.host");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -116,15 +132,8 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void groupBuild() {
|
private void groupBuild() {
|
||||||
Class clazz = null;
|
Class clazz = SwaggerTagConst.class;
|
||||||
try {
|
Class[] innerClazz = clazz.getDeclaredClasses();
|
||||||
clazz = Class.forName(swaggerTagClass);
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
log.error("swaggerTagClass unfounded :{}", swaggerTagClass);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Class[] innerClazz = clazz.getClasses();
|
|
||||||
for (Class cls : innerClazz) {
|
for (Class cls : innerClazz) {
|
||||||
String group = cls.getSimpleName();
|
String group = cls.getSimpleName();
|
||||||
List<String> apiTags = Lists.newArrayList();
|
List<String> apiTags = Lists.newArrayList();
|
||||||
@ -145,33 +154,31 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Docket baseDocket() {
|
private Docket baseDocket() {
|
||||||
// 配置全局参数 token header
|
|
||||||
ParameterBuilder tokenPar = new ParameterBuilder();
|
|
||||||
tokenPar.name(CommonConst.Token.OUTER_TOKEN_NAME)
|
|
||||||
.description("token" )
|
|
||||||
.modelRef(new ModelRef("string" ))
|
|
||||||
.parameterType("header" ).defaultValue("1" )
|
|
||||||
.required(false)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// 此行必须放在配置前面执行 因为要初始化groupName
|
// 配置全局参数
|
||||||
Predicate<RequestHandler> controllerPredicate = this.getControllerPredicate();
|
List<Parameter> parameterList = this.generateParameter();
|
||||||
// swagger配置
|
|
||||||
|
// 请求类型过滤规则
|
||||||
|
Predicate<RequestHandler> controllerPredicate = getControllerPredicate();
|
||||||
|
// controller 包路径
|
||||||
|
Predicate<RequestHandler> controllerPackage = RequestHandlerSelectors.basePackage(packAge);
|
||||||
|
|
||||||
Docket docket = new Docket(DocumentationType.SWAGGER_2)
|
Docket docket = new Docket(DocumentationType.SWAGGER_2)
|
||||||
.groupName(groupName)
|
.groupName(groupName)
|
||||||
.forCodeGeneration(true)
|
.forCodeGeneration(true)
|
||||||
.select()
|
.select()
|
||||||
.apis(RequestHandlerSelectors.basePackage(packAge))
|
.apis(controllerPackage)
|
||||||
.apis(controllerPredicate)
|
.apis(controllerPredicate)
|
||||||
.paths(PathSelectors.any())
|
.paths(PathSelectors.any())
|
||||||
.build().apiInfo(this.serviceApiInfo())
|
.build().apiInfo(this.serviceApiInfo())
|
||||||
.globalOperationParameters(Lists.newArrayList(tokenPar.build()));
|
.globalOperationParameters(parameterList);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(host)) {
|
if (StringUtils.isNotBlank(host)) {
|
||||||
docket = docket.host(host);
|
docket = docket.host(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
return docket;
|
return docket;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Predicate<RequestHandler> getControllerPredicate() {
|
private Predicate<RequestHandler> getControllerPredicate() {
|
||||||
@ -184,18 +191,71 @@ public class SmartSwaggerDynamicGroupConfig implements EnvironmentAware, BeanDef
|
|||||||
api = apiOptional.get();
|
api = apiOptional.get();
|
||||||
}
|
}
|
||||||
List<String> tags = Arrays.asList(api.tags());
|
List<String> tags = Arrays.asList(api.tags());
|
||||||
return apiTags.containsAll(tags);
|
if (apiTags.containsAll(tags)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
groupIndex++;
|
groupIndex++;
|
||||||
return Predicates.and(RequestHandlerSelectors.withClassAnnotation(RestController.class), methodPredicate);
|
return Predicates.and(RequestHandlerSelectors.withClassAnnotation(RestController.class), methodPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApiInfo serviceApiInfo() {
|
private ApiInfo serviceApiInfo() {
|
||||||
return new ApiInfoBuilder().title(title).description(description).version(version).termsOfServiceUrl(serviceUrl).build();
|
return new ApiInfoBuilder()
|
||||||
|
.title(title)
|
||||||
|
.description(description)
|
||||||
|
.version(version)
|
||||||
|
.termsOfServiceUrl(serviceUrl)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
|
public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成共用请求参数
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private List<Parameter> generateParameter() {
|
||||||
|
// 配置全局参数 token
|
||||||
|
Parameter token = new ParameterBuilder().name(CommonConst.RequestHeader.TOKEN)
|
||||||
|
.description("token")
|
||||||
|
.modelRef(new ModelRef("string"))
|
||||||
|
.parameterType("header").defaultValue("1")
|
||||||
|
.required(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Parameter agent = new ParameterBuilder().name(CommonConst.RequestHeader.USER_AGENT)
|
||||||
|
.description("agent")
|
||||||
|
.modelRef(new ModelRef("string"))
|
||||||
|
.parameterType("header").defaultValue("")
|
||||||
|
.required(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Parameter identity = new ParameterBuilder().name(CommonConst.RequestHeader.USER_IDENTITY)
|
||||||
|
.description("用户唯一标识")
|
||||||
|
.modelRef(new ModelRef("string"))
|
||||||
|
.parameterType("header").defaultValue("")
|
||||||
|
.required(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Parameter geo = new ParameterBuilder().name(CommonConst.RequestHeader.USER_GEO)
|
||||||
|
.description("定位")
|
||||||
|
.modelRef(new ModelRef("string"))
|
||||||
|
.parameterType("header").defaultValue("")
|
||||||
|
.required(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Parameter location = new ParameterBuilder().name(CommonConst.RequestHeader.USER_LOCATION)
|
||||||
|
.description("位置")
|
||||||
|
.modelRef(new ModelRef("string"))
|
||||||
|
.parameterType("header").defaultValue("")
|
||||||
|
.required(false)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return Lists.newArrayList(token, agent, identity, geo, location);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package net.lab1024.smartadmin.service.config;
|
package net.lab1024.smartadmin.service.config;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.service.common.constant.SystemEnvironmentEnum;
|
import net.lab1024.smartadmin.service.common.constant.SystemEnvironmentEnum;
|
||||||
|
import net.lab1024.smartadmin.service.common.domain.SystemEnvironmentBO;
|
||||||
import net.lab1024.smartadmin.service.util.SmartBaseEnumUtil;
|
import net.lab1024.smartadmin.service.util.SmartBaseEnumUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -11,13 +12,13 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前系统环境
|
* 系统环境
|
||||||
*
|
*
|
||||||
* @author listen
|
* @author zhuoda
|
||||||
* @date 2019/08/27 08:56
|
* @date 2021/08/13 18:56
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SmartSystemEnvNotProdCondition implements Condition {
|
public class SystemEnvironmentConfig implements Condition {
|
||||||
|
|
||||||
@Value("${spring.profiles.active}")
|
@Value("${spring.profiles.active}")
|
||||||
private String systemEnvironment;
|
private String systemEnvironment;
|
||||||
@ -29,7 +30,12 @@ public class SmartSystemEnvNotProdCondition implements Condition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SystemEnvironmentEnum initEnvironment() {
|
public SystemEnvironmentBO initEnvironment() {
|
||||||
return SmartBaseEnumUtil.getEnumByValue(systemEnvironment, SystemEnvironmentEnum.class);
|
SystemEnvironmentEnum currentEnvironment = SmartBaseEnumUtil.getEnumByValue(systemEnvironment, SystemEnvironmentEnum.class);
|
||||||
|
if (currentEnvironment == null) {
|
||||||
|
throw new ExceptionInInitializerError("无法获取当前环境!请在 application.properties 或者 application.yaml 配置好参数:spring.profiles.active");
|
||||||
|
}
|
||||||
|
return new SystemEnvironmentBO(currentEnvironment == SystemEnvironmentEnum.PROD, currentEnvironment);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package net.lab1024.smartadmin.service.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [ ]
|
||||||
|
*
|
||||||
|
* @author 罗伊
|
||||||
|
* @date 2021/1/9 11:45
|
||||||
|
*/
|
||||||
|
public class SwaggerTagConst {
|
||||||
|
|
||||||
|
public static class Support {
|
||||||
|
|
||||||
|
public static final String FILE = "基础-文件服务";
|
||||||
|
|
||||||
|
public static final String CACHE = "基础-缓存";
|
||||||
|
|
||||||
|
public static final String SYSTEM_CONFIG = "基础-系统参数";
|
||||||
|
|
||||||
|
public static final String ID_GENERATOR = "基础-ID生成器";
|
||||||
|
|
||||||
|
public static final String SMART_RELOAD = "基础-Reload";
|
||||||
|
|
||||||
|
public static final String TASK_SCHEDULER = "基础-任务调度";
|
||||||
|
|
||||||
|
public static final String USER_OPERATE_LOG = "基础-用户操作日志";
|
||||||
|
|
||||||
|
public static final String HEART_BEAT = "基础-心跳日志";
|
||||||
|
|
||||||
|
public static final String CAPTCHA = "基础-图形验证码";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Admin {
|
||||||
|
|
||||||
|
public static final String MANAGER_EMPLOYEE = "管理端-员工";
|
||||||
|
|
||||||
|
public static final String MANAGER_EMPLOYEE_LOGIN = "管理端-员工登录";
|
||||||
|
|
||||||
|
public static final String MANAGER_DEPARTMENT = "管理端-部门";
|
||||||
|
|
||||||
|
public static final String MANAGER_ROLE = "管理端-角色";
|
||||||
|
|
||||||
|
public static final String MANAGER_NOTICE = "管理端-系统通知";
|
||||||
|
|
||||||
|
public static final String MANAGER_MENU = "管理端-菜单";
|
||||||
|
|
||||||
|
public static final String MANAGER_ROLE_MENU = "管理端-角色-菜单";
|
||||||
|
|
||||||
|
public static final String MANAGER_DATA_TRACER = "管理端-数据变动跟踪";
|
||||||
|
|
||||||
|
public static final String MANAGER_CATEGORY = "管理端-分类";
|
||||||
|
|
||||||
|
public static final String MANAGER_GOODS = "管理端-商品业务";
|
||||||
|
}
|
||||||
|
}
|
@ -3,10 +3,10 @@ package net.lab1024.smartadmin.service.module.business.category.domain;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||||
import net.lab1024.smartadmin.service.common.validator.CheckEnum;
|
|
||||||
import net.lab1024.smartadmin.service.module.business.category.constant.CategoryTypeEnum;
|
import net.lab1024.smartadmin.service.module.business.category.constant.CategoryTypeEnum;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
|
import javax.validation.constraints.DecimalMax;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@ -25,7 +25,6 @@ public class CategoryBaseDTO {
|
|||||||
private String categoryName;
|
private String categoryName;
|
||||||
|
|
||||||
@ApiModelPropertyEnum(desc = "分类类型", value = CategoryTypeEnum.class)
|
@ApiModelPropertyEnum(desc = "分类类型", value = CategoryTypeEnum.class)
|
||||||
@CheckEnum(enumClazz = CategoryTypeEnum.class, required = true, message = "分类类型错误")
|
|
||||||
private Integer categoryType;
|
private Integer categoryType;
|
||||||
|
|
||||||
@ApiModelProperty("父级类目id|可选")
|
@ApiModelProperty("父级类目id|可选")
|
||||||
|
@ -3,7 +3,6 @@ package net.lab1024.smartadmin.service.module.business.category.domain;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||||
import net.lab1024.smartadmin.service.common.validator.CheckEnum;
|
|
||||||
import net.lab1024.smartadmin.service.module.business.category.constant.CategoryTypeEnum;
|
import net.lab1024.smartadmin.service.module.business.category.constant.CategoryTypeEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,7 +15,6 @@ import net.lab1024.smartadmin.service.module.business.category.constant.Category
|
|||||||
public class CategoryTreeQueryDTO {
|
public class CategoryTreeQueryDTO {
|
||||||
|
|
||||||
@ApiModelPropertyEnum(desc = "分类类型|可选", value = CategoryTypeEnum.class)
|
@ApiModelPropertyEnum(desc = "分类类型|可选", value = CategoryTypeEnum.class)
|
||||||
@CheckEnum(enumClazz = CategoryTypeEnum.class, message = "分类类型错误")
|
|
||||||
private Integer categoryType;
|
private Integer categoryType;
|
||||||
|
|
||||||
@ApiModelProperty("父级类目id|可选")
|
@ApiModelProperty("父级类目id|可选")
|
||||||
|
@ -3,9 +3,8 @@ package net.lab1024.smartadmin.service.module.business.goods.domain;
|
|||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.smartadmin.service.common.json.FileKeySerializer;
|
import net.lab1024.smartadmin.service.common.serializer.FileKeySerializer;
|
||||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||||
import net.lab1024.smartadmin.service.common.validator.CheckEnum;
|
|
||||||
import net.lab1024.smartadmin.service.module.business.goods.constant.GoodsTypeEnum;
|
import net.lab1024.smartadmin.service.module.business.goods.constant.GoodsTypeEnum;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
@ -24,7 +23,6 @@ import java.math.BigDecimal;
|
|||||||
public class GoodsBaseDTO {
|
public class GoodsBaseDTO {
|
||||||
|
|
||||||
@ApiModelPropertyEnum(desc = "商品类型", value = GoodsTypeEnum.class)
|
@ApiModelPropertyEnum(desc = "商品类型", value = GoodsTypeEnum.class)
|
||||||
@CheckEnum(enumClazz = GoodsTypeEnum.class, message = "商品类型错误")
|
|
||||||
private Integer goodsType;
|
private Integer goodsType;
|
||||||
|
|
||||||
@ApiModelProperty("商品分类")
|
@ApiModelProperty("商品分类")
|
||||||
|
@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.smartadmin.service.common.domain.PageBaseDTO;
|
import net.lab1024.smartadmin.service.common.domain.PageBaseDTO;
|
||||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||||
import net.lab1024.smartadmin.service.common.validator.CheckEnum;
|
|
||||||
import net.lab1024.smartadmin.service.module.business.goods.constant.GoodsTypeEnum;
|
import net.lab1024.smartadmin.service.module.business.goods.constant.GoodsTypeEnum;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
@ -18,7 +17,6 @@ import org.hibernate.validator.constraints.Length;
|
|||||||
public class GoodsQueryDTO extends PageBaseDTO {
|
public class GoodsQueryDTO extends PageBaseDTO {
|
||||||
|
|
||||||
@ApiModelPropertyEnum(desc = "商品类型|可选", value = GoodsTypeEnum.class)
|
@ApiModelPropertyEnum(desc = "商品类型|可选", value = GoodsTypeEnum.class)
|
||||||
@CheckEnum(enumClazz = GoodsTypeEnum.class, message = "商品类型错误")
|
|
||||||
private Integer goodsType;
|
private Integer goodsType;
|
||||||
|
|
||||||
@ApiModelProperty("商品分类")
|
@ApiModelProperty("商品分类")
|
||||||
|
@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.smartadmin.service.common.domain.PageBaseDTO;
|
import net.lab1024.smartadmin.service.common.domain.PageBaseDTO;
|
||||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||||
import net.lab1024.smartadmin.service.common.validator.CheckEnum;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.datatracer.constant.DataTracerBusinessTypeEnum;
|
import net.lab1024.smartadmin.service.module.support.datatracer.constant.DataTracerBusinessTypeEnum;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
@ -19,7 +18,6 @@ import javax.validation.constraints.NotNull;
|
|||||||
public class DataTracerQueryForm extends PageBaseDTO {
|
public class DataTracerQueryForm extends PageBaseDTO {
|
||||||
|
|
||||||
@ApiModelPropertyEnum(DataTracerBusinessTypeEnum.class)
|
@ApiModelPropertyEnum(DataTracerBusinessTypeEnum.class)
|
||||||
@CheckEnum(enumClazz = DataTracerBusinessTypeEnum.class, required = true, message = "业务类型错误")
|
|
||||||
private Integer businessType;
|
private Integer businessType;
|
||||||
|
|
||||||
@ApiModelProperty("业务id")
|
@ApiModelProperty("业务id")
|
||||||
|
@ -2,7 +2,6 @@ package net.lab1024.smartadmin.service.module.support.file.domain.dto;
|
|||||||
|
|
||||||
import net.lab1024.smartadmin.service.common.domain.PageBaseDTO;
|
import net.lab1024.smartadmin.service.common.domain.PageBaseDTO;
|
||||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||||
import net.lab1024.smartadmin.service.common.validator.CheckEnum;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.file.domain.FileFolderTypeEnum;
|
import net.lab1024.smartadmin.service.module.support.file.domain.FileFolderTypeEnum;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -21,7 +20,6 @@ public class FileQueryDTO extends PageBaseDTO {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "业务类型")
|
@ApiModelProperty(value = "业务类型")
|
||||||
@ApiModelPropertyEnum(FileFolderTypeEnum.class)
|
@ApiModelPropertyEnum(FileFolderTypeEnum.class)
|
||||||
@CheckEnum(enumClazz = FileFolderTypeEnum.class, message = "文件业务类型错误")
|
|
||||||
private Integer folderType;
|
private Integer folderType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.lab1024.smartadmin.service.module.support.file.domain.dto;
|
package net.lab1024.smartadmin.service.module.support.file.domain.dto;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||||
import net.lab1024.smartadmin.service.common.validator.CheckEnum;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.file.domain.FileFolderTypeEnum;
|
import net.lab1024.smartadmin.service.module.support.file.domain.FileFolderTypeEnum;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@ -23,7 +22,6 @@ import javax.validation.constraints.NotNull;
|
|||||||
public class FileUrlUploadDTO {
|
public class FileUrlUploadDTO {
|
||||||
|
|
||||||
@ApiModelPropertyEnum(FileFolderTypeEnum.class)
|
@ApiModelPropertyEnum(FileFolderTypeEnum.class)
|
||||||
@CheckEnum(enumClazz = FileFolderTypeEnum.class, required = true, message = "文件夹类型错误")
|
|
||||||
private Integer folder;
|
private Integer folder;
|
||||||
|
|
||||||
@ApiModelProperty("文件url")
|
@ApiModelProperty("文件url")
|
||||||
|
@ -9,7 +9,6 @@ import net.lab1024.smartadmin.service.common.codeconst.FileResponseCodeConst;
|
|||||||
import net.lab1024.smartadmin.service.common.codeconst.ResponseCodeConst;
|
import net.lab1024.smartadmin.service.common.codeconst.ResponseCodeConst;
|
||||||
import net.lab1024.smartadmin.service.common.constant.CommonConst;
|
import net.lab1024.smartadmin.service.common.constant.CommonConst;
|
||||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||||
import net.lab1024.smartadmin.service.config.SmartStorageCloudConfig;
|
|
||||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileDownloadDTO;
|
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileDownloadDTO;
|
||||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileMetadataDTO;
|
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileMetadataDTO;
|
||||||
import net.lab1024.smartadmin.service.module.support.file.domain.vo.FileUploadVO;
|
import net.lab1024.smartadmin.service.module.support.file.domain.vo.FileUploadVO;
|
||||||
|
@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.smartadmin.service.common.constant.GenderEnum;
|
import net.lab1024.smartadmin.service.common.constant.GenderEnum;
|
||||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||||
import net.lab1024.smartadmin.service.common.validator.CheckEnum;
|
|
||||||
import net.lab1024.smartadmin.service.util.SmartVerificationUtil;
|
import net.lab1024.smartadmin.service.util.SmartVerificationUtil;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
@ -32,7 +31,6 @@ public class EmployeeAddDTO {
|
|||||||
private String loginName;
|
private String loginName;
|
||||||
|
|
||||||
@ApiModelPropertyEnum(GenderEnum.class)
|
@ApiModelPropertyEnum(GenderEnum.class)
|
||||||
@CheckEnum(enumClazz = GenderEnum.class, message = "性别错误")
|
|
||||||
private Integer gender;
|
private Integer gender;
|
||||||
|
|
||||||
@ApiModelProperty("部门id")
|
@ApiModelProperty("部门id")
|
||||||
|
@ -3,7 +3,6 @@ package net.lab1024.smartadmin.service.module.system.menu.domain;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
import net.lab1024.smartadmin.service.common.swagger.ApiModelPropertyEnum;
|
||||||
import net.lab1024.smartadmin.service.common.validator.CheckEnum;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.menu.constant.MenuTypeEnum;
|
import net.lab1024.smartadmin.service.module.system.menu.constant.MenuTypeEnum;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
@ -26,7 +25,6 @@ public class MenuBasicDTO {
|
|||||||
private String menuName;
|
private String menuName;
|
||||||
|
|
||||||
@ApiModelPropertyEnum(value = MenuTypeEnum.class, desc = "类型")
|
@ApiModelPropertyEnum(value = MenuTypeEnum.class, desc = "类型")
|
||||||
@CheckEnum(enumClazz = MenuTypeEnum.class, message = "类型错误")
|
|
||||||
private Integer menuType;
|
private Integer menuType;
|
||||||
|
|
||||||
@ApiModelProperty("父菜单ID 无上级可传0")
|
@ApiModelProperty("父菜单ID 无上级可传0")
|
||||||
|
@ -47,7 +47,6 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 设置tagNav
|
// 设置tagNav
|
||||||
useUserStore().setTagNav(to, from);
|
useUserStore().setTagNav(to, from);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user