feat: ASW-6 新增 JOB 相关接口
This commit is contained in:
110
src/main/resources/db/mapper/runner/JobMapper.xml
Normal file
110
src/main/resources/db/mapper/runner/JobMapper.xml
Normal file
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="net.geedge.asw.module.runner.dao.JobDao">
|
||||
|
||||
<resultMap type="net.geedge.asw.module.runner.entity.JobEntity" id="jobResultMap">
|
||||
<id property="id" column="id"/>
|
||||
<result property="id" column="id"/>
|
||||
<result property="playbookId" column="playbook_id"/>
|
||||
<result property="packageId" column="package_id"/>
|
||||
<result property="runnerId" column="runner_id"/>
|
||||
<result property="scheduleId" column="schedule_id"/>
|
||||
<result property="signatureIds" column="signature_ids"/>
|
||||
<result property="tags" column="tags"/>
|
||||
<result property="startTimestamp" column="start_timestamp"/>
|
||||
<result property="endTimestamp" column="end_timestamp"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="pcapId" column="pcap_id"/>
|
||||
<result property="logPath" column="log_path"/>
|
||||
<result property="createTimestamp" column="create_timestamp"/>
|
||||
<result property="updateTimestamp" column="update_timestamp"/>
|
||||
<result property="createUserId" column="create_user_id"/>
|
||||
<result property="updateUserId" column="update_user_id"/>
|
||||
|
||||
<association property="pkg" columnPrefix="pkg_" javaType="net.geedge.asw.module.app.entity.PackageEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="platform" column="platform"/>
|
||||
<result property="version" column="version"/>
|
||||
<result property="logo" column="logo"/>
|
||||
</association>
|
||||
|
||||
<association property="application" columnPrefix="app_"
|
||||
javaType="net.geedge.asw.module.app.entity.ApplicationEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
|
||||
<association property="runner" columnPrefix="run_" javaType="net.geedge.asw.module.runner.entity.RunnerEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
|
||||
<association property="playbook" columnPrefix="pb_" javaType="net.geedge.asw.module.runner.entity.PlaybookEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
</association>
|
||||
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="queryList" resultMap="jobResultMap">
|
||||
SELECT
|
||||
job.*,
|
||||
pkg.id AS pkg_id,
|
||||
pkg.platform AS pkg_platform,
|
||||
pkg.version AS pkg_version,
|
||||
pkg.logo AS pkg_logo,
|
||||
|
||||
app.id AS app_id,
|
||||
app.name AS app_name,
|
||||
|
||||
run.id AS run_id,
|
||||
run.name AS run_name,
|
||||
|
||||
pb.id AS pb_id,
|
||||
pb.name AS pb_name
|
||||
FROM
|
||||
job job
|
||||
LEFT JOIN runner run ON job.runner_id = run.id
|
||||
LEFT JOIN package pkg ON job.package_id = pkg.id
|
||||
LEFT JOIN playbook pb ON job.playbook_id = pb.id
|
||||
LEFT JOIN application app ON pb.app_id = app.id
|
||||
<where>
|
||||
<if test="params.ids != null and params.ids != ''">
|
||||
job.id in
|
||||
<foreach item="id" collection="params.ids.split(',')" separator="," open="(" close=")">#{id}</foreach>
|
||||
</if>
|
||||
|
||||
<if test="params.appIds != null and params.appIds != ''">
|
||||
AND app.id in
|
||||
<foreach item="id" collection="params.appIds.split(',')" separator="," open="(" close=")">#{id}</foreach>
|
||||
</if>
|
||||
|
||||
<if test="params.packageIds != null and params.packageIds != ''">
|
||||
AND pkg.id in
|
||||
<foreach item="id" collection="params.packageIds.split(',')" separator="," open="(" close=")">#{id}</foreach>
|
||||
</if>
|
||||
|
||||
<if test="params.runnerIds != null and params.runnerIds != ''">
|
||||
AND run.id in
|
||||
<foreach item="id" collection="params.runnerIds.split(',')" separator="," open="(" close=")">#{id}</foreach>
|
||||
</if>
|
||||
|
||||
<if test="params.playbooks != null and params.playbooks != ''">
|
||||
AND pb.id in
|
||||
<foreach item="id" collection="params.playbooks.split(',')" separator="," open="(" close=")">#{id}</foreach>
|
||||
</if>
|
||||
|
||||
<if test="params.signatureIds != null and params.signatureIds != ''">
|
||||
AND <foreach item="item" collection="params.signatureIds.split(',')" separator="OR" index="" open="(" close=")">
|
||||
locate(#{item}, job.signature_ids)
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
|
||||
GROUP BY
|
||||
job.id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user