refactor: 移除无用代码,更改包名,fix IPv6获取地址位置失败 导致登录异常的问题
This commit is contained in:
@@ -7,9 +7,9 @@ import com.agileboot.common.core.page.PageDTO;
|
||||
import com.agileboot.common.exception.error.ErrorCode;
|
||||
import com.agileboot.common.utils.poi.CustomExcelUtil;
|
||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||
import com.agileboot.domain.system.loginInfo.dto.LoginInfoDTO;
|
||||
import com.agileboot.domain.system.loginInfo.LoginInfoApplicationService;
|
||||
import com.agileboot.domain.system.loginInfo.query.LoginInfoQuery;
|
||||
import com.agileboot.domain.system.logininfo.dto.LoginInfoDTO;
|
||||
import com.agileboot.domain.system.logininfo.LoginInfoApplicationService;
|
||||
import com.agileboot.domain.system.logininfo.query.LoginInfoQuery;
|
||||
import com.agileboot.infrastructure.annotations.AccessLog;
|
||||
import com.agileboot.orm.enums.BusinessType;
|
||||
import java.util.List;
|
||||
|
||||
@@ -6,9 +6,9 @@ import com.agileboot.common.core.page.PageDTO;
|
||||
import com.agileboot.common.exception.error.ErrorCode;
|
||||
import com.agileboot.common.utils.poi.CustomExcelUtil;
|
||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||
import com.agileboot.domain.system.operationLog.dto.OperationLogDTO;
|
||||
import com.agileboot.domain.system.operationLog.OperationLogApplicationService;
|
||||
import com.agileboot.domain.system.operationLog.query.OperationLogQuery;
|
||||
import com.agileboot.domain.system.operationlog.dto.OperationLogDTO;
|
||||
import com.agileboot.domain.system.operationlog.OperationLogApplicationService;
|
||||
import com.agileboot.domain.system.operationlog.query.OperationLogQuery;
|
||||
import com.agileboot.infrastructure.annotations.AccessLog;
|
||||
import com.agileboot.orm.enums.BusinessType;
|
||||
import java.util.List;
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.agileboot.common.core.dto.ResponseDTO;
|
||||
import com.agileboot.common.core.page.PageDTO;
|
||||
import com.agileboot.common.utils.poi.CustomExcelUtil;
|
||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||
import com.agileboot.domain.system.loginInfo.query.SearchUserQuery;
|
||||
import com.agileboot.domain.system.logininfo.query.SearchUserQuery;
|
||||
import com.agileboot.domain.system.user.dto.UserDTO;
|
||||
import com.agileboot.domain.system.user.dto.UserDetailDTO;
|
||||
import com.agileboot.domain.system.user.UserApplicationService;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ServletHolderUtil {
|
||||
* 获取仅含有项目根路径的url
|
||||
* 比如 localhost:8080/agileboot/user/list
|
||||
* 返回 localhost:8080/agileboot
|
||||
* @return
|
||||
* @return localhost:8080/agileboot
|
||||
*/
|
||||
public static String getContextUrl() {
|
||||
HttpServletRequest request = getRequest();
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.io.InputStream;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.lionsoul.ip2region.xdb.Searcher;
|
||||
import sun.net.util.IPAddressUtil;
|
||||
|
||||
@Slf4j
|
||||
public class OfflineIpRegionUtil {
|
||||
@@ -34,13 +35,19 @@ public class OfflineIpRegionUtil {
|
||||
public static IpRegion getIpRegion(String ip) {
|
||||
try {
|
||||
|
||||
String rawRegion = searcher.search(ip);
|
||||
if (StrUtil.isNotEmpty(rawRegion)) {
|
||||
String[] split = rawRegion.split("\\|");
|
||||
return new IpRegion(split[0], split[1], split[2], split[3], split[4]);
|
||||
if (StrUtil.isBlank(ip) || IPAddressUtil.isIPv6LiteralAddress(ip)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
String rawRegion = searcher.search(ip);
|
||||
|
||||
if (StrUtil.isEmpty(rawRegion)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] split = rawRegion.split("\\|");
|
||||
return new IpRegion(split[0], split[1], split[2], split[3], split[4]);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import cn.hutool.http.HttpUtil;
|
||||
import com.agileboot.common.config.AgileBootConfig;
|
||||
import com.agileboot.common.utils.jackson.JacksonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sun.net.util.IPAddressUtil;
|
||||
|
||||
/**
|
||||
* query geography address from ip
|
||||
@@ -23,6 +24,10 @@ public class OnlineIpRegionUtil {
|
||||
|
||||
|
||||
public static IpRegion getIpRegion(String ip) {
|
||||
if(StrUtil.isBlank(ip) || IPAddressUtil.isIPv6LiteralAddress(ip)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// no need to query address for inner ip
|
||||
if (NetUtil.isInnerIP(ip)) {
|
||||
return new IpRegion("internal", "IP");
|
||||
@@ -31,6 +36,7 @@ public class OnlineIpRegionUtil {
|
||||
try {
|
||||
String rspStr = HttpUtil.get(ADDRESS_QUERY_SITE + "ip=" + ip + "&json=true",
|
||||
CharsetUtil.CHARSET_GBK);
|
||||
|
||||
if (StrUtil.isEmpty(rspStr)) {
|
||||
log.error("获取地理位置异常 {}", ip);
|
||||
return null;
|
||||
|
||||
@@ -317,7 +317,7 @@ public class JacksonUtil {
|
||||
* 序列化为JSON
|
||||
*/
|
||||
public static <V> void toFile(String path, List<V> list) {
|
||||
try (Writer writer = new FileWriter(new File(path), true)) {
|
||||
try (Writer writer = new FileWriter(path, true)) {
|
||||
mapper.writer().writeValues(writer).writeAll(list);
|
||||
} catch (Exception e) {
|
||||
throw new JacksonException(StrUtil.format("jackson to file error, path: {}, list: {}", path, list), e);
|
||||
@@ -328,7 +328,7 @@ public class JacksonUtil {
|
||||
* 序列化为JSON
|
||||
*/
|
||||
public static <V> void toFile(String path, V v) {
|
||||
try (Writer writer = new FileWriter(new File(path), true)) {
|
||||
try (Writer writer = new FileWriter(path, true)) {
|
||||
mapper.writer().writeValues(writer).write(v);
|
||||
} catch (Exception e) {
|
||||
throw new JacksonException(StrUtil.format("jackson to file error, path: {}, data: {}", path, v), e);
|
||||
|
||||
@@ -6,11 +6,29 @@ import org.junit.Test;
|
||||
public class OfflineIpRegionUtilTest {
|
||||
|
||||
@Test
|
||||
public void getIpRegion() {
|
||||
public void testGetIpRegionWhenIpv4() {
|
||||
IpRegion ipRegion = OfflineIpRegionUtil.getIpRegion("110.81.189.80");
|
||||
|
||||
Assert.assertEquals("中国", ipRegion.getCountry());
|
||||
Assert.assertEquals("福建省", ipRegion.getProvince());
|
||||
Assert.assertEquals("泉州市", ipRegion.getCity());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetIpRegionWithIpv6() {
|
||||
IpRegion ipRegion = OfflineIpRegionUtil.getIpRegion("2001:0DB8:0000:0023:0008:0800:200C:417A");
|
||||
Assert.assertNull(ipRegion);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetIpRegionWithEmpty() {
|
||||
IpRegion ipRegion = OfflineIpRegionUtil.getIpRegion("");
|
||||
Assert.assertNull(ipRegion);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetIpRegionWithNull() {
|
||||
IpRegion ipRegion = OfflineIpRegionUtil.getIpRegion(null);
|
||||
Assert.assertNull(ipRegion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.agileboot.common.utils.ip;
|
||||
|
||||
import com.agileboot.common.config.AgileBootConfig;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class OnlineIpRegionUtilTest {
|
||||
|
||||
@Before
|
||||
public void enableOnlineAddressQuery(){
|
||||
AgileBootConfig agileBootConfig = new AgileBootConfig();
|
||||
agileBootConfig.setAddressEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getIpRegionWithIpv6() {
|
||||
IpRegion ipRegion = OnlineIpRegionUtil.getIpRegion("ABCD:EF01:2345:6789:ABCD:EF01:2345:6789");
|
||||
Assert.assertNull(ipRegion);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIpRegionWithIpv4() {
|
||||
IpRegion ipRegion = OnlineIpRegionUtil.getIpRegion("110.81.189.80");
|
||||
|
||||
if (ipRegion != null) {
|
||||
Assert.assertEquals("中国", ipRegion.getCountry());
|
||||
Assert.assertEquals("福建省", ipRegion.getProvince());
|
||||
Assert.assertEquals("泉州市", ipRegion.getCity());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIpRegionWithEmpty() {
|
||||
IpRegion ipRegion = OnlineIpRegionUtil.getIpRegion("");
|
||||
|
||||
Assert.assertNull(ipRegion);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getIpRegionWithNull() {
|
||||
IpRegion ipRegion = OnlineIpRegionUtil.getIpRegion(null);
|
||||
|
||||
Assert.assertNull(ipRegion);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@SuppressWarnings("AlibabaTransactionMustHaveRollback")
|
||||
@Service
|
||||
public class DeptApplicationService {
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class AddDeptCommand {
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.agileboot.domain.system.loginInfo;
|
||||
package com.agileboot.domain.system.logininfo;
|
||||
|
||||
import com.agileboot.common.core.page.PageDTO;
|
||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||
import com.agileboot.domain.system.loginInfo.dto.LoginInfoDTO;
|
||||
import com.agileboot.domain.system.loginInfo.query.LoginInfoQuery;
|
||||
import com.agileboot.domain.system.logininfo.dto.LoginInfoDTO;
|
||||
import com.agileboot.domain.system.logininfo.query.LoginInfoQuery;
|
||||
import com.agileboot.orm.entity.SysLoginInfoEntity;
|
||||
import com.agileboot.orm.service.ISysLoginInfoService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.domain.system.loginInfo.dto;
|
||||
package com.agileboot.domain.system.logininfo.dto;
|
||||
|
||||
import com.agileboot.common.annotation.ExcelColumn;
|
||||
import com.agileboot.common.annotation.ExcelSheet;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.domain.system.loginInfo.query;
|
||||
package com.agileboot.domain.system.logininfo.query;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.orm.entity.SysLoginInfoEntity;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.domain.system.loginInfo.query;
|
||||
package com.agileboot.domain.system.logininfo.query;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.orm.query.AbstractPageQuery;
|
||||
@@ -151,10 +151,10 @@ public class MenuApplicationService {
|
||||
|
||||
|
||||
public List<RouterDTO> buildRouterTree(List<Tree<Long>> trees) {
|
||||
List<RouterDTO> routers = new LinkedList<RouterDTO>();
|
||||
List<RouterDTO> routers = new LinkedList<>();
|
||||
if (CollUtil.isNotEmpty(trees)) {
|
||||
for (Tree<Long> tree : trees) {
|
||||
RouterDTO routerDTO = null;
|
||||
RouterDTO routerDTO;
|
||||
|
||||
Object entity = tree.get("entity");
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class MetaDTO {
|
||||
/**
|
||||
* 设置为true,则不会被 <keep-alive>缓存
|
||||
*/
|
||||
private boolean noCache;
|
||||
private Boolean noCache;
|
||||
|
||||
/**
|
||||
* 内链地址(http(s)://开头)
|
||||
|
||||
@@ -26,7 +26,7 @@ public class RouterDTO {
|
||||
/**
|
||||
* 是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现
|
||||
*/
|
||||
private boolean hidden;
|
||||
private Boolean hidden;
|
||||
|
||||
/**
|
||||
* 重定向地址,当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
|
||||
|
||||
@@ -192,7 +192,9 @@ public class RouterModel extends SysMenuEntity {
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean isParentView() {
|
||||
return StrUtil.isEmpty(getComponent()) && getParentId().intValue() != 0 && MenuTypeEnum.DIRECTORY.getValue() == getMenuType();
|
||||
return StrUtil.isEmpty(getComponent())
|
||||
&& getParentId().intValue() != 0
|
||||
&& MenuTypeEnum.DIRECTORY.getValue().equals(getMenuType());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ public class MenuQuery extends AbstractQuery {
|
||||
|
||||
QueryWrapper<SysMenuEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like(StrUtil.isNotEmpty(menuName), columnName("menu_name"), menuName)
|
||||
.eq(isVisible!=null, "is_visible", isVisible)
|
||||
.eq(status!=null, "status", status);
|
||||
.eq(isVisible != null, "is_visible", isVisible)
|
||||
.eq(status != null, "status", status);
|
||||
|
||||
queryWrapper.orderBy(true, true, Arrays.asList("parent_id", "order_num"));
|
||||
return queryWrapper;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.agileboot.domain.system.operationLog;
|
||||
package com.agileboot.domain.system.operationlog;
|
||||
|
||||
import com.agileboot.common.core.page.PageDTO;
|
||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||
import com.agileboot.domain.system.operationLog.dto.OperationLogDTO;
|
||||
import com.agileboot.domain.system.operationLog.query.OperationLogQuery;
|
||||
import com.agileboot.domain.system.operationlog.dto.OperationLogDTO;
|
||||
import com.agileboot.domain.system.operationlog.query.OperationLogQuery;
|
||||
import com.agileboot.orm.entity.SysOperationLogEntity;
|
||||
import com.agileboot.orm.service.ISysOperationLogService;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.domain.system.operationLog.dto;
|
||||
package com.agileboot.domain.system.operationlog.dto;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.agileboot.common.annotation.ExcelColumn;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.domain.system.operationLog.query;
|
||||
package com.agileboot.domain.system.operationlog.query;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.agileboot.orm.entity.SysLoginInfoEntity;
|
||||
@@ -7,6 +7,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class OperationLogQuery extends AbstractPageQuery {
|
||||
@@ -8,6 +8,9 @@ import javax.validation.constraints.PositiveOrZero;
|
||||
import javax.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author valarchie
|
||||
*/
|
||||
@Data
|
||||
public class AddPostCommand {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.agileboot.common.core.page.PageDTO;
|
||||
import com.agileboot.common.exception.ApiException;
|
||||
import com.agileboot.common.exception.error.ErrorCode;
|
||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||
import com.agileboot.domain.system.loginInfo.query.SearchUserQuery;
|
||||
import com.agileboot.domain.system.logininfo.query.SearchUserQuery;
|
||||
import com.agileboot.domain.system.post.dto.PostDTO;
|
||||
import com.agileboot.domain.system.role.dto.RoleDTO;
|
||||
import com.agileboot.domain.system.user.command.AddUserCommand;
|
||||
|
||||
@@ -27,7 +27,6 @@ public class DataSourceAspect {
|
||||
@Pointcut("@annotation(com.agileboot.infrastructure.annotations.DataSource)"
|
||||
+ "|| @within(com.agileboot.infrastructure.annotations.DataSource)")
|
||||
public void dsPointCut() {
|
||||
|
||||
}
|
||||
|
||||
@Around("dsPointCut()")
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.agileboot.infrastructure.cache.redis;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.agileboot.infrastructure.cache.RedisUtil;
|
||||
import com.agileboot.infrastructure.interceptor.repeatSubmit.RepeatRequest;
|
||||
import com.agileboot.infrastructure.interceptor.repeatsubmit.RepeatRequest;
|
||||
import com.agileboot.infrastructure.web.domain.login.LoginUser;
|
||||
import com.agileboot.orm.entity.SysUserEntity;
|
||||
import com.agileboot.orm.service.ISysUserService;
|
||||
|
||||
@@ -19,23 +19,6 @@ public class FilterConfig {
|
||||
@Value("${xss.urlPatterns}")
|
||||
private String urlPatterns;
|
||||
|
||||
/* @SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "xss.enabled", havingValue = "true")
|
||||
public FilterRegistrationBean xssFilterRegistration() {
|
||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
||||
registration.setFilter(new XssFilter());
|
||||
StrUtil.split(urlPatterns, ",");
|
||||
registration.addUrlPatterns(ArrayUtil.toArray(StrUtil.split(urlPatterns, ","), String.class));
|
||||
registration.setName("xssFilter");
|
||||
registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
|
||||
Map<String, String> initParameters = new HashMap<>();
|
||||
initParameters.put("excludes", excludes);
|
||||
registration.setInitParameters(initParameters);
|
||||
return registration;
|
||||
}*/
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Bean
|
||||
public FilterRegistrationBean someFilterRegistration() {
|
||||
|
||||
@@ -33,7 +33,6 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(connectionFactory);
|
||||
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
objectMapper.registerModule(new JavaTimeModule());
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.agileboot.infrastructure.config;
|
||||
|
||||
import com.agileboot.common.config.AgileBootConfig;
|
||||
import com.agileboot.common.constant.Constants;
|
||||
import com.agileboot.infrastructure.interceptor.repeatSubmit.AbstractRepeatSubmitInterceptor;
|
||||
import com.agileboot.infrastructure.interceptor.repeatsubmit.AbstractRepeatSubmitInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -26,11 +26,11 @@ public class ResourcesConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
/** 本地文件上传路径 */
|
||||
/* 本地文件上传路径 */
|
||||
registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**")
|
||||
.addResourceLocations("file:" + AgileBootConfig.getProfile() + "/");
|
||||
|
||||
/** swagger配置 */
|
||||
/* swagger配置 */
|
||||
registry.addResourceHandler("/swagger-ui/**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class SwaggerConfig {
|
||||
* 安全模式,这里指定token通过Authorization头请求头传递
|
||||
*/
|
||||
private List<SecurityScheme> securitySchemes() {
|
||||
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
|
||||
List<SecurityScheme> apiKeyList = new ArrayList<>();
|
||||
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
|
||||
return apiKeyList;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,10 @@ public class CaptchaMathTextCreator extends DefaultTextCreator {
|
||||
return mathExpression.toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
|
||||
enum Operand {
|
||||
/**
|
||||
* 加减乘除操作 用来生成验证码的图片表达式
|
||||
*/
|
||||
ADD {
|
||||
@Override
|
||||
public int generateMathExpression(int x, int y, StringBuilder expression) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.sql.DataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
@@ -29,6 +30,7 @@ import org.springframework.context.annotation.Primary;
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class DruidConfig {
|
||||
|
||||
@Bean
|
||||
@@ -46,10 +48,10 @@ public class DruidConfig {
|
||||
return druidProperties.dataSource(dataSource);
|
||||
}
|
||||
|
||||
@Bean(name = "dynamicDataSource")
|
||||
// @Bean(name = "dynamicDataSource")
|
||||
@Primary
|
||||
public DynamicDataSource dataSource(DataSource masterDataSource) {
|
||||
Map<Object, Object> targetDataSources = new HashMap<>();
|
||||
Map<Object, Object> targetDataSources = new HashMap<>(8);
|
||||
targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource);
|
||||
setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource");
|
||||
return new DynamicDataSource(masterDataSource, targetDataSources);
|
||||
@@ -67,6 +69,7 @@ public class DruidConfig {
|
||||
DataSource dataSource = SpringUtil.getBean(beanName);
|
||||
targetDataSources.put(sourceName, dataSource);
|
||||
} catch (Exception e) {
|
||||
log.error("设置数据库失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.infrastructure.interceptor.repeatSubmit;
|
||||
package com.agileboot.infrastructure.interceptor.repeatsubmit;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.agileboot.common.core.dto.ResponseDTO;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.infrastructure.interceptor.repeatSubmit;
|
||||
package com.agileboot.infrastructure.interceptor.repeatsubmit;
|
||||
|
||||
import java.util.Objects;
|
||||
import lombok.Data;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.agileboot.infrastructure.interceptor.repeatSubmit;
|
||||
package com.agileboot.infrastructure.interceptor.repeatsubmit;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
@@ -85,59 +85,52 @@ public class CodeGenerator {
|
||||
*/
|
||||
private void globalConfig(FastAutoGenerator generator) {
|
||||
generator.globalConfig(
|
||||
builder -> {
|
||||
builder
|
||||
// override old code of file
|
||||
.fileOverride()
|
||||
.outputDir(System.getProperty("user.dir") + module + "/src/main/java")
|
||||
// use date type under package of java utils
|
||||
.dateType(DateType.ONLY_DATE)
|
||||
// 配置生成文件中的author
|
||||
.author(author)
|
||||
builder -> builder
|
||||
// override old code of file
|
||||
.fileOverride()
|
||||
.outputDir(System.getProperty("user.dir") + module + "/src/main/java")
|
||||
// use date type under package of java utils
|
||||
.dateType(DateType.ONLY_DATE)
|
||||
// 配置生成文件中的author
|
||||
.author(author)
|
||||
// .enableKotlin()
|
||||
// generate swagger annotations.
|
||||
.enableSwagger()
|
||||
// 注释日期的格式
|
||||
.commentDate("yyyy-MM-dd")
|
||||
.build();
|
||||
});
|
||||
// generate swagger annotations.
|
||||
.enableSwagger()
|
||||
// 注释日期的格式
|
||||
.commentDate("yyyy-MM-dd")
|
||||
.build());
|
||||
}
|
||||
|
||||
|
||||
private void packageConfig(FastAutoGenerator generator) {
|
||||
generator.packageConfig(builder -> {
|
||||
builder
|
||||
// parent package name
|
||||
.parent(parentPackage)
|
||||
.moduleName("orm")
|
||||
.entity("entity")
|
||||
.service("service")
|
||||
.serviceImpl("service.impl")
|
||||
.mapper("mapper")
|
||||
.xml("mapper.xml")
|
||||
.controller("controller")
|
||||
.other("other")
|
||||
// define dir related to OutputFileType(entity,mapper,service,controller,mapper.xml)
|
||||
.pathInfo(Collections.singletonMap(OutputFile.mapperXml, System.getProperty("user.dir") + module
|
||||
+ "/src/main/resources/mapper/system/test"))
|
||||
.build();
|
||||
|
||||
});
|
||||
generator.packageConfig(builder -> builder
|
||||
// parent package name
|
||||
.parent(parentPackage)
|
||||
.moduleName("orm")
|
||||
.entity("entity")
|
||||
.service("service")
|
||||
.serviceImpl("service.impl")
|
||||
.mapper("mapper")
|
||||
.xml("mapper.xml")
|
||||
.controller("controller")
|
||||
.other("other")
|
||||
// define dir related to OutputFileType(entity,mapper,service,controller,mapper.xml)
|
||||
.pathInfo(Collections.singletonMap(OutputFile.mapperXml, System.getProperty("user.dir") + module
|
||||
+ "/src/main/resources/mapper/system/test"))
|
||||
.build());
|
||||
}
|
||||
|
||||
private void templateConfig(FastAutoGenerator generator) {
|
||||
// customization code template. disable if you don't have specific requirement.
|
||||
generator.templateConfig(builder -> {
|
||||
builder
|
||||
.disable(TemplateType.ENTITY)
|
||||
.entity("/templates/entity.java")
|
||||
.service("/templates/service.java")
|
||||
.serviceImpl("/templates/serviceImpl.java")
|
||||
.mapper("/templates/mapper.java")
|
||||
.mapperXml("/templates/mapper.xml")
|
||||
.controller("/templates/controller.java")
|
||||
.build();
|
||||
});
|
||||
generator.templateConfig(builder -> builder
|
||||
.disable(TemplateType.ENTITY)
|
||||
.entity("/templates/entity.java")
|
||||
.service("/templates/service.java")
|
||||
.serviceImpl("/templates/serviceImpl.java")
|
||||
.mapper("/templates/mapper.java")
|
||||
.mapperXml("/templates/mapper.xml")
|
||||
.controller("/templates/controller.java")
|
||||
.build());
|
||||
}
|
||||
|
||||
private void injectionConfig(FastAutoGenerator generator) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ServerInfo {
|
||||
/**
|
||||
* 磁盘相关信息
|
||||
*/
|
||||
private List<DiskInfo> diskInfos = new LinkedList<DiskInfo>();
|
||||
private List<DiskInfo> diskInfos = new LinkedList<>();
|
||||
|
||||
public static ServerInfo fillInfo() {
|
||||
ServerInfo serverInfo = new ServerInfo();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.agileboot.infrastructure.web.service;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
@@ -114,9 +115,7 @@ public class TokenService {
|
||||
setUserAgent(loginUser);
|
||||
refreshToken(loginUser);
|
||||
|
||||
Map<String, Object> claims = new HashMap<>();
|
||||
claims.put(Token.LOGIN_USER_KEY, token);
|
||||
return createToken(claims);
|
||||
return createToken(MapUtil.of(Token.LOGIN_USER_KEY, token));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,12 +42,6 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
}
|
||||
String roleKey = getRoleKey(userEntity.getUserId());
|
||||
Set<String> menuPermissions = getMenuPermissions(userEntity.getUserId());
|
||||
// SysRoleEntity roleById = roleService.getById(userEntity.getRoleId());
|
||||
//
|
||||
// Role role = new Role();
|
||||
// if(roleById != null) {
|
||||
// role = new Role(roleById);
|
||||
// }
|
||||
|
||||
return new LoginUser(userEntity, roleKey, menuPermissions);
|
||||
}
|
||||
@@ -74,7 +68,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
* @return 菜单权限信息
|
||||
*/
|
||||
public Set<String> getMenuPermissions(Long userId) {
|
||||
Set<String> perms = new HashSet<String>();
|
||||
Set<String> perms = new HashSet<>();
|
||||
// 管理员拥有所有权限
|
||||
if (LoginUser.isAdmin(userId)) {
|
||||
perms.add("*:*:*");
|
||||
|
||||
@@ -40,10 +40,6 @@ public enum CommonAnswerEnum implements DictionaryEnum<Integer> {
|
||||
return cssTag;
|
||||
}
|
||||
|
||||
public static CommonAnswerEnum getDefault() {
|
||||
return YES;
|
||||
}
|
||||
|
||||
public static String getDictName() {
|
||||
return "sys_yes_no";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user