lzm
廖忠美 2024-07-13 11:49:13 +08:00
parent 5c9259a7bf
commit 083e21da00
136 changed files with 1808 additions and 432 deletions

1
.idea/.name 100644
View File

@ -0,0 +1 @@
pom.xml

View File

@ -2,17 +2,18 @@
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="etl-database-server" />
<module name="etl-jwt-manage" />
<module name="product_seckill_server" />
<module name="etl-database-common" />
<module name="etl-auth-server" />
<module name="etl-database-server" />
<module name="etl-common" />
<module name="etl-gateway" />
<module name="etl-jwt-manage" />
<module name="etl-database-common" />
<module name="product_seckill_common" />
</profile>
</annotationProcessing>
</component>

View File

@ -19,6 +19,12 @@
<file url="file://$PROJECT_DIR$/etl-gateway/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-jwt-manage/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/etl-jwt-manage/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/product_seckill/product_seckill_common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/product_seckill/product_seckill_common/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/product_seckill/product_seckill_server/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/product_seckill/product_seckill_server/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/product_seckill/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/product_seckill/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
<file url="PROJECT" charset="UTF-8" />

View File

@ -1,19 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/etl-auth/etl-auth-server/pom.xml" />
<option value="$PROJECT_DIR$/etl-auth/etl-auth-common/pom.xml" />
<option value="$PROJECT_DIR$/etl-auth/pom.xml" />
</list>
</option>
</component>
<component name="PDMPlugin">
<option name="skipTestSources" value="false" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/../../录屏" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/etl-auth/etl-auth-server/etl-auth-server.iml" filepath="$PROJECT_DIR$/etl-auth/etl-auth-server/etl-auth-server.iml" />
</modules>
</component>
</project>

File diff suppressed because one or more lines are too long

View File

@ -52,4 +52,19 @@
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,33 @@
package com.auth.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("t_data_source")
public class PathPermission {
@TableId(value = "id",type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "权限代号")
private String permissionCode;
@ApiModelProperty(value = "路由层次")
private String hierarchy;
@ApiModelProperty(value = "路由")
private String path;
@ApiModelProperty(value = "功能描述")
private String description;
@ApiModelProperty(value = "状态 0-废弃 1-正在使用")
private boolean status;
}

View File

@ -0,0 +1,24 @@
package com.auth.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@TableName("t_role_source")
@AllArgsConstructor
@NoArgsConstructor
public class RolesPermission {
@TableId(value = "id",type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "权限代号")
private String permissionCode;
@ApiModelProperty(value = "角色")
private String role;
}

View File

@ -0,0 +1,26 @@
package com.auth.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@TableName("t_user")
public class UserAccount {
@TableId(value = "id",type = IdType.AUTO)
private Integer id;
@ApiModelProperty("角色")
private String roles;
@ApiModelProperty("名称")
private String username;
@ApiModelProperty("密码/")
private String password;
// @ApiModelProperty("uuid")
// private String UUID;
}

View File

@ -0,0 +1,13 @@
package com.auth.server.enums;
public class PermissionConstants {
public static final String ROLES = "roles";
public static final String CODE_LIST = "codeList";
public static final String ROLE = "role";
public static final String PERMISSION_CODE = "permission_code";
public static final String USER_CACHE_KEY = "user:username:";
public static final String USER_KEY = "user:key:";
public static final String USER_NAME = "username";
public static final String USER_ID = "userId";
}

View File

@ -112,23 +112,13 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.auth.server.EtlAuthServerApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>

View File

@ -23,7 +23,7 @@ public class ShiroConfig {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
shiroFilterFactoryBean.setSecurityManager(defaultWebSecurityManager);
//拦截页面
Map<String, String> filterMap = new LinkedHashMap<>();
Map<String, String> filterMap = new LinkedHashMap();
//登录/登出,所有人的权限
filterMap.put("/user/login", "anon");
filterMap.put("/user/logout", "anon");

View File

@ -42,7 +42,7 @@ public class PermissionController {
RolesPermission permission = permissionService.getOne(new QueryWrapper<RolesPermission>().eq(PermissionConstants.ROLE,roles));
String codes = StringUtils.strip(permission.getPermissionCode(), "[]");
List<String> list = Arrays.asList(codes.split(","));
List<String> pathList = new ArrayList<>();
List<String> pathList = new ArrayList();
for(String code:list){
String api = pathService.getOne(new QueryWrapper<PathPermission>().eq(PermissionConstants.PERMISSION_CODE,code.trim())).getPath();
pathList.add(api);

View File

@ -42,7 +42,7 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, RolesPe
private int updateRolePermission(RolesPermission rolesPermission, RolesPermission role, List<String> codeList) {
//去掉头尾括号,并转为列表
List<String> list = new java.util.ArrayList<>(Collections.singletonList(
List<String> list = new java.util.ArrayList(Collections.singletonList(
StringUtils.strip(role.getPermissionCode(), "[]")));
//将新数据添加至列表
list.addAll(codeList);

View File

@ -74,13 +74,13 @@ public class UserManageServiceImpl extends ServiceImpl<UserMangeMapper, UserAcco
saveUserInfoToRedis(username, user);
} catch (UnknownAccountException e) {
log.info("登录用户不存在:{}", e);
return new Result<>(416, "用户不存在", username);
return new Result(416, "用户不存在", username);
} catch (IncorrectCredentialsException e) {
log.info("登录密码错误:{}", e);
return new Result<>(412, "密码错误,请重新登录", password);
return new Result(412, "密码错误,请重新登录", password);
} catch (AuthenticationException e) {
log.warn("用户登录异常:" + e.getMessage());
return new Result<>(416, "账户异常", username);
return new Result(416, "账户异常", username);
}
String userInfo = stringRedisTemplate.opsForValue().get(PermissionConstants.USER_NAME + username);
UserAccount account = null;
@ -115,13 +115,13 @@ public class UserManageServiceImpl extends ServiceImpl<UserMangeMapper, UserAcco
private Result checkUser(String username, String password) {
// 检查用户名和密码的合法性
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
return new Result<>(400, "用户名或密码不能为空");
return new Result(400, "用户名或密码不能为空");
}
if (username.length() < 3 || username.length() > 20) {
return new Result<>(400, "用户名长度必须在6-20个字符之间");
return new Result(400, "用户名长度必须在6-20个字符之间");
}
if (password.length() < 3 || password.length() > 20) {
return new Result<>(400, "密码长度必须在6-20个字符之间");
return new Result(400, "密码长度必须在6-20个字符之间");
}
return null;
}
@ -131,14 +131,14 @@ public class UserManageServiceImpl extends ServiceImpl<UserMangeMapper, UserAcco
token = com.auth.server.util.SecurityUtils.replaceTokenPrefix(token);
if (StringUtils.isEmpty(token)) {
return new CommonResult<>(ResponseCodeEnum.TOKEN_MISSION.getCode(),
return new CommonResult(ResponseCodeEnum.TOKEN_MISSION.getCode(),
ResponseCodeEnum.TOKEN_MISSION.getMessage());
}
// 对Token解签名并验证Token是否过期
boolean isJwtNotValid = jwtTokenUtil.isTokenExpired(token);
if (isJwtNotValid) {
return new CommonResult<>(ResponseCodeEnum.TOKEN_INVALID.getCode(),
return new CommonResult(ResponseCodeEnum.TOKEN_INVALID.getCode(),
ResponseCodeEnum.TOKEN_INVALID.getMessage());
}
@ -146,7 +146,7 @@ public class UserManageServiceImpl extends ServiceImpl<UserMangeMapper, UserAcco
String userId = jwtTokenUtil.getUserIdFromToken(token);
String username = jwtTokenUtil.getUserNameFromToken(token);
if (StringUtils.isEmpty(userId)) {
return new CommonResult<>(ResponseCodeEnum.TOKEN_INVALID.getCode(),
return new CommonResult(ResponseCodeEnum.TOKEN_INVALID.getCode(),
ResponseCodeEnum.TOKEN_INVALID.getMessage());
}
@ -155,14 +155,14 @@ public class UserManageServiceImpl extends ServiceImpl<UserMangeMapper, UserAcco
// 如果使用 redis 中已过期的 refreshToken 也不能刷新令牌。
boolean isRefreshTokenNotExisted = jwtTokenUtil.isRefreshTokenNotExistCache(token);
if (isRefreshTokenNotExisted) {
return new CommonResult<>(ResponseCodeEnum.REFRESH_TOKEN_INVALID.getCode(),
return new CommonResult(ResponseCodeEnum.REFRESH_TOKEN_INVALID.getCode(),
ResponseCodeEnum.REFRESH_TOKEN_INVALID.getMessage());
}
//String us = jwtTokenUtil.getUserIdFromToken(token);
Map<String, Object> tokenMap = jwtTokenUtil.refreshTokenAndGenerateToken(userId, username);
return new CommonResult<>(200, ResponseCodeEnum.SUCCESS.getMessage(), tokenMap);
return new CommonResult(200, ResponseCodeEnum.SUCCESS.getMessage(), tokenMap);
}
}

View File

@ -44,7 +44,7 @@ public class UserRealm extends AuthorizingRealm {
String username = token.getUsername();
//调用mybatis_plus中的方法查询数据库中用户名对应的数据
QueryWrapper<UserAccount> wrapper = new QueryWrapper<>();
QueryWrapper<UserAccount> wrapper = new QueryWrapper();
wrapper.eq("username",username);
UserAccount user=userManageService.getOne(wrapper);

View File

@ -1,5 +0,0 @@
#Generated by Maven
#Wed Jul 03 15:26:21 CST 2024
version=1.0-SNAPSHOT
groupId=com.bwie
artifactId=etl-auth-server

View File

@ -1,20 +0,0 @@
com\auth\server\config\MD5s.class
com\auth\server\service\PathService.class
com\auth\server\service\PermissionService.class
com\auth\server\mapper\UserMangeMapper.class
com\auth\server\mapper\PathMapper.class
com\auth\server\service\impl\PathServiceImpl.class
com\auth\server\EtlAuthServerApplication.class
com\auth\server\entity\RolesPermission.class
com\auth\server\service\impl\UserManageServiceImpl.class
com\auth\server\config\ShiroConfig.class
com\auth\server\enums\PermissionConstants.class
com\auth\server\service\UserManageService.class
com\auth\server\mapper\PermissionMapper.class
com\auth\server\entity\PathPermission.class
com\auth\server\util\UserRealm.class
com\auth\server\controller\LoginControler.class
com\auth\server\controller\PermissionController.class
com\auth\server\util\SecurityUtils.class
com\auth\server\service\impl\PermissionServiceImpl.class
com\auth\server\entity\UserAccount.class

View File

@ -1,21 +0,0 @@
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\entity\RolesPermission.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\service\UserManageService.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\enums\PermissionConstants.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\service\impl\UserManageServiceImpl.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\entity\UserAccount.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\EtlAuthServerApplication.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\controller\LoginControler.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\interceptor\UserInterceptor.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\service\impl\PathServiceImpl.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\controller\PermissionController.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\service\PermissionService.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\service\impl\PermissionServiceImpl.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\service\PathService.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\config\MD5s.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\mapper\PermissionMapper.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\util\UserRealm.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\util\SecurityUtils.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\entity\PathPermission.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\mapper\PathMapper.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\mapper\UserMangeMapper.java
D:\workspace\ETL\etl-auth\etl-auth-server\src\main\java\com\auth\server\config\ShiroConfig.java

View File

@ -1 +0,0 @@
com\auth\server\EtlAuthServerApplicationTests.class

View File

@ -1 +0,0 @@
D:\workspace\ETL\etl-auth\etl-auth-server\src\test\java\com\auth\server\EtlAuthServerApplicationTests.java

View File

@ -100,26 +100,15 @@
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.health.cloud.common.HealthCloudCommonApplication</mainClass>
<skip>true</skip>
<mainClass>com.auth.server.EtlAuthServerApplication</mainClass>
</configuration>
<executions>
<execution>
@ -132,6 +121,4 @@
</plugin>
</plugins>
</build>
</project>

View File

@ -62,7 +62,7 @@ public class ExceptionHandlers {
.collect(Collectors.joining(";"));
result = Result.error(HttpStatus.BAD_REQUEST.value(), errorMessages);
}
return new ResponseEntity<>(result, HttpStatus.BAD_REQUEST);
return new ResponseEntity(result, HttpStatus.BAD_REQUEST);
}
/**

View File

@ -70,7 +70,7 @@ public class Result<T> implements Serializable {
}
private static <T> Result<T> restResult(T data, int code, String msg) {
Result<T> apiResult = new Result<>();
Result<T> apiResult = new Result();
apiResult.setCode(code);
apiResult.setData(data);
apiResult.setMsg(msg);

View File

@ -16,21 +16,22 @@ public class RestTemplateUtil {
@Autowired
private RestTemplate restTemplate;
public JSONObject get(String url, Map<String, Object> queryParams) throws IOException {
return get(url, queryParams, new HashMap<>(1));
return get(url, queryParams, new HashMap(1));
}
public JSONObject get(String url, Map<String, Object> queryParams, Map<String, String> headerParams) throws IOException {
String tempUrl = setParamsByAppendUrl(queryParams, url);
HttpHeaders headers = new HttpHeaders();
headerParams.forEach(headers::add);
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(null, headers);
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(null, headers);
ResponseEntity<String> response = restTemplate.exchange(tempUrl, HttpMethod.GET, httpEntity, String.class);
return JSONObject.parseObject(response.getBody());
}
public JSONObject get2(String url, Map<String, Object> queryParams, Map<String, String> headerParams) throws IOException {
String tempUrl = setParamsByPath(queryParams, url);
HttpHeaders headers = new HttpHeaders();
headerParams.forEach(headers::add);
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(null, headers);
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity(null, headers);
ResponseEntity<String> response = restTemplate.exchange(tempUrl, HttpMethod.GET, httpEntity, String.class, queryParams);
return JSONObject.parseObject(response.getBody());
}
@ -39,7 +40,7 @@ public class RestTemplateUtil {
headerParams.forEach(headers::add);
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
HttpEntity<String> httpEntity = new HttpEntity<>(json, headers);
HttpEntity<String> httpEntity = new HttpEntity(json, headers);
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
return JSONObject.parseObject(response.getBody());
}

View File

@ -1,5 +1,5 @@
#Generated by Maven
#Wed Jul 03 15:15:40 CST 2024
#Fri Jul 12 19:28:38 CST 2024
version=1.0-SNAPSHOT
groupId=com.bwie
artifactId=etl-common

View File

@ -1,20 +0,0 @@
com\etl\common\constants\Constants.class
com\etl\common\result\PageResult.class
com\etl\common\constants\JwtConstants.class
com\etl\common\Entity.class
com\etl\common\handler\ExceptionHandlers.class
com\etl\common\exception\LimitException.class
com\etl\common\util\JwtUtils.class
com\etl\common\result\CommonResult.class
com\etl\common\util\RequestUtil.class
com\etl\common\exception\ServiceException.class
com\etl\common\result\ResultBody.class
com\etl\common\exception\AllException.class
com\etl\common\enums\ResponseCodeEnum.class
com\etl\common\util\RestTemplateUtil.class
com\etl\common\result\Result.class
com\etl\common\BaseEntity.class
com\etl\common\exception\GlobalException.class
com\etl\common\util\RestTemplateConfig.class
com\etl\common\constants\TokenConstants.class
com\etl\common\util\StringUtils.class

View File

@ -1,20 +1,20 @@
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\enums\ResponseCodeEnum.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\result\ResultBody.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\util\RestTemplateConfig.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\exception\GlobalException.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\handler\ExceptionHandlers.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\BaseEntity.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\result\CommonResult.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\result\Result.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\constants\TokenConstants.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\util\JwtUtils.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\exception\LimitException.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\util\RequestUtil.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\exception\AllException.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\util\StringUtils.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\constants\Constants.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\Entity.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\result\PageResult.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\constants\JwtConstants.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\exception\ServiceException.java
D:\workspace\ETL\etl-common\src\main\java\com\etl\common\util\RestTemplateUtil.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\exception\AllException.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\result\Result.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\result\CommonResult.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\util\RestTemplateConfig.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\constants\Constants.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\exception\LimitException.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\result\PageResult.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\constants\TokenConstants.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\util\RequestUtil.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\util\StringUtils.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\enums\ResponseCodeEnum.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\util\RestTemplateUtil.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\constants\JwtConstants.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\util\JwtUtils.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\BaseEntity.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\exception\GlobalException.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\handler\ExceptionHandlers.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\Entity.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\exception\ServiceException.java
D:\workspace\etl-cloud\etl-common\src\main\java\com\etl\common\result\ResultBody.java

View File

@ -16,6 +16,11 @@
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
</properties>
<dependencies>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
@ -79,37 +84,4 @@
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.etl.database.common.EtlDatabaseCommonApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,23 @@
package com.etl.database.common.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.etl.database.common.entity.database.BaseMate;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
*
*/
@Data
@ApiModel(value = "项目实体类")
@TableName("t_access_item")
public class AccessItem extends BaseMate {
@ApiModelProperty(value = "主键")
private Integer id;
@ApiModelProperty(value = "接入项目名称")
private String accessItemName;
}

View File

@ -0,0 +1,20 @@
package com.etl.database.common.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
*/
@Data
@ApiModel(value = "分析方式")
@TableName("t_analytic_way")
public class AnalyticWay {
@ApiModelProperty(value = "主键")
private Integer id;
@ApiModelProperty(value = "分析方式名称")
private String analyticWayName;
}

View File

@ -60,4 +60,7 @@ public class DataSources extends BaseMate {
@ApiModelProperty(value = "密码")
private String password;
@ApiModelProperty(value = "数据库输入输出状态")
private Integer data;
}

View File

@ -0,0 +1,71 @@
package com.etl.database.common.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
*
*/
@Data
@TableName("t_interface")
@Api(tags = "数据集成--创建接口")
public class InterFace {
@ApiModelProperty(value = "接口id")
private Integer id;
@ApiModelProperty(value = "接口名称")
private String interfaceName;
@ApiModelProperty(value = "包名")
private String packageName;
@ApiModelProperty(value = "请求方式id")
private Integer requestTypeId;
@ApiModelProperty(value = "分析方式id")
private Integer analyticWayId;
@ApiModelProperty(value = "接入方式id")
private Integer accessItemId;
@ApiModelProperty(value = "接口描述")
private String interfaceDescribe;
@ApiModelProperty(value = "接口来源")
private String interfaceSource;
@ApiModelProperty(value = "调用次数")
private Integer invokeCount;
@ApiModelProperty(value = "成功次数")
private Integer successCount;
@ApiModelProperty(value = "失败次数")
private Integer failureCount;
@ApiModelProperty(value = "创建人")
private String createBy;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty(value = "修改人")
private String updateBy;
@ApiModelProperty(value = "修改时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
@ApiModelProperty(value = "是否删除")
private Integer isDelete;
}

View File

@ -0,0 +1,20 @@
package com.etl.database.common.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
*/
@Data
@TableName("t_request_type")
@ApiModel(value = "请求类型 实体类")
public class RequestType {
@ApiModelProperty(value = "主键")
private Integer id;
@ApiModelProperty(value = "请求类型名称")
private String requestTypeName;
}

View File

@ -18,4 +18,28 @@ public class DataSourceReq {
@ApiModelProperty("数据源类型")
private Integer dataSourceType;
@ApiModelProperty("驱动类")
private String driverClassName;
@ApiModelProperty("连接地址")
private String url;
@ApiModelProperty("用户名")
private String username;
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("状态 1-输入 2-输出")
private Integer data;
@ApiModelProperty("数据库名")
private String databaseName;
@ApiModelProperty("表名")
private String tableName;
@ApiModelProperty("规则类型id")
private Integer ruleTypeId;
}

View File

@ -0,0 +1,28 @@
package com.etl.database.common.entity.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
*/
@Data
@ApiModel(value = "接口请求实体类")
public class InterFaceReq {
@ApiModelProperty(value = "接口名称")
private String interfaceName;
@ApiModelProperty(value = "接入项目主键")
private Integer id;
@ApiModelProperty(value = "接入项目名称")
private String accessItemName;
@ApiModelProperty(value = "当前页数")
private Integer pageNum = 1;
@ApiModelProperty(value = "每页条数")
private Integer pageSize = 3;
}

View File

@ -0,0 +1,17 @@
package com.etl.database.common.entity.resp;
import com.etl.database.common.entity.InterFace;
import lombok.Data;
import java.util.List;
@Data
public class InterResp {
private Long pageNum;
private Long pageSize;
private Long total;
private List<InterFace> intervals;
}

View File

@ -119,23 +119,12 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.etl.database.server.EtlDatabaseServerApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>

View File

@ -0,0 +1,36 @@
package com.etl.database.server.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisPlusConfig {
/**
*
* 1 mybatis-plus
* MybatisPlusInterceptormybatis-plusmybatis-plus
* 2 使MybatisPlusInterceptor
* mybatis
* 1
* 2
* 3
* 3 mybatis
*
*
* @return MybatisPlusInterceptor
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
//添加:分页插件
//参数new PaginationInnerInterceptor(DbType.MYSQL)是专门为mysql定制实现的内部的分页插件
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
//添加:乐观锁插件
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
return interceptor;
}
}

View File

@ -1,6 +1,7 @@
package com.etl.database.server.controller;
import com.etl.common.result.Result;
import com.etl.database.common.annoation.Limit;
import com.etl.database.common.entity.CodeType;
import com.etl.database.server.service.CodeTypeService;
import io.swagger.annotations.Api;
@ -18,6 +19,7 @@ public class CodeTypeController {
private CodeTypeService codeTypeervice;
@RequestMapping(value = "/findCodeType")
@Limit(key = "findCodeType",permitsPerSecond = 1, timeout = 500,msg = "系统繁忙,请在稍后重试")
public Result findCodeType() {
List<CodeType> list = codeTypeervice.findCodeType();
return Result.success(list);

View File

@ -0,0 +1,32 @@
package com.etl.database.server.controller;
import com.etl.common.result.Result;
import com.etl.database.common.entity.InterFace;
import com.etl.database.common.entity.req.InterFaceReq;
import com.etl.database.common.entity.resp.InterResp;
import com.etl.database.server.service.InterFaceService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* -- controller
*/
@RestController
@RequestMapping("/interface")
@Api(tags = "数据集成--创建接口")
public class InterfaceController {
@Autowired
private InterFaceService interFaceService;
@PostMapping("/findInterFaceList")
public Result<InterResp> findInterFaceList(@RequestBody InterFaceReq interFaceReq) {
InterResp interFaceList = interFaceService.findInterFaceList(interFaceReq);
return Result.success(interFaceList);
}
}

View File

@ -2,6 +2,7 @@ package com.etl.database.server.controller;
import com.etl.common.result.Result;
import com.etl.database.common.entity.constants.DataSourceConstants;
import com.etl.database.common.entity.req.DataSourceReq;
import com.etl.database.common.entity.req.DruidReq;
import com.etl.database.common.entity.resp.ColumnInfo;
import com.etl.database.server.service.MysqlService;
@ -55,13 +56,13 @@ public class MysqlController {
@PostMapping("/findDatabaseTableFieldPrice")
@ApiOperation("数据表输入")
public Result<List<Map<String, Object>>> findDatabaseTableFieldPrice(@Valid @RequestBody DruidReq druidReq) {
return Result.success(dataSouceService.findDatabaseTableFieldPrice(druidReq));
public Result<List<Map<String, Object>>> findDatabaseTableFieldPrice(@Valid @RequestBody DataSourceReq dataSourceReq) {
return Result.success(dataSouceService.findDatabaseTableFieldPrice(dataSourceReq));
}
@PostMapping("outDatabaseTableFieldPrice")
@ApiOperation("数据表输出")
public Result outDatabaseTableFieldPrice(@Valid @RequestBody DruidReq druidReq) {
return Result.success(dataSouceService.findDatabaseTableFieldPrice(druidReq));
public Result outDatabaseTableFieldPrice(@Valid @RequestBody DataSourceReq dataSourceReq) {
return Result.success(dataSouceService.findDatabaseTableFieldPrice(dataSourceReq));
}
}

View File

@ -28,7 +28,7 @@ public class GlobalExceptionHandler {
// 使用Result封装错误信息
Result<String> result = Result.error(errorMessage);
return new ResponseEntity<>(result, HttpStatus.BAD_REQUEST);
return new ResponseEntity(result, HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(Exception.class)
@ -37,6 +37,6 @@ public class GlobalExceptionHandler {
// 使用Result封装错误信息
Result<String> result = Result.error(ex.getMessage());
return new ResponseEntity<>(result, HttpStatus.INTERNAL_SERVER_ERROR);
return new ResponseEntity(result, HttpStatus.INTERNAL_SERVER_ERROR);
}
}

View File

@ -0,0 +1,9 @@
package com.etl.database.server.mapper;
import com.etl.database.common.entity.InterFace;
import com.github.yulichang.base.MPJBaseMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface InterFaceMapper extends MPJBaseMapper<InterFace> {
}

View File

@ -0,0 +1,14 @@
package com.etl.database.server.service;
import com.etl.database.common.entity.InterFace;
import com.etl.database.common.entity.req.InterFaceReq;
import com.etl.database.common.entity.resp.InterResp;
import com.github.yulichang.base.MPJBaseService;
import java.util.List;
public interface InterFaceService extends MPJBaseService<InterFace> {
InterResp findInterFaceList(InterFaceReq interFaceReq);
}

View File

@ -1,6 +1,7 @@
package com.etl.database.server.service;
import com.etl.database.common.entity.DataSources;
import com.etl.database.common.entity.req.DataSourceReq;
import com.etl.database.common.entity.req.DruidReq;
import com.etl.database.common.entity.resp.ColumnInfo;
import com.github.yulichang.base.MPJBaseService;
@ -17,5 +18,5 @@ public interface MysqlService extends MPJBaseService<DataSources> {
List<ColumnInfo> findDatabaseTableField(DruidReq druidReq);
List<Map<String, Object>> findDatabaseTableFieldPrice(DruidReq druidReq);
List<Map<String, Object>> findDatabaseTableFieldPrice(DataSourceReq dataSourceReq);
}

View File

@ -36,7 +36,7 @@ public class DataSouceServiceImpl extends MPJBaseServiceImpl<DataSourceMapper, D
if (dataSourceReq.getDataSourceType() != null) {
dataSourceMPJLambdaWrapper.eq(DataSources::getDatabaseType, dataSourceReq.getDataSourceType());
}
Page<DataSources> page = new Page<>(dataSourceReq.getPageNum(), dataSourceReq.getPageSize());
Page<DataSources> page = new Page(dataSourceReq.getPageNum(), dataSourceReq.getPageSize());
IPage<DataSources> dataSourceReqIPage = dataSourceMapper.selectJoinPage(page, DataSources.class, dataSourceMPJLambdaWrapper);
List<DataSources> records = dataSourceReqIPage.getRecords();
return Result.success(records);

View File

@ -57,7 +57,7 @@ public class FileServiceImpl extends MPJBaseServiceImpl<FileMapper, File> implem
if (fileReq.getFilePath() != null && !fileReq.getFilePath().isEmpty()) {
taskMPJLambdaWrapper.like(File::getFilePath, fileReq.getFilePath());
}
Page<File> page = new Page<>(fileReq.getPageNum(), fileReq.getPageSize());
Page<File> page = new Page(fileReq.getPageNum(), fileReq.getPageSize());
IPage<File> dataSourceReqIPage = fileMapper.selectJoinPage(page, File.class, taskMPJLambdaWrapper);
List<File> records = dataSourceReqIPage.getRecords();
return fileMapper.selectJoinList(File.class, taskMPJLambdaWrapper);

View File

@ -0,0 +1,42 @@
package com.etl.database.server.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.etl.database.common.entity.InterFace;
import com.etl.database.common.entity.req.InterFaceReq;
import com.etl.database.common.entity.resp.InterResp;
import com.etl.database.server.mapper.InterFaceMapper;
import com.etl.database.server.service.InterFaceService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class InterFaceServiceImpl extends MPJBaseServiceImpl<InterFaceMapper,InterFace> implements InterFaceService {
@Autowired
private InterFaceMapper interFaceMapper;
@Override
public InterResp findInterFaceList(InterFaceReq interFaceReq) {
Page<InterFace> interFacePage = new Page<InterFace>().setCurrent(interFaceReq.getPageNum()).setSize(interFaceReq.getPageSize());
LambdaQueryWrapper<InterFace> interFaceLambdaQueryWrapper = new LambdaQueryWrapper();
if (interFaceReq.getAccessItemName() != null){
interFaceLambdaQueryWrapper.like(InterFace::getInterfaceName, interFaceReq.getInterfaceName());
}
Page<InterFace> interFacePage1 = interFaceMapper.selectPage(interFacePage, interFaceLambdaQueryWrapper);
InterResp interResp = new InterResp();
interResp.setPageSize(interFacePage1.getSize());
interResp.setPageNum(interFacePage1.getCurrent());
interResp.setTotal(interFacePage1.getTotal());
interResp.setIntervals(interFacePage1.getRecords());
return interResp;
}
}

View File

@ -4,12 +4,18 @@ package com.etl.database.server.service.impl;
import com.etl.common.util.StringUtils;
import com.etl.database.common.entity.DataSources;
import com.etl.database.common.entity.constants.DataSourceConstants;
import com.etl.database.common.entity.req.DataSourceReq;
import com.etl.database.common.entity.req.DruidReq;
import com.etl.database.common.entity.resp.ColumnInfo;
import com.etl.database.server.mapper.MysqlMapper;
import com.etl.database.server.service.MysqlService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
@ -18,6 +24,7 @@ import org.springframework.stereotype.Service;
import javax.sql.DataSource;
import java.sql.*;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -64,7 +71,7 @@ public class MysqlServiceImpl extends MPJBaseServiceImpl<MysqlMapper, DataSource
@Override
public List<String> findDatabaseTable(DruidReq druidReq) {
List<String> tableNames = new ArrayList<>();
List<String> tableNames = new ArrayList();
try (Connection connection = getConnection(druidReq)) {
try (Statement statement = connection.createStatement()) {
// 查询所有数据库名
@ -85,7 +92,7 @@ public class MysqlServiceImpl extends MPJBaseServiceImpl<MysqlMapper, DataSource
if (StringUtils.isNull(druidReq.getDatabaseName())) {
throw new RuntimeException("请选择数据库");
}
List<String> tableNames = new ArrayList<>();
List<String> tableNames = new ArrayList();
try (Connection connection = getConnection(druidReq)) {
try (Statement statement = connection.createStatement()) {
// 查询指定数据库的所有表名
@ -105,7 +112,7 @@ public class MysqlServiceImpl extends MPJBaseServiceImpl<MysqlMapper, DataSource
@Override
public List<ColumnInfo> findDatabaseTableField(DruidReq druidReq) {
checkDruidReq(druidReq);
List<ColumnInfo> columnInfos = new ArrayList<>();
List<ColumnInfo> columnInfos = new ArrayList();
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
@ -176,16 +183,25 @@ public class MysqlServiceImpl extends MPJBaseServiceImpl<MysqlMapper, DataSource
}
@Override
public List<Map<String, Object>> findDatabaseTableFieldPrice(DruidReq druidReq) {
List<Map<String, Object>> results = new ArrayList<>();
public List<Map<String, Object>> findDatabaseTableFieldPrice(DataSourceReq dataSourceReq) {
checkDataSourceReq(dataSourceReq);
List<Map<String, Object>> results = new ArrayList();
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
DruidReq druidReq = new DruidReq();
druidReq.setDriverClassName(dataSourceReq.getDriverClassName());
druidReq.setUrl(dataSourceReq.getUrl());
druidReq.setUsername(dataSourceReq.getUsername());
druidReq.setPassword(dataSourceReq.getPassword());
druidReq.setDatabaseName(dataSourceReq.getDatabaseName());
druidReq.setTableName(dataSourceReq.getTableName());
try {
connection = getConnection(druidReq);
// 这里我们仅作为示例直接构建SQL查询语句实际中可能需要更复杂的逻辑来构建SQL
String sql = "SELECT * FROM " + druidReq.getDatabaseName() + "." + druidReq.getTableName();
String sql = "SELECT * FROM " + dataSourceReq.getDatabaseName() + "." + dataSourceReq.getTableName();
preparedStatement = connection.prepareStatement(sql);
resultSet = preparedStatement.executeQuery();
@ -193,7 +209,7 @@ public class MysqlServiceImpl extends MPJBaseServiceImpl<MysqlMapper, DataSource
int columnCount = metaData.getColumnCount();
while (resultSet.next()) {
Map<String, Object> rowData = new HashMap<>();
Map<String, Object> rowData = new HashMap();
for (int i = 1; i <= columnCount; i++) {
String columnName = metaData.getColumnName(i);
Object columnValue = resultSet.getObject(i);
@ -209,20 +225,28 @@ public class MysqlServiceImpl extends MPJBaseServiceImpl<MysqlMapper, DataSource
} finally {
// 关闭资源
try {
if (resultSet != null) resultSet.close();
if (preparedStatement != null) preparedStatement.close();
if (connection != null) connection.close();
if (resultSet != null) {
resultSet.close();
}
if (preparedStatement != null) {
preparedStatement.close();
}
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
if (1 == druidReq.getData()) {
results = checkRoule(results, dataSourceReq.getRuleTypeId());
if (1 == dataSourceReq.getData()) {
insertDataExcludingId(druidReq, results);
}
return results;
}
public void insertDataExcludingId(DruidReq druidReq, List<Map<String, Object>> results) {
private void insertDataExcludingId(DruidReq druidReq, List<Map<String, Object>> results) {
Connection connection = null;
PreparedStatement preparedStatement = null;
@ -231,7 +255,7 @@ public class MysqlServiceImpl extends MPJBaseServiceImpl<MysqlMapper, DataSource
for (Map<String, Object> rowData : results) {
// 获取列名并构建 SQL 语句
List<String> columnNames = new ArrayList<>(rowData.keySet());
List<String> columnNames = new ArrayList(rowData.keySet());
columnNames.remove("id"); // 移除 id 列
StringBuilder sql = new StringBuilder("INSERT INTO ");
sql.append(druidReq.getDatabaseName()).append(".").append(druidReq.getTableName()).append(" (");
@ -267,13 +291,97 @@ public class MysqlServiceImpl extends MPJBaseServiceImpl<MysqlMapper, DataSource
} finally {
// 关闭资源
try {
if (preparedStatement != null) preparedStatement.close();
if (connection != null) connection.close();
if (preparedStatement != null) {
preparedStatement.close();
}
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
private List<Map<String, Object>> checkRoule(List<Map<String, Object>> results, Integer ruleTypeId) {
if (ruleTypeId != null) {
// 根据不同的ruleTypeId进行不同的处理
switch (ruleTypeId) {
case 1:
// 对results数据进行清洗将所有包含中文的字段内容转为英文
results = results.stream()
.map(map -> {
map.forEach((key, value) -> {
if (value instanceof String) {
String strValue = (String) value;
if (strValue.matches(".*[\u4e00-\u9fa5]+.*")) { // 判断是否包含中文
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
format.setCaseType(HanyuPinyinCaseType.LOWERCASE); // 小写
format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); // 不带音调
format.setVCharType(HanyuPinyinVCharType.WITH_V); // 使用带 "v" 的拼写方式
StringBuilder englishValue = new StringBuilder();
for (char c : strValue.toCharArray()) {
try {
String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, format);
if (pinyinArray != null) {
englishValue.append(String.join("", pinyinArray));
} else {
englishValue.append(c); // 非中文字符直接追加
}
} catch (Exception e) {
// 处理转换异常
System.err.println("拼音转换异常:" + e.getMessage());
}
}
map.put(key, englishValue.toString());
}
}
});
return map;
})
.collect(Collectors.toList());
break;
case 2:
// 对results数据进行脱敏对字段是username的进行脱敏
results = results.stream()
.map(map -> {
if (map.containsKey("username")) {
String name = (String) map.get("username");
if (name.length() > 1) {
// 根据姓名长度添加星号
String desensitizedName = name.substring(0, 1); // 保留第一个字
for (int i = 1; i < name.length(); i++) {
desensitizedName += "*";
}
map.put("username", desensitizedName);
}
}
if (map.containsKey("mobile")) {
String userphone = (String) map.get("mobile");
if (userphone.length() > 7) {
map.put("mobile", userphone.substring(0, 3) + "****" + userphone.substring(7)); // 保留前三位和后一位,中间用星号代替
}
}
return map;
})
.collect(Collectors.toList());
break;
default:
throw new RuntimeException("不支持的规则类型ID: " + ruleTypeId);
}
return results;
}
return results;
}
private void checkDataSourceReq(DataSourceReq dataSourceReq) {
if (StringUtils.isEmpty(dataSourceReq.getDatabaseName())){
throw new RuntimeException("请选择数据库");
}
if (StringUtils.isNull(dataSourceReq.getTableName())){
throw new RuntimeException("请选择表");
}
}

View File

@ -23,7 +23,7 @@ public class RedisServiceImpl extends MPJBaseServiceImpl<RedisMapper, DatabaseRe
@Override
public Map<String, String> testDatabaseRedis(DatabaseRedisReq databaseRedis) {
// 创建一个空的HashMap来存储Redis中的所有键值对
Map<String, String> allData = new HashMap<>();
Map<String, String> allData = new HashMap();
// 从Redis配置中获取Jedis连接池
JedisPool jedisPool = RedisConfig.getJedisPool(databaseRedis);

View File

@ -27,7 +27,7 @@ public class RuleServiceImpl extends MPJBaseServiceImpl<RuleMapper, Rule> implem
@Override
public List<Rule> findRule(RuleReq ruleReq) {
MPJLambdaWrapper<Rule> ruleMPJLambdaWrapper = new MPJLambdaWrapper<>();
MPJLambdaWrapper<Rule> ruleMPJLambdaWrapper = new MPJLambdaWrapper();
ruleMPJLambdaWrapper.select(Rule::getId, Rule::getRuleTypeId, Rule::getRuleName)
.select(RuleType::getRuleTypeName)
.select(CodeType::getCodeTypeName)
@ -40,7 +40,7 @@ public class RuleServiceImpl extends MPJBaseServiceImpl<RuleMapper, Rule> implem
if (ruleReq.getCodeTypeId() != null) {
ruleMPJLambdaWrapper.eq(Code::getCodeTypeId, ruleReq.getCodeTypeId());
}
Page<Rule> page = new Page<>(ruleReq.getPageNum(), ruleReq.getPageSize());
Page<Rule> page = new Page(ruleReq.getPageNum(), ruleReq.getPageSize());
IPage<Rule> ruleIPage = ruleMapper.selectJoinPage(page, Rule.class, ruleMPJLambdaWrapper);
List<Rule> records = ruleIPage.getRecords();
return records;

View File

@ -130,7 +130,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
javax.sql.DataSource newDataSource = createDataSource(dataSource2);
JdbcTemplate newJdbcTemplate = new JdbcTemplate(newDataSource);
ArrayList<Map<String, Object>> maps = new ArrayList<>();
ArrayList<Map<String, Object>> maps = new ArrayList();
String groovyScript = getGroovyScriptContent();
// 创建Binding对象
@ -153,7 +153,7 @@ public class TaskServiceImpl extends MPJBaseServiceImpl<TaskMapper, Task> implem
// 执行Groovy脚本脚本应该返回处理后的values
List<String> newValues = (List<String>) shell.evaluate(groovyScript);
HashMap<String, Object> map = new HashMap<>();
HashMap<String, Object> map = new HashMap();
map.put(columnName, newValues);
maps.add(map);
}

View File

@ -39,4 +39,4 @@ mybatis-plus:
typeAliasesPackage: com.etl.database.common.entity
file:
path: "D:\\"
name: "美美子新创建的文件"
name: "美美子新创建的文件7.15"

View File

@ -62,23 +62,12 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.EtlEasycodeApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>

View File

@ -44,7 +44,7 @@ public class TUserServiceImpl implements TUserService {
@Override
public Page<TUser> queryByPage(TUser tUser, PageRequest pageRequest) {
long total = this.tUserDao.count(tUser);
return new PageImpl<>(this.tUserDao.queryAllByLimit(tUser, pageRequest), pageRequest, total);
return new PageImpl(this.tUserDao.queryAllByLimit(tUser, pageRequest), pageRequest, total);
}
/**

View File

@ -112,5 +112,24 @@
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.etl.gateway.EtlGatewayApplication</mainClass>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -23,7 +23,7 @@ public class IgnoreWhiteConfig {
/**
*
*/
private List<String> whites = new ArrayList<>();
private List<String> whites = new ArrayList();
public void setWhites(List<String> whites) {
log.info("加载网关路径白名单:{}", JSONObject.toJSONString(whites));

View File

@ -126,7 +126,7 @@ public class JwtAuthCheckFilter {
log.warn("token异常处理,请求路径:{}", exchange.getRequest().getPath());
serverHttpResponse.setStatusCode(HttpStatus.UNAUTHORIZED);
serverHttpResponse.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
CommonResult<Object> responseResult = new CommonResult<>(responseCodeEnum.getCode(),responseCodeEnum.getMessage());
CommonResult<Object> responseResult = new CommonResult(responseCodeEnum.getCode(),responseCodeEnum.getMessage());
DataBuffer dataBuffer = serverHttpResponse.bufferFactory()
.wrap(JSON.toJSONStringWithDateFormat(responseResult, JSON.DEFFAULT_DATE_FORMAT)
.getBytes(StandardCharsets.UTF_8));

View File

@ -1,5 +0,0 @@
#Generated by Maven
#Wed Jul 03 15:15:42 CST 2024
version=1.0-SNAPSHOT
groupId=com.bwie
artifactId=etl-gateway

View File

@ -1,9 +0,0 @@
com\etl\gateway\service\PermissionService.class
com\etl\gateway\config\WhiteListProperties.class
com\etl\gateway\filters\LogFilter.class
com\etl\gateway\utils\GatewayUtils.class
com\etl\gateway\filters\JwtAuthCheckFilter.class
com\etl\gateway\EtlGatewayApplication.class
com\etl\gateway\config\IgnoreWhiteConfig.class
com\etl\gateway\config\FeignConfig.class
com\etl\gateway\filters\AuthFilter.class

View File

@ -1,9 +1,9 @@
D:\workspace\ETL\etl-gateway\src\main\java\com\etl\gateway\config\WhiteListProperties.java
D:\workspace\ETL\etl-gateway\src\main\java\com\etl\gateway\config\IgnoreWhiteConfig.java
D:\workspace\ETL\etl-gateway\src\main\java\com\etl\gateway\utils\GatewayUtils.java
D:\workspace\ETL\etl-gateway\src\main\java\com\etl\gateway\filters\AuthFilter.java
D:\workspace\ETL\etl-gateway\src\main\java\com\etl\gateway\EtlGatewayApplication.java
D:\workspace\ETL\etl-gateway\src\main\java\com\etl\gateway\filters\JwtAuthCheckFilter.java
D:\workspace\ETL\etl-gateway\src\main\java\com\etl\gateway\config\FeignConfig.java
D:\workspace\ETL\etl-gateway\src\main\java\com\etl\gateway\filters\LogFilter.java
D:\workspace\ETL\etl-gateway\src\main\java\com\etl\gateway\service\PermissionService.java
D:\workspace\etl-cloud\etl-gateway\src\main\java\com\etl\gateway\filters\AuthFilter.java
D:\workspace\etl-cloud\etl-gateway\src\main\java\com\etl\gateway\config\IgnoreWhiteConfig.java
D:\workspace\etl-cloud\etl-gateway\src\main\java\com\etl\gateway\filters\LogFilter.java
D:\workspace\etl-cloud\etl-gateway\src\main\java\com\etl\gateway\filters\JwtAuthCheckFilter.java
D:\workspace\etl-cloud\etl-gateway\src\main\java\com\etl\gateway\config\FeignConfig.java
D:\workspace\etl-cloud\etl-gateway\src\main\java\com\etl\gateway\service\PermissionService.java
D:\workspace\etl-cloud\etl-gateway\src\main\java\com\etl\gateway\EtlGatewayApplication.java
D:\workspace\etl-cloud\etl-gateway\src\main\java\com\etl\gateway\utils\GatewayUtils.java
D:\workspace\etl-cloud\etl-gateway\src\main\java\com\etl\gateway\config\WhiteListProperties.java

View File

@ -64,5 +64,24 @@
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.etl.groovy.SpringBootGroovyApplication</mainClass>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -101,36 +101,4 @@
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.etl.jwt.EtlJwtManageApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -61,7 +61,7 @@ public class JwtTokenUtil {
//生成刷新令牌
String refreshToken = generateRefreshToken(userId, username, null);
//存储两个令牌及过期时间,返回结果
HashMap<String, Object> tokenMap = new HashMap<>(2);
HashMap<String, Object> tokenMap = new HashMap(2);
tokenMap.put(ACCESS_TOKEN, accessToken);
tokenMap.put(REFRESH_TOKEN, refreshToken);
tokenMap.put(EXPIRE_IN, jwtProperties.getExpiration());
@ -88,7 +88,7 @@ public class JwtTokenUtil {
private Map<String, Object> buildClaims(String userId, String username, Map<String, String> payloads) {
int payloadSizes = payloads == null? 0 : payloads.size();
Map<String, Object> claims = new HashMap<>(payloadSizes + 2);
Map<String, Object> claims = new HashMap(payloadSizes + 2);
claims.put("sub", userId);
claims.put("username", username);
claims.put("created", new Date());

View File

@ -10,8 +10,7 @@
{
"name": "auth.jwt.enabled",
"type": "java.lang.Boolean",
"sourceType": "com.etl.jwt.config.AuthJwtProperties",
"defaultValue": true
"sourceType": "com.etl.jwt.config.AuthJwtProperties"
},
{
"name": "auth.jwt.expiration",
@ -27,8 +26,7 @@
"name": "auth.jwt.pwd-param-name",
"type": "java.lang.String",
"description": "用户登录-密码参数名称",
"sourceType": "com.etl.jwt.config.AuthJwtProperties",
"defaultValue": "password"
"sourceType": "com.etl.jwt.config.AuthJwtProperties"
},
{
"name": "auth.jwt.secret",
@ -43,15 +41,13 @@
{
"name": "auth.jwt.use-default-controller",
"type": "java.lang.Boolean",
"sourceType": "com.etl.jwt.config.AuthJwtProperties",
"defaultValue": false
"sourceType": "com.etl.jwt.config.AuthJwtProperties"
},
{
"name": "auth.jwt.user-param-name",
"type": "java.lang.String",
"description": "用户登录-用户名参数名称",
"sourceType": "com.etl.jwt.config.AuthJwtProperties",
"defaultValue": "userId"
"sourceType": "com.etl.jwt.config.AuthJwtProperties"
}
],
"hints": []

View File

@ -1,5 +1,5 @@
#Generated by Maven
#Wed Jul 03 15:15:41 CST 2024
#Fri Jul 12 19:28:40 CST 2024
version=1.0-SNAPSHOT
groupId=com.bwie
artifactId=etl-jwt-manage

View File

@ -1,2 +1,2 @@
D:\workspace\ETL\etl-jwt-manage\src\main\java\com\etl\jwt\config\AuthJwtProperties.java
D:\workspace\ETL\etl-jwt-manage\src\main\java\com\etl\jwt\util\JwtTokenUtil.java
D:\workspace\etl-cloud\etl-jwt-manage\src\main\java\com\etl\jwt\util\JwtTokenUtil.java
D:\workspace\etl-cloud\etl-jwt-manage\src\main\java\com\etl\jwt\config\AuthJwtProperties.java

View File

@ -2,11 +2,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.roles</groupId>
<parent>
<groupId>com.bwie</groupId>
<artifactId>etl-cloud</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>etl-roles</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>etl-roles</name>
<description>etl-roles</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -80,23 +81,12 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.etl.roles.EtlRolesApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>

View File

@ -1,8 +1,9 @@
package com.etl.roles.controlller;
import com.auth.common.entity.PathPermission;
import com.auth.common.entity.RolesPermission;
import com.auth.common.enums.PermissionConstants;
import com.auth.server.enums.PermissionConstants;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.etl.roles.service.PathService;
import com.etl.roles.service.PermissionService;
@ -42,7 +43,7 @@ public class PermissionController {
RolesPermission permission = permissionService.getOne(new QueryWrapper<RolesPermission>().eq(PermissionConstants.ROLE,roles));
String codes = StringUtils.strip(permission.getPermissionCode(), "[]");
List<String> list = Arrays.asList(codes.split(","));
List<String> pathList = new ArrayList<>();
List<String> pathList = new ArrayList();
for(String code:list){
String api = pathService.getOne(new QueryWrapper<PathPermission>().eq(PermissionConstants.PERMISSION_CODE,code.trim())).getPath();
pathList.add(api);

View File

@ -41,7 +41,7 @@ public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, RolesPe
private int updateRolePermission(RolesPermission rolesPermission, RolesPermission role, List<String> codeList) {
//去掉头尾括号,并转为列表
List<String> list = new java.util.ArrayList<>(Collections.singletonList(
List<String> list = new java.util.ArrayList(Collections.singletonList(
StringUtils.strip(role.getPermissionCode(), "[]")));
//将新数据添加至列表
list.addAll(codeList);

Some files were not shown because too many files have changed in this diff Show More