Skip to content
Permalink
Browse files
handle service test error
  • Loading branch information
nzomkxia committed Jan 28, 2019
1 parent 2dc4729 commit cd3a22725951fca35775aad02d6ee9caab29b2f3
Showing 4 changed files with 36 additions and 11 deletions.
@@ -34,7 +34,11 @@ public ServiceTestController(GenericServiceImpl genericService, ProviderService

@RequestMapping(method = RequestMethod.POST)
public Object test(@PathVariable String env, @RequestBody ServiceTestDTO serviceTestDTO) {
return genericService.invoke(serviceTestDTO.getService(), serviceTestDTO.getMethod(), serviceTestDTO.getParameterTypes(), serviceTestDTO.getParams());
try {
return genericService.invoke(serviceTestDTO.getService(), serviceTestDTO.getMethod(), serviceTestDTO.getParameterTypes(), serviceTestDTO.getParams());
} catch (Exception e) {
throw e;
}
}

@RequestMapping(value = "/method", method = RequestMethod.GET)
@@ -29,13 +29,16 @@
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn id="execute" mt-0 color="primary" @click="executeMethod()">EXECUTE</v-btn>
<v-btn id="execute" mt-0 color="primary" @click="executeMethod()">{{$t('execute')}}</v-btn>
</v-card-actions>
</v-card>
</v-flex>
<v-flex class="test-result" lg12 xl6>
<v-card>
<v-card-title class="headline">Result</v-card-title>
<v-card-title class="headline">{{$t('result') }}
<span class="green--text" v-if="success===true">{{ $t('success')}}</span>
<span class="red--text" v-if="success===false">{{ $t('fail')}}</span>
</v-card-title>
<v-card-text>
<json-editor v-model="result" name="Result" readonly></json-editor>
</v-card-text>
@@ -48,15 +51,19 @@
<script>
import JsonEditor from '@/components/public/JsonEditor'
import Breadcrumb from '@/components/public/Breadcrumb'
import axios from 'axios'
export default {
name: 'TestMethod',
components: {
JsonEditor,
Breadcrumb
Breadcrumb,
axios
},
data () {
return {
baseURL: '/api/dev',
success: null,
breads: [
{
text: 'serviceSearch',
@@ -87,11 +94,17 @@
parameterTypes: this.method.parameterTypes,
params: this.method.json
}
this.$axios.post('/test', serviceTestDTO).then(response => {
if (response.status === 200) {
this.result = response.data
}
})
axios.post(this.baseURL + '/test', serviceTestDTO)
.then(response => {
if (response && response.status === 200) {
this.success = true
this.result = response.data
}
})
.catch(error => {
this.success = false
this.result = error.response.data
})
}
},
mounted () {
@@ -124,5 +124,9 @@ export default {
warnDeleteConfig: ' Are you sure to Delete Dubbo Config: ',
configNameHint: "Application name the config belongs to, use 'global'(without quotes) for global config",
configContent: 'Config Content',
testMethod: 'Test Method'
testMethod: 'Test Method',
execute: 'EXECUTE',
result: 'Result: ',
success: 'SUCCESS',
fail: 'FAIL'
}
@@ -124,5 +124,9 @@ export default {
warnDeleteConfig: ' 是否要删除Dubbo配置: ',
configNameHint: '配置所属的应用名, global 表示全局配置',
configContent: '配置内容',
testMethod: '测试方法'
testMethod: '测试方法',
execute: '执行',
result: '结果: ',
success: ' 成功',
fail: '失败'
}

0 comments on commit cd3a227

Please sign in to comment.