fix(操作日志): 修改操作日志相关问题

This commit is contained in:
fit2-zhao 2021-05-27 11:56:01 +08:00 committed by fit2-zhao
parent 782f6ddac4
commit dc6746115f
8 changed files with 69 additions and 46 deletions

View File

@ -20,15 +20,15 @@
LEFT JOIN project t2 ON t.project_id = t2.id LEFT JOIN project t2 ON t.project_id = t2.id
LEFT JOIN workspace w on t2.workspace_id = w.id LEFT JOIN workspace w on t2.workspace_id = w.id
<where> <where>
t.project_id in ( t.project_id in
<foreach collection="request.projectIds" item="projectId" separator="," open="(" close=")"> <foreach collection="request.projectIds" item="projectId" separator="," open="(" close=")">
#{projectId} #{projectId}
</foreach> </foreach>
or t.project_id is null or t.project_id is null
or t.project_id = "" or t.project_id = ""
)
<if test="request.operUser != null and request.operUser != ''"> <if test="request.operUser != null and request.operUser != ''">
and t.oper_user like #{request.operUser, jdbcType=VARCHAR} and (t.oper_user like #{request.operUser, jdbcType=VARCHAR} or t1.name like #{request.operUser, jdbcType=VARCHAR})
or t1.NAME like #{request.operUser, jdbcType=VARCHAR}
</if> </if>
<if test="request.projectId != null and request.projectId !=''"> <if test="request.projectId != null and request.projectId !=''">
and t.project_id = #{request.projectId} and t.project_id = #{request.projectId}

View File

@ -24,7 +24,7 @@ public class SystemParameterController {
private SystemParameterService SystemParameterService; private SystemParameterService SystemParameterService;
@PostMapping("/edit/email") @PostMapping("/edit/email")
@MsAuditLog(module = "system_parameter_setting", type = OperLogConstants.UPDATE, title = "邮件设置") @MsAuditLog(module = "system_parameter_setting", type = OperLogConstants.UPDATE, title = "邮件设置",beforeEvent = "#msClass.getMailLogDetails()", content = "#msClass.getMailLogDetails()", msClass = SystemParameterService.class)
public void editMail(@RequestBody List<SystemParameter> systemParameter) { public void editMail(@RequestBody List<SystemParameter> systemParameter) {
SystemParameterService.editMail(systemParameter); SystemParameterService.editMail(systemParameter);
} }
@ -60,7 +60,7 @@ public class SystemParameterController {
} }
@PostMapping("/save/base") @PostMapping("/save/base")
@MsAuditLog(module = "system_parameter_setting", type = OperLogConstants.UPDATE, title = "基本配置") @MsAuditLog(module = "system_parameter_setting", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getBaseLogDetails()", content = "#msClass.getBaseLogDetails()", msClass = SystemParameterService.class)
public void saveBaseInfo(@RequestBody List<SystemParameter> systemParameter) { public void saveBaseInfo(@RequestBody List<SystemParameter> systemParameter) {
SystemParameterService.saveBaseInfo(systemParameter); SystemParameterService.saveBaseInfo(systemParameter);
} }

View File

@ -19,6 +19,8 @@ public class SystemReference {
public static Map<String, String> environmentColumns = new LinkedHashMap<>(); public static Map<String, String> environmentColumns = new LinkedHashMap<>();
public static Map<String, String> licenseColumns = new LinkedHashMap<>(); public static Map<String, String> licenseColumns = new LinkedHashMap<>();
public static Map<String, String> ldapColumns = new LinkedHashMap<>(); public static Map<String, String> ldapColumns = new LinkedHashMap<>();
public static Map<String, String> mailColumns = new LinkedHashMap<>();
public static Map<String, String> baseColumns = new LinkedHashMap<>();
static { static {
@ -37,6 +39,7 @@ public class SystemReference {
environmentColumns.clear(); environmentColumns.clear();
licenseColumns.clear(); licenseColumns.clear();
ldapColumns.clear(); ldapColumns.clear();
mailColumns.clear();
userColumns.put("name", "用户名称"); userColumns.put("name", "用户名称");
userColumns.put("createUser", "创建人"); userColumns.put("createUser", "创建人");
@ -127,5 +130,19 @@ public class SystemReference {
ldapColumns.put("mapping", "LDAP属性映射"); ldapColumns.put("mapping", "LDAP属性映射");
ldapColumns.put("open", "启用LDAP认证"); ldapColumns.put("open", "启用LDAP认证");
mailColumns.put("host","SMTP主机");
mailColumns.put("port","SMTP端口");
mailColumns.put("account","SMTP账号");
mailColumns.put("password","SMTP密码");
mailColumns.put("ssl","开启SSL");
mailColumns.put("tls","开启TLS");
mailColumns.put("recipient","测试接收人");
baseColumns.put("url","当前站点URL");
baseColumns.put("concurrency","并发数");
baseColumns.put("prometheusHost","Prometheus地址");
} }
} }

View File

@ -307,4 +307,25 @@ public class SystemParameterService {
} }
return null; return null;
} }
public String getMailLogDetails() {
MailInfo mailInfo = this.mailInfo(ParamConstants.Classify.MAIL.getValue());
if (mailInfo != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(mailInfo, SystemReference.mailColumns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(mailInfo.getAccount()), null, "邮件设置", null, columns);
return JSON.toJSONString(details);
}
return null;
}
public String getBaseLogDetails() {
BaseSystemConfigDTO configDTO = this.getBaseInfo();
if (configDTO != null) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(configDTO, SystemReference.baseColumns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(configDTO.getUrl()), null, "基本配置", null, columns);
return JSON.toJSONString(details);
}
return null;
}
} }

View File

@ -1171,7 +1171,7 @@ public class UserService {
DetailColumn detailColumn = new DetailColumn(); DetailColumn detailColumn = new DetailColumn();
detailColumn.setId(UUID.randomUUID().toString()); detailColumn.setId(UUID.randomUUID().toString());
detailColumn.setColumnTitle("成员"); detailColumn.setColumnTitle("成员");
detailColumn.setColumnName("roles"); detailColumn.setColumnName("roles");
detailColumn.setOriginalValue(nameBuilder.toString()); detailColumn.setOriginalValue(nameBuilder.toString());
columns.add(detailColumn); columns.add(detailColumn);

View File

@ -1146,20 +1146,11 @@ public class TestPlanService {
} }
public String getLogDetails(PlanCaseRelevanceRequest request) { public String getLogDetails(PlanCaseRelevanceRequest request) {
List<String> testCaseIds = request.getTestCaseIds(); List<String> testCaseIds = request.getIds();
List<String> names = null;
if (testCaseIds.get(0).equals("all")) {
List<TestCase> testCases = extTestCaseMapper.getTestCaseByNotInReview(request.getRequest());
if (!testCases.isEmpty()) {
names = testCases.stream().map(TestCase::getName).collect(Collectors.toList());
testCaseIds = testCases.stream().map(testCase -> testCase.getId()).collect(Collectors.toList());
}
} else {
TestCaseExample example = new TestCaseExample(); TestCaseExample example = new TestCaseExample();
example.createCriteria().andIdIn(testCaseIds); example.createCriteria().andIdIn(testCaseIds);
List<TestCase> cases = testCaseMapper.selectByExample(example); List<TestCase> cases = testCaseMapper.selectByExample(example);
names = cases.stream().map(TestCase::getName).collect(Collectors.toList()); List<String> names = cases.stream().map(TestCase::getName).collect(Collectors.toList());
}
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId()); TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId());
if (testPlan != null) { if (testPlan != null) {
List<DetailColumn> columns = new LinkedList<>(); List<DetailColumn> columns = new LinkedList<>();

@ -1 +1 @@
Subproject commit c678210fde8f9fb5c5d5c8781f6ce3d497134c73 Subproject commit 8c27caa18dd0ce5e5d81c0efdbc5ab0b16e923e7

View File

@ -17,35 +17,29 @@
<div v-if="detail && detail.details && detail.details.columns" style="margin-left: 20px"> <div v-if="detail && detail.details && detail.details.columns" style="margin-left: 20px">
<el-table :data="detail.details.columns"> <el-table :data="detail.details.columns">
<el-table-column prop="columnTitle" :label="$t('operating_log.change_field')" width="150px" show-overflow-tooltip/> <el-table-column prop="columnTitle" :label="$t('operating_log.change_field')" width="150px" show-overflow-tooltip/>
<!--<el-table-column prop="originalValue" :label="$t('operating_log.before_change')" width="400px">-->
<!--<template v-slot:default="scope">-->
<!--<span v-if="timeDates.indexOf(scope.row.columnName)!==-1">{{ scope.row.originalValue | timestampFormatDate }}</span>-->
<!--<div v-else>{{ scope.row.originalValue }}</div>-->
<!--</template>-->
<!--</el-table-column>-->
<el-table-column prop="newValue" :label="$t('operating_log.change_content')"> <el-table-column prop="newValue" :label="$t('operating_log.change_content')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span v-if="timeDates.indexOf(scope.row.columnName)!==-1">{{ scope.row.newValue | timestampFormatDate }}</span> <span v-if="timeDates.indexOf(scope.row.columnName)!==-1">{{ scope.row.newValue | timestampFormatDate }}</span>
<pre v-html="getDiff(scope.row.originalValue,scope.row.newValue)" v-else></pre> <div v-html="getDiff(scope.row.originalValue,scope.row.newValue)" v-else></div>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
</div> </div>
<div v-else-if="detail && (detail.operType ==='DELETE' || detail.details === null || (detail.details && detail.details.columns && detail.details.columns.length === 0))"> <div v-else-if="detail && (detail.operType ==='DELETE' || detail.details === null || (detail.details && detail.details.columns && detail.details.columns.length === 0))">
<pre style="overflow: auto">{{detail.operTitle}} </pre> <div>{{detail.operTitle}}</div>
<span style="color: #409EFF">{{getType(detail.operType)}} </span> <span style="color: #409EFF">{{getType(detail.operType)}} </span>
<span style="color: #409EFF"> {{$t('api_test.home_page.detail_card.success')}}</span> <span style="color: #409EFF"> {{$t('api_test.home_page.detail_card.success')}}</span>
</div> </div>
<div v-else> <div v-else>
<div v-if="detail && detail.details && detail.details.columns" style="overflow: auto"> <div v-if="detail && detail.details && detail.details.columns" style="overflow: auto">
<span v-for="n in detail.details.columns" :key="n.id"> <span v-for="n in detail.details.columns" :key="n.id">
<pre v-if="timeDates.indexOf(n.columnName)!==-1"> <div v-if="timeDates.indexOf(n.columnName)!==-1">
{{n.columnTitle}}{{ n.originalValue | timestampFormatDate }} {{n.columnTitle}}{{ n.originalValue | timestampFormatDate }}
</pre> </div>
<pre style="overflow: auto" v-else> <div style="overflow: auto" v-else>
{{n.columnTitle}}{{n.originalValue}} {{n.columnTitle}}{{n.originalValue}}
</pre> </div>
</span> </span>
</div> </div>
</div> </div>