Commit d13791ea by yuwei

2.0.0项目初始化

parent dc41b1a8
# 数据源配置
spring:
mail:
host: smtp.qq.com
username: 312075478@qq.com
password: ohxmhfsefapibjee
protocol: smtp
default-encoding: utf-8
properties.mail.smtp.auth: true
properties.mail.smtp.port: 465
properties.mail.display.sendmail: 312075478@qq.com
properties.mail.display.sendname: 测试
properties.mail.smtp.starttls.enable: true
properties.mail.smtp.starttls.required: true
properties.mail.smtp.ssl.enable: true
from: 测试1
datasource:
dynamic:
type: com.zaxxer.hikari.HikariDataSource
......
......@@ -64,8 +64,8 @@ public class DataApiDto implements Serializable {
private List<ReqParam> reqParams;
@ApiModelProperty(value = "返回参数")
@Valid
@NotEmpty(message = "返回参数不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
@Size(min = 1, message="返回参数长度不能少于{min}位")
@NotEmpty(message = "返回字段不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
@Size(min = 1, message="返回字段长度不能少于{min}位")
private List<ResParam> resParams;
@ApiModelProperty(value = "状态")
@NotNull(message = "状态不能为空", groups = {ValidationGroups.Insert.class, ValidationGroups.Update.class})
......
......@@ -87,7 +87,7 @@ public class DataApiEntity extends DataScopeBaseEntity {
private List<ReqParam> reqParams;
/**
* 返回参数
* 返回字段
*/
@TableField(value = "res_json", typeHandler = JacksonTypeHandler.class)
private List<ResParam> resParams;
......
......@@ -173,7 +173,7 @@ public class DataApiServiceImpl extends BaseServiceImpl<DataApiDao, DataApiEntit
List<ReqParam> reqParams = variables.stream().map(s -> {
ReqParam reqParam = new ReqParam();
reqParam.setParamName(s);
reqParam.setNullable(DataConstant.TrueOrFalse.TRUE.getKey());
reqParam.setNullable(DataConstant.TrueOrFalse.FALSE.getKey());
return reqParam;
}).collect(Collectors.toList());
sqlParseVo.setReqParams(reqParams);
......
......@@ -5,44 +5,18 @@ import cn.datax.service.email.service.EmailService;
import cn.datax.service.email.utils.EmailUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeUtility;
import java.io.UnsupportedEncodingException;
@Slf4j
@Service
public class EmailServiceImpl implements EmailService {
@Value("${spring.mail.from}")
private String fromNick;
@Value("${spring.mail.username}")
private String fromAddress;
@Autowired
private JavaMailSender mailSender;
private EmailUtil emailUtil;
@Override
public void sendEmail(EmailEntity emailEntity) {
log.info("实体类 {}", emailEntity);
InternetAddress from = null;
String alias = null;
try {
alias = MimeUtility.encodeText(fromNick);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try {
from = new InternetAddress(alias + " <" + fromAddress + ">");
} catch (AddressException e) {
e.printStackTrace();
}
EmailUtil emailUtil = new EmailUtil(from, mailSender);
try {
emailUtil.sendEmail(emailEntity);
} catch (Exception e) {
......
......@@ -2,27 +2,47 @@ package cn.datax.service.email.utils;
import cn.datax.service.email.api.entity.EmailEntity;
import cn.hutool.core.collection.CollUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeUtility;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.List;
@Component
public class EmailUtil {
private InternetAddress from;
private JavaMailSender mailSender;
@Value("${spring.mail.from}")
private String fromNick;
public EmailUtil(InternetAddress from, JavaMailSender mailSender) {
this.from = from;
this.mailSender = mailSender;
}
@Value("${spring.mail.username}")
private String fromAddress;
@Autowired
private JavaMailSender mailSender;
public void sendEmail(EmailEntity mailEntity) throws Exception {
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
InternetAddress from = null;
String alias = null;
try {
alias = MimeUtility.encodeText(fromNick);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try {
from = new InternetAddress(alias + " <" + fromAddress + ">");
} catch (AddressException e) {
e.printStackTrace();
}
helper.setFrom(from);
helper.setSubject(mailEntity.getSubject());
helper.setText(mailEntity.getText(),true);
......@@ -45,5 +65,4 @@ public class EmailUtil {
}
mailSender.send(mimeMessage);
}
}
......@@ -4,33 +4,47 @@
<div slot="header" class="clearfix">
<span>{{ title }}</span>
<el-button-group style="float: right;">
<el-button size="mini" icon="el-icon-s-data" round @click="dataPreview">数据预览</el-button>
<el-button size="mini" icon="el-icon-back" round @click="showCard">返回</el-button>
</el-button-group>
</div>
<div :style="classCardbody">
<el-form ref="form" :model="form" label-width="80px" disabled>
<el-form-item label="数据源" prop="sourceId">
<el-select v-model="form.sourceId" placeholder="请选择数据源">
<el-form ref="form" :model="form" :rules="rules" label-width="80px" disabled>
<el-form-item label="数据API" prop="apiId">
<el-select v-model="form.apiId" placeholder="请选择数据API">
<el-option
v-for="source in sourceOptions"
:key="source.id"
:label="source.sourceName"
:value="source.id"
:disabled="source.status === '0'"
v-for="api in apiOptions"
:key="api.id"
:label="api.apiName"
:value="api.id"
:disabled="api.status === '0'"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="数据集名称" prop="setName">
<el-input v-model="form.setName" placeholder="请输入数据集名称" />
<el-form-item label="脱敏名称" prop="maskName">
<el-input v-model="form.maskName" placeholder="请输入脱敏名称" />
</el-form-item>
<el-form-item label="数据集sql" prop="setSql">
<sql-editor
ref="sqleditor"
:value="form.setSql"
:readOnly="true"
style="height: 300px;"
></sql-editor>
<el-form-item label="脱敏字段规则配置" prop="rules">
<el-table :data="resParamList" stripe border
:max-height="300"
style="width: 100%; margin: 15px 0;">
<el-table-column label="序号" width="55" align="center">
<template slot-scope="scope">
<span>{{ scope.$index +1 }}</span>
</template>
</el-table-column>
<el-table-column prop="fieldName" label="字段名称" align="center" show-overflow-tooltip >
</el-table-column>
<el-table-column prop="remark" label="描述" align="center" show-overflow-tooltip >
</el-table-column>
<el-table-column prop="dataType" label="数据类型" align="center" show-overflow-tooltip >
</el-table-column>
<el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip >
</el-table-column>
<el-table-column prop="cipherType" label="脱敏类型" align="center" show-overflow-tooltip >
</el-table-column>
<el-table-column prop="cryptType" label="规则类型" align="center" show-overflow-tooltip >
</el-table-column>
</el-table>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="form.status">
......@@ -45,53 +59,17 @@
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<el-drawer
:visible.sync="drawer"
direction="btt"
:with-header="false">
<el-table :data="previewData.dataList" stripe border
:max-height="200"
style="width: 100%; margin: 15px 0;">
<el-table-column label="序号" width="55" align="center">
<template slot-scope="scope">
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<template v-for="(column, index) in previewData.columnList">
<el-table-column
:prop="column"
:label="column"
:key="index"
align="center"
show-overflow-tooltip
/>
</template>
</el-table>
<el-pagination
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="previewData.pageNum"
:page-size.sync="previewData.pageSize"
:total="previewData.dataTotal"
></el-pagination>
</el-drawer>
</div>
</el-card>
</div>
</template>
<script>
import { getDataSet } from '@/api/factory/dataset'
import { listDataSource, queryByPage } from '@/api/factory/datasource'
import SqlEditor from '@/components/SqlEditor'
import { getApiMask } from '@/api/market/apimask'
import { listDataApi } from '@/api/market/dataapi'
export default {
name: 'ApiMaskDetail',
components: {
SqlEditor
},
props: {
data: {
type: Object,
......@@ -116,19 +94,26 @@ export default {
showDetail: false
},
// 表单参数
form: {},
form: {
id: undefined,
apiId: undefined,
maskName: undefined,
rules: [],
status: '1',
remark: undefined
},
// 状态数据字典
statusOptions: [],
// 数据数据字典
sourceOptions: [],
drawer: false,
previewData: {
dataList: [],
columnList: [],
pageNum: 1,
pageSize: 20,
dataTotal: 0
}
// 数据API数据字典
apiOptions: [],
// 脱敏字段信息
resParamList: [],
// 脱敏类型数据字典
cipherTypeOptions: [],
// 正则替换数据字典
regexCryptoOptions: [],
// 加密算法数据字典
algorithmCryptoOptions: []
}
},
created () {
......@@ -138,64 +123,60 @@ export default {
this.statusOptions = response.data
}
})
this.getDataSourceList()
this.getDataSet(this.data.id)
this.getDataApiList()
this.getDicts('data_cipher_type').then(response => {
if (response.success) {
this.cipherTypeOptions = response.data
}
})
this.getDicts('data_regex_crypto').then(response => {
if (response.success) {
this.regexCryptoOptions = response.data
}
})
this.getDicts('data_algorithm_crypto').then(response => {
if (response.success) {
this.algorithmCryptoOptions = response.data
}
})
this.getApiMask(this.data.id)
},
methods: {
showCard () {
this.$emit('showCard', this.showOptions)
},
getDataSourceList () {
listDataSource().then(response => {
getDataApiList () {
listDataApi().then(response => {
if (response.success) {
this.sourceOptions = response.data
this.apiOptions = response.data
}
})
},
/** 获取详情 */
getDataSet: function (id) {
getDataSet(id).then(response => {
getApiMask: function (id) {
getApiMask(id).then(response => {
if (response.success) {
this.form = response.data
this.$refs.sqleditor.editor.setValue(this.form.setSql)
}
this.resParamList = this.apiOptions.filter(item => item.id === this.form.apiId).map(function (item) {
return item.resParams
})
},
dataPreview () {
if (!this.form.sourceId) {
return
}
if (!this.form.setSql) {
return
}
let data = {}
data.dataSourceId = this.form.sourceId
data.sql = this.form.setSql
data.pageNum = this.previewData.pageNum
data.pageSize = this.previewData.pageSize
queryByPage(data).then(response => {
if (response.success) {
const { data } = response
let dataList = data.data || []
let columnList = []
if (dataList.length > 0) {
columnList = Object.keys(dataList[0])
this.form.rules.forEach(rule => {
let fieldParamIndex = this.resParamList.findIndex((param) => {
return param.fieldName === rule.fieldName
})
if (fieldParamIndex != -1) {
let cipher = this.cipherTypeOptions.find((item) => {
return item.itemText === rule.cipherType
})
let crypt = this.cryptTypeOptions.find((item) => {
return item.itemText === rule.cryptType
})
let resParam = Object.assign({}, this.resParamList[fieldParamIndex], { cipherType: (cipher && cipher.itemValue) || undefined, cryptType: (crypt && crypt.itemValue) || undefined })
this.$set(this.resParamList, fieldParamIndex, resParam)
}
this.previewData.dataList = dataList
this.previewData.columnList = columnList
this.previewData.dataTotal = data.total
this.drawer = true
})
}
})
},
handleSizeChange (val) {
this.previewData.pageNum = 1
this.previewData.pageSize = val
this.dataPreview()
},
handleCurrentChange (val) {
this.previewData.pageNum = val
this.dataPreview()
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment