Commit d0b02276 by yuwei

2.0.0项目初始化

parent 15f0d08b
package cn.datax.service.data.market.api.call.controller;
import cn.datax.common.base.BaseController;
import cn.datax.common.core.R;
import cn.datax.service.data.market.api.call.service.ApiHeaderService;
import cn.datax.service.data.market.api.vo.ApiHeader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ApiHeaderController extends BaseController {
@Autowired
private ApiHeaderService apiHeaderService;
@GetMapping(value = "/{id}/header")
public R getApiHeader(@PathVariable String id){
ApiHeader apiHeader = apiHeaderService.getApiHeader(id);
return R.ok().setData(apiHeader);
}
}
package cn.datax.service.data.market.api.call.service;
import cn.datax.service.data.market.api.vo.ApiHeader;
public interface ApiHeaderService {
ApiHeader getApiHeader(String id);
}
package cn.datax.service.data.market.api.call.service.impl;
import cn.datax.common.utils.MD5Util;
import cn.datax.common.utils.SecurityUtil;
import cn.datax.service.data.market.api.call.service.ApiHeaderService;
import cn.datax.service.data.market.api.vo.ApiHeader;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class ApiHeaderServiceImpl implements ApiHeaderService {
@Override
public ApiHeader getApiHeader(String id) {
ApiHeader apiHeader = new ApiHeader();
try {
MD5Util mt = MD5Util.getInstance();
apiHeader.setApiKey(mt.encode(id));
apiHeader.setSecretKey(mt.encode(SecurityUtil.getUserId()));
} catch (Exception e) {
}
return apiHeader;
}
}
package cn.datax.service.data.market.api.vo;
import lombok.Data;
import java.io.Serializable;
@Data
public class ApiHeader implements Serializable {
private static final long serialVersionUID=1L;
private String authorization;
private String apiKey;
private String secretKey;
}
......@@ -6,6 +6,7 @@ import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class SqlParseVo implements Serializable {
......
......@@ -2,12 +2,15 @@ package cn.datax.service.data.market.service.impl;
import cn.datax.common.base.BaseServiceImpl;
import cn.datax.common.core.RedisConstant;
import cn.datax.common.exception.DataException;
import cn.datax.service.data.market.api.dto.ApiMaskDto;
import cn.datax.service.data.market.api.entity.ApiMaskEntity;
import cn.datax.service.data.market.dao.ApiMaskDao;
import cn.datax.service.data.market.mapstruct.ApiMaskMapper;
import cn.datax.service.data.market.service.ApiMaskService;
import cn.datax.service.system.api.entity.DeptEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
......@@ -42,6 +45,11 @@ public class ApiMaskServiceImpl extends BaseServiceImpl<ApiMaskDao, ApiMaskEntit
@Transactional(rollbackFor = Exception.class)
public void saveApiMask(ApiMaskDto apiMaskDto) {
ApiMaskEntity apiMask = apiMaskMapper.toEntity(apiMaskDto);
// 校验api唯一
int n = apiMaskDao.selectCount(Wrappers.<ApiMaskEntity>lambdaQuery().eq(ApiMaskEntity::getApiId, apiMask.getApiId()));
if(n > 0){
throw new DataException("该api已进行过脱敏配置");
}
apiMaskDao.insert(apiMask);
}
......
import request from '@/utils/request'
export function getApiCall (data) {
export function getApiHeader (id) {
return request({
url: '/data/api/v1/list',
url: '/data/api/' + id + '/header',
method: 'get'
})
}
export function getApiCall (url, header, data) {
return request({
url: '/data/api/v1' + url,
method: 'get',
headers: header,
params: data
})
}
export function postApiCall (data) {
export function postApiCall (url, header, data) {
return request({
url: '/data/api/v1/list',
url: '/data/api/v1' + url,
method: 'post',
headers: header,
data: data
})
}
......@@ -137,7 +137,7 @@ export default {
// 表单校验
rules: {
sourceId: [
{ required: true, message: '数据源不能为空', trigger: 'blur' }
{ required: true, message: '数据源不能为空', trigger: 'change' }
],
setName: [
{ required: true, message: '数据集名称不能为空', trigger: 'blur' }
......
......@@ -130,6 +130,9 @@ export default {
form: {},
// 表单校验
rules: {
sourceId: [
{ required: true, message: '数据源不能为空', trigger: 'change' }
],
setName: [
{ required: true, message: '数据集名称不能为空', trigger: 'blur' }
]
......
......@@ -11,7 +11,7 @@
<div :style="classCardbody">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="数据API" prop="apiId">
<el-select v-model="form.apiId" placeholder="请选择数据API" @change="apiSelectChanged">
<el-select v-model="form.apiId" placeholder="请选择数据API" disabled >
<el-option
v-for="api in apiOptions"
:key="api.id"
......@@ -254,11 +254,6 @@ export default {
}
})
},
apiSelectChanged (val) {
this.resParamList = this.apiOptions.find(function (item) {
return item.id === val
}).resParams
},
fieldRule (fieldName) {
this.cipher.open = true
this.form2.fieldName = fieldName
......
......@@ -186,36 +186,44 @@
</el-table-column>
<el-table-column prop="paramType" label="参数类型" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-select v-model="scope.row.paramType" placeholder="请选择参数类型">
<el-option
v-for="dict in paramTypeOptions"
:key="dict.id"
:label="dict.itemValue"
:value="dict.itemText"
></el-option>
</el-select>
<el-form-item :prop=" 'reqParams.' + scope.$index + '.paramType' " :rules="rules3.paramType">
<el-select v-model="scope.row.paramType" placeholder="请选择参数类型">
<el-option
v-for="dict in paramTypeOptions"
:key="dict.id"
:label="dict.itemValue"
:value="dict.itemText"
></el-option>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="whereType" label="操作符" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-select v-model="scope.row.whereType" placeholder="请选择操作符">
<el-option
v-for="dict in whereTypeOptions"
:key="dict.id"
:label="dict.itemValue"
:value="dict.itemText"
></el-option>
</el-select>
<el-form-item :prop=" 'reqParams.' + scope.$index + '.whereType' " :rules="rules3.whereType">
<el-select v-model="scope.row.whereType" placeholder="请选择操作符">
<el-option
v-for="dict in whereTypeOptions"
:key="dict.id"
:label="dict.itemValue"
:value="dict.itemText"
></el-option>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
<el-form-item :prop=" 'reqParams.' + scope.$index + '.exampleValue' " :rules="rules3.exampleValue">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="defaultValue" label="默认值" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-input v-model="scope.row.defaultValue" placeholder="请输入默认值" />
<el-form-item :prop=" 'reqParams.' + scope.$index + '.defaultValue' " :rules="rules3.defaultValue">
<el-input v-model="scope.row.defaultValue" placeholder="请输入默认值" />
</el-form-item>
</template>
</el-table-column>
</el-table>
......@@ -237,7 +245,9 @@
</el-table-column>
<el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
<el-form-item :prop=" 'resParams.' + scope.$index + '.exampleValue' " :rules="rules3.exampleValue">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
</el-form-item>
</template>
</el-table-column>
</el-table>
......@@ -281,7 +291,8 @@ export default {
showList: true,
showAdd: false,
showEdit: false,
showDetail: false
showDetail: false,
showCall: false
},
// 保存按钮
loadingOptions: {
......@@ -320,10 +331,10 @@ export default {
{ required: true, message: 'API路径不能为空', trigger: 'blur' }
],
reqMethod: [
{ required: true, message: '请求方式不能为空', trigger: 'blur' }
{ required: true, message: '请求方式不能为空', trigger: 'change' }
],
resType: [
{ required: true, message: '返回格式不能为空', trigger: 'blur' }
{ required: true, message: '返回格式不能为空', trigger: 'change' }
]
},
form2: {
......@@ -335,17 +346,30 @@ export default {
},
rules2: {
configType: [
{ required: true, message: '配置方式不能为空', trigger: 'blur' }
{ required: true, message: '配置方式不能为空', trigger: 'change' }
],
sourceId: [
{ required: true, message: '数据源不能为空', trigger: 'blur' }
{ required: true, message: '数据源不能为空', trigger: 'change' }
]
},
form3: {
reqParams: [],
resParams: []
},
rules3: {},
rules3: {
paramType: [
{ required: true, message: '参数类型不能为空', trigger: 'change' }
],
whereType: [
{ required: true, message: '操作符不能为空', trigger: 'change' }
],
exampleValue: [
{ required: true, message: '示例值不能为空', trigger: 'blur' }
],
defaultValue: [
{ required: true, message: '默认值不能为空', trigger: 'blur' }
]
},
// 请求方式数据字典
reqMethodOptions: [],
// 返回格式数据字典
......
......@@ -4,6 +4,7 @@
<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="apiCall">数据调用</el-button>
<el-button size="mini" icon="el-icon-back" round @click="showCard">返回</el-button>
</el-button-group>
</div>
......@@ -13,7 +14,7 @@
<el-step title="执行配置"></el-step>
<el-step title="参数配置"></el-step>
</el-steps>
<el-form ref="form1" :model="form1" :rules="rules1" label-width="80px" v-if="active == 1" disabled>
<el-form ref="form1" :model="form1" label-width="80px" v-if="active == 1" disabled>
<el-form-item label="API名称" prop="apiName">
<el-input v-model="form1.apiName" placeholder="请输入API名称" />
</el-form-item>
......@@ -74,7 +75,7 @@
<el-input v-model="form1.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<el-form ref="form2" :model="form2" :rules="rules2" label-width="80px" v-if="active == 2" disabled>
<el-form ref="form2" :model="form2" label-width="80px" v-if="active == 2" disabled>
<el-form-item label="配置方式" prop="configType">
<el-select v-model="form2.configType" placeholder="请选择配置方式">
<el-option
......@@ -161,7 +162,7 @@
</el-col>
</el-row>
</el-form>
<el-form ref="form3" :model="form3" :rules="rules3" label-width="80px" v-if="active == 3" disabled>
<el-form ref="form3" :model="form3" label-width="80px" v-if="active == 3" disabled>
<el-form-item label="请求参数">
<el-table :data="form3.reqParams" stripe border
:max-height="300"
......@@ -205,14 +206,8 @@
</template>
</el-table-column>
<el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
</template>
</el-table-column>
<el-table-column prop="defaultValue" label="默认值" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-input v-model="scope.row.defaultValue" placeholder="请输入默认值" />
</template>
</el-table-column>
</el-table>
</el-form-item>
......@@ -232,9 +227,6 @@
<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 >
<template slot-scope="scope">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
</template>
</el-table-column>
</el-table>
</el-form-item>
......@@ -277,7 +269,8 @@ export default {
showList: true,
showAdd: false,
showEdit: false,
showDetail: false
showDetail: false,
showCall: false
},
active: 1,
// 表单参数
......@@ -462,6 +455,15 @@ export default {
}
}
})
},
apiCall () {
this.showOptions.data.id = this.data.id
this.showOptions.showList = false
this.showOptions.showAdd = false
this.showOptions.showEdit = false
this.showOptions.showDetail = false
this.showOptions.showCall = true
this.$emit('showCard', this.showOptions)
}
}
}
......
......@@ -186,36 +186,44 @@
</el-table-column>
<el-table-column prop="paramType" label="参数类型" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-select v-model="scope.row.paramType" placeholder="请选择参数类型">
<el-option
v-for="dict in paramTypeOptions"
:key="dict.id"
:label="dict.itemValue"
:value="dict.itemText"
></el-option>
</el-select>
<el-form-item :prop=" 'reqParams.' + scope.$index + '.paramType' " :rules="rules3.paramType">
<el-select v-model="scope.row.paramType" placeholder="请选择参数类型">
<el-option
v-for="dict in paramTypeOptions"
:key="dict.id"
:label="dict.itemValue"
:value="dict.itemText"
></el-option>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="whereType" label="操作符" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-select v-model="scope.row.whereType" placeholder="请选择操作符">
<el-option
v-for="dict in whereTypeOptions"
:key="dict.id"
:label="dict.itemValue"
:value="dict.itemText"
></el-option>
</el-select>
<el-form-item :prop=" 'reqParams.' + scope.$index + '.whereType' " :rules="rules3.whereType">
<el-select v-model="scope.row.whereType" placeholder="请选择操作符">
<el-option
v-for="dict in whereTypeOptions"
:key="dict.id"
:label="dict.itemValue"
:value="dict.itemText"
></el-option>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
<el-form-item :prop=" 'reqParams.' + scope.$index + '.exampleValue' " :rules="rules3.exampleValue">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
</el-form-item>
</template>
</el-table-column>
<el-table-column prop="defaultValue" label="默认值" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-input v-model="scope.row.defaultValue" placeholder="请输入默认值" />
<el-form-item :prop=" 'reqParams.' + scope.$index + '.defaultValue' " :rules="rules3.defaultValue">
<el-input v-model="scope.row.defaultValue" placeholder="请输入默认值" />
</el-form-item>
</template>
</el-table-column>
</el-table>
......@@ -237,7 +245,9 @@
</el-table-column>
<el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
<el-form-item :prop=" 'resParams.' + scope.$index + '.exampleValue' " :rules="rules3.exampleValue">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
</el-form-item>
</template>
</el-table-column>
</el-table>
......@@ -281,7 +291,8 @@ export default {
showList: true,
showAdd: false,
showEdit: false,
showDetail: false
showDetail: false,
showCall: false
},
// 保存按钮
loadingOptions: {
......@@ -320,10 +331,10 @@ export default {
{ required: true, message: 'API路径不能为空', trigger: 'blur' }
],
reqMethod: [
{ required: true, message: '请求方式不能为空', trigger: 'blur' }
{ required: true, message: '请求方式不能为空', trigger: 'change' }
],
resType: [
{ required: true, message: '返回格式不能为空', trigger: 'blur' }
{ required: true, message: '返回格式不能为空', trigger: 'change' }
]
},
form2: {
......@@ -335,17 +346,30 @@ export default {
},
rules2: {
configType: [
{ required: true, message: '配置方式不能为空', trigger: 'blur' }
{ required: true, message: '配置方式不能为空', trigger: 'change' }
],
sourceId: [
{ required: true, message: '数据源不能为空', trigger: 'blur' }
{ required: true, message: '数据源不能为空', trigger: 'change' }
]
},
form3: {
reqParams: [],
resParams: []
},
rules3: {},
rules3: {
paramType: [
{ required: true, message: '参数类型不能为空', trigger: 'change' }
],
whereType: [
{ required: true, message: '操作符不能为空', trigger: 'change' }
],
exampleValue: [
{ required: true, message: '示例值不能为空', trigger: 'blur' }
],
defaultValue: [
{ required: true, message: '默认值不能为空', trigger: 'blur' }
]
},
// 请求方式数据字典
reqMethodOptions: [],
// 返回格式数据字典
......
......@@ -173,7 +173,8 @@ export default {
showList: true,
showAdd: false,
showEdit: false,
showDetail: false
showDetail: false,
showCall: false
},
// 遮罩层
loading: true,
......@@ -272,6 +273,7 @@ export default {
this.showOptions.showAdd = true
this.showOptions.showEdit = false
this.showOptions.showDetail = false
this.showOptions.showCall = false
this.$emit('showCard', this.showOptions)
},
/** 修改按钮操作 */
......@@ -281,6 +283,7 @@ export default {
this.showOptions.showAdd = false
this.showOptions.showEdit = true
this.showOptions.showDetail = false
this.showOptions.showCall = false
this.$emit('showCard', this.showOptions)
},
/** 详情按钮操作 */
......@@ -290,6 +293,7 @@ export default {
this.showOptions.showAdd = false
this.showOptions.showEdit = false
this.showOptions.showDetail = true
this.showOptions.showCall = false
this.$emit('showCard', this.showOptions)
},
/** 删除按钮操作 */
......
......@@ -12,6 +12,9 @@
<transition name="el-zoom-in-bottom">
<data-api-detail v-if="options.showDetail" :data="options.data" @showCard="showCard"></data-api-detail>
</transition>
<transition name="el-zoom-in-bottom">
<data-api-call v-if="options.showCall" :data="options.data" @showCard="showCard"></data-api-call>
</transition>
</div>
</template>
......@@ -20,10 +23,11 @@ import DataApiList from './DataApiList'
import DataApiAdd from './DataApiAdd'
import DataApiEdit from './DataApiEdit'
import DataApiDetail from './DataApiDetail'
import DataApiCall from './DataApiCall'
export default {
name: 'DataApi',
components: { DataApiList, DataApiAdd, DataApiEdit, DataApiDetail },
components: { DataApiList, DataApiAdd, DataApiEdit, DataApiDetail, DataApiCall },
data () {
return {
options: {
......@@ -31,7 +35,8 @@ export default {
showList: true,
showAdd: false,
showEdit: false,
showDetail: false
showDetail: false,
showCall: false
}
}
},
......
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