refactor(系统设置): 优化项目环境变更历史查询
This commit is contained in:
parent
ae73e80773
commit
fe5489b1da
|
@ -12,4 +12,7 @@ public interface ExtOperatingLogMapper {
|
|||
|
||||
List<OperatingLogDTO> findBySourceId(@Param("request") OperatingLogRequest request);
|
||||
|
||||
List<OperatingLogDTO> findBySourceIdEnv(@Param("request") OperatingLogRequest request);
|
||||
|
||||
|
||||
}
|
|
@ -82,4 +82,34 @@
|
|||
LEFT JOIN project t2 ON tt.project_id = t2.id
|
||||
order by tt.oper_time desc
|
||||
</select>
|
||||
|
||||
<select id="findBySourceIdEnv" resultType="io.metersphere.log.vo.OperatingLogDTO">
|
||||
SELECT tt.*, t1.NAME userName,t2.`name` projectName
|
||||
from (
|
||||
SELECT
|
||||
t.id,
|
||||
t.project_id,
|
||||
t.oper_user,
|
||||
t.source_id,
|
||||
t.oper_type,
|
||||
t.oper_module,
|
||||
t.oper_title,
|
||||
t.oper_time,
|
||||
t.oper_content
|
||||
FROM
|
||||
operating_log t
|
||||
INNER JOIN operating_log_resource t3 ON t.id = t3.operating_log_id
|
||||
<where>
|
||||
t.oper_type in ('UPDATE','BATCH_UPDATE')
|
||||
and t.oper_content is not null
|
||||
<if test="request.sourceId != null and request.sourceId != ''">
|
||||
and t3.source_id = #{request.sourceId, jdbcType=VARCHAR}
|
||||
</if>
|
||||
and JSON_UNQUOTE(JSON_EXTRACT(t.oper_content, '$.columns[*].diffValue')) is not null
|
||||
</where>
|
||||
)tt
|
||||
LEFT JOIN `user` t1 ON tt.oper_user = t1.id
|
||||
LEFT JOIN project t2 ON tt.project_id = t2.id
|
||||
order by tt.oper_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -7,6 +7,7 @@ import io.metersphere.base.mapper.OperatingLogMapper;
|
|||
import io.metersphere.base.mapper.OperatingLogResourceMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtOperatingLogMapper;
|
||||
import io.metersphere.commons.utils.BeanUtils;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.log.vo.OperatingLogDTO;
|
||||
import io.metersphere.log.vo.OperatingLogDetails;
|
||||
import io.metersphere.log.vo.OperatingLogRequest;
|
||||
|
@ -81,7 +82,12 @@ public class OperatingLogService {
|
|||
}
|
||||
|
||||
public List<OperatingLogDTO> findBySourceId(OperatingLogRequest request) {
|
||||
List<OperatingLogDTO> logWithBLOBs = extOperatingLogMapper.findBySourceId(request);
|
||||
List<OperatingLogDTO> logWithBLOBs = new ArrayList<>();
|
||||
if (request.getModules().toString().contains(Translator.get("project_environment_setting"))) {
|
||||
logWithBLOBs = extOperatingLogMapper.findBySourceIdEnv(request);
|
||||
} else {
|
||||
logWithBLOBs = extOperatingLogMapper.findBySourceId(request);
|
||||
}
|
||||
List<OperatingLogDTO> dtos = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(logWithBLOBs)) {
|
||||
for (OperatingLogDTO logWithBLOB : logWithBLOBs) {
|
||||
|
|
Loading…
Reference in New Issue