Compare commits

..

8 Commits

Author SHA1 Message Date
陈思豪 b33b59222e 任务管理 2024-08-22 08:33:25 +08:00
陈思豪 76761de5e8 任务管理 2024-08-21 22:43:03 +08:00
陈思豪 bf60933eac 数据脱敏 2024-08-21 22:10:26 +08:00
陈思豪 3dc7b35e04 数据脱敏 2024-08-21 20:48:50 +08:00
陈思豪 37c71a5d3e 数据脱敏 2024-08-21 20:45:05 +08:00
陈思豪 2983c635ff Merge branch 'dev.csh.oneweek' of https://gitea.qinmian.online/TreeData/cloud-etl 2024-08-21 20:43:45 +08:00
陈思豪 6233a50911 数据脱敏 2024-08-21 20:31:34 +08:00
陈思豪 a2d2caac79 修改 2024-08-21 10:38:40 +08:00
40 changed files with 4492 additions and 4874 deletions

View File

@ -22,6 +22,32 @@
<groupId>com.muyu</groupId>
<artifactId>cloud-common-core</artifactId>
</dependency>
<!--hutool-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-core</artifactId>
<version>${hutool.version}</version>
</dependency>
<!--json模块-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</dependency>
<dependency>
<groupId>io.gitee.chemors</groupId>
<artifactId>secure-ext-spring-boot-starter</artifactId>
<version>1.0.3-RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
</project>

View File

@ -1,31 +0,0 @@
package com.muyu.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorqdm
* @Packagecom.muyu.domain
* @Projectcloud-etlw3123123
* @nameActionScope
* @Date2024/8/21 20:53
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ActionScope {
/**
*
*/
private Integer id;
/**
*
*/
@Schema(name = "规则作用域名称", type = "String", defaultValue = "数据字段", description = "规则作用域名称")
private String name;
}

View File

@ -0,0 +1,31 @@
package com.muyu.domain;
import com.mos.secure.ext.annotations.DesensitizationProp;
import com.mos.secure.ext.enums.SensitiveTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* @PackageName:com.muyu.domain
* @ClassName:DesensitizationAdmin
* @Description:
* @author:
* @date: 2024/8/21 21:00
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class DesensitizationAdmin {
private Integer uid;
@DesensitizationProp(SensitiveTypeEnum.CHINESE_NAME)
private String userName;//姓名
@DesensitizationProp(SensitiveTypeEnum.MOBILE_PHONE)
private String userMobile;//手机号
@DesensitizationProp(SensitiveTypeEnum.FIXED_PHONE)
private String userTel;//固定电话
@DesensitizationProp(SensitiveTypeEnum.ID_CARD)
private String userBkId;//银行卡号
}

View File

@ -1,56 +0,0 @@
package com.muyu.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorqdm
* @Packagecom.muyu.domain
* @Project cloud-etlw3123123
* @nameRule
* @Date2024/8/21 19:34
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Tag(name = "客户支付单", description = "客户支付单简略信息")
public class Rule {
/**
* id
*/
private Integer id;
/**
*
*/
@Schema(name = "规则名称", type = "String", defaultValue = "基础规则", description = "规则名称")
private String name;
/**
*
*/
@Schema(name = "规则类型", type = "Integer", defaultValue = "1", description = "规则类型")
private Integer type;
/**
*
*/
@Schema(name = "规则作用域", type = "Integer", defaultValue = "1", description = "规则作用域")
private Integer actionScope;
/**
*
*/
@Schema(name = "规则邮编码", type = "String", defaultValue = "123456", description = "规则邮编码")
private String code;
/**
*
*/
@Schema(name = "是否激活", type = "Integer", defaultValue = "1", description = "是否激活")
private Integer flag;
/**
*
*/
@Schema(name = "规则状态", type = "Integer", defaultValue = "1", description = "规则状态")
private Integer status;
}

View File

@ -26,7 +26,6 @@ public class SourceType extends BaseEntity {
@TableField(value = "driver_class")
private String driverClass;
//
private String prefix;
private String suffix;

View File

@ -21,6 +21,7 @@ public class TableInfo extends TreeEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id", type = IdType.AUTO)
private Long id;

View File

@ -1,30 +0,0 @@
package com.muyu.domain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorqdm
* @Packagecom.muyu.domain
* @Projectcloud-etlw3123123
* @nameType
* @Date2024/8/21 20:54
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Type {
/**
* id
*/
private Integer id;
/**
*
*/
@Schema(name = "类型名称", type = "String", defaultValue = "基础类型", description = "类型名称")
private String name;
}

View File

@ -0,0 +1,40 @@
package com.muyu.domain.dto;
import com.muyu.domain.enumerate.Desensitization;
import com.muyu.domain.enumerate.DesensitizationTypeEnum;
import lombok.Data;
import java.io.Serializable;
/**
* @PackageName:com.muyu.domain
* @ClassName:AnnotainDTO
* @Description:
* @author:
* @date: 2024/8/21 16:10
*/
@Data
public class AnnotationDTO implements Serializable {
/**
*
*/
@Desensitization(type = DesensitizationTypeEnum.CUSTOMER,startInclude = 5,endExclude = 10)
private String name;
/**
*
*/
@Desensitization(type = DesensitizationTypeEnum.MOBILE_PHONE)
private String tel;
/**
*
*/
@Desensitization(type = DesensitizationTypeEnum.EMAIL)
private String email;
/**
*
*/
@Desensitization(type = DesensitizationTypeEnum.ID_CARD)
private String idCard;
}

View File

@ -0,0 +1,41 @@
package com.muyu.domain.enumerate;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.muyu.domain.serialize.DesensitizationSerialize;
import kotlin.annotation.AnnotationRetention;
import kotlin.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* @PackageName:com.muyu.domain.enumerate
* @ClassName:Desensitization
* @Description:
* @author:
* @date: 2024/8/21 14:04
*/
@Retention(AnnotationRetention.RUNTIME)
@JacksonAnnotationsInside
@JsonSerialize(using = DesensitizationSerialize.class)
public @interface Desensitization {
/**
*
* @return
*/
DesensitizationTypeEnum type() default DesensitizationTypeEnum.CUSTOMER;
/**
*
*/
int startInclude() default 0;
/**
*
*/
int endExclude() default 0;
}

View File

@ -0,0 +1,93 @@
package com.muyu.domain.enumerate;
/**
* @PackageName:com.muyu.domain
* @ClassName:SensitiveType
* @Description:
* @author:
* @date: 2024/8/21 13:59
*/
public enum DesensitizationTypeEnum {
//自定义
CUSTOMER,
//用户id
USER_ID,
//中文名
CHINESE_NAME,
//身份证号
ID_CARD,
//座机号
FIXED_PHONE,
//手机号
MOBILE_PHONE,
//地址
ADDRESS,
//电子邮件
EMAIL,
//密码
PASSWORD,
//中国大陆车牌,包含普通车辆、新能源车辆
CAR_LICENSE,
//银行卡
BANK_CARD
}

View File

@ -0,0 +1,54 @@
package com.muyu.domain.job;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* @PackageName:com.muyu.domain.job
* @ClassName:SysJob
* @Description:
* @author:
* @date: 2024/8/21 22:29
*/
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@Data
@SuperBuilder
public class SysJob extends BaseEntity {
/**
* id
*/
private Long jobId;
/**
*
*/
private String jobName;
/**
*
*/
private String jobGroup;
/**
*
*/
private String characterString;
/**
*
*/
private String description;
/**
* 0 1
*/
private String status;
}

View File

@ -1,38 +0,0 @@
package com.muyu.domain.req;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Authorqdm
* @Packagecom.muyu.domain.req
* @Projectcloud-etlw3123123
* @nameRuleReq
* @Date2024/8/21 21:38
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RuleReq {
/**
*
*/
@Schema(name = "名称模糊查询", type = "String", defaultValue = "基础规则", description = "名称模糊查询")
private String name;
/**
*
*/
private Integer type;
/**
*
*/
private Integer flag;
/**
*
*/
private Integer status;
}

View File

@ -2,24 +2,15 @@ package com.muyu.domain.req;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.Date;
import java.util.Map;
@Data
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@TableName(value ="source",autoResultMap = true) //数据库表相关
public class SourceReq extends BaseEntity {
/** 主键 */
@TableId(value = "id", type = IdType.AUTO)
@ -65,16 +56,6 @@ public class SourceReq extends BaseEntity {
@Excel(name = "最大等待次数")
private Long maxWaitTimes;
@Excel(name ="连接参数")
private String connectionParams;
@Excel(name ="用户名")
private String username;
@Excel(name ="密码")
private String password;
@Override
public String toString() {
return "SourceReq{" +

View File

@ -0,0 +1,50 @@
package com.muyu.domain.rule;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* @PackageName:com.muyu.domain.rule
* @ClassName:Rule
* @Description:
* @author:
* @date: 2024/8/22 2:09
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Tag(name = "规则")
public class Rule {
/**
* ID
*/
private Long id;
/**
*
*/
private String name;
/**
*
*/
private String ruleType;
/**
*
*/
private String isActivate;
/**
*
*/
private String ruleDesc;
}

View File

@ -0,0 +1,89 @@
package com.muyu.domain.serialize;
import cn.hutool.core.util.DesensitizedUtil;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
import com.muyu.domain.enumerate.DesensitizationTypeEnum;
import com.muyu.domain.enumerate.Desensitization;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import java.io.IOException;
import java.util.Objects;
@NoArgsConstructor
@AllArgsConstructor
public class DesensitizationSerialize extends JsonSerializer<String> implements ContextualSerializer {
private DesensitizationTypeEnum type;
private Integer startInclude;
private Integer endExclude;
@Override
public void serialize(String str, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
switch (type) {
//自定义 Java 对象如何序列化成 JSON 格式
// 中文姓名脱敏
case CHINESE_NAME:
jsonGenerator.writeString(DesensitizedUtil.chineseName(String.valueOf(str)));
break;
// 身份证脱敏
case ID_CARD:
jsonGenerator.writeString(DesensitizedUtil.idCardNum(String.valueOf(str), 1, 2));
break;
// 手机号脱敏
case MOBILE_PHONE:
jsonGenerator.writeString(DesensitizedUtil.mobilePhone(String.valueOf(str)));
break;
// 地址脱敏
case ADDRESS:
jsonGenerator.writeString(DesensitizedUtil.address(String.valueOf(str), 8));
break;
// 邮箱脱敏
case EMAIL:
jsonGenerator.writeString(DesensitizedUtil.email(String.valueOf(str)));
break;
// 密码脱敏
case PASSWORD:
jsonGenerator.writeString(DesensitizedUtil.password(String.valueOf(str)));
break;
// 银行卡脱敏
case BANK_CARD:
jsonGenerator.writeString(DesensitizedUtil.bankCard(String.valueOf(str)));
break;
default:
}
}
@Override
public JsonSerializer<?> createContextual(SerializerProvider serializerProvider, BeanProperty beanProperty) throws JsonMappingException {
if (beanProperty != null) {
System.out.println("aaa");
// 判断数据类型是否为String类型
if (Objects.equals(beanProperty.getType().getRawClass(), String.class)) {
// 获取定义的注解
Desensitization desensitization = beanProperty.getAnnotation(Desensitization.class);
// 为null
if (desensitization == null) {
desensitization = beanProperty.getContextAnnotation(Desensitization.class);
}
// 不为null
if (desensitization != null) {
// 创建定义的序列化类的实例并且返回入参为注解定义的type,开始位置,结束位置。
return new DesensitizationSerialize(desensitization.type(), desensitization.startInclude(),
desensitization.endExclude());
}
}
return serializerProvider.findValueSerializer(beanProperty.getType(), beanProperty);
}
return serializerProvider.findNullValueSerializer(null);
}
}

View File

@ -0,0 +1,261 @@
package com.muyu.domain.util;
import com.muyu.common.core.utils.StringUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
*/
public class Desensitization {
/**
*
*
* @param idCard
* @return
*/
public static String idCardDesensitization(String idCard) {
if (StringUtils.isNotEmpty(idCard)) {
// 身份证号脱敏规则一:保留前六后三
if (idCard.length() == 15) {
idCard = idCard.replaceAll("(\\w{6})\\w*(\\w{3})", "$1******$2");
} else if (idCard.length() == 18) {
idCard = idCard.replaceAll("(\\w{6})\\w*(\\w{3})", "$1*********$2");
}
// 身份证号脱敏规则二:保留前三后四
// idCard = idCard.replaceAll("(?<=\\w{3})\\w(?=\\w{4})", "*");
}
return idCard;
}
/**
*
*
* @param mobilePhone
* @return
*/
public static String mobilePhoneDesensitization(String mobilePhone) {
// 手机号码保留前三后四
if (StringUtils.isNotEmpty(mobilePhone)) {
mobilePhone = mobilePhone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
}
return mobilePhone;
}
/**
*
*
* @param email
* @return
*/
public static String emailDesensitization(String email) {
// 电子邮箱隐藏@前面的3个字符
if (StringUtils.isEmpty(email)) {
return email;
}
String encrypt = email.replaceAll("(\\w+)\\w{3}@(\\w+)", "$1***@$2");
if (email.equalsIgnoreCase(encrypt)) {
encrypt = email.replaceAll("(\\w*)\\w{1}@(\\w+)", "$1*@$2");
}
return encrypt;
}
/**
*
*
* @param acctNo
* @return
*/
public static String acctNoDesensitization(String acctNo) {
// 银行账号保留前六后四
if (StringUtils.isNotEmpty(acctNo)) {
String regex = "(\\w{6})(.*)(\\w{4})";
Matcher m = Pattern.compile(regex).matcher(acctNo);
if (m.find()) {
String rep = m.group(2);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < rep.length(); i++) {
sb.append("*");
}
acctNo = acctNo.replaceAll(rep, sb.toString());
}
}
return acctNo;
}
/**
*
*
* @param custName
* @return
*/
public static String custNameDesensitization(String custName) {
if (StringUtils.isNotEmpty(custName)) {
char[] chars = custName.toCharArray();
if (chars.length < 5) {// 表示姓名
if (chars.length > 1) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < chars.length - 2; i++) {
sb.append("*");
}
custName = custName.replaceAll(custName.substring(1, chars.length - 1), sb.toString());
}
} else {
int start = 4;
String str1 = custName.substring(0, start);
String str2 = "";
if (chars.length == 5) {
str2 = "*";
} else if (chars.length == 6) {
str2 = "**";
} else if (chars.length == 7) {
str2 = "***";
} else if (chars.length == 8) {
str2 = "****";
} else if (chars.length == 9) {
str2 = "*****";
} else {
str2 = "******";
}
// 通过计算得到第三部分需要从第几个字符截取
int subIndex = start + str2.length();
// 第三部分
String str3 = custName.substring(subIndex);
StringBuffer sb = new StringBuffer();
sb.append(str1);
sb.append(str2);
sb.append(str3);
custName = sb.toString();
}
}
return custName;
}
/**
*
*
* @param address
* @return
*/
public static String addressDesensitization(String address) {
// 规则说明从第4位开始隐藏隐藏8位。
if (StringUtils.isNotEmpty(address)) {
char[] chars = address.toCharArray();
if (chars.length > 11) {// 由于需要从第4位开始隐藏8位因此数据长度必须大于11位
// 获取第一部分内容
String str1 = address.substring(0, 4);
// 获取第二部分
String str2 = "********";
// 获取第三部分
String str3 = address.substring(12);
StringBuffer sb = new StringBuffer();
sb.append(str1);
sb.append(str2);
sb.append(str3);
address = sb.toString();
}
}
return address;
}
//下面代码是从别人博客看到的。
/**
*
*/
public static final int ONE = 1;
public static final int TWO = 2;
/**
*
*
* @param realName
* @return
*/
public static String desensitizedName(String realName) {
if (realName == null) {
return null;
}
if (realName.length() == ONE) {
return realName;
} else if (realName.length() == TWO) {
return realName.substring(0, 1) +"*";
} else {
Integer length = realName.length();
StringBuffer middle = new StringBuffer();
for (int i = 0; i < realName.substring(1, length - 1).length(); i++) {
middle.append("*");
}
return realName.substring(0, 1) + middle + realName.substring(length - 1, length);
}
}
/**
*
*
* @param address
* @return
*/
public static String desensitizedAddress(String address){
//江西省宜春市丰城市剑南街道人才教育小区41号丰城住总运营有限公司-->江西省宜春市丰城市剑南街道人才教育小区*************
if (StringUtils.isNotEmpty(address)) {
int length = address.length();
int indes = address.indexOf("区");
if (indes == -1) {
indes = address.indexOf("市");
}
address = address.substring(0, indes + 1);
StringBuffer middle = new StringBuffer();
for (int i = 0; i < length - indes; i++) {
middle.append("*");
}
return address + middle;
}
return address;
}
/**
*
*
* @param origin
* @param prefixNoMaskLen
* @param suffixNoMaskLen
* @param maskStr , '*'
* @return
*/
public static String desValue(String origin, int prefixNoMaskLen, int suffixNoMaskLen, String maskStr) {
if (origin == null) {
return null;
}
StringBuilder sb = new StringBuilder();
for (int i = 0, n = origin.length(); i < n; i++) {
if (i < prefixNoMaskLen) {
sb.append(origin.charAt(i));
continue;
}
if (i > (n - suffixNoMaskLen - 1)) {
sb.append(origin.charAt(i));
continue;
}
sb.append(maskStr);
}
return sb.toString();
}
/**
* **
*
* @param fullName
* @return
*/
public static String chineseName(String fullName) {
if (fullName == null) {
return null;
}
return desValue(fullName, 0, 1, "*");
}
}

View File

@ -0,0 +1,116 @@
package com.muyu.domain.util;
import org.apache.commons.lang3.StringUtils;
public class DesensitizationUtil {
/**
* [] 2<**>
*/
public static String chineseName(final String fullName) {
if (StringUtils.isBlank(fullName)) {
return "";
}
final String name = StringUtils.left(fullName, 1);
return StringUtils.rightPad(name, StringUtils.length(fullName), "*");
}
public static String chineseName(final String familyName, final String givenName) {
if (StringUtils.isBlank(familyName) || StringUtils.isBlank(givenName)) {
return "";
}
return chineseName(familyName + givenName);
}
/**
* [] 1815<*************5762>
*/
public static String annotationDTO(final String id) {
if (StringUtils.isBlank(id)) {
return "";
}
return StringUtils.left(id, 3).concat(StringUtils
.removeStart(StringUtils.leftPad(StringUtils.right(id, 3), StringUtils.length(id), "*"),
"***"));
}
/**
* [] <****1234>
*/
public static String fixedPhone(final String num) {
if (StringUtils.isBlank(num)) {
return "";
}
return StringUtils.leftPad(StringUtils.right(num, 4), StringUtils.length(num), "*");
}
/**
* [] <:138******1234>
*/
public static String mobilePhone(final String num) {
if (StringUtils.isBlank(num)) {
return "";
}
return StringUtils.left(num, 2).concat(StringUtils
.removeStart(StringUtils.leftPad(StringUtils.right(num, 2), StringUtils.length(num), "*"),
"***"));
}
/**
* [] <****>
*
* @param sensitiveSize
*/
public static String address(final String address, final int sensitiveSize) {
if (StringUtils.isBlank(address)) {
return "";
}
final int length = StringUtils.length(address);
return StringUtils.rightPad(StringUtils.left(address, length - sensitiveSize), length, "*");
}
/**
* [] @<:g**@163.com>
*/
public static String email(final String email) {
if (StringUtils.isBlank(email)) {
return "";
}
final int index = StringUtils.indexOf(email, "@");
if (index <= 1) {
return email;
} else {
return StringUtils.rightPad(StringUtils.left(email, 1), index, "*")
.concat(StringUtils.mid(email, index, StringUtils.length(email)));
}
}
/**
* [] 1<:6222600**********1234>
*/
public static String bankCard(final String cardNum) {
if (StringUtils.isBlank(cardNum)) {
return "";
}
return StringUtils.left(cardNum, 6).concat(StringUtils.removeStart(
StringUtils.leftPad(StringUtils.right(cardNum, 4), StringUtils.length(cardNum), "*"),
"******"));
}
/**
* [] ,1<:12********>
*/
public static String cnapsCode(final String code) {
if (StringUtils.isBlank(code)) {
return "";
}
return StringUtils.rightPad(StringUtils.left(code, 2), StringUtils.length(code), "*");
}
public static void main(String[] args) {
System.out.println(DesensitizationUtil.chineseName("李王丽"));
}
}

View File

@ -0,0 +1,24 @@
package com.muyu.cloud.etl.controller;
import com.muyu.cloud.etl.service.AnnotationDTOService;
import com.muyu.common.core.web.controller.BaseController;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
/**
* @PackageName:com.muyu.cloud.etl.controller
* @ClassName:SensitiveController
* @Description:
* @author:
* @date: 2024/8/21 15:23
*/
@RestController
public class SensitiveController extends BaseController {
@Autowired
private AnnotationDTOService annotationDTOService;
// Desensitization
}

View File

@ -5,9 +5,9 @@ import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.domain.Source;
import com.muyu.domain.req.SourceReq;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -21,10 +21,10 @@ public class SourceController extends BaseController {
@Autowired
private SourceService sourceService;
//列表
@PostMapping("/list")
public Result<TableDataInfo<Source>> list(@RequestBody SourceReq sourceReq) {
@RequiresPermissions("etl:info:list")
@GetMapping("/list")
public Result<TableDataInfo<Source>> list(SourceReq sourceReq) {
startPage();
List<Source> list = sourceService.selectSourceList(sourceReq);
return getDataTable(list);
@ -33,6 +33,7 @@ public class SourceController extends BaseController {
/*
*
*/
@RequiresPermissions("etl:info:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SourceReq sourceReq) {
List<Source> list= sourceService.selectSourceList(sourceReq);
@ -40,27 +41,28 @@ public class SourceController extends BaseController {
util.exportExcel(response,list,"基础信息");
}
/**
*
*/
@RequiresPermissions("etl:info:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id) {
Source source= sourceService.getInfo(id);
return success(source);
}
/**
*
*/
@PostMapping("/insert")
@RequiresPermissions("etl:info:add")
@PostMapping
public Result add(@RequestBody Source sourceReq) {
return toAjax(sourceService.insertBasicConfigInfo(sourceReq));
}
//批量删除
@RequiresPermissions("etl:info:deleteIds")
@DeleteMapping("{ids}")
public Integer delete(@PathVariable("ids") String ids) {
return sourceService.deleteByIds(ids);
@ -69,22 +71,12 @@ public class SourceController extends BaseController {
/**
*
*/
@PostMapping("/update")
public Result update(@RequestBody Source sourceReq) {
return toAjax(sourceService.updataSource(sourceReq));
}
/**
*
*/
@PostMapping("/connectionTest")
public Result connectionTest(@RequestBody Source source) throws ServletException {
return toAjax(sourceService.connectionTest(source));
}
// @RequiresPermissions("etl:info:updata")
// @PostMapping
// public Result update(@RequestBody Source sourceReq) {
//
// return toAjax(sourceService.updataSource(sourceReq));
// }

View File

@ -0,0 +1,59 @@
package com.muyu.cloud.etl.controller;
import com.muyu.cloud.etl.service.SysJobService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.domain.job.SysJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static io.netty.handler.codec.http.multipart.DiskFileUpload.prefix;
/**
* @PackageName:com.muyu.cloud.etl.controller
* @ClassName:SysJobController
* @Description:
* @author:
* @date: 2024/8/21 22:37
*/
@RestController
@RequestMapping("/monitor/job")
public class SysJobController extends BaseController {
@Autowired
private SysJobService jobService;
@RequiresPermissions("monitor:job:view")
@GetMapping()
public String job()
{
return prefix + "/job";
}
@RequiresPermissions("monitor:job:list")
@PostMapping("/list")
public Result<TableDataInfo<SysJob>> list(SysJob job)
{
List<SysJob> list = jobService.selectJobList(job);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("monitor:job:changeStatus")
@PostMapping("/changeStatus")
public Result changeStatus(SysJob job)
{
SysJob newJob = jobService.selectJobById(job.getJobId());
newJob.setStatus(job.getStatus());
return Result.success(jobService.changeStatus(newJob));
}
}

View File

@ -0,0 +1,32 @@
package com.muyu.cloud.etl.controller;
import com.muyu.domain.DesensitizationAdmin;
import com.muyu.domain.dto.AnnotationDTO;
import com.muyu.domain.enumerate.Desensitization;
import com.muyu.domain.util.DesensitizationUtil;
import org.apache.catalina.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @PackageName:com.muyu.cloud.etl.controller
* @ClassName:Text2Controller
* @Description:
* @author:
* @date: 2024/8/21 21:01
*/
@RestController
public class Text2Controller {
@Desensitization //意思为当前返回的数据要进行脱敏
@RequestMapping("/datase")
public AnnotationDTO test(AnnotationDTO annotationDTO){
String s = DesensitizationUtil.chineseName(annotationDTO.getName());
annotationDTO.setName(s);
annotationDTO.setEmail(DesensitizationUtil.email(annotationDTO.getEmail()));
annotationDTO.setTel(DesensitizationUtil.email(annotationDTO.getTel()));
annotationDTO.setIdCard(DesensitizationUtil.email(annotationDTO.getIdCard()));
return annotationDTO;
}
}

View File

@ -0,0 +1,30 @@
package com.muyu.cloud.etl.controller;
import com.muyu.domain.dto.AnnotationDTO;
import com.muyu.domain.enumerate.Desensitization;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @PackageName:com.muyu.cloud.etl.controller
* @ClassName:TextController
* @Description:
* @author:
* @date: 2024/8/21 16:32
*/
@RestController
@Desensitization
@RequestMapping("/test")
public class TextController {
@GetMapping("/test-annotation")
public AnnotationDTO testAnnotation(AnnotationDTO annotationDTO) {
annotationDTO.setTel("1111111111111");
annotationDTO.setEmail("1437200980@qq.com");
annotationDTO.setIdCard("1342543654544322754635");
return annotationDTO;
}
}

View File

@ -0,0 +1,9 @@
package com.muyu.cloud.etl.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.domain.dto.AnnotationDTO;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface AnnotationDTOMapper extends BaseMapper<AnnotationDTO>{
}

View File

@ -10,7 +10,4 @@ import java.util.List;
@Mapper
public interface SourceMapper extends BaseMapper<Source> {
List<Source> selectSourceList(SourceReq sourceReq);
Integer updataSource(Source sourceReq);
}

View File

@ -0,0 +1,9 @@
package com.muyu.cloud.etl.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.domain.job.SysJob;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysJobMapper extends BaseMapper<SysJob> {
}

View File

@ -0,0 +1,8 @@
package com.muyu.cloud.etl.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.domain.dto.AnnotationDTO;
public interface AnnotationDTOService extends IService<AnnotationDTO> {
}

View File

@ -15,7 +15,6 @@ public interface SourceService extends IService<Source> {
Integer deleteByIds(String ids);
int updataSource(Source sourceReq);
// int updataSource(Source sourceReq);
int connectionTest(Source source);
}

View File

@ -0,0 +1,44 @@
package com.muyu.cloud.etl.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.domain.SourceType;
import com.muyu.domain.job.SysJob;
import java.util.List;
/**
* @PackageName:com.muyu.cloud.etl.service
* @ClassName:SysJobService
* @Description:
* @author:
* @date: 2024/8/21 22:42
*/
public interface SysJobService extends IService<SysJob> {
/**
* quartz
*
* @param job
* @return
*/
public List<SysJob> selectJobList(SysJob job);
/**
* ID
*
* @param jobId ID
* @return
*/
public SysJob selectJobById(Long jobId);
/**
*
*
* @param job
* @return
*/
public int changeStatus(SysJob job);
}

View File

@ -0,0 +1,20 @@
package com.muyu.cloud.etl.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.cloud.etl.mapper.AnnotationDTOMapper;
import com.muyu.cloud.etl.service.AnnotationDTOService;
import com.muyu.domain.dto.AnnotationDTO;
import org.springframework.stereotype.Service;
/**
* @PackageName:com.muyu.cloud.etl.service.impl
* @ClassName:SensitiveServiceImpl
* @Description:
* @author:
* @date: 2024/8/21 15:24
*/
@Service
public class AnnotationDTOServiceImpl extends ServiceImpl<AnnotationDTOMapper, AnnotationDTO> implements AnnotationDTOService {
}

View File

@ -9,9 +9,6 @@ import com.muyu.domain.req.SourceReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.List;
@Service
@ -46,32 +43,11 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
return delete;
}
@Override
public int updataSource(Source sourceReq) {
Integer i= sourceMapper.updataSource(sourceReq);
return i;
}
@Override
public int connectionTest(Source source) {
String host = source.getHost();
String port = source.getPort();
String databaseName = source.getDatabaseName();
String databaseType = source.getDatabaseType();
String url = "jdbc:" + databaseType + "://" + host + ":" + port + "/" + databaseName + "?" + source.getConnectionParams();
String user = source.getUsername();
String password = source.getPassword();
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return 1;
}
// @Override
// public int updataSource(Source sourceReq) {
// LambdaQueryWrapper<Source> lambdaQueryWrapper = new LambdaQueryWrapper<>();
// int update = sourceMapper.update(lambdaQueryWrapper);
// return update;
// }
}

View File

@ -0,0 +1,40 @@
package com.muyu.cloud.etl.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.cloud.etl.mapper.SourceTypeMapper;
import com.muyu.cloud.etl.mapper.SysJobMapper;
import com.muyu.cloud.etl.service.SourceTypeService;
import com.muyu.cloud.etl.service.SysJobService;
import com.muyu.domain.SourceType;
import com.muyu.domain.job.SysJob;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @PackageName:com.muyu.cloud.etl.service.impl
* @ClassName:SysJobServiceImpl
* @Description:
* @author:
* @date: 2024/8/22 0:35
*/
@Service
public class SysJobServiceImpl extends ServiceImpl<SysJobMapper, SysJob> implements SysJobService {
@Override
public List<SysJob> selectJobList(SysJob job) {
return List.of();
}
@Override
public SysJob selectJobById(Long jobId) {
return null;
}
@Override
public int changeStatus(SysJob job) {
return 0;
}
}

View File

@ -0,0 +1,66 @@
package com.muyu.cloud.rule.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.domain.rule.Rule;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @PackageName:com.muyu.cloud.rule
* @ClassName:RuleController
* @Description:
* @author:
* @date: 2024/8/22 2:10
*/
@RestController
@RequestMapping("/rule")
public class RuleController {
@Autowired
private RuleService ruleService;
/**
*
*
* @return
*/
@PostMapping("/list")
@Operation(summary = "查看规则", description = "规则")
public Result<List<Rule>> select(@RequestBody Rule rule) {
return Result.success(ruleService.select(rule));
}
/**
*
*
* @return
*/
@GetMapping("/update")
public Result update(@RequestBody Rule rule) {
return Result.success(ruleService.updateById(rule));
}
/**
*
*
* @return
*/
@GetMapping("/delete")
public Result delete(@RequestParam Integer id) {
return Result.success(ruleService.removeById(id));
}
/**
*
*
* @return
*/
@GetMapping("/insert")
public Result insert(@RequestBody Rule rule) {
return Result.success(ruleService.save(rule));
}
}

View File

@ -0,0 +1,10 @@
package com.muyu.cloud.rule.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.domain.rule.Rule;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface RuleMapper extends BaseMapper<Rule> {
}

View File

@ -0,0 +1,15 @@
package com.muyu.cloud.rule.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.domain.rule.Rule;
import java.util.List;
public interface RuleService extends IService<Rule> {
/**
*
* @param rule
* @return
*/
List<Rule> select(Rule rule);
}

View File

@ -0,0 +1,19 @@
package com.muyu.cloud.rule.service.impl
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import com.muyu.cloud.rule.mapper.RuleMapper
import com.muyu.cloud.rule.service.RuleService
import com.muyu.domain.SourceType
import com.muyu.domain.rule.Rule
import org.springframework.stereotype.Service
@Service
public class RuleServiceImpl extends ServiceImpl<RuleMapper, Rule> implements RuleService {
@Override
public List<Rule> select(Rule rule) {
LambdaQueryWrapper<Rule> sourceTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
return this.list(sourceTypeLambdaQueryWrapper);
}
}

View File

@ -7,7 +7,7 @@ nacos:
addr: 47.116.184.54:8848
user-name: nacos
password: nacos
namespace: cloud-2112
namespace: text
# Spring
spring:

View File

@ -21,27 +21,7 @@
<sql id="selectSourceList">
select id, data_resource_name,username,password, data_sources_system_name, host, port, database_type, database_name, init_link_num, max_link_num, max_wait_time, max_wait_times,connection_params, remark from source
</sql>
<update id="updataSource">
update source
<trim prefix="SET" suffixOverrides=",">
<if test="dataResourceName != null">data_resource_name = #{dataResourceName},</if>
<if test="dataSourcesSystemName != null">data_sources_system_name = #{dataSourcesSystemName},</if>
<if test="host != null">host = #{host},</if>
<if test="port != null">port = #{port},</if>
<if test="databaseType != null">database_type = #{databaseType},</if>
<if test="databaseName != null">database_name = #{databaseName},</if>
<if test="username != null">username = #{username},</if>
<if test="password != null">password = #{password},</if>
<if test="initLinkNum != null">init_link_num = #{initLinkNum},</if>
<if test="maxLinkNum != null">max_link_num = #{maxLinkNum},</if>
<if test="maxWaitTime != null">max_wait_time = #{maxWaitTime},</if>
<if test="maxWaitTimes != null">max_wait_times = #{maxWaitTimes},</if>
<if test="connectionParams != null">connection_params = #{connectionParams},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<!-- <select id="selectSourceList" resultType="com.muyu.domain.Source">-->
<!-- <select id="selectSourceList" resultType="com.muyu.domain.Source">-->
<!-- -->
<!-- </select>-->

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -24,4 +24,8 @@
</project>