Skip to content

Commit 53ffa82

Browse files
author
cookie
committed
1.修复sql语句中因为有;号导致语句分割错误的问题
2.修复数据源全部删除时会报错的显示问题 3.工单说明修改为textarea类型 4.修改数据源删除二次确认提示
1 parent e9ab8c8 commit 53ffa82

File tree

8 files changed

+21
-12
lines changed

8 files changed

+21
-12
lines changed

src/core/api/auditorder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import ast
44
import threading
55
import datetime
6+
import sqlparse
67
from libs import baseview, call_inception, util, serializers, send_email
78
from rest_framework.response import Response
89
from django.http import HttpResponse
@@ -268,7 +269,8 @@ def get(self, request, args: str = None):
268269
bundle = request.GET.get('bundle_id')
269270
baseCon = DatabaseList.objects.filter(id=bundle).first()
270271
sql = SqlOrder.objects.filter(id=id).only('sql').first()
271-
return Response({'sql': sql.sql, 'comRoom': baseCon.computer_room, 'conn': baseCon.connection_name})
272+
ser_sql = sqlparse.split(sql.sql)
273+
return Response({'sql': json.dumps(ser_sql), 'comRoom': baseCon.computer_room, 'conn': baseCon.connection_name})
272274

273275

274276
def push_message(message=None, type=None, user=None, to_addr=None, work_id=None, status=None):

src/core/api/managerdb.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ def get(self, request, args=None):
6868
computer_room__contains=con['computer_room'])[start:end]
6969
else:
7070
page_number = DatabaseList.objects.count()
71+
if page_number == 0:
72+
return Response(
73+
{
74+
'page': page_number,
75+
'data': [],
76+
'custom': custom_com['con_room']
77+
}
78+
)
7179
info = DatabaseList.objects.all().order_by('connection_name')[start:end]
7280
serializers = Sqllist(info, many=True)
7381

src/core/api/sqlorder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import json
3+
import sqlparse
34
from libs import baseview, util
45
from libs import call_inception
56
from core.task import submit_push_messages
@@ -46,7 +47,6 @@ def put(self, request, args=None):
4647
id = request.data['id']
4748
base = request.data['base']
4849
sql = request.data['sql']
49-
sql = str(sql).strip('\n').strip().rstrip(';')
5050
data = DatabaseList.objects.filter(id=id).first()
5151
info = {
5252
'host': data.ip,
@@ -78,10 +78,10 @@ def post(self, request, args=None):
7878
return HttpResponse(status=500)
7979
else:
8080
try:
81-
x = [x.rstrip(';') for x in tmp]
81+
x = [x for x in sqlparse.split(tmp)]
8282
if str(x[0]).lstrip().startswith('use'):
8383
del x[0]
84-
sql = ';'.join(x)
84+
sql = ''.join(x)
8585
sql = sql.strip(' ').rstrip(';')
8686
workId = util.workId()
8787
SqlOrder.objects.get_or_create(

webpage/src/components/audit/sqlAudit.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,7 @@
401401
this.tableData[index].status === 2 ? this.switch_show = true : this.switch_show = false
402402
axios.get(`${this.$config.url}/getsql?id=${this.formitem.id}&bundle_id=${this.formitem.bundle_id}`)
403403
.then(res => {
404-
let tmpSql = res.data.sql.split(';')
405-
for (let i of tmpSql) {
404+
for (let i of JSON.parse(res.data.sql)) {
406405
this.sql.push({'sql': i})
407406
}
408407
this.formitem.computer_room = res.data.comRoom

webpage/src/components/home/home.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<Col span="8">
5151
<p class="notwrap">当前版本:</p>
5252
</Col>
53-
<Col span="16" class="padding-left-8"> <a target="_Blank" href="https://cookiey.github.io/Yearning-document/update/">v1.4.2</a></Col>
53+
<Col span="16" class="padding-left-8"> <a target="_Blank" href="https://cookiey.github.io/Yearning-document/update/">v1.4.4</a></Col>
5454
</Row>
5555
</Card>
5656
</Row>

webpage/src/components/management/databaseManager.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<Button type="success" size="small" @click="dingInfoModal(row)" style="margin-right: 5px">钉钉消息</Button>
5757
<Poptip
5858
confirm
59-
title="确定要删除此连接名吗"
59+
title="删除数据源将会删除对应的所有工单信息,确定要删除吗"
6060
@on-ok="delConnection(row)">
6161
<Button type="warning" size="small">删除</Button>
6262
</Poptip>

webpage/src/components/order/ddlOrder.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ p {
5656
<Button type="error" @click="canel()">重置</Button>
5757
</Form-item>
5858
<FormItem label="工单提交说明:" prop="text">
59-
<Input v-model="formItem.text" placeholder="请输入工单说明"></Input>
59+
<Input v-model="formItem.text" placeholder="请输入工单说明" type="textarea" rows="4"></Input>
6060
</FormItem>
6161
<FormItem label="指定审核人:" prop="assigned">
6262
<Select v-model="formItem.assigned" filterable transfer>
@@ -459,7 +459,7 @@ export default {
459459
commitOrder () {
460460
this.$refs['formItem'].validate((valid) => {
461461
if (valid) {
462-
let sql = this.formDynamic.replace(/(;|;)$/gi, '').replace(/\s/g, ' ').replace(//g, ';').split(';')
462+
let sql = this.formDynamic.replace(/(;|;)$/gi, '').replace(/\s/g, ' ').replace(//g, ';')
463463
axios.post(`${this.$config.url}/sqlsyntax/`, {
464464
'data': JSON.stringify(this.formItem),
465465
'sql': JSON.stringify(sql),

webpage/src/components/order/dmlOrder.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</FormItem>
4545

4646
<FormItem label="工单说明:" prop="text">
47-
<Input v-model="formItem.text" placeholder="请输入"></Input>
47+
<Input v-model="formItem.text" placeholder="请输入" type="textarea" rows="4"></Input>
4848
</FormItem>
4949

5050
<FormItem label="指定审核人:" prop="assigned">
@@ -323,7 +323,7 @@
323323
this.$refs['formItem'].validate((valid) => {
324324
if (valid) {
325325
if (this.formItem.textarea) {
326-
this.datalist.sqllist = this.formItem.textarea.replace(/(;|;)$/gi, '').replace(/\s/g, ' ').replace(//g, ';').split(';')
326+
this.datalist.sqllist = this.formItem.textarea.replace(/(;|;)$/gi, '').replace(/\s/g, ' ').replace(//g, ';')
327327
axios.post(`${this.$config.url}/sqlsyntax/`, {
328328
'data': JSON.stringify(this.formItem),
329329
'sql': JSON.stringify(this.datalist.sqllist),

0 commit comments

Comments
 (0)