Skip to content

Commit

Permalink
增加系统配置项,使前端可以调整dml是否经过DBA审批
Browse files Browse the repository at this point in the history
  • Loading branch information
陈超 authored and 陈超 committed Sep 1, 2023
1 parent 61f493e commit 878e3a4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
32 changes: 32 additions & 0 deletions common/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,34 @@ <h5 style="color: darkgrey"><b>SQL上线</b></h5>
</div>
</div>
</div>
<div class="form-group">
<label for="dml_audit"
class="col-sm-4 control-label">DML_AUDIT</label>
<div class="col-sm-8">
<div class="switch switch-small">
<label>
<input id="dml_audit"
key="dml_audit"
value="{{ config.dml_audit }}"
type="checkbox">
是否开启DML审批分流
</label>
</div>
</div>
</div>
<div id="div-dml-audit-config" style="display: none">
<div class="form-group">
<label for="auto_dml_max_update_rows"
class="col-sm-4 control-label">MAX_UPDATE_ROWS</label>
<div class="col-sm-5">
<input type="number" class="form-control"
id="auto_dml_max_update_rows"
key="auto_dml_max_update_rows"
value="{{ config.auto_dml_max_update_rows }}"
placeholder="自动审批允许工单最大更新行数">
</div>
</div>
</div>
<div class="form-group">
<label for="manual"
class="col-sm-4 control-label">MANNUAL</label>
Expand Down Expand Up @@ -1175,6 +1203,8 @@ <h5 class="control-label text-bold">当前审批流程:<b id="workflow_auditor
$("#div-ding-config").show();
} else if (id === 'auto_review') {
$("#div-auto-review-config").show();
} else if (id === 'dml_audit') {
$("#div-dml-audit-config").show();
} else if (id === 'wx') {
$("#div-wx-config").show();
} else if (id === 'feishu') {
Expand All @@ -1191,6 +1221,8 @@ <h5 class="control-label text-bold">当前审批流程:<b id="workflow_auditor
$("#div-ding-config").hide();
} else if (id === 'auto_review') {
$("#div-auto-review-config").hide();
} else if (id === 'dml_audit') {
$("#div-dml-audit-config").hide();
} else if (id === 'wx') {
$("#div-wx-config").hide();
} else if (id === 'feishu') {
Expand Down
11 changes: 11 additions & 0 deletions sql/utils/workflow_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ArchiveConfig,
)
from common.config import SysConfig
import json


class Audit(object):
Expand Down Expand Up @@ -54,6 +55,11 @@ def add(workflow_type, workflow_id):
create_user_display = workflow_detail.engineer_display
audit_auth_groups = workflow_detail.audit_auth_groups
workflow_remark = ""
syntax_type = workflow_detail.syntax_type
all_affected_rows = 0
review_content = workflow_detail.sqlworkflowcontent.review_content
for review_row in json.loads(review_content):
all_affected_rows += int(review_row["affected_rows"])
elif workflow_type == WorkflowDict.workflow_type["archive"]:
workflow_detail = ArchiveConfig.objects.get(pk=workflow_id)
workflow_title = workflow_detail.title
Expand All @@ -73,6 +79,11 @@ def add(workflow_type, workflow_id):
raise Exception(result["msg"])
else:
audit_auth_groups_list = audit_auth_groups.split(",")
if SysConfig().get("dml_audit"):
dml_max_rows = int(SysConfig().get("auto_dml_max_update_rows"))
if syntax_type == 2 and all_affected_rows < dml_max_rows:
group_dba_id = Group.objects.get(name="DBA").id
audit_auth_groups_list.remove(str(group_dba_id))

# 判断是否无需审核,并且修改审批人为空
if SysConfig().get("auto_review", False):
Expand Down

0 comments on commit 878e3a4

Please sign in to comment.