This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
appsketch-works-asw-controller/src/main/resources/db/mapper/runner/JobMapper.xml
shizhendong 806ba7a01b feat: job 列表接口新增 params.q 查询参数
1. 模糊查询 package,environment,playbook
2024-10-23 11:29:51 +08:00

96 lines
3.6 KiB
XML

<?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="playbookId" column="playbook_id"/>
<result property="packageId" column="package_id"/>
<result property="envId" column="env_id"/>
<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"/>
<result property="workspaceId" column="workspace_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="name" column="name"/>
</association>
<association property="environment" columnPrefix="em_" javaType="net.geedge.asw.module.environment.entity.EnvironmentEntity">
<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.name AS pkg_name,
env.id AS em_id,
env.name AS em_name,
pb.id AS pb_id,
pb.name AS pb_name
FROM
job job
LEFT JOIN environment env ON job.env_id = env.id
LEFT JOIN package pkg ON job.package_id = pkg.id
LEFT JOIN playbook pb ON job.playbook_id = pb.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.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.environmentIds != null and params.environmentIds != ''">
AND env.id in
<foreach item="id" collection="params.environmentIds.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.workspaceId != null and params.workspaceId != ''">
AND job.workspace_id = #{params.workspaceId}
</if>
<if test="params.q != null and params.q != ''">
AND ( locate(#{params.q}, pkg.name) OR locate(#{params.q}, env.name) OR locate(#{params.q}, pb.name) )
</if>
</where>
GROUP BY
job.id
<if test="params.orderBy == null or params.orderBy == ''">
ORDER BY job.id
</if>
</select>
</mapper>